Changeset 19979
- Timestamp:
- 03/06/07 01:05:42 (23 months ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLDocument/document-special-properties.html (modified) (4 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bindings/js/kjs_html.cpp (modified) (1 diff)
-
WebCore/html/HTMLImageElement.cpp (modified) (3 diffs)
-
WebCore/html/HTMLImageElement.h (modified) (1 diff)
-
WebCore/html/HTMLNameCollection.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r19977 r19979 1 2007-03-06 Anders Carlsson <acarlsson@apple.com> 2 3 Reviewed by Maciej. 4 5 <rdar://problem/5035045> 6 REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html 7 8 Add some tests where image elements have id _and_ name elements. 9 10 * fast/dom/HTMLDocument/document-special-properties-expected.txt: 11 * fast/dom/HTMLDocument/document-special-properties.html: 12 1 13 2007-03-05 Kevin McCullough <kmccullough@apple.com> 2 14 -
trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties-expected.txt
r11962 r19979 11 11 Image by id (multiple): undefined 12 12 Image by id/name mixed: collection(2) IMG(name) IMG(name) 13 Image by id, name present (unique): single IMG(id,name) 14 Image by id, empty name present (unique): single IMG(id) 15 Image by id, name present (multiple): collection(2) IMG(id,name) IMG(id,name) 16 Image by name, id present (unique): single IMG(id,name) 13 17 14 18 Nonexistent form name: undefined -
trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html
r11995 r19979 33 33 <img name="image5" width="0" height="0"> 34 34 <img id="image5" width="0" height="0"> 35 <img id="image6" name="image6name" width="0" height="0"> 36 <img id="image7" name="" width="0" height="0"> 37 <img id="image8" name="image8name" width="0" height="0"> 38 <img id="image8" width="0" height="0"> 39 <img id="image8" name="image7name" width="0" height="0"> 40 <img id="image9" name="image9name" width="0" height="0"> 35 41 36 42 <form name="form1" width="0" height="0"></form> … … 151 157 print(" " + e.tagName); 152 158 153 if (e.name && e.id) {154 print("(id,name)");155 } else if (e.name) {156 print("(name)");159 if (e.name && e.id) { 160 print("(id,name)"); 161 } else if (e.name) { 162 print("(name)"); 157 163 } else if (e.id) { 158 print("(id)");159 }164 print("(id)"); 165 } 160 166 } else if (e.navigator) { 161 167 print(" WINDOW"); … … 174 180 } else if (propVal.length) { 175 181 print(" collection(" + propVal.length + ")"); 176 for (var i = 0; i < propVal.length; i++) {177 printElement(propVal[i]);178 }182 for (var i = 0; i < propVal.length; i++) { 183 printElement(propVal[i]); 184 } 179 185 } else { 180 186 print(" single"); 181 printElement(propVal);187 printElement(propVal); 182 188 } 183 189 … … 191 197 testProperty("Image by id (multiple)", "image4"); 192 198 testProperty("Image by id/name mixed", "image5"); 199 testProperty("Image by id, name present (unique)", "image6"); 200 testProperty("Image by id, empty name present (unique)", "image7"); 201 testProperty("Image by id, name present (multiple)", "image8"); 202 testProperty("Image by name, id present (unique)", "image9name"); 203 193 204 print("<br>"); 194 205 -
trunk/WebCore/ChangeLog
r19978 r19979 1 2007-03-06 Anders Carlsson <acarlsson@apple.com> 2 3 Reviewed by Maciej. 4 5 <rdar://problem/5035045> 6 REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html 7 8 It turns out WinIE does allow you to access images by their id as special document properties. However, this is only 9 allowed when the element also has a name attribute. The value of the name attribute is ignored and can even be empty! 10 11 * bindings/js/kjs_html.cpp: 12 (KJS::JSHTMLDocument::namedItemGetter): 13 Return jsUndefined() if the collection is empty. 14 15 * html/HTMLImageElement.cpp: 16 (WebCore::HTMLImageElement::parseMappedAttribute): 17 (WebCore::HTMLImageElement::insertedIntoDocument): 18 (WebCore::HTMLImageElement::removedFromDocument): 19 * html/HTMLImageElement.h: 20 Add the id attribute value to the extra named item map. 21 22 * html/HTMLNameCollection.cpp: 23 (WebCore::HTMLNameCollection::traverseNextItem): 24 Check for images with name attributes that match, as well as elements with id attributes that match where 25 the element also has a name attribute. 26 1 27 2007-03-06 Anders Carlsson <acarlsson@apple.com> 2 28 -
trunk/WebCore/bindings/js/kjs_html.cpp
r19971 r19979 208 208 return Window::retrieve(frame); 209 209 return toJS(exec, node); 210 } 210 } else if (collection->length() == 0) 211 return jsUndefined(); 211 212 212 213 return getHTMLCollection(exec, collection.get()); -
trunk/WebCore/html/HTMLImageElement.cpp
r18940 r19979 140 140 } 141 141 oldNameAttr = newNameAttr; 142 } else if (attr->name() == idAttr) { 143 String newIdAttr = attr->value(); 144 if (inDocument() && document()->isHTMLDocument()) { 145 HTMLDocument *doc = static_cast<HTMLDocument *>(document()); 146 doc->removeDocExtraNamedItem(oldIdAttr); 147 doc->addDocExtraNamedItem(newIdAttr); 148 } 149 oldIdAttr = newIdAttr; 150 // also call superclass 151 HTMLElement::parseMappedAttribute(attr); 142 152 } else 143 153 HTMLElement::parseMappedAttribute(attr); … … 181 191 void HTMLImageElement::insertedIntoDocument() 182 192 { 183 Document* doc = document(); 184 if (doc->isHTMLDocument()) 185 static_cast<HTMLDocument*>(doc)->addNamedItem(oldNameAttr); 193 if (document()->isHTMLDocument()) { 194 HTMLDocument* doc = static_cast<HTMLDocument*>(document()); 195 196 doc->addNamedItem(oldNameAttr); 197 doc->addDocExtraNamedItem(oldIdAttr); 198 } 186 199 187 200 HTMLElement::insertedIntoDocument(); … … 190 203 void HTMLImageElement::removedFromDocument() 191 204 { 192 Document* doc = document(); 193 if (doc->isHTMLDocument()) 194 static_cast<HTMLDocument*>(doc)->removeNamedItem(oldNameAttr); 205 if (document()->isHTMLDocument()) { 206 HTMLDocument* doc = static_cast<HTMLDocument*>(document()); 207 208 doc->removeNamedItem(oldNameAttr); 209 doc->removeDocExtraNamedItem(oldIdAttr); 210 } 195 211 196 212 HTMLElement::removedFromDocument(); -
trunk/WebCore/html/HTMLImageElement.h
r18940 r19979 117 117 HTMLFormElement* m_form; 118 118 String oldNameAttr; 119 String oldIdAttr; 119 120 CompositeOperator m_compositeOperator; 120 121 }; -
trunk/WebCore/html/HTMLNameCollection.cpp
r15006 r19979 67 67 case DocumentNamedItems: 68 68 // find images, forms, applets, embeds, objects and iframes by name, 69 // but only applets and object by id (this strange rule matches IE)70 if (e->hasTagName(imgTag) ||71 e->hasTagName(formTag) ||69 // applets and object by id, and images by id but only if they have 70 // a name attribute (this very strange rule matches IE) 71 if (e->hasTagName(formTag) || 72 72 e->hasTagName(embedTag) || 73 73 e->hasTagName(iframeTag)) … … 79 79 found = (e->getAttribute(nameAttr) == m_name || e->getAttribute(idAttr) == m_name) && 80 80 static_cast<HTMLObjectElement*>(e)->isDocNamedItem(); 81 else if (e->hasTagName(imgTag)) 82 found = e->getAttribute(nameAttr) == m_name || (e->getAttribute(idAttr) == m_name && e->hasAttribute(nameAttr)); 81 83 break; 82 84 default: