Title: [270227] trunk/Source/WebCore
Revision
270227
Author
[email protected]
Date
2020-11-29 10:46:55 -0800 (Sun, 29 Nov 2020)

Log Message

[LFC][IFC] FloatingContext should take const FloatingState&
https://bugs.webkit.org/show_bug.cgi?id=219331

Reviewed by Antti Koivisto.

Let's not use FloatContext as a proxy for adding float items to the FloatingState.
It enables us to use FloatingContext when we don't have mutable FloatingState e.g. while
computing preferred width.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
* layout/floats/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::FloatingContext):
(WebCore::Layout::FloatingContext::toFloatItem const):
(WebCore::Layout::FloatingContext::append): Deleted.
* layout/floats/FloatingContext.h:
(WebCore::Layout::FloatingContext::floatingState const):
(WebCore::Layout::FloatingContext::layoutState const):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270226 => 270227)


--- trunk/Source/WebCore/ChangeLog	2020-11-29 06:47:37 UTC (rev 270226)
+++ trunk/Source/WebCore/ChangeLog	2020-11-29 18:46:55 UTC (rev 270227)
@@ -1,3 +1,26 @@
+2020-11-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] FloatingContext should take const FloatingState&
+        https://bugs.webkit.org/show_bug.cgi?id=219331
+
+        Reviewed by Antti Koivisto.
+
+        Let's not use FloatContext as a proxy for adding float items to the FloatingState.
+        It enables us to use FloatingContext when we don't have mutable FloatingState e.g. while
+        computing preferred width.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+        * layout/floats/FloatingContext.cpp:
+        (WebCore::Layout::FloatingContext::FloatingContext):
+        (WebCore::Layout::FloatingContext::toFloatItem const):
+        (WebCore::Layout::FloatingContext::append): Deleted.
+        * layout/floats/FloatingContext.h:
+        (WebCore::Layout::FloatingContext::floatingState const):
+        (WebCore::Layout::FloatingContext::layoutState const):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+
 2020-11-28  Don Olmstead  <[email protected]>
 
         Non-unified build fixes, late November 2020 edition, take three

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (270226 => 270227)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-11-29 06:47:37 UTC (rev 270226)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-11-29 18:46:55 UTC (rev 270227)
@@ -62,7 +62,8 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> block formatting context -> formatting root(" << &root() << ")");
     auto& formattingRoot = root();
     ASSERT(formattingRoot.hasInFlowOrFloatingChild());
-    auto floatingContext = FloatingContext { *this, formattingState().floatingState() };
+    auto& floatingState = formattingState().floatingState();
+    auto floatingContext = FloatingContext { *this, floatingState };
 
     LayoutQueue layoutQueue;
     enum class LayoutDirection { Child, Sibling };
@@ -143,7 +144,7 @@
             // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
             computeHeightAndMargin(layoutBox, containingBlockConstraints);
             if (layoutBox.isFloatingPositioned())
-                floatingContext.append(layoutBox);
+                floatingState.append(floatingContext.toFloatItem(layoutBox));
 
             auto establishesFormattingContext = layoutBox.establishesFormattingContext(); 
             if (establishesFormattingContext) {

Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (270226 => 270227)


--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2020-11-29 06:47:37 UTC (rev 270226)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2020-11-29 18:46:55 UTC (rev 270227)
@@ -212,7 +212,7 @@
     HorizontalEdges containingBlockContentBox;
 };
 
-FloatingContext::FloatingContext(const FormattingContext& formattingContext, FloatingState& floatingState)
+FloatingContext::FloatingContext(const FormattingContext& formattingContext, const FloatingState& floatingState)
     : m_formattingContext(formattingContext)
     , m_floatingState(floatingState)
 {
@@ -440,11 +440,11 @@
     return constraints;
 }
 
-void FloatingContext::append(const Box& floatBox)
+FloatingState::FloatItem FloatingContext::toFloatItem(const Box& floatBox) const
 {
     auto absoluteBoxGeometry = BoxGeometry(formattingContext().geometryForBox(floatBox));
     absoluteBoxGeometry.setLogicalTopLeft(mapTopLeftToFloatingStateRoot(floatBox));
-    floatingState().append(FloatingState::FloatItem { floatBox, absoluteBoxGeometry });
+    return { floatBox, absoluteBoxGeometry };
 }
 
 void FloatingContext::findPositionForFormattingContextRoot(FloatAvoider& floatAvoider) const

Modified: trunk/Source/WebCore/layout/floats/FloatingContext.h (270226 => 270227)


--- trunk/Source/WebCore/layout/floats/FloatingContext.h	2020-11-29 06:47:37 UTC (rev 270226)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.h	2020-11-29 18:46:55 UTC (rev 270227)
@@ -44,9 +44,9 @@
 class FloatingContext {
     WTF_MAKE_ISO_ALLOCATED(FloatingContext);
 public:
-    FloatingContext(const FormattingContext&, FloatingState&);
+    FloatingContext(const FormattingContext&, const FloatingState&);
 
-    FloatingState& floatingState() const { return m_floatingState; }
+    const FloatingState& floatingState() const { return m_floatingState; }
 
     LayoutPoint positionForFloat(const Box&, const HorizontalConstraints&) const;
     LayoutPoint positionForNonFloatingFloatAvoider(const Box&, const HorizontalConstraints&) const;
@@ -69,12 +69,13 @@
         Optional<PointInContextRoot> right;
     };
     Constraints constraints(LayoutUnit candidateTop, LayoutUnit candidateHeight) const;
-    void append(const Box&);
 
+    FloatingState::FloatItem toFloatItem(const Box& floatBox) const;
+
 private:
     Optional<LayoutUnit> bottom(Clear) const;
 
-    LayoutState& layoutState() const { return m_floatingState.layoutState(); }
+    const LayoutState& layoutState() const { return m_floatingState.layoutState(); }
     const FormattingContext& formattingContext() const { return m_formattingContext; }
     const ContainerBox& root() const { return m_formattingContext.root(); }
 
@@ -86,7 +87,7 @@
     Point mapPointFromFormattingContextRootToFloatingStateRoot(Point) const;
 
     const FormattingContext& m_formattingContext;
-    FloatingState& m_floatingState;
+    const FloatingState& m_floatingState;
 };
 
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (270226 => 270227)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-11-29 06:47:37 UTC (rev 270226)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-11-29 18:46:55 UTC (rev 270227)
@@ -415,7 +415,8 @@
     auto updateFloatGeometry = [&] {
         if (lineContent.floats.isEmpty())
             return;
-        auto floatingContext = FloatingContext { *this, formattingState.floatingState() };
+        auto& floatingState = formattingState.floatingState();
+        auto floatingContext = FloatingContext { *this, floatingState };
         // Move floats to their final position.
         for (auto* floatBox : lineContent.floats) {
             auto& boxGeometry = formattingState.boxGeometry(*floatBox);
@@ -423,7 +424,7 @@
             boxGeometry.setLogicalTopLeft({ lineBoxLogicalRect.left(), lineBoxLogicalRect.top() });
             // Float it.
             boxGeometry.setLogicalTopLeft(floatingContext.positionForFloat(*floatBox, horizontalConstraints));
-            floatingContext.append(*floatBox);
+            floatingState.append(floatingContext.toFloatItem(*floatBox));
         }
     };
     updateFloatGeometry();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to