Skip to content

Commit

Permalink
[IFC] inline-block child preceded by an inline child has incorrect po…
Browse files Browse the repository at this point in the history
…sitioning in vertical writing modes with a right-to-left direction

https://bugs.webkit.org/show_bug.cgi?id=264425
<rdar://problem/118128181>

Reviewed by Antti Koivisto.

Turn (half)logical left to visual on BoxGeometry too.

* LayoutTests/fast/text/rtl-vertical-text-misalign-with-inline-blocks-expected.html: Added.
* LayoutTests/fast/text/rtl-vertical-text-misalign-with-inline-blocks.html: Added.
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox):
(WebCore::Layout::InlineDisplayContentBuilder::setLeftForWritingMode const):
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h:

Canonical link: https://commits.webkit.org/270442@main
  • Loading branch information
alanbaradlay committed Nov 9, 2023
1 parent c2058bf commit 1a7f8f4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<style>
.container {
writing-mode: vertical-rl;
font-family: Ahem;
}
</style>
<div class=container>this shouldall be on the same line</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<style>
.container {
writing-mode: vertical-rl;
direction: rtl;
font-family: Ahem;
}
.content {
display: inline-block;
}
</style>
<div class=container><div class=content>all be on the same line</div><span></span><div class=content>this should</div></div>
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ void InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox(size_t displ
auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
auto boxMarginLeft = marginLeftInInlineDirection(boxGeometry, isLeftToRightDirection);

auto borderBoxLeft = LayoutUnit { contentRightInInlineDirectionVisualOrder + boxMarginLeft };
boxGeometry.setLeft(borderBoxLeft);
auto borderBoxLeft = InlineLayoutUnit { contentRightInInlineDirectionVisualOrder + boxMarginLeft };
setLeftForWritingMode(boxGeometry, LayoutUnit { borderBoxLeft }, writingMode);
setLeftForWritingMode(displayBox, borderBoxLeft, writingMode);

contentRightInInlineDirectionVisualOrder += boxGeometry.marginBoxWidth();
Expand Down Expand Up @@ -1178,16 +1178,17 @@ InlineRect InlineDisplayContentBuilder::flipRootInlineBoxRectToVisualForWritingM
return rootInlineBoxLogicalRect;
}

void InlineDisplayContentBuilder::setLeftForWritingMode(InlineDisplay::Box& displayBox, InlineLayoutUnit logicalLeft, WritingMode writingMode) const
template <typename BoxType, typename LayoutUnitType>
void InlineDisplayContentBuilder::setLeftForWritingMode(BoxType& box, LayoutUnitType logicalLeft, WritingMode writingMode) const
{
switch (writingModeToBlockFlowDirection(writingMode)) {
case BlockFlowDirection::TopToBottom:
case BlockFlowDirection::BottomToTop:
displayBox.setLeft(logicalLeft);
box.setLeft(logicalLeft);
break;
case BlockFlowDirection::LeftToRight:
case BlockFlowDirection::RightToLeft:
displayBox.setTop(logicalLeft);
box.setTop(logicalLeft);
break;
default:
ASSERT_NOT_REACHED();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class InlineDisplayContentBuilder {

InlineRect flipLogicalRectToVisualForWritingModeWithinLine(const InlineRect& logicalRect, const InlineRect& lineLogicalRect, WritingMode) const;
InlineRect flipRootInlineBoxRectToVisualForWritingMode(const InlineRect& rootInlineBoxLogicalRect, WritingMode) const;
void setLeftForWritingMode(InlineDisplay::Box&, InlineLayoutUnit logicalRight, WritingMode) const;
template <typename BoxType, typename LayoutUnitType>
void setLeftForWritingMode(BoxType&, LayoutUnitType logicalLeft, WritingMode) const;
void setRightForWritingMode(InlineDisplay::Box&, InlineLayoutUnit logicalRight, WritingMode) const;
InlineLayoutPoint movePointHorizontallyForWritingMode(const InlineLayoutPoint& topLeft, InlineLayoutUnit horizontalOffset, WritingMode) const;
InlineLayoutUnit outsideListMarkerVisualPosition(const ElementBox&) const;
Expand Down

0 comments on commit 1a7f8f4

Please sign in to comment.