Introduce RenderTreeBuilder
[WebKit-https.git] / Source / WebCore / style / RenderTreeUpdaterListItem.cpp
index cf0a064..2362b34 100644 (file)
@@ -69,17 +69,15 @@ static RenderObject* firstNonMarkerChild(RenderBlock& parent)
     return child;
 }
 
-void RenderTreeUpdater::ListItem::updateMarker(RenderListItem& listItemRenderer)
+void RenderTreeUpdater::ListItem::updateMarker(RenderTreeBuilder& builder, RenderListItem& listItemRenderer)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!listItemRenderer.view().layoutState());
+    ASSERT_WITH_SECURITY_IMPLICATION(!listItemRenderer.view().frameView().layoutContext().layoutState());
 
     auto& style = listItemRenderer.style();
 
     if (style.listStyleType() == NoneListStyle && (!style.listStyleImage() || style.listStyleImage()->errorOccurred())) {
-        if (listItemRenderer.markerRenderer()) {
-            listItemRenderer.markerRenderer()->destroy();
-            ASSERT(!listItemRenderer.markerRenderer());
-        }
+        if (auto* marker = listItemRenderer.markerRenderer())
+            marker->removeFromParentAndDestroy();
         return;
     }
 
@@ -92,7 +90,7 @@ void RenderTreeUpdater::ListItem::updateMarker(RenderListItem& listItemRenderer)
         newMarkerRenderer = WebCore::createRenderer<RenderListMarker>(listItemRenderer, WTFMove(newStyle));
         newMarkerRenderer->initializeStyle();
         markerRenderer = newMarkerRenderer.get();
-        listItemRenderer.setMarkerRenderer(markerRenderer);
+        listItemRenderer.setMarkerRenderer(*markerRenderer);
     }
 
     RenderElement* currentParent = markerRenderer->parent();
@@ -112,13 +110,13 @@ void RenderTreeUpdater::ListItem::updateMarker(RenderListItem& listItemRenderer)
 
     if (newParent != currentParent) {
         if (currentParent)
-            newParent->addChild(currentParent->takeChild(*markerRenderer), firstNonMarkerChild(*newParent));
+            builder.insertChild(*newParent, currentParent->takeChild(*markerRenderer), firstNonMarkerChild(*newParent));
         else
-            newParent->addChild(WTFMove(newMarkerRenderer), firstNonMarkerChild(*newParent));
+            builder.insertChild(*newParent, WTFMove(newMarkerRenderer), firstNonMarkerChild(*newParent));
 
         // If current parent is an anonymous block that has lost all its children, destroy it.
         if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !downcast<RenderBlock>(*currentParent).continuation())
-            currentParent->destroy();
+            currentParent->removeFromParentAndDestroy();
     }
 }