Changeset 295478 in webkit
- Timestamp:
-
Jun 12, 2022 7:45:22 AM
(2 years ago)
- Author:
- Alan Bujtas
- Message:
-
Incorrect sizing of elements with visually hidden text inside
https://bugs.webkit.org/show_bug.cgi?id=241459
Reviewed by Antti Koivisto.
This patch fixes the incorrect inline width computation when an inline box (e.g. <span>) with margin-inline-start (e.g. margin-left) is followed by an out-of-flow element.
<div id=container>some<span style="margin-left: 10px"><div style="position: absolute"></div>text</span></div>
In LineBreaker::nextLineBreak, while iterating through the content of [container], the margin-left of the inline box (span) is included twice; first for the out-of-flow box and second for the [text] content. This patch ensures that when we reach the [text] content, we check if we have already reserved the space for the inline box's margin (padding and border).
(While out-of-flow inline level boxes are not supposed to participate in inline layout, (in legacy line layout) in order to compute their static position we include them in line layout. A more involved fix would be to exclude all out-of-flow boxes from line layout and deal with their static positioning after completing the core line layout).
- LayoutTests/fast/block/shrink-to-fit-with-out-of-flow-and-inline-box-margin-expected.html: Added.
- LayoutTests/fast/block/shrink-to-fit-with-out-of-flow-and-inline-box-margin.html: Added.
- Source/WebCore/rendering/line/BreakingContext.h: Make sure when the out-of-flow box takes the margin, we don't add it again for the text content. Also, reset this flag for subsequent content.
(WebCore::inlineLogicalWidth):
Canonical link: https://commits.webkit.org/251483@main
- Location:
- trunk
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
-
r288067
|
r295478
|
|
353 | 353 | positionedObjects.append(&box); |
354 | 354 | |
355 | | m_width.addUncommittedWidth(inlineLogicalWidth(box)); |
| 355 | if (auto inlineBoxStartWidth = inlineLogicalWidth(box)) { |
| 356 | m_width.addUncommittedWidth(inlineBoxStartWidth); |
| 357 | m_appliedStartWidth = true; |
| 358 | } |
356 | 359 | // Reset prior line break context characters. |
357 | 360 | m_renderTextInfo.lineBreakIterator.resetPriorContext(); |
… |
… |
|
638 | 641 | inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool& hyphenated, unsigned& consecutiveHyphenatedLines) |
639 | 642 | { |
640 | | if (!m_current.offset()) |
641 | | m_appliedStartWidth = false; |
642 | | |
643 | 643 | auto& renderer = downcast<RenderText>(*m_current.renderer()); |
644 | 644 | bool isSVGText = renderer.isSVGInlineText(); |
… |
… |
|
1051 | 1051 | } |
1052 | 1052 | } |
| 1053 | m_appliedStartWidth = false; |
1053 | 1054 | return false; |
1054 | 1055 | } |