Title: [109864] trunk/Source/WebCore
- Revision
- 109864
- Author
- [email protected]
- Date
- 2012-03-05 22:59:02 -0800 (Mon, 05 Mar 2012)
Log Message
InsertionPoint::attach should be consistent with Element.
https://bugs.webkit.org/show_bug.cgi?id=80373
Reviewed by Hajime Morita.
This patch is preparation for coming <shadow> patches.
InsertionPoint used to attach fallback elements before attaching distributed elements.
To be consistent with Element::attach behavior, attaching distributed elements first is
natural, because Element attaches a shadow tree first.
Also, this patch extracts a few methods form InsretionPoint::attach() and detach()
to keep code clean. They will become messy without this refactoring when adding
<shadow> patch.
No new tests. Should be covered by existing tests.
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::attach):
(WebCore::InsertionPoint::detach):
(WebCore::InsertionPoint::distributeHostChildren):
(WebCore):
(WebCore::InsertionPoint::clearDistribution):
(WebCore::InsertionPoint::attachDistributedNode):
* html/shadow/InsertionPoint.h:
(InsertionPoint):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (109863 => 109864)
--- trunk/Source/WebCore/ChangeLog 2012-03-06 06:54:23 UTC (rev 109863)
+++ trunk/Source/WebCore/ChangeLog 2012-03-06 06:59:02 UTC (rev 109864)
@@ -1,3 +1,32 @@
+2012-03-05 Shinya Kawanaka <[email protected]>
+
+ InsertionPoint::attach should be consistent with Element.
+ https://bugs.webkit.org/show_bug.cgi?id=80373
+
+ Reviewed by Hajime Morita.
+
+ This patch is preparation for coming <shadow> patches.
+
+ InsertionPoint used to attach fallback elements before attaching distributed elements.
+ To be consistent with Element::attach behavior, attaching distributed elements first is
+ natural, because Element attaches a shadow tree first.
+
+ Also, this patch extracts a few methods form InsretionPoint::attach() and detach()
+ to keep code clean. They will become messy without this refactoring when adding
+ <shadow> patch.
+
+ No new tests. Should be covered by existing tests.
+
+ * html/shadow/InsertionPoint.cpp:
+ (WebCore::InsertionPoint::attach):
+ (WebCore::InsertionPoint::detach):
+ (WebCore::InsertionPoint::distributeHostChildren):
+ (WebCore):
+ (WebCore::InsertionPoint::clearDistribution):
+ (WebCore::InsertionPoint::attachDistributedNode):
+ * html/shadow/InsertionPoint.h:
+ (InsertionPoint):
+
2012-03-05 Adam Barth <[email protected]>
Attempt to fix a number of GTK tests.
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (109863 => 109864)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp 2012-03-06 06:54:23 UTC (rev 109863)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp 2012-03-06 06:59:02 UTC (rev 109864)
@@ -48,31 +48,23 @@
void InsertionPoint::attach()
{
- ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
-
- if (root) {
- HTMLContentSelector* selector = root->tree()->ensureSelector();
- selector->unselect(&m_selections);
- selector->select(this, &m_selections);
+ if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
+ distributeHostChildren(root->tree());
+ attachDistributedNode();
}
HTMLElement::attach();
-
- if (root) {
- for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
- selection->node()->attach();
- }
}
void InsertionPoint::detach()
{
if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
- if (HTMLContentSelector* selector = root->tree()->selector())
- selector->unselect(&m_selections);
+ ShadowTree* tree = root->tree();
+ clearDistribution(tree);
// When shadow element is detached, shadow tree should be recreated to re-calculate selector for
// other insertion points.
- root->tree()->setNeedsReattachHostChildrenAndShadow();
+ tree->setNeedsReattachHostChildrenAndShadow();
}
ASSERT(m_selections.isEmpty());
@@ -91,4 +83,23 @@
return !isShadowBoundary() && HTMLElement::rendererIsNeeded(context);
}
+inline void InsertionPoint::distributeHostChildren(ShadowTree* tree)
+{
+ HTMLContentSelector* selector = tree->ensureSelector();
+ selector->unselect(&m_selections);
+ selector->select(this, &m_selections);
+}
+
+inline void InsertionPoint::clearDistribution(ShadowTree* tree)
+{
+ if (HTMLContentSelector* selector = tree->selector())
+ selector->unselect(&m_selections);
+}
+
+inline void InsertionPoint::attachDistributedNode()
+{
+ for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
+ selection->node()->attach();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (109863 => 109864)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-03-06 06:54:23 UTC (rev 109863)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-03-06 06:59:02 UTC (rev 109864)
@@ -54,6 +54,11 @@
InsertionPoint(const QualifiedName&, Document*);
virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
+private:
+ void distributeHostChildren(ShadowTree*);
+ void clearDistribution(ShadowTree*);
+ void attachDistributedNode();
+
HTMLContentSelectionList m_selections;
};
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes