Title: [107661] trunk
Revision
107661
Author
[email protected]
Date
2012-02-13 19:15:16 -0800 (Mon, 13 Feb 2012)

Log Message

Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE.
https://bugs.webkit.org/show_bug.cgi?id=77514

Reviewed by Dimitri Glazkov.

NodeType.SHADOW_ROOT_NODE type is finally gone.

Source/WebCore:

* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* bindings/objc/DOM.mm:
(kitClass):
* bindings/v8/custom/V8NodeCustom.cpp:
(WebCore::toV8Slow):
* dom/ContainerNode.cpp:
(WebCore::collectTargetNodes):
(WebCore::ContainerNode::replaceChild):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::childTypeAllowed):
(WebCore::Document::canReplaceChild):
* dom/Node.cpp:
(WebCore::Node::dumpStatistics):
(WebCore::Node::isDefaultNamespace):
(WebCore::Node::lookupPrefix):
(WebCore::Node::lookupNamespaceURI):
(WebCore::appendTextContent):
(WebCore::Node::setTextContent):
* dom/Node.h:
* dom/Range.cpp:
(WebCore::lengthOfContentsInNode):
(WebCore::Range::processContentsBetweenOffsets):
(WebCore::Range::insertNode):
(WebCore::Range::checkNodeWOffset):
(WebCore::Range::checkNodeBA):
(WebCore::Range::selectNode):
(WebCore::Range::selectNodeContents):
(WebCore::Range::surroundContents):
* dom/ShadowRoot.cpp:
* dom/ShadowRoot.h:
(ShadowRoot):
(WebCore::toShadowRoot):
* editing/FrameSelection.cpp:
(WebCore::nodeIsDetachedFromDocument):
(WebCore):
(WebCore::FrameSelection::textWillBeReplaced):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendStartMarkup):
* html/parser/HTMLElementStack.cpp:
(WebCore::HTMLNames::isRootNode):
(WebCore::HTMLElementStack::pushRootNode):
* html/parser/HTMLElementStack.h:
(WebCore::isInHTMLNamespace):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
(WebCore::InspectorDOMAgent::buildObjectForNode):
* xml/XPathUtil.cpp:
(WebCore::XPath::isValidContextNode):

Source/WebKit/chromium:

* src/WebPageSerializerImpl.cpp:
(WebKit::WebPageSerializerImpl::buildContentForNode):

LayoutTests:

* fast/dom/shadow/nodetype-expected.txt:
* fast/dom/shadow/nodetype.html:
* resources/dump-as-markup.js:
(Markup._get):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107660 => 107661)


--- trunk/LayoutTests/ChangeLog	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/LayoutTests/ChangeLog	2012-02-14 03:15:16 UTC (rev 107661)
@@ -1,3 +1,17 @@
+2012-02-13  Hayato Ito  <[email protected]>
+
+        Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE.
+        https://bugs.webkit.org/show_bug.cgi?id=77514
+
+        Reviewed by Dimitri Glazkov.
+
+        NodeType.SHADOW_ROOT_NODE type is finally gone.
+
+        * fast/dom/shadow/nodetype-expected.txt:
+        * fast/dom/shadow/nodetype.html:
+        * resources/dump-as-markup.js:
+        (Markup._get):
+
 2012-02-13  Tony Chang  <[email protected]>
 
         [chromium] Unreviewed gardening.  Small cleanup after r107638.

Modified: trunk/LayoutTests/fast/dom/shadow/nodetype-expected.txt (107660 => 107661)


--- trunk/LayoutTests/fast/dom/shadow/nodetype-expected.txt	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/LayoutTests/fast/dom/shadow/nodetype-expected.txt	2012-02-14 03:15:16 UTC (rev 107661)
@@ -1,9 +1,9 @@
 
 This tests the shadow host's and shadow root's nodeType.
 PASS keygen.nodeType is Node.ELEMENT_NODE
-PASS shadow.nodeType is 14
+PASS shadow.nodeType is Node.DOCUMENT_FRAGMENT_NODE
 PASS shadowChild is non-null.
