Title: [235711] trunk/Source/WebCore
Revision
235711
Author
[email protected]
Date
2018-09-05 15:08:23 -0700 (Wed, 05 Sep 2018)

Log Message

[LFC] Construct the Display::Box objects on demand.
https://bugs.webkit.org/show_bug.cgi?id=189320

Reviewed by Antti Koivisto.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::initializeRoot):
(WebCore::Layout::LayoutContext::displayBoxForLayoutBox const):
(WebCore::Layout::LayoutContext::createDisplayBox): Deleted.
* layout/LayoutContext.h:
(WebCore::Layout::LayoutContext::displayBoxForLayoutBox const): Deleted.
* layout/Verification.cpp:
(WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
* layout/displaytree/DisplayBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235710 => 235711)


--- trunk/Source/WebCore/ChangeLog	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/ChangeLog	2018-09-05 22:08:23 UTC (rev 235711)
@@ -1,3 +1,24 @@
+2018-09-05  Zalan Bujtas  <[email protected]>
+
+        [LFC] Construct the Display::Box objects on demand.
+        https://bugs.webkit.org/show_bug.cgi?id=189320
+
+        Reviewed by Antti Koivisto.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::initializeRoot):
+        (WebCore::Layout::LayoutContext::displayBoxForLayoutBox const):
+        (WebCore::Layout::LayoutContext::createDisplayBox): Deleted.
+        * layout/LayoutContext.h:
+        (WebCore::Layout::LayoutContext::displayBoxForLayoutBox const): Deleted.
+        * layout/Verification.cpp:
+        (WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree const):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        * layout/displaytree/DisplayBox.h:
+
 2018-09-05  Woodrow Wang  <[email protected]>
 
         Add infrastructure to dump resource load statistics

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (235710 => 235711)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-05 22:08:23 UTC (rev 235711)
@@ -113,7 +113,6 @@
 
     for (auto& outOfFlowBox : container.outOfFlowDescendants()) {
         auto& layoutBox = *outOfFlowBox;
-        layoutContext.createDisplayBox(layoutBox);
 
         ASSERT(layoutBox.establishesFormattingContext());
         auto formattingContext = layoutContext.formattingContext(layoutBox);

Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (235710 => 235711)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2018-09-05 22:08:23 UTC (rev 235711)
@@ -54,7 +54,7 @@
     ASSERT(root.establishesFormattingContext());
 
     m_root = makeWeakPtr(const_cast<Container&>(root));
-    auto& displayBox = createDisplayBox(root);
+    auto& displayBox = displayBoxForLayoutBox(root);
 
     // FIXME: m_root could very well be a formatting context root with ancestors and resolvable border and padding (as opposed to the topmost root)
     displayBox.setHorizontalMargin({ });
@@ -86,12 +86,11 @@
     formattingContext->layoutOutOfFlowDescendants(*this, layoutRoot);
 }
 
-Display::Box& LayoutContext::createDisplayBox(const Box& layoutBox)
+Display::Box& LayoutContext::displayBoxForLayoutBox(const Box& layoutBox) const
 {
-    std::unique_ptr<Display::Box> displayBox(new Display::Box(layoutBox.style()));
-    auto* displayBoxPtr = displayBox.get();
-    m_layoutToDisplayBox.add(&layoutBox, WTFMove(displayBox));
-    return *displayBoxPtr;
+    return *m_layoutToDisplayBox.ensure(&layoutBox, [&layoutBox] {
+        return std::make_unique<Display::Box>(layoutBox.style());
+    }).iterator->value;
 }
 
 void LayoutContext::styleChanged(const Box& layoutBox, StyleDiff styleDiff)

Modified: trunk/Source/WebCore/layout/LayoutContext.h (235710 => 235711)


--- trunk/Source/WebCore/layout/LayoutContext.h	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/LayoutContext.h	2018-09-05 22:08:23 UTC (rev 235711)
@@ -80,8 +80,7 @@
     FormattingState& formattingStateForBox(const Box&) const;
     FormattingState& establishedFormattingState(const Box& formattingRoot);
 
-    Display::Box& createDisplayBox(const Box&);
-    Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const { return *m_layoutToDisplayBox.get(&layoutBox); }
+    Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const;
 
     bool inQuirksMode() const { return m_inQuirksMode; }
     // For testing purposes only
@@ -93,7 +92,7 @@
     WeakPtr<Container> m_root;
     HashSet<const Container*> m_formattingContextRootListForLayout;
     HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
-    HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;
+    mutable HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;
     bool m_inQuirksMode { false };
 };
 

Modified: trunk/Source/WebCore/layout/Verification.cpp (235710 => 235711)


--- trunk/Source/WebCore/layout/Verification.cpp	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/Verification.cpp	2018-09-05 22:08:23 UTC (rev 235711)
@@ -219,6 +219,7 @@
     showLayoutTree(*m_root.get(), this);
 #endif
     WTFLogAlways("%s", stream.release().utf8().data());
+    ASSERT_NOT_REACHED();
 }
 
 }

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (235710 => 235711)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-05 22:08:23 UTC (rev 235711)
@@ -65,10 +65,8 @@
     FloatingContext floatingContext(formattingState.floatingState());
     // This is a post-order tree traversal layout.
     // The root container layout is done in the formatting context it lives in, not that one it creates, so let's start with the first child.
-    if (auto* firstChild = formattingRoot.firstInFlowOrFloatingChild()) {
+    if (auto* firstChild = formattingRoot.firstInFlowOrFloatingChild())
         layoutQueue.append(firstChild);
-        layoutContext.createDisplayBox(*firstChild);
-    }
     // 1. Go all the way down to the leaf node
     // 2. Compute static position and width as we traverse down
     // 3. As we climb back on the tree, compute height and finialize position
@@ -85,9 +83,7 @@
                 // Continue with next sibling if exists.
                 if (!layoutBox.nextInFlowOrFloatingSibling())
                     break;
-                auto* nextSibling = layoutBox.nextInFlowOrFloatingSibling();
-                layoutQueue.append(nextSibling);
-                layoutContext.createDisplayBox(*nextSibling);
+                layoutQueue.append(layoutBox.nextInFlowOrFloatingSibling());
                 continue;
             }
 
@@ -97,9 +93,7 @@
             computeWidthAndMargin(layoutContext, layoutBox);
             if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
                 break;
-            auto* firstChild = downcast<Container>(layoutBox).firstInFlowOrFloatingChild();
-            layoutQueue.append(firstChild);
-            layoutContext.createDisplayBox(*firstChild);
+            layoutQueue.append(downcast<Container>(layoutBox).firstInFlowOrFloatingChild());
         }
 
         // Climb back on the ancestors and compute height/final position.
@@ -121,7 +115,6 @@
             placeInFlowPositionedChildren(layoutContext, container);
             if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) {
                 layoutQueue.append(nextSibling);
-                layoutContext.createDisplayBox(*nextSibling);
                 break;
             }
         }

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (235710 => 235711)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2018-09-05 21:57:32 UTC (rev 235710)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2018-09-05 22:08:23 UTC (rev 235711)
@@ -56,6 +56,7 @@
     friend class Layout::FloatingContext;
     friend class Layout::LayoutContext;
 
+    Box(const RenderStyle&);
     Box(const Box&);
 
     class Rect {
@@ -172,8 +173,6 @@
     Rect contentBox() const;
 
 private:
-    Box(const RenderStyle&);
-
     struct Style {
         Style(const RenderStyle&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to