Skip to content
Permalink
Browse files
[LFC][IFC] Do not generate text runs for empty text content
https://bugs.webkit.org/show_bug.cgi?id=244071

Reviewed by Antti Koivisto.

Empty text inline items (initiated by "" generated content) is supposed to be all collapsed.
This fixes certain alignment issues where an empty inline-block box now behaves like one and its baseline is computed accordingly (wpt/css/css-content/attr-case-sensitivity-002.html and /css/css-inline/empty-text-node-001.html).

* LayoutTests/fast/css/empty-generated-content-expected.txt:
* LayoutTests/platform/mac/fast/text/capitalize-empty-generated-string-expected.txt:
* Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::appendTextContent):

Canonical link: https://commits.webkit.org/253569@main
  • Loading branch information
alanbaradlay committed Aug 18, 2022
1 parent 232e9ce commit 85e031dc15b29db800bff87451782df542bca724
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 65 deletions.
@@ -3,12 +3,10 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x34
RenderBlock {HTML} at (0,0) size 800x34
RenderBody {BODY} at (8,8) size 784x18
RenderText {#text} at (0,0) size 221x18
text run at (0,0) width 221: "This page intentionally left blank. "
RenderText {#text} at (0,0) size 217x18
text run at (0,0) width 217: "This page intentionally left blank."
RenderInline (generated) at (0,0) size 0x18
RenderText at (220,0) size 1x18
text run at (220,0) width 1: ""
RenderText at (0,0) size 0x0
RenderBlock (anonymous) at (0,34) size 800x0
RenderInline (generated) at (0,0) size 0x0
RenderText at (0,-14) size 0x18
text run at (0,-14) width 0: ""
RenderText at (0,0) size 0x0
@@ -14,96 +14,84 @@ layer at (0,0) size 800x100
RenderBlock {DIV} at (0,36) size 784x20
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (0,0) size 0x19
text run at (0,0) width 0: ""
RenderCounter at (0,0) size 0x0
RenderText at (0,0) size 8x19
text run at (0,0) width 8: "z"
RenderText {#text} at (7,0) size 5x19
text run at (7,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (11,0) size 1x19
text run at (11,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (11,0) size 8x19
text run at (11,0) width 8: "z"
RenderText {#text} at (18,0) size 5x19
text run at (18,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (22,0) size 1x19
text run at (22,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (22,0) size 8x19
text run at (22,0) width 8: "z"
RenderText {#text} at (29,0) size 5x19
text run at (29,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (33,0) size 1x19
text run at (33,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (33,0) size 8x19
text run at (33,0) width 8: "z"
RenderText {#text} at (40,0) size 5x19
text run at (40,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (44,0) size 1x19
text run at (44,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (44,0) size 8x19
text run at (44,0) width 8: "z"
RenderText {#text} at (51,0) size 5x19
text run at (51,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (55,0) size 1x19
text run at (55,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (55,0) size 8x19
text run at (55,0) width 8: "z"
RenderText {#text} at (62,0) size 5x19
text run at (62,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (66,0) size 1x19
text run at (66,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (66,0) size 8x19
text run at (66,0) width 8: "z"
RenderText {#text} at (73,0) size 5x19
text run at (73,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (77,0) size 1x19
text run at (77,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (77,0) size 8x19
text run at (77,0) width 8: "z"
RenderText {#text} at (84,0) size 5x19
text run at (84,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (88,0) size 1x19
text run at (88,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (88,0) size 8x19
text run at (88,0) width 8: "z"
RenderText {#text} at (95,0) size 5x19
text run at (95,0) width 5: " "
RenderInline {SPAN} at (0,0) size 9x19
RenderInline (generated) at (0,0) size 9x19
RenderCounter at (99,0) size 1x19
text run at (99,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (99,0) size 9x19
text run at (99,0) width 9: "z"
RenderText {#text} at (107,0) size 5x19
text run at (107,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (111,0) size 1x19
text run at (111,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (111,0) size 8x19
text run at (111,0) width 8: "z"
RenderText {#text} at (118,0) size 5x19
text run at (118,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x19
RenderInline (generated) at (0,0) size 8x19
RenderCounter at (122,0) size 1x19
text run at (122,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (122,0) size 8x19
text run at (122,0) width 8: "z"
RenderText {#text} at (0,0) size 0x0
@@ -3,12 +3,10 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x36
RenderBlock {HTML} at (0,0) size 800x36
RenderBody {BODY} at (8,8) size 784x20
RenderText {#text} at (0,0) size 221x19
text run at (0,0) width 221: "This page intentionally left blank. "
RenderText {#text} at (0,0) size 217x19
text run at (0,0) width 217: "This page intentionally left blank."
RenderInline (generated) at (0,0) size 0x19
RenderText at (220,0) size 1x19
text run at (220,0) width 1: ""
RenderText at (0,0) size 0x0
RenderBlock (anonymous) at (0,36) size 800x0
RenderInline (generated) at (0,0) size 0x0
RenderText at (0,-15) size 0x19
text run at (0,-15) width 0: ""
RenderText at (0,0) size 0x0
@@ -14,96 +14,84 @@ layer at (0,0) size 800x94
RenderBlock {DIV} at (0,34) size 784x18
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (0,0) size 0x18
text run at (0,0) width 0: ""
RenderCounter at (0,0) size 0x0
RenderText at (0,0) size 8x18
text run at (0,0) width 8: "z"
RenderText {#text} at (7,0) size 5x18
text run at (7,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (11,0) size 1x18
text run at (11,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (11,0) size 8x18
text run at (11,0) width 8: "z"
RenderText {#text} at (18,0) size 5x18
text run at (18,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (22,0) size 1x18
text run at (22,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (22,0) size 8x18
text run at (22,0) width 8: "z"
RenderText {#text} at (29,0) size 5x18
text run at (29,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (33,0) size 1x18
text run at (33,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (33,0) size 8x18
text run at (33,0) width 8: "z"
RenderText {#text} at (40,0) size 5x18
text run at (40,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (44,0) size 1x18
text run at (44,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (44,0) size 8x18
text run at (44,0) width 8: "z"
RenderText {#text} at (51,0) size 5x18
text run at (51,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (55,0) size 1x18
text run at (55,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (55,0) size 8x18
text run at (55,0) width 8: "z"
RenderText {#text} at (62,0) size 5x18
text run at (62,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (66,0) size 1x18
text run at (66,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (66,0) size 8x18
text run at (66,0) width 8: "z"
RenderText {#text} at (73,0) size 5x18
text run at (73,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (77,0) size 1x18
text run at (77,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (77,0) size 8x18
text run at (77,0) width 8: "z"
RenderText {#text} at (84,0) size 5x18
text run at (84,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (88,0) size 1x18
text run at (88,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (88,0) size 8x18
text run at (88,0) width 8: "z"
RenderText {#text} at (95,0) size 5x18
text run at (95,0) width 5: " "
RenderInline {SPAN} at (0,0) size 9x18
RenderInline (generated) at (0,0) size 9x18
RenderCounter at (99,0) size 1x18
text run at (99,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (99,0) size 9x18
text run at (99,0) width 9: "z"
RenderText {#text} at (107,0) size 5x18
text run at (107,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (111,0) size 1x18
text run at (111,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (111,0) size 8x18
text run at (111,0) width 8: "z"
RenderText {#text} at (118,0) size 5x18
text run at (118,0) width 5: " "
RenderInline {SPAN} at (0,0) size 8x18
RenderInline (generated) at (0,0) size 8x18
RenderCounter at (122,0) size 1x18
text run at (122,0) width 1: ""
RenderCounter at (0,0) size 0x0
RenderText at (122,0) size 8x18
text run at (122,0) width 8: "z"
RenderText {#text} at (0,0) size 0x0
@@ -23,8 +23,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 47: "Lorem "
RenderInline {SPAN} at (0,0) size 41x18
RenderInline (generated) at (0,0) size 0x18
RenderText at (46,0) size 1x18
text run at (46,0) width 1: ""
RenderText at (0,0) size 0x0
RenderText {#text} at (46,0) size 41x18
text run at (46,0) width 41: "Ipsum"
RenderText {#text} at (86,0) size 5x18
@@ -40,8 +39,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 24: "Lor"
RenderInline {SPAN} at (0,0) size 64x18
RenderInline (generated) at (0,0) size 0x18
RenderText at (23,0) size 1x18
text run at (23,0) width 1: ""
RenderText at (0,0) size 0x0
RenderText {#text} at (23,0) size 64x18
text run at (23,0) width 64: "em Ipsum"
RenderText {#text} at (86,0) size 5x18
@@ -293,7 +293,7 @@ void Line::appendInlineBoxEnd(const InlineItem& inlineItem, const RenderStyle& s
void Line::appendTextContent(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
{
auto willCollapseCompletely = [&] {
if (m_runs.isEmpty() && inlineTextItem.isEmpty()) {
if (inlineTextItem.isEmpty()) {
// Some generated content initiates empty text items. They are truly collapsible.
return true;
}

0 comments on commit 85e031d

Please sign in to comment.