-PASS shadowChild.nodeType != 14 is true
+PASS shadowChild.nodeType != Node.DOCUMENT_FRAGMENT_NODE is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/shadow/nodetype.html (107660 => 107661)


--- trunk/LayoutTests/fast/dom/shadow/nodetype.html	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/LayoutTests/fast/dom/shadow/nodetype.html	2012-02-14 03:15:16 UTC (rev 107661)
@@ -16,9 +16,9 @@
         var shadow = internals.shadowRoot(keygen);
         var shadowChild = shadow.firstChild;
         shouldBe('keygen.nodeType', 'Node.ELEMENT_NODE');
-        shouldBe('shadow.nodeType', '14');
+        shouldBe('shadow.nodeType', 'Node.DOCUMENT_FRAGMENT_NODE');
         shouldBeNonNull('shadowChild');
-        shouldBeTrue('shadowChild.nodeType != 14');
+        shouldBeTrue('shadowChild.nodeType != Node.DOCUMENT_FRAGMENT_NODE');
     }
 </script>
 <script src=""

Modified: trunk/LayoutTests/resources/dump-as-markup.js (107660 => 107661)


--- trunk/LayoutTests/resources/dump-as-markup.js	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/LayoutTests/resources/dump-as-markup.js	2012-02-14 03:15:16 UTC (rev 107661)
@@ -215,8 +215,9 @@
                 str += Markup._indent(depth + 1) + 'this.value="' + node.value + '"';
 
         break;
-    case 14: // See SHADOW_ROOT_NODE on Node::NodeType
-        str += "<shadow:root>";
+    case Node.DOCUMENT_FRAGMENT_NODE:
+        if (node.nodeName == "#shadow-root")
+          str += "<shadow:root>";
     }
 
     for (var i = 0, len = node.childNodes.length; i < len; i++) {

Modified: trunk/Source/WebCore/ChangeLog (107660 => 107661)


--- trunk/Source/WebCore/ChangeLog	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/ChangeLog	2012-02-14 03:15:16 UTC (rev 107661)
@@ -1,3 +1,63 @@
+2012-02-13  Hayato Ito  <[email protected]>
+
+        Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE.
+        https://bugs.webkit.org/show_bug.cgi?id=77514
+
+        Reviewed by Dimitri Glazkov.
+
+        NodeType.SHADOW_ROOT_NODE type is finally gone.
+
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::createWrapperInline):
+        * bindings/objc/DOM.mm:
+        (kitClass):
+        * bindings/v8/custom/V8NodeCustom.cpp:
+        (WebCore::toV8Slow):
+        * dom/ContainerNode.cpp:
+        (WebCore::collectTargetNodes):
+        (WebCore::ContainerNode::replaceChild):
+        * dom/Document.cpp:
+        (WebCore::Document::importNode):
+        (WebCore::Document::childTypeAllowed):
+        (WebCore::Document::canReplaceChild):
+        * dom/Node.cpp:
+        (WebCore::Node::dumpStatistics):
+        (WebCore::Node::isDefaultNamespace):
+        (WebCore::Node::lookupPrefix):
+        (WebCore::Node::lookupNamespaceURI):
+        (WebCore::appendTextContent):
+        (WebCore::Node::setTextContent):
+        * dom/Node.h:
+        * dom/Range.cpp:
+        (WebCore::lengthOfContentsInNode):
+        (WebCore::Range::processContentsBetweenOffsets):
+        (WebCore::Range::insertNode):
+        (WebCore::Range::checkNodeWOffset):
+        (WebCore::Range::checkNodeBA):
+        (WebCore::Range::selectNode):
+        (WebCore::Range::selectNodeContents):
+        (WebCore::Range::surroundContents):
+        * dom/ShadowRoot.cpp:
+        * dom/ShadowRoot.h:
+        (ShadowRoot):
+        (WebCore::toShadowRoot):
+        * editing/FrameSelection.cpp:
+        (WebCore::nodeIsDetachedFromDocument):
+        (WebCore):
+        (WebCore::FrameSelection::textWillBeReplaced):
+        * editing/MarkupAccumulator.cpp:
+        (WebCore::MarkupAccumulator::appendStartMarkup):
+        * html/parser/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isRootNode):
+        (WebCore::HTMLElementStack::pushRootNode):
+        * html/parser/HTMLElementStack.h:
+        (WebCore::isInHTMLNamespace):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        * xml/XPathUtil.cpp:
+        (WebCore::XPath::isValidContextNode):
+
 2012-02-13  Ojan Vafai  <[email protected]>
 
         rtl + flex-direction:column is positioning elements incorrectly

