Diff
Modified: trunk/Source/WebCore/ChangeLog (254852 => 254853)
--- trunk/Source/WebCore/ChangeLog 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/ChangeLog 2020-01-21 16:07:21 UTC (rev 254853)
@@ -1,3 +1,25 @@
+2020-01-21 Antti Koivisto <[email protected]>
+
+ [LFC][Integration] Use InlineFormattingContext directly
+ https://bugs.webkit.org/show_bug.cgi?id=206526
+
+ Reviewed by Zalan Bujtas.
+
+ Stop using LayoutContext (which is more of a full tree layout thing) and use InlineFormattingContext directly instead.
+ This has a side benefit of not needing to setup a root display box.
+
+ * layout/LayoutContext.cpp:
+ (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/inlineformatting/InlineFormattingContext.h:
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::LineLayout):
+ (WebCore::LayoutIntegration::LineLayout::layout):
+ (WebCore::LayoutIntegration::LineLayout::displayInlineContent const):
+ (WebCore::LayoutIntegration::LineLayout::prepareRootGeometryForLayout): Deleted.
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * layout/tableformatting/TableFormattingContext.h:
+
2020-01-21 Cathie Chen <[email protected]>
Add support for scroll behavior relies on ScrollAnimation of the Web process
Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (254852 => 254853)
--- trunk/Source/WebCore/layout/LayoutContext.cpp 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp 2020-01-21 16:07:21 UTC (rev 254853)
@@ -102,8 +102,7 @@
// FIXME: layoutFormattingContextSubtree() does not perform layout on the root, rather it lays out the root's content.
// It constructs an FC for descendant boxes and runs layout on them. The formattingContextRoot is laid out in the FC in which it lives (parent formatting context).
// It also means that the formattingContextRoot has to have a valid/clean geometry at this point.
- // Currently the integration codepath does not guarantee it and that's fine as long as we layout inflow content only.
- if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
+ {
auto horizontalConstraints = HorizontalConstraints { displayBox.paddingBoxLeft(), displayBox.paddingBoxWidth() };
auto verticalConstraints = VerticalConstraints { displayBox.paddingBoxTop(), displayBox.paddingBoxHeight() };
formattingContext->layoutOutOfFlowContent(invalidationState, horizontalConstraints, verticalConstraints);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (254852 => 254853)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-01-21 16:07:21 UTC (rev 254853)
@@ -43,7 +43,7 @@
// This class implements the layout logic for block formatting contexts.
// https://www.w3.org/TR/CSS22/visuren.html#block-formatting
-class BlockFormattingContext : public FormattingContext {
+class BlockFormattingContext final : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
public:
BlockFormattingContext(const Container& formattingContextRoot, BlockFormattingState&);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (254852 => 254853)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2020-01-21 16:07:21 UTC (rev 254853)
@@ -39,7 +39,7 @@
// This class implements the layout logic for inline formatting contexts.
// https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
-class InlineFormattingContext : public FormattingContext {
+class InlineFormattingContext final : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
public:
InlineFormattingContext(const Container& formattingContextRoot, InlineFormattingState&);
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (254852 => 254853)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-01-21 16:07:21 UTC (rev 254853)
@@ -30,12 +30,13 @@
#include "DisplayBox.h"
#include "EventRegion.h"
+#include "FloatingState.h"
#include "HitTestLocation.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
+#include "InlineFormattingContext.h"
#include "InlineFormattingState.h"
#include "InvalidationState.h"
-#include "LayoutContext.h"
#include "LayoutTreeBuilder.h"
#include "PaintInfo.h"
#include "RenderBlockFlow.h"
@@ -53,7 +54,10 @@
LineLayout::LineLayout(const RenderBlockFlow& flow)
: m_flow(flow)
, m_boxTree(flow)
+ , m_layoutState(m_flow.document(), rootLayoutBox())
+ , m_inlineFormattingState(downcast<Layout::InlineFormattingState>(m_layoutState.createFormattingStateForFormattingRootIfNeeded(rootLayoutBox())))
{
+ m_layoutState.setIsIntegratedRootBoxFirstChild(m_flow.parent()->firstChild() == &m_flow);
}
LineLayout::~LineLayout() = default;
@@ -95,30 +99,21 @@
void LineLayout::layout()
{
- if (!m_layoutState) {
- m_layoutState.emplace(m_flow.document(), m_boxTree.rootLayoutBox());
- m_layoutState->setIsIntegratedRootBoxFirstChild(m_flow.parent()->firstChild() == &m_flow);
- }
+ auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox(), m_inlineFormattingState };
- prepareRootGeometryForLayout();
+ m_layoutState.setViewportSize(m_flow.frame().view()->size());
- auto layoutContext = Layout::LayoutContext { *m_layoutState };
auto invalidationState = Layout::InvalidationState { };
+ auto horizontalConstraints = Layout::HorizontalConstraints { m_flow.borderAndPaddingStart(), m_flow.contentSize().width() };
+ auto verticalConstraints = Layout::VerticalConstraints { m_flow.borderAndPaddingBefore(), { } };
- layoutContext.layoutWithPreparedRootGeometry(invalidationState);
-
- auto& lineBoxes = downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent()->lineBoxes;
- m_contentLogicalHeight = lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop();
+ inlineFormattingContext.layoutInFlowContent(invalidationState, horizontalConstraints, verticalConstraints);
}
-void LineLayout::prepareRootGeometryForLayout()
+LayoutUnit LineLayout::contentLogicalHeight() const
{
- auto& displayBox = m_layoutState->displayBoxForRootLayoutBox();
- m_layoutState->setViewportSize(m_flow.frame().view()->size());
- // Don't set marging properties or height. These should not be be accessed by inline layout.
- displayBox.setBorder(Layout::Edges { { m_flow.borderStart(), m_flow.borderEnd() }, { m_flow.borderBefore(), m_flow.borderAfter() } });
- displayBox.setPadding(Layout::Edges { { m_flow.paddingStart(), m_flow.paddingEnd() }, { m_flow.paddingBefore(), m_flow.paddingAfter() } });
- displayBox.setContentBoxWidth(m_flow.contentSize().width());
+ auto& lineBoxes = displayInlineContent()->lineBoxes;
+ return LayoutUnit { lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop() };
}
size_t LineLayout::lineCount() const
@@ -168,7 +163,7 @@
const Display::InlineContent* LineLayout::displayInlineContent() const
{
- return downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();
+ return m_inlineFormattingState.displayInlineContent();
}
LineLayoutTraversal::TextBoxIterator LineLayout::textBoxesFor(const RenderText& renderText) const
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (254852 => 254853)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-01-21 16:07:21 UTC (rev 254853)
@@ -64,7 +64,7 @@
void updateStyle();
void layout();
- LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; }
+ LayoutUnit contentLogicalHeight() const;
size_t lineCount() const;
LayoutUnit firstLineBaseline() const;
@@ -83,13 +83,12 @@
private:
const Layout::Container& rootLayoutBox() const;
Layout::Container& rootLayoutBox();
- void prepareRootGeometryForLayout();
ShadowData* debugTextShadow();
const RenderBlockFlow& m_flow;
BoxTree m_boxTree;
- Optional<Layout::LayoutState> m_layoutState;
- LayoutUnit m_contentLogicalHeight;
+ Layout::LayoutState m_layoutState;
+ Layout::InlineFormattingState& m_inlineFormattingState;
};
}
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h (254852 => 254853)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h 2020-01-21 15:39:51 UTC (rev 254852)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h 2020-01-21 16:07:21 UTC (rev 254853)
@@ -38,7 +38,7 @@
class TableFormattingState;
// This class implements the layout logic for table formatting contexts.
// https://www.w3.org/TR/CSS22/tables.html
-class TableFormattingContext : public FormattingContext {
+class TableFormattingContext final : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(TableFormattingContext);
public:
TableFormattingContext(const Container& formattingContextRoot, TableFormattingState&);