- Revision
- 272834
- Author
- [email protected]
- Date
- 2021-02-13 11:07:16 -0800 (Sat, 13 Feb 2021)
Log Message
[LFC][Integration] Not every inline box contributes to line overflow
https://bugs.webkit.org/show_bug.cgi?id=221867
Reviewed by Antti Koivisto.
Consider the follow content:
<div style="font-size: 20px;">content<span style="font-size: 200px;"><img></span></div>
In quirks mode, the inline box (<span>) does not stretch the line box vertically. What it means in practice is
that the inline box's descent is ignored. While the inline box has a relatively large descent and
in theory it overflows the line (since it is larger than the root inline box's descent)
it should not be taken into account when computing the scrollable overflow.
However adding "padding: 1px" to the <span> will make the inline box stretch the line and now this "1px padding" will
contribute to the scrollable overflow.
* layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
(WebCore::LayoutIntegration::InlineContentBuilder::build const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayNonRootInlineBoxes const):
* layout/integration/LayoutIntegrationInlineContentBuilder.h:
* layout/integration/LayoutIntegrationLine.h:
(WebCore::LayoutIntegration::NonRootInlineBox::NonRootInlineBox):
(WebCore::LayoutIntegration::NonRootInlineBox::canContributeToLineOverflow const):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::constructContent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272833 => 272834)
--- trunk/Source/WebCore/ChangeLog 2021-02-13 18:18:59 UTC (rev 272833)
+++ trunk/Source/WebCore/ChangeLog 2021-02-13 19:07:16 UTC (rev 272834)
@@ -1,3 +1,31 @@
+2021-02-13 Zalan Bujtas <[email protected]>
+
+ [LFC][Integration] Not every inline box contributes to line overflow
+ https://bugs.webkit.org/show_bug.cgi?id=221867
+
+ Reviewed by Antti Koivisto.
+
+ Consider the follow content:
+ <div style="font-size: 20px;">content<span style="font-size: 200px;"><img></span></div>
+
+ In quirks mode, the inline box (<span>) does not stretch the line box vertically. What it means in practice is
+ that the inline box's descent is ignored. While the inline box has a relatively large descent and
+ in theory it overflows the line (since it is larger than the root inline box's descent)
+ it should not be taken into account when computing the scrollable overflow.
+ However adding "padding: 1px" to the <span> will make the inline box stretch the line and now this "1px padding" will
+ contribute to the scrollable overflow.
+
+ * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+ (WebCore::LayoutIntegration::InlineContentBuilder::build const):
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayNonRootInlineBoxes const):
+ * layout/integration/LayoutIntegrationInlineContentBuilder.h:
+ * layout/integration/LayoutIntegrationLine.h:
+ (WebCore::LayoutIntegration::NonRootInlineBox::NonRootInlineBox):
+ (WebCore::LayoutIntegration::NonRootInlineBox::canContributeToLineOverflow const):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::constructContent):
+
2021-02-12 Jer Noble <[email protected]>
[Mac] Sound does not play on YouTube after switching back to foreground
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (272833 => 272834)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-02-13 18:18:59 UTC (rev 272833)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-02-13 19:07:16 UTC (rev 272834)
@@ -156,11 +156,12 @@
{
}
-void InlineContentBuilder::build(const Layout::InlineFormattingState& inlineFormattingState, InlineContent& inlineContent) const
+void InlineContentBuilder::build(const Layout::InlineFormattingContext& inlineFormattingContext, InlineContent& inlineContent) const
{
+ auto& inlineFormattingState = inlineFormattingContext.formattingState();
auto lineLevelVisualAdjustmentsForRuns = computeLineLevelVisualAdjustmentsForRuns(inlineFormattingState);
createDisplayLineRuns(inlineFormattingState, inlineContent, lineLevelVisualAdjustmentsForRuns);
- createDisplayNonRootInlineBoxes(inlineFormattingState, inlineContent, lineLevelVisualAdjustmentsForRuns);
+ createDisplayNonRootInlineBoxes(inlineFormattingContext, inlineContent);
createDisplayLines(inlineFormattingState, inlineContent, lineLevelVisualAdjustmentsForRuns);
}
@@ -322,8 +323,11 @@
while (runIndex < runs.size() && runs[runIndex].lineIndex() == lineIndex)
lineInkOverflowRect.unite(runs[runIndex++].inkOverflow());
// Collect scrollable overflow from inline boxes. All other inline level boxes (e.g atomic inline level boxes) stretch the line.
- while (inlineBoxIndex < nonRootInlineBoxes.size() && nonRootInlineBoxes[inlineBoxIndex].lineIndex() == lineIndex)
- scrollableOverflowRect.unite(nonRootInlineBoxes[inlineBoxIndex++].rect());
+ while (inlineBoxIndex < nonRootInlineBoxes.size() && nonRootInlineBoxes[inlineBoxIndex].lineIndex() == lineIndex) {
+ auto& inlineBox = nonRootInlineBoxes[inlineBoxIndex++];
+ if (inlineBox.canContributeToLineOverflow())
+ scrollableOverflowRect.unite(inlineBox.rect());
+ }
auto adjustedLineBoxRect = FloatRect { lineBoxLogicalRect };
auto enclosingTopAndBottom = line.enclosingTopAndBottom();
@@ -337,8 +341,10 @@
}
}
-void InlineContentBuilder::createDisplayNonRootInlineBoxes(const Layout::InlineFormattingState& inlineFormattingState, InlineContent& inlineContent, const LineLevelVisualAdjustmentsForRunsList&) const
+void InlineContentBuilder::createDisplayNonRootInlineBoxes(const Layout::InlineFormattingContext& inlineFormattingContext, InlineContent& inlineContent) const
{
+ auto& inlineFormattingState = inlineFormattingContext.formattingState();
+ auto inlineQuirks = inlineFormattingContext.quirks();
for (size_t lineIndex = 0; lineIndex < inlineFormattingState.lineBoxes().size(); ++lineIndex) {
auto& lineBox = inlineFormattingState.lineBoxes()[lineIndex];
auto& lineBoxLogicalRect = lineBox.logicalRect();
@@ -351,7 +357,7 @@
auto inlineBoxRect = lineBox.logicalRectForInlineBox(layoutBox, boxGeometry);
inlineBoxRect.moveBy(lineBoxLogicalRect.topLeft());
- inlineContent.nonRootInlineBoxes.append({ lineIndex, layoutBox, inlineBoxRect });
+ inlineContent.nonRootInlineBoxes.append({ lineIndex, layoutBox, inlineBoxRect, inlineQuirks.inlineLevelBoxAffectsLineBox(*inlineLevelBox, lineBox) });
}
}
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h (272833 => 272834)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h 2021-02-13 18:18:59 UTC (rev 272833)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h 2021-02-13 19:07:16 UTC (rev 272834)
@@ -34,7 +34,7 @@
class RenderBlockFlow;
namespace Layout {
-class InlineFormattingState;
+class InlineFormattingContext;
class LayoutState;
}
@@ -47,7 +47,7 @@
public:
InlineContentBuilder(const Layout::LayoutState&, const RenderBlockFlow&);
- void build(const Layout::InlineFormattingState&, InlineContent&) const;
+ void build(const Layout::InlineFormattingContext&, InlineContent&) const;
private:
using LineLevelVisualAdjustmentsForRunsList = Vector<LineLevelVisualAdjustmentsForRuns>;
@@ -55,7 +55,7 @@
LineLevelVisualAdjustmentsForRunsList computeLineLevelVisualAdjustmentsForRuns(const Layout::InlineFormattingState&) const;
void createDisplayLineRuns(const Layout::InlineFormattingState&, InlineContent&, const LineLevelVisualAdjustmentsForRunsList&) const;
void createDisplayLines(const Layout::InlineFormattingState&, InlineContent&, const LineLevelVisualAdjustmentsForRunsList&) const;
- void createDisplayNonRootInlineBoxes(const Layout::InlineFormattingState&, InlineContent&, const LineLevelVisualAdjustmentsForRunsList&) const;
+ void createDisplayNonRootInlineBoxes(const Layout::InlineFormattingContext&, InlineContent&) const;
const Layout::LayoutState& m_layoutState;
const RenderBlockFlow& m_blockFlow;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h (272833 => 272834)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h 2021-02-13 18:18:59 UTC (rev 272833)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h 2021-02-13 19:07:16 UTC (rev 272834)
@@ -88,10 +88,11 @@
class NonRootInlineBox {
public:
- NonRootInlineBox(size_t lineIndex, const Layout::Box& layoutBox, const FloatRect& rect)
+ NonRootInlineBox(size_t lineIndex, const Layout::Box& layoutBox, const FloatRect& rect, bool canContributeToLineOverflow)
: m_lineIndex(lineIndex)
, m_layoutBox(makeWeakPtr(layoutBox))
, m_rect(rect)
+ , m_canContributeToLineOverflow(canContributeToLineOverflow)
{
}
@@ -102,10 +103,13 @@
FloatRect rect() const { return m_rect; }
+ bool canContributeToLineOverflow() const { return m_canContributeToLineOverflow; }
+
private:
const size_t m_lineIndex;
WeakPtr<const Layout::Box> m_layoutBox;
FloatRect m_rect;
+ bool m_canContributeToLineOverflow { false };
};
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (272833 => 272834)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-02-13 18:18:59 UTC (rev 272833)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-02-13 19:07:16 UTC (rev 272834)
@@ -214,8 +214,10 @@
void LineLayout::constructContent()
{
+ auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox(), m_inlineFormattingState };
+
auto inlineContentBuilder = InlineContentBuilder { m_layoutState, flow() };
- inlineContentBuilder.build(m_inlineFormattingState, ensureInlineContent());
+ inlineContentBuilder.build(inlineFormattingContext, ensureInlineContent());
ASSERT(m_inlineContent);
for (auto& run : m_inlineContent->runs) {