Modified: trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp (107660 => 107661)


--- trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -254,11 +254,12 @@
             wrapper = CREATE_DOM_WRAPPER(exec, globalObject, Notation, node);
             break;
         case Node::DOCUMENT_FRAGMENT_NODE:
+            // In case of ShadowRoot, a cached ShadowRoot binding is always used and this
+            // code path never be used in current API set.
+            // Once we have such APIs, we should call CREATE_DOM_WRAPPER using ShadowRoot.
+            ASSERT(!node->isShadowRoot());
             wrapper = CREATE_DOM_WRAPPER(exec, globalObject, DocumentFragment, node);
             break;
-        case Node::SHADOW_ROOT_NODE:
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, Node, node);
-            break;
         case Node::ENTITY_REFERENCE_NODE:
             wrapper = CREATE_DOM_WRAPPER(exec, globalObject, EntityReference, node);
             break;

Modified: trunk/Source/WebCore/bindings/objc/DOM.mm (107660 => 107661)


--- trunk/Source/WebCore/bindings/objc/DOM.mm	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/bindings/objc/DOM.mm	2012-02-14 03:15:16 UTC (rev 107661)
@@ -327,8 +327,6 @@
             // FIXME: Create an XPath objective C wrapper
             // See http://bugs.webkit.org/show_bug.cgi?id=8755
             return nil;
-        case WebCore::Node::SHADOW_ROOT_NODE:
-            return [DOMNode class];
     }
     ASSERT_NOT_REACHED();
     return nil;

Modified: trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp (107660 => 107661)


--- trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -163,10 +163,13 @@
     case Node::DOCUMENT_TYPE_NODE:
         return toV8(static_cast<DocumentType*>(impl), forceNewObject);
     case Node::DOCUMENT_FRAGMENT_NODE:
+        // In case of ShadowRoot, a cached ShadowRoot is always used and this
+        // code path never be used in current API set.
+        // Once we have such APIs, we should call toV8(static_cast<ShadowRoot*>..).
+        ASSERT(!impl->isShadowRoot());
         return toV8(static_cast<DocumentFragment*>(impl), forceNewObject);
     case Node::NOTATION_NODE:
         return toV8(static_cast<Notation*>(impl), forceNewObject);
-    case Node::SHADOW_ROOT_NODE: // There's no IDL class for ShadowRoot, fall-through to default and use Node instead.
     default: break; // XPATH_NAMESPACE_NODE
     }
     return V8Node::wrap(impl, forceNewObject);

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (107660 => 107661)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -69,7 +69,7 @@
 
 static void collectTargetNodes(Node* node, NodeVector& nodes)
 {
-    if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
+    if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE || node->isShadowRoot()) {
         nodes.append(node);
         return;
     }
@@ -298,7 +298,7 @@
     // that no callers call with ref count == 0 and parent = 0 (as of this
     // writing, there are definitely callers who call that way).
 
-    bool isFragment = newChild->nodeType() == DOCUMENT_FRAGMENT_NODE;
+    bool isFragment = newChild->nodeType() == DOCUMENT_FRAGMENT_NODE && !newChild->isShadowRoot();
 
     // Add the new child(ren)
     RefPtr<Node> child = isFragment ? newChild->firstChild() : newChild;

