<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[19979] trunk</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/19979">19979</a></dd>
<dt>Author</dt> <dd>andersca</dd>
<dt>Date</dt> <dd>2007-03-06 01:05:42 -0800 (Tue, 06 Mar 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>LayoutTests:
Reviewed by Maciej.
<rdar://problem/5035045>
REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html
Add some tests where image elements have id _and_ name elements.
* fast/dom/HTMLDocument/document-special-properties-expected.txt:
* fast/dom/HTMLDocument/document-special-properties.html:
WebCore:
Reviewed by Maciej.
<rdar://problem/5035045>
REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html
It turns out WinIE does allow you to access images by their id as special document properties. However, this is only
allowed when the element also has a name attribute. The value of the name attribute is ignored and can even be empty!
* bindings/js/kjs_html.cpp:
(KJS::JSHTMLDocument::namedItemGetter):
Return jsUndefined() if the collection is empty.
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseMappedAttribute):
(WebCore::HTMLImageElement::insertedIntoDocument):
(WebCore::HTMLImageElement::removedFromDocument):
* html/HTMLImageElement.h:
Add the id attribute value to the extra named item map.
* html/HTMLNameCollection.cpp:
(WebCore::HTMLNameCollection::traverseNextItem):
Check for images with name attributes that match, as well as elements with id attributes that match where
the element also has a name attribute.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLDocumentdocumentspecialpropertiesexpectedtxt">trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLDocumentdocumentspecialpropertieshtml">trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebindingsjskjs_htmlcpp">trunk/WebCore/bindings/js/kjs_html.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLImageElementcpp">trunk/WebCore/html/HTMLImageElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLImageElementh">trunk/WebCore/html/HTMLImageElement.h</a></li>
<li><a href="#trunkWebCorehtmlHTMLNameCollectioncpp">trunk/WebCore/html/HTMLNameCollection.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/LayoutTests/ChangeLog        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2007-03-06 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Maciej.
+
+ <rdar://problem/5035045>
+ REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html
+
+ Add some tests where image elements have id _and_ name elements.
+
+ * fast/dom/HTMLDocument/document-special-properties-expected.txt:
+ * fast/dom/HTMLDocument/document-special-properties.html:
+
</ins><span class="cx"> 2007-03-05 Kevin McCullough <kmccullough@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by Mark and Dave H.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLDocumentdocumentspecialpropertiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -10,6 +10,10 @@
</span><span class="cx"> Image by id (unique): undefined
</span><span class="cx"> Image by id (multiple): undefined
</span><span class="cx"> Image by id/name mixed: collection(2) IMG(name) IMG(name)
</span><ins>+Image by id, name present (unique): single IMG(id,name)
+Image by id, empty name present (unique): single IMG(id)
+Image by id, name present (multiple): collection(2) IMG(id,name) IMG(id,name)
+Image by name, id present (unique): single IMG(id,name)
</ins><span class="cx">
</span><span class="cx"> Nonexistent form name: undefined
</span><span class="cx"> Form by name (unique): single FORM(name)
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLDocumentdocumentspecialpropertieshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -32,6 +32,12 @@
</span><span class="cx"> <img name="image5" width="0" height="0">
</span><span class="cx"> <img name="image5" width="0" height="0">
</span><span class="cx"> <img id="image5" width="0" height="0">
</span><ins>+<img id="image6" name="image6name" width="0" height="0">
+<img id="image7" name="" width="0" height="0">
+<img id="image8" name="image8name" width="0" height="0">
+<img id="image8" width="0" height="0">
+<img id="image8" name="image7name" width="0" height="0">
+<img id="image9" name="image9name" width="0" height="0">
</ins><span class="cx">
</span><span class="cx"> <form name="form1" width="0" height="0"></form>
</span><span class="cx"> <form name="form2" width="0" height="0"></form>
</span><span class="lines">@@ -150,13 +156,13 @@
</span><span class="cx"> if (e.tagName) {
</span><span class="cx"> print(" " + e.tagName);
</span><span class="cx">
</span><del>-        if (e.name && e.id) {
-         print("(id,name)");
-        } else if (e.name) {
-         print("(name)");
</del><ins>+ if (e.name && e.id) {
+ print("(id,name)");
+ } else if (e.name) {
+ print("(name)");
</ins><span class="cx"> } else if (e.id) {
</span><del>-         print("(id)");
-        }
</del><ins>+ print("(id)");
+ }
</ins><span class="cx"> } else if (e.navigator) {
</span><span class="cx"> print(" WINDOW");
</span><span class="cx"> } else {
</span><span class="lines">@@ -173,12 +179,12 @@
</span><span class="cx"> print(" undefined");
</span><span class="cx"> } else if (propVal.length) {
</span><span class="cx"> print(" collection(" + propVal.length + ")");
</span><del>-        for (var i = 0; i < propVal.length; i++) {
-         printElement(propVal[i]);
-        }
</del><ins>+ for (var i = 0; i < propVal.length; i++) {
+ printElement(propVal[i]);
+ }
</ins><span class="cx"> } else {
</span><span class="cx"> print(" single");
</span><del>-        printElement(propVal);
</del><ins>+ printElement(propVal);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> print("<br>");
</span><span class="lines">@@ -190,6 +196,11 @@
</span><span class="cx"> testProperty("Image by id (unique)", "image3");
</span><span class="cx"> testProperty("Image by id (multiple)", "image4");
</span><span class="cx"> testProperty("Image by id/name mixed", "image5");
</span><ins>+testProperty("Image by id, name present (unique)", "image6");
+testProperty("Image by id, empty name present (unique)", "image7");
+testProperty("Image by id, name present (multiple)", "image8");
+testProperty("Image by name, id present (unique)", "image9name");
+
</ins><span class="cx"> print("<br>");
</span><span class="cx">
</span><span class="cx"> testProperty("Nonexistent form name", "form0");
</span></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/WebCore/ChangeLog        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -1,5 +1,31 @@
</span><span class="cx"> 2007-03-06 Anders Carlsson <acarlsson@apple.com>
</span><span class="cx">
</span><ins>+ Reviewed by Maciej.
+
+ <rdar://problem/5035045>
+ REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html
+
+ It turns out WinIE does allow you to access images by their id as special document properties. However, this is only
+ allowed when the element also has a name attribute. The value of the name attribute is ignored and can even be empty!
+
+ * bindings/js/kjs_html.cpp:
+ (KJS::JSHTMLDocument::namedItemGetter):
+ Return jsUndefined() if the collection is empty.
+
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseMappedAttribute):
+ (WebCore::HTMLImageElement::insertedIntoDocument):
+ (WebCore::HTMLImageElement::removedFromDocument):
+ * html/HTMLImageElement.h:
+ Add the id attribute value to the extra named item map.
+
+ * html/HTMLNameCollection.cpp:
+ (WebCore::HTMLNameCollection::traverseNextItem):
+ Check for images with name attributes that match, as well as elements with id attributes that match where
+ the element also has a name attribute.
+
+2007-03-06 Anders Carlsson <acarlsson@apple.com>
+
</ins><span class="cx"> Reviewed by Adam.
</span><span class="cx">
</span><span class="cx"> WebCore part of patch to make it possible to have different user agents for different URLs.
</span></span></pre></div>
<a id="trunkWebCorebindingsjskjs_htmlcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/js/kjs_html.cpp (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/js/kjs_html.cpp        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/WebCore/bindings/js/kjs_html.cpp        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -207,7 +207,8 @@
</span><span class="cx"> if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
</span><span class="cx"> return Window::retrieve(frame);
</span><span class="cx"> return toJS(exec, node);
</span><del>- }
</del><ins>+ } else if (collection->length() == 0)
+ return jsUndefined();
</ins><span class="cx">
</span><span class="cx"> return getHTMLCollection(exec, collection.get());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLImageElement.cpp (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLImageElement.cpp        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/WebCore/html/HTMLImageElement.cpp        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -139,6 +139,16 @@
</span><span class="cx"> doc->addNamedItem(newNameAttr);
</span><span class="cx"> }
</span><span class="cx"> oldNameAttr = newNameAttr;
</span><ins>+ } else if (attr->name() == idAttr) {
+ String newIdAttr = attr->value();
+ if (inDocument() && document()->isHTMLDocument()) {
+ HTMLDocument *doc = static_cast<HTMLDocument *>(document());
+ doc->removeDocExtraNamedItem(oldIdAttr);
+ doc->addDocExtraNamedItem(newIdAttr);
+ }
+ oldIdAttr = newIdAttr;
+ // also call superclass
+ HTMLElement::parseMappedAttribute(attr);
</ins><span class="cx"> } else
</span><span class="cx"> HTMLElement::parseMappedAttribute(attr);
</span><span class="cx"> }
</span><span class="lines">@@ -180,19 +190,25 @@
</span><span class="cx">
</span><span class="cx"> void HTMLImageElement::insertedIntoDocument()
</span><span class="cx"> {
</span><del>- Document* doc = document();
- if (doc->isHTMLDocument())
- static_cast<HTMLDocument*>(doc)->addNamedItem(oldNameAttr);
</del><ins>+ if (document()->isHTMLDocument()) {
+ HTMLDocument* doc = static_cast<HTMLDocument*>(document());
</ins><span class="cx">
</span><ins>+ doc->addNamedItem(oldNameAttr);
+ doc->addDocExtraNamedItem(oldIdAttr);
+ }
+
</ins><span class="cx"> HTMLElement::insertedIntoDocument();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLImageElement::removedFromDocument()
</span><span class="cx"> {
</span><del>- Document* doc = document();
- if (doc->isHTMLDocument())
- static_cast<HTMLDocument*>(doc)->removeNamedItem(oldNameAttr);
</del><ins>+ if (document()->isHTMLDocument()) {
+ HTMLDocument* doc = static_cast<HTMLDocument*>(document());
</ins><span class="cx">
</span><ins>+ doc->removeNamedItem(oldNameAttr);
+ doc->removeDocExtraNamedItem(oldIdAttr);
+ }
+
</ins><span class="cx"> HTMLElement::removedFromDocument();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLImageElementh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLImageElement.h (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLImageElement.h        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/WebCore/html/HTMLImageElement.h        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx"> bool ismap;
</span><span class="cx"> HTMLFormElement* m_form;
</span><span class="cx"> String oldNameAttr;
</span><ins>+ String oldIdAttr;
</ins><span class="cx"> CompositeOperator m_compositeOperator;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLNameCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLNameCollection.cpp (19978 => 19979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLNameCollection.cpp        2007-03-06 08:37:36 UTC (rev 19978)
+++ trunk/WebCore/html/HTMLNameCollection.cpp        2007-03-06 09:05:42 UTC (rev 19979)
</span><span class="lines">@@ -66,9 +66,9 @@
</span><span class="cx"> break;
</span><span class="cx"> case DocumentNamedItems:
</span><span class="cx"> // find images, forms, applets, embeds, objects and iframes by name,
</span><del>- // but only applets and object by id (this strange rule matches IE)
- if (e->hasTagName(imgTag) ||
- e->hasTagName(formTag) ||
</del><ins>+ // applets and object by id, and images by id but only if they have
+ // a name attribute (this very strange rule matches IE)
+ if (e->hasTagName(formTag) ||
</ins><span class="cx"> e->hasTagName(embedTag) ||
</span><span class="cx"> e->hasTagName(iframeTag))
</span><span class="cx"> found = e->getAttribute(nameAttr) == m_name;
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx"> else if (e->hasTagName(objectTag))
</span><span class="cx"> found = (e->getAttribute(nameAttr) == m_name || e->getAttribute(idAttr) == m_name) &&
</span><span class="cx"> static_cast<HTMLObjectElement*>(e)->isDocNamedItem();
</span><ins>+ else if (e->hasTagName(imgTag))
+ found = e->getAttribute(nameAttr) == m_name || (e->getAttribute(idAttr) == m_name && e->hasAttribute(nameAttr));
</ins><span class="cx"> break;
</span><span class="cx"> default:
</span><span class="cx"> ASSERT(0);
</span></span></pre>
</div>
</div>
</body>
</html>