Changeset 288497 in webkit
- Timestamp:
- Jan 24, 2022, 5:54:47 PM (5 years ago)
- Location:
- branches/safari-613-branch
- 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
-
branches/safari-613-branch/LayoutTests/ChangeLog
r288496 r288497 1 2022-01-24 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r287922. rdar://problem/87455957 4 5 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 6 https://bugs.webkit.org/show_bug.cgi?id=235095 7 8 Reviewed by Antti Koivisto. 9 10 Source/WebCore: 11 12 The simplified negative margin handling on inline boxes does not work well with RTL inline base direction. 13 With LTR direction, we could just treat the negative left margin value (which pulls content to the left) 14 as part the "logical width" (may resulting in negative width values) and let this shorter width pull 15 the the adjoining content. 16 However this setup produces incorrect box positions when the inline base direction is RTL. 17 In this patch, we switch over to a more correct inline box positioning where the negative margin 18 affects the logical left while it does not make the run shorter anymore. 19 20 Test: fast/inline/rtl-negative-margins.html 21 22 * layout/formattingContexts/inline/InlineLine.cpp: 23 (WebCore::Layout::Line::appendInlineBoxStart): 24 (WebCore::Layout::Line::appendNonReplacedInlineLevelBox): 25 * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: 26 (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes): 27 * layout/formattingContexts/inline/InlineLineBuilder.cpp: 28 (WebCore::Layout::LineBuilder::layoutInlineContent): 29 * layout/formattingContexts/inline/InlineLineBuilder.h: 30 * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp: 31 (WebCore::Layout::InlineDisplayLineBuilder::build const): 32 33 LayoutTests: 34 35 * fast/inline/rtl-negative-margins-expected.html: Added. 36 * fast/inline/rtl-negative-margins.html: Added. 37 38 39 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287922 268f45cc-cd09-0410-ab3c-d52691b4dbfc 40 41 2022-01-12 Alan Bujtas <zalan@apple.com> 42 43 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 44 https://bugs.webkit.org/show_bug.cgi?id=235095 45 46 Reviewed by Antti Koivisto. 47 48 * fast/inline/rtl-negative-margins-expected.html: Added. 49 * fast/inline/rtl-negative-margins.html: Added. 50 1 51 2022-01-24 Alan Coon <alancoon@apple.com> 2 52 -
branches/safari-613-branch/Source/WebCore/ChangeLog
r288496 r288497 1 2022-01-24 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r287922. rdar://problem/87455957 4 5 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 6 https://bugs.webkit.org/show_bug.cgi?id=235095 7 8 Reviewed by Antti Koivisto. 9 10 Source/WebCore: 11 12 The simplified negative margin handling on inline boxes does not work well with RTL inline base direction. 13 With LTR direction, we could just treat the negative left margin value (which pulls content to the left) 14 as part the "logical width" (may resulting in negative width values) and let this shorter width pull 15 the the adjoining content. 16 However this setup produces incorrect box positions when the inline base direction is RTL. 17 In this patch, we switch over to a more correct inline box positioning where the negative margin 18 affects the logical left while it does not make the run shorter anymore. 19 20 Test: fast/inline/rtl-negative-margins.html 21 22 * layout/formattingContexts/inline/InlineLine.cpp: 23 (WebCore::Layout::Line::appendInlineBoxStart): 24 (WebCore::Layout::Line::appendNonReplacedInlineLevelBox): 25 * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: 26 (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes): 27 * layout/formattingContexts/inline/InlineLineBuilder.cpp: 28 (WebCore::Layout::LineBuilder::layoutInlineContent): 29 * layout/formattingContexts/inline/InlineLineBuilder.h: 30 * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp: 31 (WebCore::Layout::InlineDisplayLineBuilder::build const): 32 33 LayoutTests: 34 35 * fast/inline/rtl-negative-margins-expected.html: Added. 36 * fast/inline/rtl-negative-margins.html: Added. 37 38 39 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287922 268f45cc-cd09-0410-ab3c-d52691b4dbfc 40 41 2022-01-12 Alan Bujtas <zalan@apple.com> 42 43 [LFC][IFC] Incorrect negative margin handling (both left/right) with RTL inline base direction 44 https://bugs.webkit.org/show_bug.cgi?id=235095 45 46 Reviewed by Antti Koivisto. 47 48 The simplified negative margin handling on inline boxes does not work well with RTL inline base direction. 49 With LTR direction, we could just treat the negative left margin value (which pulls content to the left) 50 as part the "logical width" (may resulting in negative width values) and let this shorter width pull 51 the the adjoining content. 52 However this setup produces incorrect box positions when the inline base direction is RTL. 53 In this patch, we switch over to a more correct inline box positioning where the negative margin 54 affects the logical left while it does not make the run shorter anymore. 55 56 Test: fast/inline/rtl-negative-margins.html 57 58 * layout/formattingContexts/inline/InlineLine.cpp: 59 (WebCore::Layout::Line::appendInlineBoxStart): 60 (WebCore::Layout::Line::appendNonReplacedInlineLevelBox): 61 * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: 62 (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes): 63 * layout/formattingContexts/inline/InlineLineBuilder.cpp: 64 (WebCore::Layout::LineBuilder::layoutInlineContent): 65 * layout/formattingContexts/inline/InlineLineBuilder.h: 66 * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp: 67 (WebCore::Layout::InlineDisplayLineBuilder::build const): 68 1 69 2022-01-24 Alan Coon <alancoon@apple.com> 2 70 -
branches/safari-613-branch/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp
r287824 r288497 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(); -
branches/safari-613-branch/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
r287731 r288497 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); -
branches/safari-613-branch/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
r287482 r288497 354 354 , m_lineLogicalRect.width() 355 355 , m_line.contentLogicalWidth() 356 , m_line.contentLogicalRight() 356 357 , m_line.hangingTrailingContentWidth() 357 358 , isLastLine -
branches/safari-613-branch/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h
r287471 r288497 62 62 InlineLayoutUnit lineLogicalWidth { 0 }; 63 63 InlineLayoutUnit contentLogicalWidth { 0 }; 64 InlineLayoutUnit contentLogicalRight { 0 }; 64 65 InlineLayoutUnit hangingContentWidth { 0 }; 65 66 bool isLastLineWithInlineContent { true }; -
branches/safari-613-branch/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp
r287486 r288497 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.