Modified: trunk/Source/WebCore/dom/Document.cpp (107660 => 107661)


--- trunk/Source/WebCore/dom/Document.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -876,6 +876,11 @@
     case ATTRIBUTE_NODE:
         return Attr::create(0, this, static_cast<Attr*>(importedNode)->attr()->clone());
     case DOCUMENT_FRAGMENT_NODE: {
+        if (importedNode->isShadowRoot()) {
+            // ShadowRoot nodes should not be explicitly importable.
+            // Either they are imported along with their host node, or created implicitly.
+            break;
+        }
         DocumentFragment* oldFragment = static_cast<DocumentFragment*>(importedNode);
         RefPtr<DocumentFragment> newFragment = createDocumentFragment();
         if (deep) {
@@ -898,9 +903,6 @@
     case DOCUMENT_NODE:
     case DOCUMENT_TYPE_NODE:
     case XPATH_NAMESPACE_NODE:
-    case SHADOW_ROOT_NODE:
-        // ShadowRoot nodes should not be explicitly importable.
-        // Either they are imported along with their host node, or created implicitly.
         break;
     }
     ec = NOT_SUPPORTED_ERR;
@@ -2856,7 +2858,6 @@
     case NOTATION_NODE:
     case TEXT_NODE:
     case XPATH_NAMESPACE_NODE:
-    case SHADOW_ROOT_NODE:
         return false;
     case COMMENT_NODE:
     case PROCESSING_INSTRUCTION_NODE:
@@ -2926,9 +2927,6 @@
             case ELEMENT_NODE:
                 numElements++;
                 break;
-            case SHADOW_ROOT_NODE:
-                ASSERT_NOT_REACHED();
-                return false;
             }
         }
     } else {
@@ -2942,7 +2940,6 @@
         case NOTATION_NODE:
         case TEXT_NODE:
         case XPATH_NAMESPACE_NODE:
-        case SHADOW_ROOT_NODE:
             return false;
         case COMMENT_NODE:
         case PROCESSING_INSTRUCTION_NODE:

Modified: trunk/Source/WebCore/dom/Node.cpp (107660 => 107661)


--- trunk/Source/WebCore/dom/Node.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -227,7 +227,10 @@
                 break;
             }
             case DOCUMENT_FRAGMENT_NODE: {
-                ++fragmentNodes;
+                if (node->isShadowRoot())
+                    ++shadowRootNodes;
+                else
+                    ++fragmentNodes;
                 break;
             }
             case NOTATION_NODE: {
@@ -238,10 +241,6 @@
                 ++xpathNSNodes;
                 break;
             }
-            case SHADOW_ROOT_NODE: {
-                ++shadowRootNodes;
-                break;
-            }
         }
     }
 
@@ -1845,7 +1844,6 @@
         case NOTATION_NODE:
         case DOCUMENT_TYPE_NODE:
         case DOCUMENT_FRAGMENT_NODE:
