Remove StyleResolver::State::m_parentNode
[WebKit-https.git] / Source / WebCore / rendering / RenderNamedFlowFragment.cpp
index 0184820..4590f9d 100644 (file)
@@ -34,6 +34,7 @@
 #include "PaintInfo.h"
 #include "RenderBoxRegionInfo.h"
 #include "RenderFlowThread.h"
+#include "RenderIterator.h"
 #include "RenderNamedFlowThread.h"
 #include "RenderView.h"
 #include "StyleResolver.h"
@@ -349,24 +350,21 @@ void RenderNamedFlowFragment::checkRegionStyle()
     toRenderNamedFlowThread(m_flowThread)->checkRegionsWithStyling();
 }
 
-PassRefPtr<RenderStyle> RenderNamedFlowFragment::computeStyleInRegion(const RenderObject* object)
+PassRefPtr<RenderStyle> RenderNamedFlowFragment::computeStyleInRegion(RenderElement& renderer, RenderStyle& parentStyle)
 {
-    ASSERT(object);
-    ASSERT(!object->isAnonymous());
-    ASSERT(object->node() && object->node()->isElementNode());
+    ASSERT(!renderer.isAnonymous());
 
     // FIXME: Region styling fails for pseudo-elements because the renderers don't have a node.
-    Element* element = toElement(object->node());
-    RefPtr<RenderStyle> renderObjectRegionStyle = object->view().document().ensureStyleResolver().styleForElement(element, 0, DisallowStyleSharing, MatchAllRules, this);
+    RefPtr<RenderStyle> renderObjectRegionStyle = renderer.view().document().ensureStyleResolver().styleForElement(renderer.element(), &parentStyle, DisallowStyleSharing, MatchAllRules, this);
 
     return renderObjectRegionStyle.release();
 }
 
-void RenderNamedFlowFragment::computeChildrenStyleInRegion(const RenderElement* object)
+void RenderNamedFlowFragment::computeChildrenStyleInRegion(RenderElement& renderer)
 {
-    for (RenderObject* child = object->firstChild(); child; child = child->nextSibling()) {
+    for (auto& child : childrenOfType<RenderObject>(renderer)) {
 
-        auto it = m_renderObjectRegionStyle.find(child);
+        auto it = m_renderObjectRegionStyle.find(&child);
 
         RefPtr<RenderStyle> childStyleInRegion;
         bool objectRegionStyleCached = false;
@@ -374,17 +372,17 @@ void RenderNamedFlowFragment::computeChildrenStyleInRegion(const RenderElement*
             childStyleInRegion = it->value.style;
             objectRegionStyleCached = true;
         } else {
-            if (child->isAnonymous() || child->isInFlowRenderFlowThread())
-                childStyleInRegion = RenderStyle::createAnonymousStyleWithDisplay(&object->style(), child->style().display());
-            else if (child->isText())
-                childStyleInRegion = RenderStyle::clone(&object->style());
+            if (child.isAnonymous() || child.isInFlowRenderFlowThread())
+                childStyleInRegion = RenderStyle::createAnonymousStyleWithDisplay(&renderer.style(), child.style().display());
+            else if (child.isText())
+                childStyleInRegion = RenderStyle::clone(&renderer.style());
             else
-                childStyleInRegion = computeStyleInRegion(child);
+                childStyleInRegion = computeStyleInRegion(toRenderElement(child), renderer.style());
         }
 
-        setObjectStyleInRegion(child, childStyleInRegion, objectRegionStyleCached);
+        setObjectStyleInRegion(&child, childStyleInRegion, objectRegionStyleCached);
 
-        if (child->isRenderElement())
+        if (child.isRenderElement())
             computeChildrenStyleInRegion(toRenderElement(child));
     }
 }
@@ -452,11 +450,11 @@ void RenderNamedFlowFragment::setRegionObjectsRegionStyle()
             ASSERT(it->value.cached);
             objectRegionStyleCached = true;
         } else
-            objectStyleInRegion = computeStyleInRegion(object);
+            objectStyleInRegion = computeStyleInRegion(*object, style());
 
         setObjectStyleInRegion(object, objectStyleInRegion, objectRegionStyleCached);
 
-        computeChildrenStyleInRegion(object);
+        computeChildrenStyleInRegion(*object);
     }
 }