Changeset 287922 in webkit
- Timestamp:
- Jan 12, 2022, 6:37:38 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/inline/rtl-negative-margins-expected.html (added)
-
LayoutTests/fast/inline/rtl-negative-margins.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (modified) (2 diffs)
-
Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (modified) (2 diffs)
-
Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (modified) (1 diff)
-
Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h (modified) (1 diff)
-
Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r287911 r287922 1 2022-01-12 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 4 https://bugs.webkit.org/show_bug.cgi?id=235095 5 6 Reviewed by Antti Koivisto. 7 8 * fast/inline/rtl-negative-margins-expected.html: Added. 9 * fast/inline/rtl-negative-margins.html: Added. 10 1 11 2022-01-11 Said Abou-Hallawa <said@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r287921 r287922 1 2022-01-12 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 4 https://bugs.webkit.org/show_bug.cgi?id=235095 5 6 Reviewed by Antti Koivisto. 7 8 The simplified negative margin handling on inline boxes does not work well with RTL inline base direction. 9 With LTR direction, we could just treat the negative left margin value (which pulls content to the left) 10 as part the "logical width" (may resulting in negative width values) and let this shorter width pull 11 the the adjoining content. 12 However this setup produces incorrect box positions when the inline base direction is RTL. 13 In this patch, we switch over to a more correct inline box positioning where the negative margin 14 affects the logical left while it does not make the run shorter anymore. 15 16 Test: fast/inline/rtl-negative-margins.html 17 18 * layout/formattingContexts/inline/InlineLine.cpp: 19 (WebCore::Layout::Line::appendInlineBoxStart): 20 (WebCore::Layout::Line::appendNonReplacedInlineLevelBox): 21 * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: 22 (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes): 23 * layout/formattingContexts/inline/InlineLineBuilder.cpp: 24 (WebCore::Layout::LineBuilder::layoutInlineContent): 25 * layout/formattingContexts/inline/InlineLineBuilder.h: 26 * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp: 27 (WebCore::Layout::InlineDisplayLineBuilder::build const): 28 1 29 2022-01-12 Nikolas Zimmermann <nzimmermann@igalia.com> 2 30 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp
r287824 r287922 229 229 // Incoming logical width includes the cloned decoration end to be able to do line breaking. 230 230 auto borderAndPaddingEndForDecorationClone = addBorderAndPaddingEndForInlineBoxDecorationClone(inlineItem); 231 m_runs.append({ inlineItem, style, logicalLeft, logicalWidth - borderAndPaddingEndForDecorationClone });232 231 // Do not let negative margin make the content shorter than it already is. 233 232 m_contentLogicalWidth = std::max(m_contentLogicalWidth, logicalLeft + logicalWidth); 233 234 auto marginStart = formattingContext().geometryForBox(inlineItem.layoutBox()).marginStart(); 235 if (marginStart >= 0) { 236 m_runs.append({ inlineItem, style, logicalLeft, logicalWidth - borderAndPaddingEndForDecorationClone }); 237 return; 238 } 239 // Negative margin-start pulls the content to the logical left direction. 240 m_runs.append({ inlineItem, style, logicalLeft + marginStart, logicalWidth - marginStart - borderAndPaddingEndForDecorationClone }); 234 241 } 235 242 … … 352 359 { 353 360 resetTrailingContent(); 354 m_contentLogicalWidth += marginBoxLogicalWidth; 361 // Do not let negative margin make the content shorter than it already is. 362 m_contentLogicalWidth = std::max(m_contentLogicalWidth, lastRunLogicalRight() + marginBoxLogicalWidth); 355 363 ++m_nonSpanningInlineLevelBoxCount; 356 364 auto marginStart = formattingContext().geometryForBox(inlineItem.layoutBox()).marginStart(); -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
r287731 r287922 284 284 marginStart = formattingContext().geometryForBox(layoutBox).marginStart(); 285 285 #endif 286 auto adjustedLogicalStart = logicalLeft + marginStart;286 auto adjustedLogicalStart = logicalLeft + std::max(0.0f, marginStart); 287 287 auto logicalWidth = rootInlineBox.logicalWidth() - adjustedLogicalStart; 288 288 auto inlineBox = InlineLevelBox::createInlineBox(layoutBox, style, adjustedLogicalStart, logicalWidth, InlineLevelBox::LineSpanningInlineBox::Yes); … … 297 297 // Inline box run is based on margin box. Let's convert it to border box. 298 298 auto marginStart = formattingContext().geometryForBox(layoutBox).marginStart(); 299 auto initialLogicalWidth = rootInlineBox.logicalWidth() - (run.logicalLeft() + marginStart); 299 logicalLeft += std::max(0_lu, marginStart); 300 auto initialLogicalWidth = rootInlineBox.logicalWidth() - (logicalLeft - rootInlineBox.logicalLeft()); 300 301 ASSERT(initialLogicalWidth >= 0 || lineContent.hangingContentWidth); 301 302 initialLogicalWidth = std::max(initialLogicalWidth, 0.f); 302 auto inlineBox = InlineLevelBox::createInlineBox(layoutBox, style, logicalLeft + marginStart, initialLogicalWidth);303 auto inlineBox = InlineLevelBox::createInlineBox(layoutBox, style, logicalLeft, initialLogicalWidth); 303 304 inlineBox.setIsFirstBox(); 304 305 setInitialVerticalGeometryForInlineBox(inlineBox); -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
r287482 r287922 354 354 , m_lineLogicalRect.width() 355 355 , m_line.contentLogicalWidth() 356 , m_line.contentLogicalRight() 356 357 , m_line.hangingTrailingContentWidth() 357 358 , isLastLine -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h
r287471 r287922 62 62 InlineLayoutUnit lineLogicalWidth { 0 }; 63 63 InlineLayoutUnit contentLogicalWidth { 0 }; 64 InlineLayoutUnit contentLogicalRight { 0 }; 64 65 InlineLayoutUnit hangingContentWidth { 0 }; 65 66 bool isLastLineWithInlineContent { true }; -
trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp
r287486 r287922 90 90 auto contentVisualLeft = isLeftToRightDirection 91 91 ? lineBox.rootInlineBoxAlignmentOffset() 92 : rootGeometry.contentBoxWidth() - lineOffsetFromContentBox - lineBox.rootInlineBoxAlignmentOffset() - rootInlineBox.logicalWidth() - lineContent.hangingContentWidth;92 : rootGeometry.contentBoxWidth() - lineOffsetFromContentBox - lineBox.rootInlineBoxAlignmentOffset() - lineContent.contentLogicalRight; 93 93 94 94 auto lineBoxRect = InlineRect { lineContent.lineLogicalTopLeft.y(), lineBoxVisualLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
Note:
See TracChangeset
for help on using the changeset viewer.