<!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.

        &lt;rdar://problem/5035045&gt;
        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.

        &lt;rdar://problem/5035045&gt;
        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  &lt;acarlsson@apple.com&gt;
+
+        Reviewed by Maciej.
+
+        &lt;rdar://problem/5035045&gt;
+        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  &lt;kmccullough@apple.com&gt;
</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"> &lt;img name=&quot;image5&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
</span><span class="cx"> &lt;img name=&quot;image5&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
</span><span class="cx"> &lt;img id=&quot;image5&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
</span><ins>+&lt;img id=&quot;image6&quot; name=&quot;image6name&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
+&lt;img id=&quot;image7&quot; name=&quot;&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
+&lt;img id=&quot;image8&quot; name=&quot;image8name&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
+&lt;img id=&quot;image8&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
+&lt;img id=&quot;image8&quot; name=&quot;image7name&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
+&lt;img id=&quot;image9&quot; name=&quot;image9name&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;form name=&quot;form1&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/form&gt;
</span><span class="cx"> &lt;form name=&quot;form2&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/form&gt;
</span><span class="lines">@@ -150,13 +156,13 @@
</span><span class="cx">     if (e.tagName) {
</span><span class="cx">         print(&quot; &quot; + e.tagName);
</span><span class="cx"> 
</span><del>-        if (e.name &amp;&amp; e.id) {
-            print(&quot;(id,name)&quot;);
-        } else if (e.name) {
-            print(&quot;(name)&quot;);
</del><ins>+    if (e.name &amp;&amp; e.id) {
+        print(&quot;(id,name)&quot;);
+    } else if (e.name) {
+        print(&quot;(name)&quot;);
</ins><span class="cx">         } else if (e.id) {
</span><del>-            print(&quot;(id)&quot;);
-        }
</del><ins>+        print(&quot;(id)&quot;);
+    }
</ins><span class="cx">     } else if (e.navigator) {
</span><span class="cx">         print(&quot; WINDOW&quot;);
</span><span class="cx">     } else {
</span><span class="lines">@@ -173,12 +179,12 @@
</span><span class="cx">         print(&quot; undefined&quot;);
</span><span class="cx">     } else if (propVal.length) {
</span><span class="cx">         print(&quot; collection(&quot; + propVal.length + &quot;)&quot;);
</span><del>-        for (var i = 0; i &lt; propVal.length; i++) {
-            printElement(propVal[i]);
-        }
</del><ins>+    for (var i = 0; i &lt; propVal.length; i++) {
+        printElement(propVal[i]);
+    }
</ins><span class="cx">     } else {
</span><span class="cx">         print(&quot; single&quot;);
</span><del>-        printElement(propVal);
</del><ins>+    printElement(propVal);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     print(&quot;&lt;br&gt;&quot;);
</span><span class="lines">@@ -190,6 +196,11 @@
</span><span class="cx"> testProperty(&quot;Image by id (unique)&quot;, &quot;image3&quot;);
</span><span class="cx"> testProperty(&quot;Image by id (multiple)&quot;, &quot;image4&quot;);
</span><span class="cx"> testProperty(&quot;Image by id/name mixed&quot;, &quot;image5&quot;);
</span><ins>+testProperty(&quot;Image by id, name present (unique)&quot;, &quot;image6&quot;);
+testProperty(&quot;Image by id, empty name present (unique)&quot;, &quot;image7&quot;);
+testProperty(&quot;Image by id, name present (multiple)&quot;, &quot;image8&quot;);
+testProperty(&quot;Image by name, id present (unique)&quot;, &quot;image9name&quot;);
+
</ins><span class="cx"> print(&quot;&lt;br&gt;&quot;);
</span><span class="cx"> 
</span><span class="cx"> testProperty(&quot;Nonexistent form name&quot;, &quot;form0&quot;);
</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  &lt;acarlsson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Reviewed by Maciej.
+
+        &lt;rdar://problem/5035045&gt;
+        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  &lt;acarlsson@apple.com&gt;
+
</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-&gt;hasTagName(iframeTag) &amp;&amp; (frame = static_cast&lt;HTMLIFrameElement*&gt;(node)-&gt;contentFrame()))
</span><span class="cx">       return Window::retrieve(frame);
</span><span class="cx">     return toJS(exec, node);
</span><del>-  }
</del><ins>+  } else if (collection-&gt;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-&gt;addNamedItem(newNameAttr);
</span><span class="cx">         }
</span><span class="cx">         oldNameAttr = newNameAttr;
</span><ins>+    } else if (attr-&gt;name() == idAttr) {
+        String newIdAttr = attr-&gt;value();
+        if (inDocument() &amp;&amp; document()-&gt;isHTMLDocument()) {
+            HTMLDocument *doc = static_cast&lt;HTMLDocument *&gt;(document());
+            doc-&gt;removeDocExtraNamedItem(oldIdAttr);
+            doc-&gt;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-&gt;isHTMLDocument())
-        static_cast&lt;HTMLDocument*&gt;(doc)-&gt;addNamedItem(oldNameAttr);
</del><ins>+    if (document()-&gt;isHTMLDocument()) {
+        HTMLDocument* doc = static_cast&lt;HTMLDocument*&gt;(document());
</ins><span class="cx"> 
</span><ins>+        doc-&gt;addNamedItem(oldNameAttr);
+        doc-&gt;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-&gt;isHTMLDocument())
-        static_cast&lt;HTMLDocument*&gt;(doc)-&gt;removeNamedItem(oldNameAttr);
</del><ins>+    if (document()-&gt;isHTMLDocument()) {
+        HTMLDocument* doc = static_cast&lt;HTMLDocument*&gt;(document());
</ins><span class="cx"> 
</span><ins>+        doc-&gt;removeNamedItem(oldNameAttr);
+        doc-&gt;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-&gt;hasTagName(imgTag) ||
-                    e-&gt;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-&gt;hasTagName(formTag) ||
</ins><span class="cx">                     e-&gt;hasTagName(embedTag) ||
</span><span class="cx">                     e-&gt;hasTagName(iframeTag))
</span><span class="cx">                     found = e-&gt;getAttribute(nameAttr) == m_name;
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx">                 else if (e-&gt;hasTagName(objectTag))
</span><span class="cx">                     found = (e-&gt;getAttribute(nameAttr) == m_name || e-&gt;getAttribute(idAttr) == m_name) &amp;&amp;
</span><span class="cx">                         static_cast&lt;HTMLObjectElement*&gt;(e)-&gt;isDocNamedItem();
</span><ins>+                else if (e-&gt;hasTagName(imgTag))
+                    found = e-&gt;getAttribute(nameAttr) == m_name || (e-&gt;getAttribute(idAttr) == m_name &amp;&amp; e-&gt;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>