Changeset 34543 in webkit
- Timestamp:
- Jun 14, 2008 7:03:24 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r34542 r34543 1 2008-06-14 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Dan Bernstein. 4 5 Tests for <rdar://problem/5775192> 6 insertAdjacentHTML and insertAdjacentText are not implemented although insertAdjacentElement is. 7 8 * fast/dom/Window/window-properties-expected.txt: 9 * fast/dom/domListEnumeration-expected.txt: 10 * fast/dom/resources/domListEnumeration.js: 11 * fast/dynamic/insertAdjacentElement.html: 12 * fast/dynamic/insertAdjacentHTML-expected.txt: Added. 13 * fast/dynamic/insertAdjacentHTML.html: Copied from fast/dynamic/insertAdjacentElement.html. 14 * fast/dynamic/insertAdjacentText-expected.txt: Added. 15 * fast/dynamic/insertAdjacentText.html: Copied from fast/dynamic/insertAdjacentElement.html. 16 * platform/mac/fast/dynamic/insertAdjacentElement-expected.txt: 17 1 18 2008-06-14 Darin Adler <darin@apple.com> 2 19 -
trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt
r34010 r34543 521 521 window.Element.prototype.hasAttributes [function] 522 522 window.Element.prototype.hasChildNodes [function] 523 window.Element.prototype.insertAdjacentElement [function]524 523 window.Element.prototype.insertBefore [function] 525 524 window.Element.prototype.isDefaultNamespace [function] -
trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt
r34452 r34543 33 33 34 34 [object HTMLFormElement] 35 PASS resultArray.length is 1 1935 PASS resultArray.length is 121 36 36 PASS resultArray[0].i is '0' 37 37 PASS resultArray[0].item is document.getElementsByTagName('select')[0] … … 42 42 43 43 [object HTMLSelectElement] 44 PASS resultArray.length is 12 244 PASS resultArray.length is 124 45 45 PASS resultArray[0].i is '0' 46 46 PASS resultArray[0].item is document.getElementsByTagName('option')[0] -
trunk/LayoutTests/fast/dom/resources/domListEnumeration.js
r34452 r34543 131 131 var htmlFormElement = document.getElementsByTagName('form')[0]; 132 132 resultArray = iterateList(htmlFormElement); 133 shouldBe("resultArray.length", "1 19");133 shouldBe("resultArray.length", "121"); 134 134 shouldBe("resultArray[0].i", "'0'"); 135 135 shouldBe("resultArray[0].item", "document.getElementsByTagName('select')[0]"); … … 142 142 var htmlSelectElement = document.getElementsByTagName('select')[0]; 143 143 resultArray = iterateList(htmlSelectElement); 144 shouldBe("resultArray.length", "12 2");144 shouldBe("resultArray.length", "124"); 145 145 shouldBe("resultArray[0].i", "'0'"); 146 146 shouldBe("resultArray[0].item", "document.getElementsByTagName('option')[0]"); -
trunk/LayoutTests/fast/dynamic/insertAdjacentElement.html
r13492 r34543 1 1 <body> 2 2 <pre id="error-log"></pre> 3 4 3 <span id="container" style="color: green"> 5 4 </span> … … 23 22 </body> 24 23 <script> 24 if (window.layoutTestController) 25 layoutTestController.dumpAsText(); 26 25 27 // verify all standard cases 26 28 document.getElementById("container").insertAdjacentElement("beforeBegin", document.getElementById("1")); … … 55 57 if (passes) { 56 58 document.getElementById("status").style.color = "green"; 57 document.getElementById("status").innerHTML = " PASS";59 document.getElementById("status").innerHTML = "<br><br>PASS"; 58 60 } 59 61 </script> -
trunk/LayoutTests/fast/dynamic/insertAdjacentHTML.html
r34540 r34543 1 1 <body> 2 2 <pre id="error-log"></pre> 3 4 3 <span id="container" style="color: green"> 5 4 </span> 6 <div style="display: none">7 <span id="1">8 1 (black)9 </span>10 <span id="2">11 2 (green)12 </span>13 <span id="3">14 3 (green)15 </span>16 <span id="4">17 4 (black)18 </span>19 </div>20 5 <span id="status" style="color: red"> 21 6 FAILURE … … 23 8 </body> 24 9 <script> 10 if (window.layoutTestController) 11 layoutTestController.dumpAsText(); 12 25 13 // verify all standard cases 26 document.getElementById("container").insertAdjacent Element("beforeBegin", document.getElementById("1"));27 document.getElementById("container").insertAdjacent Element("afterBegin", document.getElementById("2"));28 document.getElementById("container").insertAdjacent Element("beforeEnd", document.getElementById("3"));29 document.getElementById("container").insertAdjacent Element("afterEnd", document.getElementById("4"));14 document.getElementById("container").insertAdjacentHTML("beforeBegin", "<span id='1''> 1 (black)</span>"); 15 document.getElementById("container").insertAdjacentHTML("afterBegin", "<span id='2''> 2 (green)</span>"); 16 document.getElementById("container").insertAdjacentHTML("beforeEnd", "<span id='3''> 3 (green)</span>"); 17 document.getElementById("container").insertAdjacentHTML("afterEnd", "<span id='4''> 4 (black)</span>"); 30 18 31 19 function assertThrows(func) { … … 44 32 passes = passes & assertThrows(function() { 45 33 // should throw TYPE_MISMATCH_ERR 46 document.getElementById("container").insertAdjacentElement("blah", document.getElementById("1")); 47 }); 48 passes = passes & assertThrows(function() { 49 // should throw NOT_SUPPORTED_ERR 50 document.getElementById("container").insertAdjacentElement("beforeEnd", null); 34 document.getElementById("container").insertAdjacentHTML("blah", "<span>html</span>"); 51 35 }); 52 36 53 var elt = document.createElement("div");54 passes = passes & (elt.insertAdjacentElement("beforeBegin", document.createElement("p")) == null);55 37 if (passes) { 56 38 document.getElementById("status").style.color = "green"; 57 document.getElementById("status").innerHTML = " PASS";39 document.getElementById("status").innerHTML = "<br<br>PASS"; 58 40 } 59 41 </script> -
trunk/LayoutTests/fast/dynamic/insertAdjacentText.html
r34540 r34543 1 1 <body> 2 2 <pre id="error-log"></pre> 3 4 3 <span id="container" style="color: green"> 5 4 </span> 6 <div style="display: none">7 <span id="1">8 1 (black)9 </span>10 <span id="2">11 2 (green)12 </span>13 <span id="3">14 3 (green)15 </span>16 <span id="4">17 4 (black)18 </span>19 </div>20 5 <span id="status" style="color: red"> 21 6 FAILURE … … 23 8 </body> 24 9 <script> 10 if (window.layoutTestController) 11 layoutTestController.dumpAsText(); 12 25 13 // verify all standard cases 26 document.getElementById("container").insertAdjacent Element("beforeBegin", document.getElementById("1"));27 document.getElementById("container").insertAdjacent Element("afterBegin", document.getElementById("2"));28 document.getElementById("container").insertAdjacent Element("beforeEnd", document.getElementById("3"));29 document.getElementById("container").insertAdjacent Element("afterEnd", document.getElementById("4"));14 document.getElementById("container").insertAdjacentText("beforeBegin", " 1 (black)"); 15 document.getElementById("container").insertAdjacentText("afterBegin", " 2 (green)"); 16 document.getElementById("container").insertAdjacentText("beforeEnd", " 3 (green)"); 17 document.getElementById("container").insertAdjacentText("afterEnd", " 4 (black)"); 30 18 31 19 function assertThrows(func) { … … 44 32 passes = passes & assertThrows(function() { 45 33 // should throw TYPE_MISMATCH_ERR 46 document.getElementById("container").insertAdjacentElement("blah", document.getElementById("1")); 47 }); 48 passes = passes & assertThrows(function() { 49 // should throw NOT_SUPPORTED_ERR 50 document.getElementById("container").insertAdjacentElement("beforeEnd", null); 34 document.getElementById("container").insertAdjacentText("blah", "text"); 51 35 }); 52 36 53 var elt = document.createElement("div");54 passes = passes & (elt.insertAdjacentElement("beforeBegin", document.createElement("p")) == null);55 37 if (passes) { 56 38 document.getElementById("status").style.color = "green"; 57 document.getElementById("status").innerHTML = " PASS";39 document.getElementById("status").innerHTML = "<br<br>PASS"; 58 40 } 59 41 </script> -
trunk/LayoutTests/platform/mac/fast/dynamic/insertAdjacentElement-expected.txt
r30635 r34543 1 layer at (0,0) size 800x600 2 RenderView at (0,0) size 800x600 3 layer at (0,0) size 800x600 4 RenderBlock {HTML} at (0,0) size 800x600 5 RenderBody {BODY} at (8,8) size 784x584 6 RenderBlock {PRE} at (0,0) size 784x30 7 RenderText {#text} at (0,0) size 552x30 8 text run at (0,0) width 544: "Caught expected exception: Error: NOT_SUPPORTED_ERR: DOM Exception 9" 9 text run at (544,0) width 0: " " 10 text run at (0,15) width 552: "Caught expected exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17" 11 text run at (552,15) width 0: " " 12 RenderBlock (anonymous) at (0,43) size 784x18 13 RenderInline {SPAN} at (0,0) size 60x18 14 RenderText {#text} at (0,0) size 60x18 15 text run at (0,0) width 60: "1 (black) " 16 RenderInline {SPAN} at (0,0) size 122x18 [color=#008000] 17 RenderInline {SPAN} at (0,0) size 61x18 18 RenderText {#text} at (60,0) size 61x18 19 text run at (60,0) width 61: "2 (green) " 20 RenderText {#text} at (0,0) size 0x0 21 RenderInline {SPAN} at (0,0) size 61x18 22 RenderText {#text} at (121,0) size 61x18 23 text run at (121,0) width 61: "3 (green) " 24 RenderInline {SPAN} at (0,0) size 60x18 25 RenderText {#text} at (182,0) size 60x18 26 text run at (182,0) width 60: "4 (black) " 27 RenderText {#text} at (0,0) size 0x0 28 RenderText {#text} at (0,0) size 0x0 29 RenderInline {SPAN} at (0,0) size 39x18 [color=#008000] 30 RenderText {#text} at (242,0) size 39x18 31 text run at (242,0) width 39: "PASS" 32 RenderText {#text} at (0,0) size 0x0 33 RenderText {#text} at (0,0) size 0x0 34 RenderText {#text} at (0,0) size 0x0 1 Caught expected exception: Error: NOT_SUPPORTED_ERR: DOM Exception 9 2 Caught expected exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17 3 1 (black) 2 (green) 3 (green) 4 (black) 4 5 PASS -
trunk/WebCore/ChangeLog
r34542 r34543 1 2008-06-14 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Dan Bernstein. 4 5 Fix for <rdar://problem/5775192> 6 insertAdjacentHTML and insertAdjacentText are not implemented although insertAdjacentElement is. 7 8 - Implements insertAdjacentHTML and insertAdjacentText for HTMLElement. 9 - Moves the insertAdjacentElement implementation from Element to HTMLElement. 10 11 Tests: fast/dynamic/insertAdjacentHTML.html 12 fast/dynamic/insertAdjacentText.html 13 14 * dom/Element.cpp: 15 * dom/Element.h: 16 * dom/Element.idl: 17 * html/HTMLElement.cpp: 18 (WebCore::HTMLElement::insertAdjacent): 19 (WebCore::HTMLElement::insertAdjacentElement): 20 (WebCore::HTMLElement::insertAdjacentHTML): 21 (WebCore::HTMLElement::insertAdjacentText): 22 * html/HTMLElement.h: 23 * html/HTMLElement.idl: 24 1 25 2008-06-14 Darin Adler <darin@apple.com> 2 26 -
trunk/WebCore/dom/Element.cpp
r34536 r34543 618 618 } 619 619 620 Node* Element::insertAdjacentElement(const String& where, Node* newChild, int& exception)621 {622 if (!newChild) {623 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative624 exception = TYPE_MISMATCH_ERR;625 return 0;626 }627 628 // In Internet Explorer if the element has no parent and where is "beforeBegin" or "afterEnd",629 // a document fragment is created and the elements appended in the correct order. This document630 // fragment isn't returned anywhere.631 //632 // This is impossible for us to implement as the DOM tree does not allow for such structures,633 // Opera also appears to disallow such usage.634 635 if (equalIgnoringCase(where, "beforeBegin")) {636 if (Node* p = parent())637 return p->insertBefore(newChild, this, exception) ? newChild : 0;638 } else if (equalIgnoringCase(where, "afterBegin")) {639 return insertBefore(newChild, firstChild(), exception) ? newChild : 0;640 } else if (equalIgnoringCase(where, "beforeEnd")) {641 return appendChild(newChild, exception) ? newChild : 0;642 } else if (equalIgnoringCase(where, "afterEnd")) {643 if (Node* p = parent())644 return p->insertBefore(newChild, nextSibling(), exception) ? newChild : 0;645 } else {646 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative647 exception = NOT_SUPPORTED_ERR;648 }649 return 0;650 }651 652 620 bool Element::contains(const Node* node) const 653 621 { -
trunk/WebCore/dom/Element.h
r34536 r34543 169 169 #endif 170 170 171 Node* insertAdjacentElement(const String& where, Node* newChild, ExceptionCode&);172 171 bool contains(const Node*) const; 173 172 -
trunk/WebCore/dom/Element.idl
r34515 r34543 93 93 // IE extensions 94 94 95 Node insertAdjacentElement(in DOMString position,96 in Node element)97 raises(DOMException);98 95 boolean contains(in Element element); 99 96 -
trunk/WebCore/html/HTMLElement.cpp
r34432 r34543 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 493 493 } 494 494 495 Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, ExceptionCode& ec) 496 { 497 // In Internet Explorer if the element has no parent and where is "beforeBegin" or "afterEnd", 498 // a document fragment is created and the elements appended in the correct order. This document 499 // fragment isn't returned anywhere. 500 // 501 // This is impossible for us to implement as the DOM tree does not allow for such structures, 502 // Opera also appears to disallow such usage. 503 504 if (equalIgnoringCase(where, "beforeBegin")) { 505 if (Node* p = parent()) 506 return p->insertBefore(newChild, this, ec) ? newChild : 0; 507 return 0; 508 } 509 510 if (equalIgnoringCase(where, "afterBegin")) 511 return insertBefore(newChild, firstChild(), ec) ? newChild : 0; 512 513 if (equalIgnoringCase(where, "beforeEnd")) 514 return appendChild(newChild, ec) ? newChild : 0; 515 516 if (equalIgnoringCase(where, "afterEnd")) { 517 if (Node* p = parent()) 518 return p->insertBefore(newChild, nextSibling(), ec) ? newChild : 0; 519 return 0; 520 } 521 522 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative 523 ec = NOT_SUPPORTED_ERR; 524 return 0; 525 } 526 527 Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChild, ExceptionCode& ec) 528 { 529 if (!newChild) { 530 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative 531 ec = TYPE_MISMATCH_ERR; 532 return 0; 533 } 534 535 Node* returnValue = insertAdjacent(where, newChild, ec); 536 ASSERT(!returnValue || returnValue->isElementNode()); 537 return static_cast<Element*>(returnValue); 538 } 539 540 void HTMLElement::insertAdjacentHTML(const String& where, const String& html, ExceptionCode& ec) 541 { 542 // FIXME: perhaps this should use createFragmentFromMarkup() instead as 543 // createContextualFragment() has all sorts of odd rules in it. 544 RefPtr<DocumentFragment> fragment = createContextualFragment(html); 545 if (!fragment) { 546 ec = NO_MODIFICATION_ALLOWED_ERR; 547 return; 548 } 549 550 insertAdjacent(where, fragment.get(), ec); 551 } 552 553 void HTMLElement::insertAdjacentText(const String& where, const String& text, ExceptionCode& ec) 554 { 555 RefPtr<Text> textNode = document()->createTextNode(text); 556 insertAdjacent(where, textNode.get(), ec); 557 } 558 495 559 void HTMLElement::addHTMLAlignment(MappedAttribute* attr) 496 560 { -
trunk/WebCore/html/HTMLElement.h
r33577 r34543 70 70 void setInnerText(const String&, ExceptionCode&); 71 71 void setOuterText(const String&, ExceptionCode&); 72 72 73 Element* insertAdjacentElement(const String& where, Element* newChild, ExceptionCode&); 74 void insertAdjacentHTML(const String& where, const String& html, ExceptionCode&); 75 void insertAdjacentText(const String& where, const String& text, ExceptionCode&); 76 73 77 virtual bool isFocusable() const; 74 78 virtual bool isContentEditable() const; … … 108 112 private: 109 113 virtual HTMLFormElement* virtualForm() const; 114 Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&); 110 115 }; 111 116 112 } // namespace117 } // namespace WebCore 113 118 114 #endif 119 #endif // HTMLElement_h -
trunk/WebCore/html/HTMLElement.idl
r32664 r34543 50 50 setter raises(DOMException); 51 51 52 Element insertAdjacentElement(in DOMString where, 53 in Element element) 54 raises(DOMException); 55 void insertAdjacentHTML(in DOMString where, 56 in DOMString html) 57 raises(DOMException); 58 void insertAdjacentText(in DOMString where, 59 in DOMString text) 60 raises(DOMException); 61 52 62 readonly attribute HTMLCollection children; 53 63
Note: See TracChangeset
for help on using the changeset viewer.