Changeset 176630 in webkit
- Timestamp:
- Dec 2, 2014, 2:50:11 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt (modified) (3 diffs)
-
LayoutTests/svg/css/svg-attribute-length-parsing-expected.txt (modified) (1 diff)
-
LayoutTests/svg/in-html/svg-inner-html-expected.txt (added)
-
LayoutTests/svg/in-html/svg-inner-html.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/objc/PublicDOMInterfaces.h (modified) (2 diffs)
-
Source/WebCore/dom/Element.cpp (modified) (3 diffs)
-
Source/WebCore/dom/Element.h (modified) (2 diffs)
-
Source/WebCore/dom/Element.idl (modified) (1 diff)
-
Source/WebCore/html/HTMLElement.cpp (modified) (2 diffs)
-
Source/WebCore/html/HTMLElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLElement.idl (modified) (1 diff)
-
Source/WebCore/html/parser/HTMLTreeBuilder.cpp (modified) (10 diffs)
-
Source/WebCore/html/parser/HTMLTreeBuilder.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r176628 r176630 1 2014-12-02 Sylvain Galineau <galineau@adobe.com> 2 3 Missing support for innerHTML on SVGElement 4 https://bugs.webkit.org/show_bug.cgi?id=136903 5 6 Reviewed by Dean Jackson. 7 8 * js/dom/dom-static-property-for-in-iteration-expected.txt: The property enumeration order is different now that inner/outerHTML are inherited from Element 9 * platform/mac/svg/in-html/svg-inner-html-expected.png: Added. 10 * svg/css/svg-attribute-length-parsing-expected.txt: 11 Now that innerHTML works, the output should start with 'Test' 12 * svg/in-html/svg-inner-html-expected.txt: Added. 13 * svg/in-html/svg-inner-html.html: Added. 14 1 15 2014-12-02 Andrzej Badowski <a.badowski@samsung.com> 2 16 -
trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt
r175028 r176630 38 38 PASS a["hidden"] is false 39 39 PASS a["accessKey"] is 40 PASS a["innerHTML"] is nerget41 40 PASS a["innerText"] is nerget 42 PASS a["outerHTML"] is <a id="foo" href="bar">nerget</a>43 41 PASS a["outerText"] is nerget 44 42 PASS a["children"] is [object HTMLCollection] … … 51 49 PASS a["id"] is foo 52 50 PASS a["offsetLeft"] is 8 53 PASS a["offsetTop"] is 7 8951 PASS a["offsetTop"] is 759 54 52 PASS a["offsetWidth"] is 39 55 53 PASS a["offsetHeight"] is 18 … … 63 61 PASS a["scrollHeight"] is 0 64 62 PASS a["offsetParent"] is [object HTMLBodyElement] 63 PASS a["innerHTML"] is nerget 64 PASS a["outerHTML"] is <a id="foo" href="bar">nerget</a> 65 65 PASS a["className"] is 66 66 PASS a["classList"] is -
trunk/LayoutTests/svg/css/svg-attribute-length-parsing-expected.txt
r112769 r176630 1 Test 1 2 Test CSS parsing on SVG presentation attributes. 2 3 -
trunk/Source/WebCore/ChangeLog
r176626 r176630 1 2014-12-02 Sylvain Galineau <galineau@adobe.com> 2 3 Missing support for innerHTML on SVGElement 4 https://bugs.webkit.org/show_bug.cgi?id=136903 5 6 Reviewed by Dean Jackson. 7 8 Two parts to this patch: 9 1. Move innerHTML/outerHTML to Element so SVG elements can inherit them, per https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#innerhtml 10 2. Make sure fragment insertion is processed relative to the proper node, per http://www.whatwg.org/specs/web-apps/current-work/#adjusted-current-node 11 12 The latter part was ported over from Blink. 13 14 Test: svg/in-html/svg-inner-html.html 15 16 * bindings/objc/PublicDOMInterfaces.h: Move innerHTML/outerHTML to Element. 17 * dom/Element.cpp: 18 (WebCore::Element::mergeWithNextTextNode): Helper used by Element::innerHTML/outerHTML as well as HTMLElement::innerText/outerText; moved to Element as protected static. 19 (WebCore::Element::innerHTML): Moved from HTMLElement. 20 (WebCore::Element::outerHTML): Moved from HTMLElement. 21 (WebCore::Element::setOuterHTML): Moved from HTMLElement. 22 (WebCore::Element::setInnerHTML): Moved from HTMLElement. 23 * dom/Element.h: 24 * dom/Element.idl: 25 * html/HTMLElement.cpp: 26 (WebCore::HTMLElement::innerHTML): Deleted. 27 (WebCore::HTMLElement::outerHTML): Deleted. 28 (WebCore::HTMLElement::setInnerHTML): Deleted. 29 (WebCore::mergeWithNextTextNode): Deleted. 30 (WebCore::HTMLElement::setOuterHTML): Deleted. 31 * html/HTMLElement.h: 32 * html/HTMLElement.idl: 33 * html/parser/HTMLTreeBuilder.cpp: 34 (WebCore::HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext): no more m_contextElement. 35 (WebCore::HTMLTreeBuilder::constructTree): read namespace from adjusted current node. 36 (WebCore::HTMLTreeBuilder::resetInsertionModeAppropriately): use contextElementStackItem for insertion. 37 (WebCore::HTMLTreeBuilder::adjustedCurrentStackItem): compute adjusted current node. 38 (WebCore::HTMLTreeBuilder::shouldProcessTokenInForeignContent): use adjusted current node for context. 39 (WebCore::HTMLTreeBuilder::processTokenInForeignContent): use adjusted current node to read namespace. 40 * html/parser/HTMLTreeBuilder.h: 41 (WebCore::HTMLTreeBuilder::FragmentParsingContext::contextElement): Deleted. Read from contextElementStackItem. 42 (WebCore::HTMLTreeBuilder::FragmentParsingContext::contextElementStackItem): Added. 43 1 44 2014-11-20 Jeffrey Pfau <jpfau@apple.com> 2 45 -
trunk/Source/WebCore/bindings/objc/PublicDOMInterfaces.h
r172884 r176630 196 196 @property (readonly) int clientTop WEBKIT_AVAILABLE_MAC(10_5); 197 197 @property (readonly, copy) NSString *innerText WEBKIT_AVAILABLE_MAC(10_5); 198 @property (copy) NSString *innerHTML; 199 @property (copy) NSString *outerHTML; 198 200 @property (readonly, strong) DOMElement *firstElementChild WEBKIT_AVAILABLE_MAC(10_6); 199 201 @property (readonly, strong) DOMElement *lastElementChild WEBKIT_AVAILABLE_MAC(10_6); … … 477 479 @property (copy) NSString *lang; 478 480 @property (copy) NSString *dir; 479 @property (copy) NSString *innerHTML;480 481 @property (copy) NSString *innerText; 481 @property (copy) NSString *outerHTML;482 482 @property (copy) NSString *outerText; 483 483 @property (readonly, strong) DOMHTMLCollection *children; -
trunk/Source/WebCore/dom/Element.cpp
r176502 r176630 55 55 #include "HTMLSelectElement.h" 56 56 #include "HTMLTableRowsCollection.h" 57 #include "HTMLTemplateElement.h" 57 58 #include "InsertionPoint.h" 58 59 #include "KeyboardEvent.h" … … 82 83 #include "XMLNames.h" 83 84 #include "htmlediting.h" 85 #include "markup.h" 84 86 #include <wtf/BitVector.h> 85 87 #include <wtf/CurrentTime.h> … … 2023 2025 } 2024 2026 2027 void Element::mergeWithNextTextNode(Text& node, ExceptionCode& ec) 2028 { 2029 Node* next = node.nextSibling(); 2030 if (!is<Text>(next)) 2031 return; 2032 2033 Ref<Text> textNode(node); 2034 Ref<Text> textNext(downcast<Text>(*next)); 2035 textNode->appendData(textNext->data(), ec); 2036 if (ec) 2037 return; 2038 textNext->remove(ec); 2039 } 2040 2041 String Element::innerHTML() const 2042 { 2043 return createMarkup(*this, ChildrenOnly); 2044 } 2045 2046 String Element::outerHTML() const 2047 { 2048 return createMarkup(*this); 2049 } 2050 2051 void Element::setOuterHTML(const String& html, ExceptionCode& ec) 2052 { 2053 Element* p = parentElement(); 2054 if (!is<HTMLElement>(p)) { 2055 ec = NO_MODIFICATION_ALLOWED_ERR; 2056 return; 2057 } 2058 RefPtr<HTMLElement> parent = downcast<HTMLElement>(p); 2059 RefPtr<Node> prev = previousSibling(); 2060 RefPtr<Node> next = nextSibling(); 2061 2062 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, parent.get(), AllowScriptingContent, ec); 2063 if (ec) 2064 return; 2065 2066 parent->replaceChild(fragment.release(), this, ec); 2067 RefPtr<Node> node = next ? next->previousSibling() : nullptr; 2068 if (!ec && is<Text>(node.get())) 2069 mergeWithNextTextNode(downcast<Text>(*node), ec); 2070 if (!ec && is<Text>(prev.get())) 2071 mergeWithNextTextNode(downcast<Text>(*prev), ec); 2072 } 2073 2074 2075 void Element::setInnerHTML(const String& html, ExceptionCode& ec) 2076 { 2077 if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, this, AllowScriptingContent, ec)) { 2078 ContainerNode* container = this; 2079 2080 #if ENABLE(TEMPLATE_ELEMENT) 2081 if (is<HTMLTemplateElement>(*this)) 2082 container = downcast<HTMLTemplateElement>(*this).content(); 2083 #endif 2084 2085 replaceChildrenWithFragment(*container, fragment.release(), ec); 2086 } 2087 } 2025 2088 2026 2089 String Element::innerText() -
trunk/Source/WebCore/dom/Element.h
r176502 r176630 396 396 virtual void blur(); 397 397 398 String innerHTML() const; 399 String outerHTML() const; 400 void setInnerHTML(const String&, ExceptionCode&); 401 void setOuterHTML(const String&, ExceptionCode&); 398 402 WEBCORE_EXPORT String innerText(); 399 403 String outerText(); … … 573 577 // svgAttributeChanged (called when element.className.baseValue is set) 574 578 void classAttributeChanged(const AtomicString& newClassString); 579 580 static void mergeWithNextTextNode(Text& node, ExceptionCode& ec); 575 581 576 582 private: -
trunk/Source/WebCore/dom/Element.idl
r174363 r176630 109 109 // HTML 5 110 110 NodeList getElementsByClassName([Default=Undefined] optional DOMString name); 111 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString innerHTML; 112 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString outerHTML; 113 111 114 112 115 [Reflect=class] attribute DOMString className; -
trunk/Source/WebCore/html/HTMLElement.cpp
r176502 r176630 49 49 #include "HTMLNames.h" 50 50 #include "HTMLParserIdioms.h" 51 #include "HTMLTemplateElement.h"52 51 #include "HTMLTextFormControlElement.h" 53 52 #include "NodeTraversal.h" … … 415 414 } 416 415 417 String HTMLElement::innerHTML() const418 {419 return createMarkup(*this, ChildrenOnly);420 }421 422 String HTMLElement::outerHTML() const423 {424 return createMarkup(*this);425 }426 427 void HTMLElement::setInnerHTML(const String& html, ExceptionCode& ec)428 {429 if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, this, AllowScriptingContent, ec)) {430 ContainerNode* container = this;431 #if ENABLE(TEMPLATE_ELEMENT)432 if (is<HTMLTemplateElement>(*this))433 container = downcast<HTMLTemplateElement>(*this).content();434 #endif435 replaceChildrenWithFragment(*container, fragment.release(), ec);436 }437 }438 439 static void mergeWithNextTextNode(Text& node, ExceptionCode& ec)440 {441 Node* next = node.nextSibling();442 if (!is<Text>(next))443 return;444 445 Ref<Text> textNode(node);446 Ref<Text> textNext(downcast<Text>(*next));447 textNode->appendData(textNext->data(), ec);448 if (ec)449 return;450 textNext->remove(ec);451 }452 453 void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec)454 {455 Element* p = parentElement();456 if (!is<HTMLElement>(p)) {457 ec = NO_MODIFICATION_ALLOWED_ERR;458 return;459 }460 RefPtr<HTMLElement> parent = downcast<HTMLElement>(p);461 RefPtr<Node> prev = previousSibling();462 RefPtr<Node> next = nextSibling();463 464 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, parent.get(), AllowScriptingContent, ec);465 if (ec)466 return;467 468 parent->replaceChild(fragment.release(), this, ec);469 RefPtr<Node> node = next ? next->previousSibling() : nullptr;470 if (!ec && is<Text>(node.get()))471 mergeWithNextTextNode(downcast<Text>(*node), ec);472 if (!ec && is<Text>(prev.get()))473 mergeWithNextTextNode(downcast<Text>(*prev), ec);474 }475 476 416 RefPtr<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionCode& ec) 477 417 { -
trunk/Source/WebCore/html/HTMLElement.h
r176502 r176630 49 49 virtual short tabIndex() const override; 50 50 51 String innerHTML() const;52 String outerHTML() const;53 void setInnerHTML(const String&, ExceptionCode&);54 void setOuterHTML(const String&, ExceptionCode&);55 51 void setInnerText(const String&, ExceptionCode&); 56 52 void setOuterText(const String&, ExceptionCode&); -
trunk/Source/WebCore/html/HTMLElement.idl
r160068 r176630 39 39 40 40 // Extensions 41 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString innerHTML; 42 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString innerText; 43 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString outerHTML; 44 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString outerText; 45 41 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString innerText; 42 [TreatNullAs=NullString, SetterRaisesException] attribute DOMString outerText; 43 46 44 [RaisesException] Element insertAdjacentElement([Default=Undefined] optional DOMString where, 47 45 [Default=Undefined] optional Element element); -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r174225 r176630 321 321 HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext() 322 322 : m_fragment(0) 323 , m_contextElement(0)324 323 { 325 324 } … … 327 326 HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext(DocumentFragment& fragment, Element* contextElement) 328 327 : m_fragment(&fragment) 329 , m_contextElement(contextElement)330 328 { 331 329 ASSERT(!fragment.hasChildNodes()); 330 m_contextElementStackItem = HTMLStackItem::create(contextElement, HTMLStackItem::ItemForContextElement); 332 331 } 333 332 … … 357 356 if (m_parser.tokenizer()) { 358 357 bool inForeignContent = !m_tree.isEmpty() 359 && ! m_tree.currentStackItem()->isInHTMLNamespace()358 && !adjustedCurrentStackItem()->isInHTMLNamespace() 360 359 && !HTMLElementStack::isHTMLIntegrationPoint(m_tree.currentStackItem()) 361 360 && !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.currentStackItem()); … … 1618 1617 #endif 1619 1618 if (shouldCreateItem) 1620 item = HTMLStackItem::create(m_fragmentContext.contextElement(), HTMLStackItem::ItemForContextElement);1619 item = m_fragmentContext.contextElementStackItem(); 1621 1620 } 1622 1621 #if ENABLE(TEMPLATE_ELEMENT) … … 2841 2840 setInsertionMode(InsertionMode::Text); 2842 2841 } 2842 2843 // http://www.whatwg.org/specs/web-apps/current-work/#adjusted-current-node 2844 HTMLStackItem* HTMLTreeBuilder::adjustedCurrentStackItem() const 2845 { 2846 ASSERT(!m_tree.isEmpty()); 2847 if (isParsingFragment() && m_tree.openElements()->hasOnlyOneElement()) 2848 return m_fragmentContext.contextElementStackItem(); 2849 2850 return m_tree.currentStackItem(); 2851 } 2852 2843 2853 2844 2854 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#tree-construction … … 2847 2857 if (m_tree.isEmpty()) 2848 2858 return false; 2849 HTMLStackItem* item = m_tree.currentStackItem();2850 if ( item->isInHTMLNamespace())2859 HTMLStackItem* adjustedCurrentNode = adjustedCurrentStackItem(); 2860 if (adjustedCurrentNode->isInHTMLNamespace()) 2851 2861 return false; 2852 if (HTMLElementStack::isMathMLTextIntegrationPoint( item)) {2862 if (HTMLElementStack::isMathMLTextIntegrationPoint(adjustedCurrentNode)) { 2853 2863 if (token->type() == HTMLToken::StartTag 2854 2864 && token->name() != MathMLNames::mglyphTag … … 2858 2868 return false; 2859 2869 } 2860 if ( item->hasTagName(MathMLNames::annotation_xmlTag)2870 if (adjustedCurrentNode->hasTagName(MathMLNames::annotation_xmlTag) 2861 2871 && token->type() == HTMLToken::StartTag 2862 2872 && token->name() == SVGNames::svgTag) 2863 2873 return false; 2864 if (HTMLElementStack::isHTMLIntegrationPoint( item)) {2874 if (HTMLElementStack::isHTMLIntegrationPoint(adjustedCurrentNode)) { 2865 2875 if (token->type() == HTMLToken::StartTag) 2866 2876 return false; … … 2875 2885 void HTMLTreeBuilder::processTokenInForeignContent(AtomicHTMLToken* token) 2876 2886 { 2887 HTMLStackItem* adjustedCurrentNode = adjustedCurrentStackItem(); 2888 2877 2889 switch (token->type()) { 2878 2890 case HTMLToken::Uninitialized: … … 2928 2940 return; 2929 2941 } 2930 const AtomicString& currentNamespace = m_tree.currentStackItem()->namespaceURI();2942 const AtomicString& currentNamespace = adjustedCurrentNode->namespaceURI(); 2931 2943 if (currentNamespace == MathMLNames::mathmlNamespaceURI) 2932 2944 adjustMathMLAttributes(*token); … … 2940 2952 } 2941 2953 case HTMLToken::EndTag: { 2942 if ( m_tree.currentStackItem()->namespaceURI() == SVGNames::svgNamespaceURI)2954 if (adjustedCurrentNode->namespaceURI() == SVGNames::svgNamespaceURI) 2943 2955 adjustSVGTagNameCase(*token); 2944 2956 -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r165708 r176630 33 33 #include "HTMLFormattingElementList.h" 34 34 #include "HTMLParserOptions.h" 35 #include "HTMLStackItem.h" 35 36 #include "HTMLTokenizer.h" 36 37 #include <wtf/Noncopyable.h> … … 171 172 inline bool shouldProcessTokenInForeignContent(AtomicHTMLToken*); 172 173 void processTokenInForeignContent(AtomicHTMLToken*); 174 175 inline HTMLStackItem* adjustedCurrentStackItem() const; 173 176 174 177 Vector<Attribute> attributesForIsindexInput(AtomicHTMLToken*); … … 202 205 203 206 DocumentFragment* fragment() const { return m_fragment; } 204 Element* contextElement() const { ASSERT(m_fragment); return m_contextElement; } 207 Element* contextElement() const { ASSERT(m_fragment); return m_contextElementStackItem->element(); } 208 HTMLStackItem* contextElementStackItem() const { ASSERT(m_fragment); return m_contextElementStackItem.get(); } 205 209 206 210 private: 207 211 DocumentFragment* m_fragment; 208 Element* m_contextElement;212 RefPtr<HTMLStackItem> m_contextElementStackItem; 209 213 }; 210 214
Note:
See TracChangeset
for help on using the changeset viewer.