- Revision
- 138404
- Author
- [email protected]
- Date
- 2012-12-21 16:24:18 -0800 (Fri, 21 Dec 2012)
Log Message
Replace documentFragmentIsShadowRoot with isTreeScope
https://bugs.webkit.org/show_bug.cgi?id=105345
Reviewed by Dimitri Glazkov.
.:
Expose isTreeScope symbol.
* Source/autotools/symbols.filter:
Source/WebCore:
We can replace documentFragmentIsShadowRoot with isTreeScope() which is
trival to detect by checking treeScope()->rootNode() == this. To do this
we must stop adopting ShadowRoots into the document when they're removed,
which was always wrong anyway as it meant that the TreeScope of a ShadowRoot
was no longer itself after it had been removed. It also meant that the
children of a ShadowRoot that was removed were no longer in it's tree scope
despite being descendants of it.
Making this simplification allows further simplication like
Node::containingShadowRoot can be made O(1) instead of O(k) where k is
the depth of the node.
No new tests, just refactoring.
* WebCore.exp.in:
* dom/DocumentFragment.h:
(DocumentFragment):
* dom/ElementShadow.cpp:
(WebCore::ElementShadow::removeAllShadowRoots):
* dom/Node.cpp:
(WebCore::Node::setTreeScope):
(WebCore::Node::isTreeScope):
(WebCore):
* dom/Node.h:
(Node):
(WebCore::Node::isShadowRoot):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::~ShadowRoot):
* dom/ShadowRoot.h:
(ShadowRoot):
Source/WebKit2:
Expose isTreeScope symbol.
* win/WebKit2.def.in:
Modified Paths
Diff
Modified: trunk/ChangeLog (138403 => 138404)
--- trunk/ChangeLog 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/ChangeLog 2012-12-22 00:24:18 UTC (rev 138404)
@@ -1,3 +1,14 @@
+2012-12-21 Elliott Sprehn <[email protected]>
+
+ Replace documentFragmentIsShadowRoot with isTreeScope
+ https://bugs.webkit.org/show_bug.cgi?id=105345
+
+ Reviewed by Dimitri Glazkov.
+
+ Expose isTreeScope symbol.
+
+ * Source/autotools/symbols.filter:
+
2012-12-21 Sheriff Bot <[email protected]>
Unreviewed, rolling out r138338.
Modified: trunk/Source/WebCore/ChangeLog (138403 => 138404)
--- trunk/Source/WebCore/ChangeLog 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/ChangeLog 2012-12-22 00:24:18 UTC (rev 138404)
@@ -1,3 +1,41 @@
+2012-12-21 Elliott Sprehn <[email protected]>
+
+ Replace documentFragmentIsShadowRoot with isTreeScope
+ https://bugs.webkit.org/show_bug.cgi?id=105345
+
+ Reviewed by Dimitri Glazkov.
+
+ We can replace documentFragmentIsShadowRoot with isTreeScope() which is
+ trival to detect by checking treeScope()->rootNode() == this. To do this
+ we must stop adopting ShadowRoots into the document when they're removed,
+ which was always wrong anyway as it meant that the TreeScope of a ShadowRoot
+ was no longer itself after it had been removed. It also meant that the
+ children of a ShadowRoot that was removed were no longer in it's tree scope
+ despite being descendants of it.
+
+ Making this simplification allows further simplication like
+ Node::containingShadowRoot can be made O(1) instead of O(k) where k is
+ the depth of the node.
+
+ No new tests, just refactoring.
+
+ * WebCore.exp.in:
+ * dom/DocumentFragment.h:
+ (DocumentFragment):
+ * dom/ElementShadow.cpp:
+ (WebCore::ElementShadow::removeAllShadowRoots):
+ * dom/Node.cpp:
+ (WebCore::Node::setTreeScope):
+ (WebCore::Node::isTreeScope):
+ (WebCore):
+ * dom/Node.h:
+ (Node):
+ (WebCore::Node::isShadowRoot):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::~ShadowRoot):
+ * dom/ShadowRoot.h:
+ (ShadowRoot):
+
2012-12-21 Xianzhu Wang <[email protected]>
[Chromium-Android] Use harfbuzz-ng instead of harfbuzz-old on Android
Modified: trunk/Source/WebCore/WebCore.exp.in (138403 => 138404)
--- trunk/Source/WebCore/WebCore.exp.in 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-12-22 00:24:18 UTC (rev 138404)
@@ -1368,6 +1368,7 @@
__ZN7WebCore4Node12insertBeforeEN3WTF10PassRefPtrIS0_EEPS0_Rib
__ZNK7WebCore4Node13ownerDocumentEv
__ZNK7WebCore4Node14isDescendantOfEPKS0_
+__ZNK7WebCore4Node11isTreeScopeEv
__ZNK7WebCore4Node18getSubresourceURLsERN3WTF11ListHashSetINS_4KURLELm256ENS_8KURLHashEEE
__ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv
__ZNK7WebCore4Node9nodeIndexEv
Modified: trunk/Source/WebCore/dom/DocumentFragment.h (138403 => 138404)
--- trunk/Source/WebCore/dom/DocumentFragment.h 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/DocumentFragment.h 2012-12-22 00:24:18 UTC (rev 138404)
@@ -46,7 +46,6 @@
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/ElementShadow.cpp (138403 => 138404)
--- trunk/Source/WebCore/dom/ElementShadow.cpp 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/ElementShadow.cpp 2012-12-22 00:24:18 UTC (rev 138404)
@@ -113,9 +113,9 @@
m_shadowRoots.removeHead();
oldRoot->setHost(0);
+ oldRoot->setParentTreeScope(shadowHost->document());
oldRoot->setPrev(0);
oldRoot->setNext(0);
- shadowHost->document()->adoptIfNeeded(oldRoot.get());
ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get());
}
Modified: trunk/Source/WebCore/dom/Node.cpp (138403 => 138404)
--- trunk/Source/WebCore/dom/Node.cpp 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-12-22 00:24:18 UTC (rev 138404)
@@ -449,6 +449,8 @@
void Node::setTreeScope(TreeScope* scope)
{
+ ASSERT(!isShadowRoot());
+
if (!hasRareData() && scope->rootNode()->isDocumentNode())
return;
@@ -913,6 +915,11 @@
return true;
}
+bool Node::isTreeScope() const
+{
+ return treeScope()->rootNode() == this;
+}
+
bool Node::isKeyboardFocusable(KeyboardEvent*) const
{
return isFocusable() && tabIndex() >= 0;
@@ -923,12 +930,6 @@
return isFocusable();
}
-bool Node::documentFragmentIsShadowRoot() const
-{
- ASSERT_NOT_REACHED();
- return false;
-}
-
Node* Node::focusDelegate()
{
return this;
Modified: trunk/Source/WebCore/dom/Node.h (138403 => 138404)
--- trunk/Source/WebCore/dom/Node.h 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/Node.h 2012-12-22 00:24:18 UTC (rev 138404)
@@ -246,12 +246,12 @@
virtual bool isCharacterDataNode() const { return false; }
virtual bool isFrameOwnerElement() const { return false; }
virtual bool isPluginElement() const { return false; }
- virtual bool documentFragmentIsShadowRoot() const;
virtual bool isInsertionPointNode() const { return false; }
bool isDocumentNode() const;
+ bool isTreeScope() const;
bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); }
- bool isShadowRoot() const { return isDocumentFragment() && documentFragmentIsShadowRoot(); }
+ bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); }
bool isInsertionPoint() const { return getFlag(NeedsShadowTreeWalkerFlag) && isInsertionPointNode(); }
bool needsShadowTreeWalker() const;
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (138403 => 138404)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-12-22 00:24:18 UTC (rev 138404)
@@ -88,6 +88,11 @@
ASSERT(!m_prev);
ASSERT(!m_next);
+ // We must remove all of our children first before the TreeScope destructor
+ // runs so we don't go through TreeScopeAdopter for each child with a
+ // destructed tree scope in each descendant.
+ removeAllChildren();
+
// We must call clearRareData() here since a ShadowRoot class inherits TreeScope
// as well as Node. See a comment on TreeScope.h for the reason.
if (hasRareData())
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (138403 => 138404)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2012-12-22 00:24:18 UTC (rev 138404)
@@ -121,7 +121,6 @@
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; }
Modified: trunk/Source/WebKit2/ChangeLog (138403 => 138404)
--- trunk/Source/WebKit2/ChangeLog 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-22 00:24:18 UTC (rev 138404)
@@ -1,3 +1,14 @@
+2012-12-21 Elliott Sprehn <[email protected]>
+
+ Replace documentFragmentIsShadowRoot with isTreeScope
+ https://bugs.webkit.org/show_bug.cgi?id=105345
+
+ Reviewed by Dimitri Glazkov.
+
+ Expose isTreeScope symbol.
+
+ * win/WebKit2.def.in:
+
2012-12-21 Sheriff Bot <[email protected]>
Unreviewed, rolling out r138331.
Modified: trunk/Source/WebKit2/win/WebKit2.def.in (138403 => 138404)
--- trunk/Source/WebKit2/win/WebKit2.def.in 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/WebKit2/win/WebKit2.def.in 2012-12-22 00:24:18 UTC (rev 138404)
@@ -302,6 +302,7 @@
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVNodeList@1@@Z
?toRange@WebCore@@YAPAVRange@1@VJSValue@JSC@@@Z
?treeScope@Node@WebCore@@QBEPAVTreeScope@2@XZ
+ ?isTreeScope@Node@WebCore@@QBE_NXZ
?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
?userPreferredLanguages@WebCore@@YA?AV?$Vector@VString@WTF@@$0A@@WTF@@XZ
?utf8@String@WTF@@QBE?AVCString@2@W4ConversionMode@12@@Z
Modified: trunk/Source/autotools/symbols.filter (138403 => 138404)
--- trunk/Source/autotools/symbols.filter 2012-12-22 00:22:16 UTC (rev 138403)
+++ trunk/Source/autotools/symbols.filter 2012-12-22 00:24:18 UTC (rev 138404)
@@ -137,6 +137,7 @@
_ZNK7WebCore4Node11textContentEb;
_ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv;
_ZNK7WebCore4Node9treeScopeEv;
+_ZNK7WebCore4Node11isTreeScopeEv;
_ZNK7WebCore4Page17viewportArgumentsEv;
_ZNK7WebCore12RenderObject23absoluteBoundingBoxRectEb;
_ZNK7WebCore16HTMLInputElement14suggestedValueEv;