Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[IFC][truncation] Content gets truncated too early caused by subpixel…
… flooring

https://bugs.webkit.org/show_bug.cgi?id=255991

Reviewed by Antti Koivisto.

This is caused by using LayoutUnit on block level to set the constraint value on the inline content,
while using InlineLayoutUnit (float) to accumulate inline content on the line.
e.g. <div width="10ch"> with ch length of 7.82px -> 78.2px which gets turned into a LayoutUnit : 5004.8 -> floored to 5004 raw value.

This is similar to what we do for regular line breaking at LineBuilder:availableWidth.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-ui/text-overflow-028.html:
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp:
(WebCore::Layout::truncateOverflowingDisplayBoxes):

Canonical link: https://commits.webkit.org/263428@main
  • Loading branch information
alanbaradlay committed Apr 26, 2023
1 parent db0a320 commit dc24ddb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions LayoutTests/TestExpectations
Expand Up @@ -3303,8 +3303,6 @@ imported/w3c/web-platform-tests/css/css-display/run-in/run-in-table-cell-between
imported/w3c/web-platform-tests/css/css-display/run-in/run-in-table-row-between-003.xht [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-display/run-in/run-in-text-between-004.xht [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-display/run-in/run-in-text-between-005.xht [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-ui/text-overflow-027.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-ui/text-overflow-028.html [ ImageOnlyFailure ]

imported/w3c/web-platform-tests/css/mediaqueries/viewport-script-dynamic.html [ ImageOnlyFailure ]

Expand Down
Expand Up @@ -6,6 +6,7 @@
<link rel="help" href="http://www.w3.org/TR/css-ui-4/#text-overflow">
<link rel="match" href="reference/text-overflow-028-ref.html">
<meta name="assert" content="text-overflow is a visual operation that occurs after layout, and therfore ellides text from the visual end of the line, even in bidi situations">
<meta name="fuzzy" content="maxDifference=86; totalPixels=58" />
<style>
div {
font-family: monospace;
Expand Down
Expand Up @@ -241,6 +241,10 @@ static float truncateOverflowingDisplayBoxes(const InlineDisplay::Line& displayL
auto isFirstContentRun = true;
if (rootStyle.isLeftToRightDirection()) {
auto visualRightForContentEnd = std::max(0.f, right(displayLine) - ellipsisWidth);
#if USE_FLOAT_AS_INLINE_LAYOUT_UNIT
if (visualRightForContentEnd)
visualRightForContentEnd += LayoutUnit::epsilon();
#endif
auto truncateRight = std::optional<float> { };
for (auto& displayBox : boxes) {
if (displayBox.isInlineBox())
Expand All @@ -258,6 +262,10 @@ static float truncateOverflowingDisplayBoxes(const InlineDisplay::Line& displayL

auto truncateLeft = std::optional<float> { };
auto visualLeftForContentEnd = std::max(0.f, left(displayLine) + ellipsisWidth);
#if USE_FLOAT_AS_INLINE_LAYOUT_UNIT
if (visualLeftForContentEnd)
visualLeftForContentEnd -= LayoutUnit::epsilon();
#endif
for (auto& displayBox : makeReversedRange(boxes)) {
if (displayBox.isInlineBox())
continue;
Expand Down

0 comments on commit dc24ddb

Please sign in to comment.