Title: [282684] trunk/Source/WebCore
Revision
282684
Author
[email protected]
Date
2021-09-17 12:28:49 -0700 (Fri, 17 Sep 2021)

Log Message

[LFC][IFC] Add InlineInvalidation::horizontalConstraintChanged
https://bugs.webkit.org/show_bug.cgi?id=230290

Reviewed by Antti Koivisto.

Add the "resize" invalidation codepath. It notifies formatting context about the available horizontal space change.

* layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::invalidateFormattingState):
* layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp:
(WebCore::Layout::InlineInvalidation::horizontalConstraintChanged):
* layout/formattingContexts/inline/invalidation/InlineInvalidation.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::layout):
(WebCore::LayoutIntegration::LineLayout::updateFormattingRootGeometry):
(WebCore::LayoutIntegration::LineLayout::prepareLayoutState):
* layout/integration/LayoutIntegrationLineLayout.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282683 => 282684)


--- trunk/Source/WebCore/ChangeLog	2021-09-17 19:08:13 UTC (rev 282683)
+++ trunk/Source/WebCore/ChangeLog	2021-09-17 19:28:49 UTC (rev 282684)
@@ -1,3 +1,23 @@
+2021-09-17  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add InlineInvalidation::horizontalConstraintChanged
+        https://bugs.webkit.org/show_bug.cgi?id=230290
+
+        Reviewed by Antti Koivisto.
+
+        Add the "resize" invalidation codepath. It notifies formatting context about the available horizontal space change.
+
+        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::invalidateFormattingState):
+        * layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp:
+        (WebCore::Layout::InlineInvalidation::horizontalConstraintChanged):
+        * layout/formattingContexts/inline/invalidation/InlineInvalidation.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::layout):
+        (WebCore::LayoutIntegration::LineLayout::updateFormattingRootGeometry):
+        (WebCore::LayoutIntegration::LineLayout::prepareLayoutState):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+
 2021-09-17  Philippe Normand  <[email protected]>
 
         REGRESSION(r282220): [GCC] Several flaky crashes on media/track/cue tests

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp (282683 => 282684)


--- trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp	2021-09-17 19:08:13 UTC (rev 282683)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp	2021-09-17 19:28:49 UTC (rev 282684)
@@ -78,6 +78,11 @@
     m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
 }
 
+void InlineInvalidation::horizontalConstraintChanged()
+{
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
 }
+
 }
+}
 #endif

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h (282683 => 282684)


--- trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h	2021-09-17 19:08:13 UTC (rev 282683)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h	2021-09-17 19:28:49 UTC (rev 282684)
@@ -51,6 +51,8 @@
     void inlineLevelBoxInserted(const Box&);
     void inlineLevelBoxWillBeRemoved(const Box&);
 
+    void horizontalConstraintChanged();
+
 private:
     InlineDamage& m_inlineDamage;
 };

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (282683 => 282684)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-17 19:08:13 UTC (rev 282683)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-17 19:28:49 UTC (rev 282684)
@@ -214,6 +214,7 @@
         return;
 
     prepareLayoutState();
+    updateFormattingRootGeometryAndInvalidate();
     prepareFloatingState();
 
     // FIXME: Do not clear the lines and runs here unconditionally, but consult with the damage object instead.
@@ -251,22 +252,33 @@
     m_inlineFormattingState.shrinkToFit();
 }
 
-void LineLayout::prepareLayoutState()
+void LineLayout::updateFormattingRootGeometryAndInvalidate()
 {
     auto& flow = this->flow();
-    m_layoutState.setViewportSize(flow.frame().view()->size());
 
-    // FIXME: Turn prepareLayoutState to a setter and call it when the flow size changes so that we can do proper invalidation and not "force-constructing" the line damage object here.
-    ensureLineDamage();
+    auto updateGeometry = [&](auto& root) {
+        root.setContentBoxWidth(flow.contentLogicalWidth());
+        root.setPadding(Layout::Edges { { flow.paddingStart(), flow.paddingEnd() }, { flow.paddingBefore(), flow.paddingAfter() } });
+        root.setBorder(Layout::Edges { { flow.borderStart(), flow.borderEnd() }, { flow.borderBefore(), flow.borderAfter() } });
+        root.setHorizontalMargin({ });
+        root.setVerticalMargin({ });
+    };
+    auto& rootLayoutBox = this->rootLayoutBox();
+    if (!m_layoutState.hasBoxGeometry(rootLayoutBox))
+        return updateGeometry(m_layoutState.ensureGeometryForBox(rootLayoutBox));
 
-    auto& rootGeometry = m_layoutState.ensureGeometryForBox(rootLayoutBox());
-    rootGeometry.setContentBoxWidth(flow.contentSize().width());
-    rootGeometry.setPadding(Layout::Edges { { flow.paddingStart(), flow.paddingEnd() }, { flow.paddingBefore(), flow.paddingAfter() } });
-    rootGeometry.setBorder(Layout::Edges { { flow.borderStart(), flow.borderEnd() }, { flow.borderBefore(), flow.borderAfter() } });
-    rootGeometry.setHorizontalMargin({ });
-    rootGeometry.setVerticalMargin({ });
+    auto& rootGeometry = m_layoutState.geometryForRootBox();
+    auto newLogicalWidth = flow.contentLogicalWidth();
+    if (newLogicalWidth != rootGeometry.contentBoxWidth())
+        Layout::InlineInvalidation(ensureLineDamage()).horizontalConstraintChanged();
+    updateGeometry(rootGeometry);
 }
 
+void LineLayout::prepareLayoutState()
+{
+    m_layoutState.setViewportSize(flow().frame().view()->size());
+}
+
 void LineLayout::prepareFloatingState()
 {
     auto& floatingState = m_inlineFormattingState.floatingState();

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (282683 => 282684)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-17 19:08:13 UTC (rev 282683)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-17 19:28:49 UTC (rev 282684)
@@ -117,6 +117,7 @@
 
 private:
     void prepareLayoutState();
+    void updateFormattingRootGeometryAndInvalidate();
     void prepareFloatingState();
     void constructContent();
     InlineContent& ensureInlineContent();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to