-        case SHADOW_ROOT_NODE:
             return false;
         case ATTRIBUTE_NODE: {
             const Attr* attr = static_cast<const Attr*>(this);
@@ -1879,7 +1877,6 @@
         case NOTATION_NODE:
         case DOCUMENT_FRAGMENT_NODE:
         case DOCUMENT_TYPE_NODE:
-        case SHADOW_ROOT_NODE:
             return String();
         case ATTRIBUTE_NODE: {
             const Attr *attr = static_cast<const Attr *>(this);
@@ -1938,7 +1935,6 @@
         case NOTATION_NODE:
         case DOCUMENT_TYPE_NODE:
         case DOCUMENT_FRAGMENT_NODE:
-        case SHADOW_ROOT_NODE:
             return String();
         case ATTRIBUTE_NODE: {
             const Attr *attr = static_cast<const Attr *>(this);
@@ -2006,7 +2002,6 @@
     case Node::ENTITY_NODE:
     case Node::ENTITY_REFERENCE_NODE:
     case Node::DOCUMENT_FRAGMENT_NODE:
-    case Node::SHADOW_ROOT_NODE:
         isNullString = false;
         for (Node* child = node->firstChild(); child; child = child->nextSibling()) {
             if (child->nodeType() == Node::COMMENT_NODE || child->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
@@ -2044,8 +2039,7 @@
         case ATTRIBUTE_NODE:
         case ENTITY_NODE:
         case ENTITY_REFERENCE_NODE:
-        case DOCUMENT_FRAGMENT_NODE:
-        case SHADOW_ROOT_NODE: {
+        case DOCUMENT_FRAGMENT_NODE: {
             ContainerNode* container = toContainerNode(this);
 #if ENABLE(MUTATION_OBSERVERS)
             ChildListMutationScope mutation(this);

Modified: trunk/Source/WebCore/dom/Node.h (107660 => 107661)


--- trunk/Source/WebCore/dom/Node.h	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/Node.h	2012-02-14 03:15:16 UTC (rev 107661)
@@ -122,7 +122,6 @@
         DOCUMENT_FRAGMENT_NODE = 11,
         NOTATION_NODE = 12,
         XPATH_NAMESPACE_NODE = 13,
-        SHADOW_ROOT_NODE = 14
     };
     enum DocumentPosition {
         DOCUMENT_POSITION_EQUIVALENT = 0x00,

Modified: trunk/Source/WebCore/dom/Range.cpp (107660 => 107661)


--- trunk/Source/WebCore/dom/Range.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/Range.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -677,7 +677,6 @@
     case Node::DOCUMENT_FRAGMENT_NODE:
     case Node::NOTATION_NODE:
     case Node::XPATH_NAMESPACE_NODE:
-    case Node::SHADOW_ROOT_NODE:
         return node->childNodeCount();
     }
     ASSERT_NOT_REACHED();
@@ -840,7 +839,6 @@
     case Node::DOCUMENT_FRAGMENT_NODE:
     case Node::NOTATION_NODE:
     case Node::XPATH_NAMESPACE_NODE:
-    case Node::SHADOW_ROOT_NODE:
         // FIXME: Should we assert that some nodes never appear here?
         if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) {
             if (fragment)
@@ -997,7 +995,7 @@
 
     Node::NodeType newNodeType = newNode->nodeType();
     int numNewChildren;
-    if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) {
+    if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot()) {
         // check each child node, not the DocumentFragment itself
         numNewChildren = 0;
         for (Node* c = newNode->firstChild(); c; c = c->nextSibling()) {
@@ -1028,10 +1026,13 @@
     case Node::ENTITY_NODE:
     case Node::NOTATION_NODE:
     case Node::DOCUMENT_NODE:
-    case Node::SHADOW_ROOT_NODE:
         ec = RangeException::INVALID_NODE_TYPE_ERR;
         return;
     default:
+        if (newNode->isShadowRoot()) {
+            ec = RangeException::INVALID_NODE_TYPE_ERR;
+            return;
+        }
         break;
     }
 
@@ -1217,8 +1218,7 @@
         case Node::DOCUMENT_NODE:
         case Node::ELEMENT_NODE:
         case Node::ENTITY_REFERENCE_NODE:
-        case Node::XPATH_NAMESPACE_NODE:
-        case Node::SHADOW_ROOT_NODE: {
+        case Node::XPATH_NAMESPACE_NODE: {
             if (!offset)
                 return 0;
             Node* childBefore = n->childNode(offset - 1);
@@ -1243,7 +1243,6 @@
         case Node::DOCUMENT_NODE:
         case Node::ENTITY_NODE:
         case Node::NOTATION_NODE:
-        case Node::SHADOW_ROOT_NODE:
             ec = RangeException::INVALID_NODE_TYPE_ERR;
             return;
         case Node::CDATA_SECTION_NODE:
@@ -1265,7 +1264,6 @@
         case Node::ATTRIBUTE_NODE:
         case Node::DOCUMENT_NODE:
         case Node::DOCUMENT_FRAGMENT_NODE:
-        case Node::SHADOW_ROOT_NODE:
             break;
         case Node::CDATA_SECTION_NODE:
         case Node::COMMENT_NODE:
@@ -1397,7 +1395,6 @@
             case Node::PROCESSING_INSTRUCTION_NODE:
             case Node::TEXT_NODE:
             case Node::XPATH_NAMESPACE_NODE:
-            case Node::SHADOW_ROOT_NODE:
                 break;
             case Node::DOCUMENT_TYPE_NODE:
             case Node::ENTITY_NODE:
@@ -1422,7 +1419,6 @@
         case Node::DOCUMENT_NODE:
         case Node::ENTITY_NODE:
         case Node::NOTATION_NODE:
-        case Node::SHADOW_ROOT_NODE:
             ec = RangeException::INVALID_NODE_TYPE_ERR;
             return;
     }
@@ -1463,7 +1459,6 @@
             case Node::PROCESSING_INSTRUCTION_NODE:
             case Node::TEXT_NODE:
             case Node::XPATH_NAMESPACE_NODE:
-            case Node::SHADOW_ROOT_NODE:
                 break;
             case Node::DOCUMENT_TYPE_NODE:
             case Node::ENTITY_NODE:
@@ -1512,7 +1507,6 @@
         case Node::PROCESSING_INSTRUCTION_NODE:
         case Node::TEXT_NODE:
         case Node::XPATH_NAMESPACE_NODE:
-        case Node::SHADOW_ROOT_NODE:
             break;
     }
 

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (107660 => 107661)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -125,11 +125,6 @@
     return "#shadow-root";
 }
 
-Node::NodeType ShadowRoot::nodeType() const
-{
-    return SHADOW_ROOT_NODE;
-}
-
 PassRefPtr<Node> ShadowRoot::cloneNode(bool)
 {
     // ShadowRoot should not be arbitrarily cloned.

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (107660 => 107661)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-02-14 03:15:16 UTC (rev 107661)
@@ -83,7 +83,6 @@
     virtual ~ShadowRoot();
 
     virtual String nodeName() const;
-    virtual NodeType nodeType() const;
     virtual PassRefPtr<Node> cloneNode(bool deep);
     virtual bool childTypeAllowed(NodeType) const;
 
@@ -113,7 +112,7 @@
 
 inline ShadowRoot* toShadowRoot(Node* node)
 {
-    ASSERT(!node || node->nodeType() == Node::SHADOW_ROOT_NODE);
+    ASSERT(!node || node->isShadowRoot());
     return static_cast<ShadowRoot*>(node);
 }
 

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (107660 => 107661)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -425,10 +425,17 @@
         position.moveToOffset(positionOffset - oldLength + newLength);
 }
 
+static inline bool nodeIsDetachedFromDocument(Node* node)
+{
+    ASSERT(node);
+    Node* highest = highestAncestor(node);
+    return highest->nodeType() == Node::DOCUMENT_FRAGMENT_NODE && !highest->isShadowRoot();
+}
+
 void FrameSelection::textWillBeReplaced(CharacterData* node, unsigned offset, unsigned oldLength, unsigned newLength)
 {
     // The fragment check is a performance optimization. See http://trac.webkit.org/changeset/30062.
-    if (isNone() || !node || highestAncestor(node)->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
+    if (isNone() || !node || nodeIsDetachedFromDocument(node))
         return;
 
     Position base = m_selection.base();

Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (107660 => 107661)


--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -444,7 +444,6 @@
     case Node::ENTITY_REFERENCE_NODE:
     case Node::NOTATION_NODE:
     case Node::XPATH_NAMESPACE_NODE:
-    case Node::SHADOW_ROOT_NODE:
         ASSERT_NOT_REACHED();
         break;
     }

Modified: trunk/Source/WebCore/html/parser/HTMLElementStack.cpp (107660 => 107661)


--- trunk/Source/WebCore/html/parser/HTMLElementStack.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/html/parser/HTMLElementStack.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -53,7 +53,6 @@
 inline bool isRootNode(ContainerNode* node)
 {
     return node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE
-        || node->nodeType() == Node::SHADOW_ROOT_NODE
         || node->hasTagName(htmlTag);
 }
 
@@ -310,7 +309,7 @@
     
 void HTMLElementStack::pushRootNode(PassRefPtr<ContainerNode> rootNode)
 {
-    ASSERT(rootNode->nodeType() == Node::DOCUMENT_FRAGMENT_NODE || rootNode->nodeType() == Node::SHADOW_ROOT_NODE);
+    ASSERT(rootNode->nodeType() == Node::DOCUMENT_FRAGMENT_NODE);
     pushRootNodeCommon(rootNode);
 }
 

Modified: trunk/Source/WebCore/html/parser/HTMLElementStack.h (107660 => 107661)


--- trunk/Source/WebCore/html/parser/HTMLElementStack.h	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/html/parser/HTMLElementStack.h	2012-02-14 03:15:16 UTC (rev 107661)
@@ -180,8 +180,7 @@
     // A DocumentFragment takes the place of the document element when parsing
     // fragments and should be considered in the HTML namespace.
     return node->namespaceURI() == HTMLNames::xhtmlNamespaceURI
-        || node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE
-        || node->nodeType() == Node::SHADOW_ROOT_NODE; // FIXME: Does this also apply to ShadowRoot?
+        || node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE; // FIXME: Does this also apply to ShadowRoot?
 }
 
 

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (107660 => 107661)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -402,7 +402,7 @@
 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId)
 {
     Node* node = nodeForId(nodeId);
-    if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE))
+    if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) || node->isShadowRoot())
         return;
     if (m_childrenRequested.contains(nodeId))
         return;
@@ -1160,7 +1160,9 @@
         localName = node->localName();
         break;
     case Node::DOCUMENT_FRAGMENT_NODE:
-        break;
+        if (!node->isShadowRoot())
+            break;
+        // Fall through
     case Node::DOCUMENT_NODE:
     case Node::ELEMENT_NODE:
     default:

Modified: trunk/Source/WebCore/xml/XPathUtil.cpp (107660 => 107661)


--- trunk/Source/WebCore/xml/XPathUtil.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebCore/xml/XPathUtil.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -85,7 +85,6 @@
         case Node::ENTITY_NODE:
         case Node::ENTITY_REFERENCE_NODE:
         case Node::NOTATION_NODE:
-        case Node::SHADOW_ROOT_NODE:
             return false;
         case Node::TEXT_NODE:
             return !(node->parentNode() && node->parentNode()->isAttributeNode());

Modified: trunk/Source/WebKit/chromium/ChangeLog (107660 => 107661)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-14 03:15:16 UTC (rev 107661)
@@ -1,3 +1,15 @@
+2012-02-13  Hayato Ito  <[email protected]>
+
+        Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE.
+        https://bugs.webkit.org/show_bug.cgi?id=77514
+
+        Reviewed by Dimitri Glazkov.
+
+        NodeType.SHADOW_ROOT_NODE type is finally gone.
+
+        * src/WebPageSerializerImpl.cpp:
+        (WebKit::WebPageSerializerImpl::buildContentForNode):
+
 2012-02-13  Nico Weber  <[email protected]>
 
         [chromium] Let WebKit::initialize call InitWebCoreSystemInterface on mac.

Modified: trunk/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp (107660 => 107661)


--- trunk/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp	2012-02-14 02:50:18 UTC (rev 107660)
+++ trunk/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp	2012-02-14 03:15:16 UTC (rev 107661)
@@ -417,7 +417,6 @@
     case Node::ATTRIBUTE_NODE:
     case Node::DOCUMENT_NODE:
     case Node::DOCUMENT_FRAGMENT_NODE:
-    case Node::SHADOW_ROOT_NODE:
         // Should not exist.
         ASSERT_NOT_REACHED();
         break;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to