Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ee88d3c74d9dcce408ca3839a2961c5038e4686a
https://github.com/WebKit/WebKit/commit/ee88d3c74d9dcce408ca3839a2961c5038e4686a
Author: Alan Baradlay <[email protected]>
Date: 2026-04-24 (Fri, 24 Apr 2026)
Changed paths:
M LayoutTests/TestExpectations
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001.html
M Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
M Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h
M
Source/WebCore/layout/integration/inline/InlineIteratorBoxModernPathInlines.h
M Source/WebCore/platform/graphics/FontCascadeInlines.h
Log Message:
-----------
Fix
imported/w3c/web-platform-tests/css/css-text/text-indent/text-indent-tab-positions-001.html
https://bugs.webkit.org/show_bug.cgi?id=313203
Reviewed by Antti Koivisto.
Tab stops are at fixed positions from the block's content edge (multiples of
tab-size). But when text-indent or floats shift the line's content start,
tab stops were shifting with it:
text-indent: 20px
|<-20px->|
| a------>b (wrong: tab measured from indented start)
a----------->b (right: tab measured from content edge)
| |
content 64px tab stop
edge
Three bugs combined to cause this:
1. During line building, the tab's position was measured relative to the
line's origin, not relative to the block's content edge.
The line is shifted by text-indent and floats, but contentLogicalRight
doesn't account for this.
Fix: introduce m_lineContentEdgeOffset - the total displacement from the
block's content edge (text-indent + float offset) - and add it to the
position passed to text measurement in candidateContentForLine.
2. During painting, the font code re-measures tabs using the TextRun's xPos
to compute glyph positions. Again, the xPos was relative to the line's
content
start, not relative to the block's content edge.
3. With negative text-indent, the position passed to tabWidth() is negative.
fmodf preserves the sign, so the tab stop computation overshoots:
text-indent: -10px, char width: 5px, tab-size: 64px
"a" starts at -10px, tab starts at -10px + 5px = -5px
-10px -5px 0px 64px
[ a ][ tab ] |
tab stop tab stop
The next tab stop after -5px should be 0px.
But fmodf(-5, 64) = -5, so 64 - (-5) = 69 -- the tab lands
at -5 + 69 = 64px, skipping the 0px stop entirely.
Fix: when fmodf returns a negative remainder, add baseTabWidth to
normalize it before subtracting.
* LayoutTests/TestExpectations:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-with-float-001.html:
Added.
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::candidateContentForLine):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h:
* Source/WebCore/layout/integration/inline/InlineIteratorBoxModernPathInlines.h:
(WebCore::InlineIterator::BoxModernPath::textRun const):
* Source/WebCore/platform/graphics/FontCascadeInlines.h:
(WebCore::FontCascade::tabWidth const):
Canonical link: https://commits.webkit.org/311971@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications