Title: [163969] trunk/Source/WebCore
Revision
163969
Author
[email protected]
Date
2014-02-12 12:15:05 -0800 (Wed, 12 Feb 2014)

Log Message

RenderNamedFlowThread should only support RenderElement children.
<https://webkit.org/b/128675>

Tighten up flow-thread rendering so that it only supports element
children directly. This means we don't have to worry about text
renderers on this code path.

Reviewed by Antti Koivisto.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::insertedIntoTree):
(WebCore::RenderElement::willBeRemovedFromTree):
(WebCore::RenderElement::willBeDestroyed):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::nextRendererForElement):
(WebCore::RenderNamedFlowThread::addFlowChild):
(WebCore::RenderNamedFlowThread::removeFlowChild):
* rendering/RenderNamedFlowThread.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::willBeDestroyed):
(WebCore::RenderObject::insertedIntoTree):
(WebCore::RenderObject::willBeRemovedFromTree):
* style/StyleResolveTree.cpp:
(WebCore::Style::createRendererIfNeeded):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163968 => 163969)


--- trunk/Source/WebCore/ChangeLog	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/ChangeLog	2014-02-12 20:15:05 UTC (rev 163969)
@@ -1,3 +1,30 @@
+2014-02-12  Andreas Kling  <[email protected]>
+
+        RenderNamedFlowThread should only support RenderElement children.
+        <https://webkit.org/b/128675>
+
+        Tighten up flow-thread rendering so that it only supports element
+        children directly. This means we don't have to worry about text
+        renderers on this code path.
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::insertedIntoTree):
+        (WebCore::RenderElement::willBeRemovedFromTree):
+        (WebCore::RenderElement::willBeDestroyed):
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::nextRendererForElement):
+        (WebCore::RenderNamedFlowThread::addFlowChild):
+        (WebCore::RenderNamedFlowThread::removeFlowChild):
+        * rendering/RenderNamedFlowThread.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::willBeDestroyed):
+        (WebCore::RenderObject::insertedIntoTree):
+        (WebCore::RenderObject::willBeRemovedFromTree):
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::createRendererIfNeeded):
+
 2014-02-12  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Modernize missed inspector files

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (163968 => 163969)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2014-02-12 20:15:05 UTC (rev 163969)
@@ -33,6 +33,7 @@
 #include "Frame.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
+#include "FlowThreadController.h"
 #include "RenderCounter.h"
 #include "RenderDeprecatedFlexibleBox.h"
 #include "RenderFlexibleBox.h"
@@ -967,6 +968,9 @@
 {
     RenderObject::insertedIntoTree();
 
+    if (auto* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
+        containerFlowThread->addFlowChild(*this);
+
     // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children
     // and don't have a layer attached to ourselves.
     RenderLayer* layer = nullptr;
@@ -1007,6 +1011,9 @@
     if (isOutOfFlowPositioned() && parent()->childrenInline())
         parent()->dirtyLinesFromChangedChild(this);
 
+    if (auto* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
+        containerFlowThread->removeFlowChild(*this);
+
     RenderObject::willBeRemovedFromTree();
 }
 
@@ -1017,6 +1024,16 @@
     destroyLeftoverChildren();
 
     RenderObject::willBeDestroyed();
+
+#if !ASSERT_DISABLED
+    if (!documentBeingDestroyed() && view().hasRenderNamedFlowThreads()) {
+        // After remove, the object and the associated information should not be in any flow thread.
+        for (auto& flowThread : *view().flowThreadController().renderNamedFlowThreadList()) {
+            ASSERT(!flowThread->hasChild(*this));
+            ASSERT(!flowThread->hasChildInfo(this));
+        }
+    }
+#endif
 }
 
 void RenderElement::setNeedsPositionedMovementLayout(const RenderStyle* oldStyle)

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp (163968 => 163969)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2014-02-12 20:15:05 UTC (rev 163969)
@@ -97,11 +97,11 @@
     setStyle(std::move(newStyle));
 }
 
-RenderObject* RenderNamedFlowThread::nextRendererForNode(Node* node) const
+RenderElement* RenderNamedFlowThread::nextRendererForElement(Element& element) const
 {
     for (auto& child : m_flowThreadChildList) {
-        ASSERT(child->node());
-        unsigned short position = node->compareDocumentPosition(child->node());
+        ASSERT(!child->isAnonymous());
+        unsigned short position = element.compareDocumentPosition(child->element());
         if (position & Node::DOCUMENT_POSITION_FOLLOWING)
             return child;
     }
@@ -109,29 +109,24 @@
     return 0;
 }
 
-void RenderNamedFlowThread::addFlowChild(RenderObject* newChild)
+void RenderNamedFlowThread::addFlowChild(RenderElement& newChild)
 {
     // The child list is used to sort the flow thread's children render objects 
     // based on their corresponding nodes DOM order. The list is needed to avoid searching the whole DOM.
 
-    Node* childNode = newChild->node();
-
-    // Do not add anonymous objects.
-    if (!childNode)
+    if (newChild.isAnonymous())
         return;
 
-    ASSERT(childNode->isElementNode());
-
-    RenderObject* beforeChild = nextRendererForNode(childNode);
+    auto* beforeChild = nextRendererForElement(*newChild.element());
     if (beforeChild)
-        m_flowThreadChildList.insertBefore(beforeChild, newChild);
+        m_flowThreadChildList.insertBefore(beforeChild, &newChild);
     else
-        m_flowThreadChildList.add(newChild);
+        m_flowThreadChildList.add(&newChild);
 }
 
-void RenderNamedFlowThread::removeFlowChild(RenderObject* child)
+void RenderNamedFlowThread::removeFlowChild(RenderElement& child)
 {
-    m_flowThreadChildList.remove(child);
+    m_flowThreadChildList.remove(&child);
 }
 
 bool RenderNamedFlowThread::dependsOn(RenderNamedFlowThread* otherRenderFlowThread) const

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.h (163968 => 163969)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2014-02-12 20:15:05 UTC (rev 163969)
@@ -52,13 +52,13 @@
 
     const RenderRegionList& invalidRenderRegionList() const { return m_invalidRegionList; }
 
-    RenderObject* nextRendererForNode(Node*) const;
+    RenderElement* nextRendererForElement(Element&) const;
 
-    void addFlowChild(RenderObject* newChild);
-    void removeFlowChild(RenderObject*);
+    void addFlowChild(RenderElement&);
+    void removeFlowChild(RenderElement&);
     bool hasChildren() const { return !m_flowThreadChildList.isEmpty(); }
 #ifndef NDEBUG
-    bool hasChild(RenderObject* child) const { return m_flowThreadChildList.contains(child); }
+    bool hasChild(RenderElement& child) const { return m_flowThreadChildList.contains(&child); }
 #endif
 
     void pushDependencies(RenderNamedFlowThreadList&);
@@ -129,7 +129,7 @@
     RenderNamedFlowThreadCountedSet m_layoutBeforeThreadsSet;
 
     // Holds the sorted children of a named flow. This is the only way we can get the ordering right.
-    ListHashSet<RenderObject*> m_flowThreadChildList;
+    ListHashSet<RenderElement*> m_flowThreadChildList;
 
     NamedFlowContentElements m_contentElements;
 

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (163968 => 163969)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2014-02-12 20:15:05 UTC (rev 163969)
@@ -1855,18 +1855,6 @@
     if (AXObjectCache* cache = document().existingAXObjectCache())
         cache->remove(this);
 
-#ifndef NDEBUG
-    if (!documentBeingDestroyed() && view().hasRenderNamedFlowThreads()) {
-        // After remove, the object and the associated information should not be in any flow thread.
-        const RenderNamedFlowThreadList* flowThreadList = view().flowThreadController().renderNamedFlowThreadList();
-        for (RenderNamedFlowThreadList::const_iterator iter = flowThreadList->begin(); iter != flowThreadList->end(); ++iter) {
-            const RenderNamedFlowThread* renderFlowThread = *iter;
-            ASSERT(!renderFlowThread->hasChild(this));
-            ASSERT(!renderFlowThread->hasChildInfo(this));
-        }
-    }
-#endif
-
     // If this renderer had a parent, remove should have destroyed any counters
     // attached to this renderer and marked the affected other counters for
     // reevaluation. This apparently redundant check is here for the case when
@@ -1891,9 +1879,6 @@
 
     if (!isFloating() && parent()->childrenInline())
         parent()->dirtyLinesFromChangedChild(this);
-
-    if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
-        containerFlowThread->addFlowChild(this);
 }
 
 void RenderObject::willBeRemovedFromTree()
@@ -1902,9 +1887,6 @@
 
     removeFromRenderFlowThread();
 
-    if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
-        containerFlowThread->removeFlowChild(this);
-
     // Update cached boundaries in SVG renderers, if a child is removed.
     parent()->setNeedsBoundariesUpdate();
 }

Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (163968 => 163969)


--- trunk/Source/WebCore/style/StyleResolveTree.cpp	2014-02-12 19:29:39 UTC (rev 163968)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp	2014-02-12 20:15:05 UTC (rev 163969)
@@ -226,7 +226,7 @@
     RenderObject* nextRenderer;
     if (parentFlowRenderer) {
         parentRenderer = parentFlowRenderer;
-        nextRenderer = parentFlowRenderer->nextRendererForNode(&element);
+        nextRenderer = parentFlowRenderer->nextRendererForElement(element);
     } else {
         // FIXME: Make this path Element only, handle the root special case separately.
         parentRenderer = renderingParentNode->renderer();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to