Diff
Modified: trunk/Source/WebCore/ChangeLog (288435 => 288436)
--- trunk/Source/WebCore/ChangeLog 2022-01-24 12:41:47 UTC (rev 288435)
+++ trunk/Source/WebCore/ChangeLog 2022-01-24 13:58:57 UTC (rev 288436)
@@ -1,3 +1,23 @@
+2022-01-24 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Display builders should flip coords for writing mode
+ https://bugs.webkit.org/show_bug.cgi?id=235498
+
+ Reviewed by Antti Koivisto.
+
+ Display boxes/lines all have visual geometries. This patch flips their coords when they
+ are inside a block with vertical writing mode.
+
+ This is in preparation for enabling vertical writing mode for IFC.
+
+ * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+ (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
+ (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+ (WebCore::Layout::InlineDisplayContentBuilder::flipLogicalRectToVisualForWritingMode):
+ * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h:
+ * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp:
+ (WebCore::Layout::InlineDisplayLineBuilder::build const):
+
2022-01-24 Youenn Fablet <[email protected]>
MediaStream canvas.captureStream() playback to LocalSampleBufferDisplayLayer is flaky
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp (288435 => 288436)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp 2022-01-24 12:41:47 UTC (rev 288435)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp 2022-01-24 13:58:57 UTC (rev 288436)
@@ -326,6 +326,7 @@
hasContent = hasContent || lineRun.isText() || lineRun.isBox();
ASSERT(lineContent.inlineBaseDirection == TextDirection::LTR || !hasContent);
#endif
+ auto writingMode = root().style().writingMode();
auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLeft();
for (auto& lineRun : lineContent.runs) {
@@ -332,8 +333,9 @@
auto& layoutBox = lineRun.layoutBox();
auto visualRectRelativeToRoot = [&](auto logicalRect) {
- logicalRect.moveBy({ contentStartInVisualOrder, displayLine.top() });
- return logicalRect;
+ auto visualRect = flipLogicalRectToVisualForWritingMode(logicalRect, writingMode);
+ visualRect.moveBy({ contentStartInVisualOrder, displayLine.top() });
+ return visualRect;
};
if (lineRun.isText()) {
@@ -542,6 +544,7 @@
auto displayBoxTree = DisplayBoxTree { };
ancestorStack.push({ }, root());
+ auto writingMode = root().style().writingMode();
auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLeft();
auto hasInlineBox = false;
auto createDisplayBoxesInVisualOrder = [&] {
@@ -559,9 +562,13 @@
continue;
auto visualRectRelativeToRoot = [&](auto logicalRect) {
- logicalRect.setLeft(contentRightInVisualOrder);
- logicalRect.moveVertically(displayLine.top());
- return logicalRect;
+ auto visualRect = flipLogicalRectToVisualForWritingMode(logicalRect, writingMode);
+ if (WebCore::isHorizontalWritingMode(writingMode))
+ visualRect.setLeft(contentRightInVisualOrder);
+ else
+ visualRect.setTop(contentRightInVisualOrder);
+ visualRect.moveVertically(displayLine.top());
+ return visualRect;
};
auto parentDisplayBoxNodeIndex = ensureDisplayBoxForContainer(layoutBox.parent(), displayBoxTree, ancestorStack, boxes);
@@ -774,7 +781,24 @@
boxes[lastRootInlineBoxIndex].setIsLastForLayoutBox(true);
}
+InlineRect InlineDisplayContentBuilder::flipLogicalRectToVisualForWritingMode(const InlineRect& logicalRect, WritingMode writingMode)
+{
+ switch (writingMode) {
+ case WritingMode::TopToBottom:
+ return logicalRect;
+ case WritingMode::LeftToRight:
+ case WritingMode::RightToLeft: {
+ // See InlineFormattingGeometry for more info.
+ return InlineRect { logicalRect.left(), logicalRect.top(), logicalRect.height(), logicalRect.width() };
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ return logicalRect;
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h (288435 => 288436)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h 2022-01-24 12:41:47 UTC (rev 288435)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h 2022-01-24 13:58:57 UTC (rev 288436)
@@ -47,6 +47,7 @@
DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, const size_t lineIndex);
static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&);
+ static InlineRect flipLogicalRectToVisualForWritingMode(const InlineRect& logicalRect, WritingMode);
private:
void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, DisplayBoxes&);
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp (288435 => 288436)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp 2022-01-24 12:41:47 UTC (rev 288435)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp 2022-01-24 13:58:57 UTC (rev 288436)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "InlineDisplayContentBuilder.h"
#include "LayoutBoxGeometry.h"
namespace WebCore {
@@ -93,8 +94,10 @@
auto lineBoxRect = InlineRect { lineContent.lineLogicalTopLeft.y(), lineBoxVisualLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
auto enclosingLineGeometry = collectEnclosingLineGeometry(lineBox, lineBoxRect);
- return InlineDisplay::Line { lineBoxRect
- , enclosingLineGeometry.scrollableOverflowRect
+ // FIXME: Figure out if properties like enclosingLineGeometry top and bottom needs to be flipped as well.
+ auto writingMode = root().style().writingMode();
+ return InlineDisplay::Line { InlineDisplayContentBuilder::flipLogicalRectToVisualForWritingMode(lineBoxRect, writingMode)
+ , InlineDisplayContentBuilder::flipLogicalRectToVisualForWritingMode(enclosingLineGeometry.scrollableOverflowRect, writingMode)
, enclosingLineGeometry.enclosingTopAndBottom
, rootInlineBox.logicalTop() + rootInlineBox.baseline()
, contentVisualLeft