Title: [288421] trunk/Source/WebCore
Revision
288421
Author
za...@apple.com
Date
2022-01-23 10:43:37 -0800 (Sun, 23 Jan 2022)

Log Message

[LFC][IFC] InlineFormattingContext::computeGeometryForLineContent should always return the line logical rect
https://bugs.webkit.org/show_bug.cgi?id=235494

Reviewed by Antti Koivisto.

The return rect of computeGeometryForLineContent (based on the display line) is input to the next line's
initial rect and therefore it is supposed to be logical (in general, layout should strictly use logical coords).

This is in preparation for supporting vertical writing mode.

* layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
* layout/formattingContexts/inline/InlineFormattingGeometry.cpp:
(WebCore::Layout::InlineFormattingGeometry::flipVisualRectToLogicalForWritingMode):
* layout/formattingContexts/inline/InlineFormattingGeometry.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288420 => 288421)


--- trunk/Source/WebCore/ChangeLog	2022-01-23 16:59:15 UTC (rev 288420)
+++ trunk/Source/WebCore/ChangeLog	2022-01-23 18:43:37 UTC (rev 288421)
@@ -1,3 +1,21 @@
+2022-01-23  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] InlineFormattingContext::computeGeometryForLineContent should always return the line logical rect
+        https://bugs.webkit.org/show_bug.cgi?id=235494
+
+        Reviewed by Antti Koivisto.
+
+        The return rect of computeGeometryForLineContent (based on the display line) is input to the next line's
+        initial rect and therefore it is supposed to be logical (in general, layout should strictly use logical coords).
+
+        This is in preparation for supporting vertical writing mode.
+
+        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+        * layout/formattingContexts/inline/InlineFormattingGeometry.cpp:
+        (WebCore::Layout::InlineFormattingGeometry::flipVisualRectToLogicalForWritingMode):
+        * layout/formattingContexts/inline/InlineFormattingGeometry.h:
+
 2022-01-23  Ziran Sun  <z...@igalia.com>
 
         [forms] Prevent contenteditable anchors from being stuck

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (288420 => 288421)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2022-01-23 16:59:15 UTC (rev 288420)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2022-01-23 18:43:37 UTC (rev 288421)
@@ -557,7 +557,7 @@
     formattingState.addLineBox(WTFMove(lineBoxAndHeight.lineBox));
     formattingState.addLine(displayLine);
 
-    return formattingState.lines().last().lineBoxRect();
+    return InlineFormattingGeometry::flipVisualRectToLogicalForWritingMode(formattingState.lines().last().lineBoxRect(), root().style().writingMode());
 }
 
 void InlineFormattingContext::invalidateFormattingState()

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp (288420 => 288421)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp	2022-01-23 16:59:15 UTC (rev 288420)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp	2022-01-23 18:43:37 UTC (rev 288421)
@@ -115,7 +115,26 @@
     return false;
 }
 
+InlineRect InlineFormattingGeometry::flipVisualRectToLogicalForWritingMode(const InlineRect& visualRect, WritingMode writingMode)
+{
+    switch (writingMode) {
+    case WritingMode::TopToBottom:
+        return visualRect;
+    case WritingMode::LeftToRight:
+    case WritingMode::RightToLeft: {
+        // FIXME: While vertical-lr and vertical-rl modes do differ in the ordering direction of line boxes
+        // in a block container (see: https://drafts.csswg.org/css-writing-modes/#block-flow)
+        // we ignore it for now as RenderBlock takes care of it for us.
+        return InlineRect { visualRect.left(), visualRect.top(), visualRect.height(), visualRect.width() };
+    }
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+    return visualRect;
 }
+
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h (288420 => 288421)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h	2022-01-23 16:59:15 UTC (rev 288420)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h	2022-01-23 18:43:37 UTC (rev 288421)
@@ -47,6 +47,8 @@
 
     bool inlineLevelBoxAffectsLineBox(const InlineLevelBox&, const LineBox&) const;
 
+    static InlineRect flipVisualRectToLogicalForWritingMode(const InlineRect& visualRect, WritingMode);
+
 private:
     const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingGeometry::formattingContext()); }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to