Title: [272468] trunk/Source/WebCore
- Revision
- 272468
- Author
- [email protected]
- Date
- 2021-02-06 21:08:14 -0800 (Sat, 06 Feb 2021)
Log Message
[LFC][IFC] Incorrect line box height when line-height is set on an empty root inline box
https://bugs.webkit.org/show_bug.cgi?id=221522
Reviewed by Antti Koivisto.
The root inline box with non-initial line height value stretches the line box even when root has no content.
e.g. <div style="line-height: 100px;"><span>content</span></div>
This content produces a ~100px tall line box.
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272467 => 272468)
--- trunk/Source/WebCore/ChangeLog 2021-02-07 03:28:55 UTC (rev 272467)
+++ trunk/Source/WebCore/ChangeLog 2021-02-07 05:08:14 UTC (rev 272468)
@@ -1,3 +1,18 @@
+2021-02-06 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Incorrect line box height when line-height is set on an empty root inline box
+ https://bugs.webkit.org/show_bug.cgi?id=221522
+
+ Reviewed by Antti Koivisto.
+
+ The root inline box with non-initial line height value stretches the line box even when root has no content.
+
+ e.g. <div style="line-height: 100px;"><span>content</span></div>
+ This content produces a ~100px tall line box.
+
+ * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+ (WebCore::Layout::InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox const):
+
2021-02-06 Wenson Hsieh <[email protected]>
Introduce image overlays and add UA shadow root support for image extraction
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (272467 => 272468)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2021-02-07 03:28:55 UTC (rev 272467)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2021-02-07 05:08:14 UTC (rev 272468)
@@ -333,7 +333,7 @@
// FIXME: Add support for simple inline boxes too.
// We can do simplified vertical alignment with non-atomic inline boxes as long as the line has no content.
// e.g. <div><span></span><span></span></div> is still okay.
- m_inlineLevelBoxesNeedVerticalAlignment = lineHasContent;
+ m_inlineLevelBoxesNeedVerticalAlignment = m_inlineLevelBoxesNeedVerticalAlignment || lineHasContent;
if (run.isInlineBoxStart()) {
auto initialLogicalWidth = lineBox.logicalWidth() - run.logicalLeft();
ASSERT(initialLogicalWidth >= 0);
@@ -369,6 +369,11 @@
}
lineBox.setHasContent(lineHasContent);
+ if (lineHasContent && !m_inlineLevelBoxesNeedVerticalAlignment) {
+ // FIXME: Add fast path support for line-height content.
+ m_inlineLevelBoxesNeedVerticalAlignment = !rootBox().style().lineHeight().isNegative();
+ }
+
if (!m_inlineLevelBoxesNeedVerticalAlignment) {
if (!lineHasContent) {
simplifiedVerticalAlignment.rootInlineBoxTop = -rootInlineBox.baseline();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (272467 => 272468)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2021-02-07 03:28:55 UTC (rev 272467)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2021-02-07 05:08:14 UTC (rev 272468)
@@ -69,17 +69,35 @@
}
if (inlineLevelBox.isInlineBox()) {
// Inline boxes (e.g. root inline box or <span>) affects line boxes either through the strut or actual content.
- if (inlineLevelBox.hasContent())
+ auto inlineBoxHasImaginaryStrut = layoutState().inStandardsMode();
+ if (inlineLevelBox.hasContent() || inlineBoxHasImaginaryStrut)
return true;
- if (!inlineLevelBox.isRootInlineBox()) {
- auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
- if (boxGeometry.horizontalBorder() || boxGeometry.horizontalPadding().valueOr(0_lu)) {
- // Horizontal border and padding make the inline box stretch the line (e.g. <span style="padding: 10px;"></span>).
- return true;
- }
+ if (inlineLevelBox.isRootInlineBox()) {
+ auto shouldRootInlineBoxWithNoContentStretchLineBox = [&] {
+ if (inlineLevelBox.layoutBox().style().lineHeight().isNegative())
+ return false;
+ // The root inline box with non-initial line height value stretches the line box even when root has no content
+ // but there's at least one inline box with content.
+ // e.g. <div style="line-height: 100px;"><span>content</span></div>
+ if (!lineBox.hasInlineBox())
+ return false;
+ for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
+ if (!inlineLevelBox->isInlineBox())
+ continue;
+ if (inlineLevelBox->hasContent())
+ return true;
+ }
+ return false;
+ };
+ return shouldRootInlineBoxWithNoContentStretchLineBox();
}
- auto inlineBoxHasImaginaryStrut = layoutState().inStandardsMode();
- return inlineBoxHasImaginaryStrut;
+ // Non-root inline boxes (e.g. <span>).
+ auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
+ if (boxGeometry.horizontalBorder() || boxGeometry.horizontalPadding().valueOr(0_lu)) {
+ // Horizontal border and padding make the inline box stretch the line (e.g. <span style="padding: 10px;"></span>).
+ return true;
+ }
+ return false;
}
if (inlineLevelBox.isAtomicInlineLevelBox()) {
if (inlineLevelBox.layoutBounds().height())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes