Remove public attachRenderTree
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jan 2014 09:49:41 +0000 (09:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jan 2014 09:49:41 +0000 (09:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126368

Reviewed by Andreas Kling.

Remove the remaining explicit render tree construction.

* dom/Document.cpp:
(WebCore::Document::createRenderTree):

   Use recalcStyle() instead of calling attachRenderTree directly.

* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::addText):

    Remove forgotten attachTextRenderer.

* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::InsertionPoint):

    Remove willAttachRenderers/didAttachRenderers hack.

* html/shadow/InsertionPoint.h:
(WebCore::toInsertionPoint):
* loader/PlaceholderDocument.cpp:
(WebCore::PlaceholderDocument::createRenderTree):

    Seriously, nothing to do here.

* style/StyleResolveTree.cpp:
(WebCore::Style::attachDistributedChildren):
(WebCore::Style::attachChildren):
(WebCore::Style::detachDistributedChildren):
(WebCore::Style::detachChildren):

    Making attaching and detaching distributed insertion point children part of ResolveTree internals.

* style/StyleResolveTree.h:

    Remove interfaces with no clients.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161205 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/html/HTMLViewSourceDocument.cpp
Source/WebCore/html/shadow/InsertionPoint.cpp
Source/WebCore/html/shadow/InsertionPoint.h
Source/WebCore/loader/PlaceholderDocument.cpp
Source/WebCore/style/StyleResolveTree.cpp
Source/WebCore/style/StyleResolveTree.h

index 70ef928..ef9d8cb 100644 (file)
@@ -1,3 +1,46 @@
+2014-01-01  Antti Koivisto  <antti@apple.com>
+
+        Remove public attachRenderTree
+        https://bugs.webkit.org/show_bug.cgi?id=126368
+
+        Reviewed by Andreas Kling.
+
+        Remove the remaining explicit render tree construction.
+
+        * dom/Document.cpp:
+        (WebCore::Document::createRenderTree):
+        
+           Use recalcStyle() instead of calling attachRenderTree directly.
+
+        * html/HTMLViewSourceDocument.cpp:
+        (WebCore::HTMLViewSourceDocument::addText):
+        
+            Remove forgotten attachTextRenderer.
+
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::InsertionPoint):
+        
+            Remove willAttachRenderers/didAttachRenderers hack.
+
+        * html/shadow/InsertionPoint.h:
+        (WebCore::toInsertionPoint):
+        * loader/PlaceholderDocument.cpp:
+        (WebCore::PlaceholderDocument::createRenderTree):
+        
+            Seriously, nothing to do here.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::attachDistributedChildren):
+        (WebCore::Style::attachChildren):
+        (WebCore::Style::detachDistributedChildren):
+        (WebCore::Style::detachChildren):
+        
+            Making attaching and detaching distributed insertion point children part of ResolveTree internals.
+
+        * style/StyleResolveTree.h:
+        
+            Remove interfaces with no clients.
+
 2014-01-01  Seokju Kwon  <seokju@webkit.org>
 
         Remove stale ScriptProfiler methods
index a792443..302306e 100644 (file)
@@ -1959,9 +1959,6 @@ void Document::createRenderTree()
 #endif
 
     recalcStyle(Style::Force);
-
-    if (m_documentElement)
-        Style::attachRenderTree(*m_documentElement);
 }
 
 static void pageWheelEventHandlerCountChanged(Page& page)
index b43b3e5..5b705d9 100644 (file)
@@ -240,7 +240,6 @@ void HTMLViewSourceDocument::addText(const String& text, const AtomicString& cla
         }
         RefPtr<Text> text = Text::create(*this, substring);
         m_current->parserAppendChild(text);
-        Style::attachTextRenderer(*text);
         if (i < size - 1)
             finishLine();
     }
index 7073f6b..102c8f2 100644 (file)
@@ -43,44 +43,12 @@ InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document, CreateInsertionPoint)
     , m_hasDistribution(false)
 {
-    setHasCustomStyleResolveCallbacks();
 }
 
 InsertionPoint::~InsertionPoint()
 {
 }
 
-void InsertionPoint::willAttachRenderers()
-{
-    if (ShadowRoot* shadowRoot = containingShadowRoot())
-        ContentDistributor::ensureDistribution(shadowRoot);
-    for (Node* current = firstDistributed(); current; current = nextDistributedTo(current)) {
-        if (current->isTextNode()) {
-            if (current->renderer())
-                continue;
-            Style::attachTextRenderer(*toText(current));
-            continue;
-        }
-        if (current->isElementNode()) {
-            if (current->renderer())
-                Style::detachRenderTree(*toElement(current));
-            Style::attachRenderTree(*toElement(current));
-        }
-    }
-}
-
-void InsertionPoint::willDetachRenderers()
-{
-    for (Node* current = firstDistributed(); current; current = nextDistributedTo(current)) {
-        if (current->isTextNode()) {
-            Style::detachTextRenderer(*toText(current));
-            continue;
-        }
-        if (current->isElementNode())
-            Style::detachRenderTree(*toElement(current));
-    }
-}
-
 bool InsertionPoint::shouldUseFallbackElements() const
 {
     return isActive() && !hasDistribution();
index f299aa9..4a83cc1 100644 (file)
@@ -55,9 +55,6 @@ public:
 
     virtual MatchType matchTypeFor(Node*) const { return AlwaysMatches; }
 
-    virtual void willAttachRenderers() OVERRIDE;
-    virtual void willDetachRenderers() OVERRIDE;
-
     bool shouldUseFallbackElements() const;
 
     Node* firstDistributed() const;
@@ -78,17 +75,9 @@ private:
     bool m_hasDistribution;
 };
 
