Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Incorrect tab stop if tab-size is a <length> and the distance to the …
…next tab stop is less than 0.5ch

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

Reviewed by Myles C. Maxfield.

FontCascade::tabWidth returns the width between the current
position and the next tab stop. If it is less than 0.5ch, it
should return the width between the current position and the next
next tab stop.
<https://drafts.csswg.org/css-text-3/#white-space-phase-2>

The width of the next next tab stop is the sum of the width of
the next tab stop and the tab size. However, it just returned the
tab size in the case.

This change makes the following wpt tests pass.
  imported/w3c/web-platform-tests/css/css-text/tab-size/tab-min-rendered-width-1.html
  imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-004.html
  imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-002.html
  imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-006.html

* LayoutTests/TestExpectations:
* Source/WebCore/platform/graphics/FontCascade.h:
(WebCore::FontCascade::tabWidth const):

Canonical link: https://commits.webkit.org/265922@main
  • Loading branch information
fujii committed Jul 10, 2023
1 parent 784117b commit d88306b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 0 additions & 4 deletions LayoutTests/TestExpectations
Expand Up @@ -2825,7 +2825,6 @@ webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/shaping/shaping
webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/shaping/shaping-025.html [ ImageOnlyFailure ]
webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/shaping/shaping_lig-000.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/tab-size/tab-size-spacing-001.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/tab-size/tab-min-rendered-width-1.html [ ImageOnlyFailure ]
webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-001.html [ ImageOnlyFailure ]
webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-002.html [ ImageOnlyFailure ]
webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-003.html [ ImageOnlyFailure ]
Expand Down Expand Up @@ -2865,9 +2864,6 @@ webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/text-transform/
webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/text-transform/math/text-transform-math-auto-002.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/text-space-collapse-discard-001.xht [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/text-space-trim-trim-inner-001.xht [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-004.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-002.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-006.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/control-chars-000.html [ ImageOnlyFailure ]
webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/text-space-collapse-preserve-breaks-001.xht [ ImageOnlyFailure ]
webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-012.html [ ImageOnlyFailure ]
Expand Down
5 changes: 3 additions & 2 deletions Source/WebCore/platform/graphics/FontCascade.h
Expand Up @@ -353,8 +353,9 @@ inline float FontCascade::tabWidth(const Font& font, const TabSize& tabSize, flo
if (!baseTabWidth)
result = letterSpacing();
else {
float tabDeltaWidth = baseTabWidth - fmodf(position, baseTabWidth);
result = (tabDeltaWidth < font.spaceWidth() / 2) ? baseTabWidth : tabDeltaWidth;
result = baseTabWidth - fmodf(position, baseTabWidth);
if (result < font.spaceWidth() / 2)
result += baseTabWidth;
}
// If our caller passes in SyntheticBoldInclusion::Exclude, that means they're going to apply synthetic bold themselves later.
// However, regardless of that, the space characters that are fed into the width calculation need to have their correct width, including the synthetic bold.
Expand Down

0 comments on commit d88306b

Please sign in to comment.