Title: [135833] trunk/Source/WebCore
Revision
135833
Author
morr...@google.com
Date
2012-11-27 00:49:23 -0800 (Tue, 27 Nov 2012)

Log Message

[Refactoring] NodeFlags::IsShadowRootFlag should be Node::IsDocumentFragmentFlag
https://bugs.webkit.org/show_bug.cgi?id=103370

Reviewed by Kentaro Hara.

This chagne introduces Node::IsDocumentFragmentFlag so that we can
have fast Node::isDocumentFragment().

Note that Node::isShadowRoot() can become slightly slower when it
returns true, but that is minor in terms of the number of calls at runtime.

No new tests. No behavior change.

* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::create):
* dom/DocumentFragment.h:
* dom/Node.cpp:
(WebCore::Node::documentFragmentIsShadowRoot):
(WebCore):
* dom/Node.h:
(Node):
(WebCore::Node::isDocumentFragment):
(WebCore::Node::isShadowRoot):
(WebCore::Node::parentNode):
(WebCore::Node::parentNodeGuaranteedHostFree):
* dom/ShadowRoot.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135832 => 135833)


--- trunk/Source/WebCore/ChangeLog	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/ChangeLog	2012-11-27 08:49:23 UTC (rev 135833)
@@ -1,3 +1,32 @@
+2012-11-27  Hajime Morrita  <morr...@google.com>
+
+        [Refactoring] NodeFlags::IsShadowRootFlag should be Node::IsDocumentFragmentFlag
+        https://bugs.webkit.org/show_bug.cgi?id=103370
+
+        Reviewed by Kentaro Hara.
+
+        This chagne introduces Node::IsDocumentFragmentFlag so that we can
+        have fast Node::isDocumentFragment().
+
+        Note that Node::isShadowRoot() can become slightly slower when it
+        returns true, but that is minor in terms of the number of calls at runtime.
+
+        No new tests. No behavior change.
+
+        * dom/DocumentFragment.cpp:
+        (WebCore::DocumentFragment::create):
+        * dom/DocumentFragment.h:
+        * dom/Node.cpp:
+        (WebCore::Node::documentFragmentIsShadowRoot):
+        (WebCore):
+        * dom/Node.h:
+        (Node):
+        (WebCore::Node::isDocumentFragment):
+        (WebCore::Node::isShadowRoot):
+        (WebCore::Node::parentNode):
+        (WebCore::Node::parentNodeGuaranteedHostFree):
+        * dom/ShadowRoot.h:
+
 2012-11-26  Kent Tamura  <tk...@chromium.org>
 
         :read-only selector should match to date/time input types

Modified: trunk/Source/WebCore/dom/DocumentFragment.cpp (135832 => 135833)


--- trunk/Source/WebCore/dom/DocumentFragment.cpp	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/dom/DocumentFragment.cpp	2012-11-27 08:49:23 UTC (rev 135833)
@@ -40,7 +40,7 @@
 
 PassRefPtr<DocumentFragment> DocumentFragment::create(Document* document)
 {
-    return adoptRef(new DocumentFragment(document));
+    return adoptRef(new DocumentFragment(document, Node::CreateDocumentFragment));
 }
 
 String DocumentFragment::nodeName() const

Modified: trunk/Source/WebCore/dom/DocumentFragment.h (135832 => 135833)


--- trunk/Source/WebCore/dom/DocumentFragment.h	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/dom/DocumentFragment.h	2012-11-27 08:49:23 UTC (rev 135833)
@@ -46,6 +46,7 @@
     virtual NodeType nodeType() const;
     virtual PassRefPtr<Node> cloneNode(bool deep);
     virtual bool childTypeAllowed(NodeType) const;
+    virtual bool documentFragmentIsShadowRoot() const OVERRIDE { return false; }
 };
 
 } //namespace

Modified: trunk/Source/WebCore/dom/Node.cpp (135832 => 135833)


--- trunk/Source/WebCore/dom/Node.cpp	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-11-27 08:49:23 UTC (rev 135833)
@@ -954,6 +954,12 @@
     return isFocusable();
 }
 
+bool Node::documentFragmentIsShadowRoot() const
+{
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 Node* Node::focusDelegate()
 {
     return this;

Modified: trunk/Source/WebCore/dom/Node.h (135832 => 135833)


--- trunk/Source/WebCore/dom/Node.h	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/dom/Node.h	2012-11-27 08:49:23 UTC (rev 135833)
@@ -233,8 +233,10 @@
     virtual bool isCharacterDataNode() const { return false; }
     virtual bool isFrameOwnerElement() const { return false; }
     virtual bool isPluginElement() const { return false; }
+    virtual bool documentFragmentIsShadowRoot() const;
     bool isDocumentNode() const;
-    bool isShadowRoot() const { return getFlag(IsShadowRootFlag); }
+    bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); }
+    bool isShadowRoot() const { return isDocumentFragment() && documentFragmentIsShadowRoot(); }
     bool isInsertionPoint() const { return getFlag(IsInsertionPointFlag); }
     bool inNamedFlow() const { return getFlag(InNamedFlowFlag); }
     bool hasCustomCallbacks() const { return getFlag(HasCustomCallbacksFlag); }
@@ -699,7 +701,7 @@
         IsHoveredFlag = 1 << 11,
         InActiveChainFlag = 1 << 12,
         HasRareDataFlag = 1 << 13,
-        IsShadowRootFlag = 1 << 14,
+        IsDocumentFragmentFlag = 1 << 14,
 
         // These bits are used by derived classes, pulled up here so they can
         // be stored in the same memory word as the Node bits above.
@@ -738,7 +740,8 @@
         CreateText = DefaultNodeFlags | IsTextFlag,
         CreateContainer = DefaultNodeFlags | IsContainerFlag, 
         CreateElement = CreateContainer | IsElementFlag, 
-        CreateShadowRoot = CreateContainer | IsShadowRootFlag,
+        CreateShadowRoot = CreateContainer | IsDocumentFragmentFlag,
+        CreateDocumentFragment = CreateContainer | IsDocumentFragmentFlag,
         CreateStyledElement = CreateElement | IsStyledElementFlag, 
         CreateHTMLElement = CreateStyledElement | IsHTMLFlag, 
         CreateFrameOwnerElement = CreateHTMLElement | HasCustomCallbacksFlag,
@@ -855,7 +858,7 @@
 
 inline ContainerNode* Node::parentNode() const
 {
-    return getFlag(IsShadowRootFlag) ? 0 : parent();
+    return isShadowRoot() ? 0 : parent();
 }
 
 inline void Node::setParentOrHostNode(ContainerNode* parent)
@@ -870,7 +873,7 @@
 
 inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
 {
-    ASSERT(!getFlag(IsShadowRootFlag));
+    ASSERT(!isShadowRoot());
     return parentOrHostNode();
 }
 

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (135832 => 135833)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-11-27 08:38:54 UTC (rev 135832)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-11-27 08:49:23 UTC (rev 135833)
@@ -119,6 +119,7 @@
     virtual PassRefPtr<Node> cloneNode(bool deep);
     virtual bool childTypeAllowed(NodeType) const;
     virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) OVERRIDE;
+    virtual bool documentFragmentIsShadowRoot() const OVERRIDE { return true; }
 
     void setType(ShadowRootType type) { m_isAuthorShadowRoot = type == AuthorShadowRoot; }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to