-inline InsertionPoint* toInsertionPoint(Node* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isInsertionPoint());
-    return static_cast<InsertionPoint*>(node);
-}
+inline bool isInsertionPoint(const Node& node) { return node.isInsertionPoint(); }
 
-inline const InsertionPoint* toInsertionPoint(const Node* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isInsertionPoint());
-    return static_cast<const InsertionPoint*>(node);
-}
+NODE_TYPE_CASTS(InsertionPoint);
 
 inline bool isActiveInsertionPoint(const Node* node)
 {
index 00d2cc7..596d5ef 100644 (file)
@@ -33,9 +33,6 @@ namespace WebCore {
 void PlaceholderDocument::createRenderTree()
 {
     ASSERT(!renderView());
-
-    for (auto& child : childrenOfType<Element>(*this))
-        Style::attachRenderTree(child);
 }
 
 } // namespace WebCore
index 6fdee89..1bd69e0 100644 (file)
@@ -34,6 +34,7 @@
 #include "ElementRareData.h"
 #include "ElementTraversal.h"
 #include "FlowThreadController.h"
+#include "InsertionPoint.h"
 #include "NodeRenderStyle.h"
 #include "NodeRenderingTraversal.h"
 #include "NodeTraversal.h"
@@ -61,6 +62,7 @@ namespace Style {
 enum DetachType { NormalDetach, ReattachDetach };
 
 static void attachRenderTree(Element&, PassRefPtr<RenderStyle>);
+static void attachTextRenderer(Text&);
 static void detachRenderTree(Element&, DetachType);
 
 Change determineChange(const RenderStyle* s1, const RenderStyle* s2, Settings* settings)
@@ -296,7 +298,7 @@ static RenderObject* nextSiblingRenderer(const Text& textNode)
 
 static void reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(Node& current)
 {
-    if (current.isInsertionPoint())
+    if (isInsertionPoint(current))
         return;
     // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of
     // the current node gaining or losing the renderer. This can only affect white space text nodes.
@@ -431,10 +433,32 @@ void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfRepla
     textRenderer->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData);
 }
 
+static void attachDistributedChildren(InsertionPoint& insertionPoint)
+{
+    if (ShadowRoot* shadowRoot = insertionPoint.containingShadowRoot())
+        ContentDistributor::ensureDistribution(shadowRoot);
+    for (Node* current = insertionPoint.firstDistributed(); current; current = insertionPoint.nextDistributedTo(current)) {
+        if (current->isTextNode()) {
+            if (current->renderer())
+                continue;
+            attachTextRenderer(*toText(current));
+            continue;
+        }
+        if (current->isElementNode()) {
+            if (current->renderer())
+                detachRenderTree(*toElement(current));
+            attachRenderTree(*toElement(current), nullptr);
+        }
+    }
+}
+
 static void attachChildren(ContainerNode& current)
 {
+    if (isInsertionPoint(current))
+        attachDistributedChildren(toInsertionPoint(current));
+
     for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
-        ASSERT(!child->renderer() || current.shadowRoot() || current.isInsertionPoint());
+        ASSERT(!child->renderer() || current.shadowRoot() || isInsertionPoint(current));
         if (child->renderer())
             continue;
         if (child->isTextNode()) {
@@ -549,8 +573,23 @@ static void attachRenderTree(Element& current, PassRefPtr<RenderStyle> resolvedS
         current.didAttachRenderers();
 }
 
+static void detachDistributedChildren(InsertionPoint& insertionPoint)
+{
+    for (Node* current = insertionPoint.firstDistributed(); current; current = insertionPoint.nextDistributedTo(current)) {
+        if (current->isTextNode()) {
+            detachTextRenderer(*toText(current));
+            continue;
+        }
+        if (current->isElementNode())
+            detachRenderTree(*toElement(current));
+    }
+}
+
 static void detachChildren(ContainerNode& current, DetachType detachType)
 {
+    if (isInsertionPoint(current))
+        detachDistributedChildren(toInsertionPoint(current));
+
     for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
         if (child->isTextNode()) {
             Style::detachTextRenderer(*toText(child));
@@ -875,21 +914,10 @@ void resolveTree(Document& document, Change change)
     resolveTree(*documentElement, change);
 }
 
-void attachRenderTree(Element& element)
-{
-    attachRenderTree(element, nullptr);
-    reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(element);
-}
-
 void detachRenderTree(Element& element)
 {
     detachRenderTree(element, NormalDetach);
 }
 
-void detachRenderTreeInReattachMode(Element& element)
-{
-    detachRenderTree(element, ReattachDetach);
-}
-
 }
 }
index 55a5db4..7f8648d 100644 (file)
@@ -41,12 +41,8 @@ enum Change { NoChange, NoInherit, Inherit, Detach, Force };
 void resolveTree(Element&, Change);
 void resolveTree(Document&, Change);
 
-void attachRenderTree(Element&);
 void detachRenderTree(Element&);
-// FIXME: This is only used for "lazy reattach" for shadow trees.
-void detachRenderTreeInReattachMode(Element&);
 
-void attachTextRenderer(Text&);
 void detachTextRenderer(Text&);
 void updateTextRendererAfterContentChange(Text&, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);