Diff
Modified: trunk/Source/WebCore/ChangeLog (252892 => 252893)
--- trunk/Source/WebCore/ChangeLog 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/ChangeLog 2019-11-26 20:15:39 UTC (rev 252893)
@@ -1,5 +1,50 @@
2019-11-26 Antti Koivisto <[email protected]>
+ [LFC][Render tree] Add LFC line layout path to RenderBlockFlow
+ https://bugs.webkit.org/show_bug.cgi?id=204613
+
+ Reviewed by Zalan Bujtas.
+
+ Add a basic LFC line layout implementation for RenderBlockFlow.
+ It can layout lines and do simple painting but doesn't do anything else (like hit testing) yet.
+
+ Add a new layoutFormattingContextRenderTreeIntegrationEnabled feature flag, default to false.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/RenderBlockFlowLineLayout.cpp: Added.
+ (WebCore::Layout::RenderBlockFlowLineLayout::RenderBlockFlowLineLayout):
+ (WebCore::Layout::RenderBlockFlowLineLayout::canUseFor):
+ (WebCore::Layout::RenderBlockFlowLineLayout::layout):
+ (WebCore::Layout::RenderBlockFlowLineLayout::height const):
+ (WebCore::Layout::RenderBlockFlowLineLayout::paint):
+ * layout/RenderBlockFlowLineLayout.h: Copied from Source/WebCore/layout/displaytree/DisplayPainter.h.
+ * layout/displaytree/DisplayPainter.cpp:
+ (WebCore::Display::Painter::paintInlineFlow):
+ * layout/displaytree/DisplayPainter.h:
+ * layout/invalidation/InvalidationState.cpp:
+ (WebCore::Layout::InvalidationState::markNeedsUpdate):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::TreeBuilder::buildLayoutTree):
+ * layout/layouttree/LayoutTreeBuilder.h:
+ * page/RuntimeEnabledFeatures.h:
+ (WebCore::RuntimeEnabledFeatures::setLayoutFormattingContextRenderTreeIntegrationEnabled):
+ (WebCore::RuntimeEnabledFeatures::layoutFormattingContextRenderTreeIntegrationEnabled const):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutInlineChildren):
+ (WebCore::RenderBlockFlow::addOverflowFromInlineChildren):
+ (WebCore::RenderBlockFlow::paintInlineChildren):
+ (WebCore::RenderBlockFlow::invalidateLineLayoutPath):
+ (WebCore::RenderBlockFlow::layoutSimpleLines):
+ (WebCore::RenderBlockFlow::layoutLFCLines):
+ (WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
+ * rendering/RenderBlockFlow.h:
+ (WebCore::RenderBlockFlow::hasLFCLineLayout const):
+ (WebCore::RenderBlockFlow::lfcLineLayout const):
+ (WebCore::RenderBlockFlow::lfcLineLayout):
+
+2019-11-26 Antti Koivisto <[email protected]>
+
Destroy linebox tree from ComplexLineLayout destructor
https://bugs.webkit.org/show_bug.cgi?id=204620
Modified: trunk/Source/WebCore/Sources.txt (252892 => 252893)
--- trunk/Source/WebCore/Sources.txt 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/Sources.txt 2019-11-26 20:15:39 UTC (rev 252893)
@@ -1421,6 +1421,7 @@
layout/LayoutPhase.cpp
layout/LayoutState.cpp
layout/LayoutUnits.cpp
+layout/RenderBlockFlowLineLayout.cpp
layout/Verification.cpp
layout/blockformatting/BlockFormattingContext.cpp
layout/blockformatting/BlockFormattingContextGeometry.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (252892 => 252893)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-11-26 20:15:39 UTC (rev 252893)
@@ -4851,6 +4851,7 @@
E4A814DA1C70E10D00BF85AC /* AttributeChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814D91C70E10D00BF85AC /* AttributeChangeInvalidation.h */; };
E4A814E01C7338EB00BF85AC /* IdChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814DF1C7338EB00BF85AC /* IdChangeInvalidation.h */; };
E4A8D21622578DB700A8463C /* EventRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A8D21422578DA000A8463C /* EventRegion.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E4ABABDD236088FE00FA4345 /* RenderBlockFlowLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */; };
E4ABABE42361A32900FA4345 /* PropertyCascade.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABE22361A32900FA4345 /* PropertyCascade.h */; };
E4ABABF32368B95900FA4345 /* StyleBuilderState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABF22368B95800FA4345 /* StyleBuilderState.h */; };
E4ABABF52368C6EF00FA4345 /* CascadeLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABF42368C6EF00FA4345 /* CascadeLevel.h */; };
@@ -15213,6 +15214,8 @@
E4A814DF1C7338EB00BF85AC /* IdChangeInvalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdChangeInvalidation.h; sourceTree = "<group>"; };
E4A8D21422578DA000A8463C /* EventRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventRegion.h; sourceTree = "<group>"; };
E4A8D21522578DA000A8463C /* EventRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventRegion.cpp; sourceTree = "<group>"; };
+ E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderBlockFlowLineLayout.h; sourceTree = "<group>"; };
+ E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBlockFlowLineLayout.cpp; sourceTree = "<group>"; };
E4ABABE22361A32900FA4345 /* PropertyCascade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyCascade.h; sourceTree = "<group>"; };
E4ABABE52361A34200FA4345 /* PropertyCascade.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyCascade.cpp; sourceTree = "<group>"; };
E4ABABF02368B91800FA4345 /* StyleBuilderState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilderState.cpp; sourceTree = "<group>"; };
@@ -16635,6 +16638,8 @@
115CA83023328B1E00FD3B08 /* LayoutUnits.cpp */,
6F73918C2106CEDD006AF262 /* LayoutUnits.h */,
6FE7AA2621C37B6300296DCD /* MarginTypes.h */,
+ E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */,
+ E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */,
11FF02D520BA3C810083F25B /* Verification.cpp */,
);
path = layout;
@@ -32457,6 +32462,7 @@
088C2F7A12390081003D65CE /* SVGTextLayoutAttributes.h in Headers */,
081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */,
081668DA125603D5006F25DE /* SVGTextLayoutEngine.h in Headers */,
+ E4ABABDD236088FE00FA4345 /* RenderBlockFlowLineLayout.h in Headers */,
080E49261255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h in Headers */,
080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */,
08F0BFC61255C53C00075185 /* SVGTextMetrics.h in Headers */,
Added: trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp (0 => 252893)
--- trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp (rev 0)
+++ trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp 2019-11-26 20:15:39 UTC (rev 252893)
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RenderBlockFlowLineLayout.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayBox.h"
+#include "DisplayPainter.h"
+#include "InlineFormattingState.h"
+#include "InvalidationState.h"
+#include "LayoutContext.h"
+#include "LayoutTreeBuilder.h"
+#include "PaintInfo.h"
+#include "RenderBlockFlow.h"
+#include "RuntimeEnabledFeatures.h"
+#include "SimpleLineLayout.h"
+
+namespace WebCore {
+namespace Layout {
+
+RenderBlockFlowLineLayout::RenderBlockFlowLineLayout(const RenderBlockFlow& flow)
+ : m_flow(flow)
+{
+ m_treeContent = TreeBuilder::buildLayoutTree(flow);
+}
+
+RenderBlockFlowLineLayout::~RenderBlockFlowLineLayout() = default;
+
+bool RenderBlockFlowLineLayout::canUseFor(const RenderBlockFlow& flow)
+{
+ if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextRenderTreeIntegrationEnabled())
+ return false;
+
+ // Initially only a subset of SLL features is supported.
+ if (!SimpleLineLayout::canUseFor(flow))
+ return false;
+
+ if (flow.style().textTransform() == TextTransform::Capitalize)
+ return false;
+
+ if (flow.fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow)
+ return false;
+
+ return true;
+}
+
+void RenderBlockFlowLineLayout::layout()
+{
+ if (!m_layoutState)
+ m_layoutState = makeUnique<LayoutState>(*m_treeContent);
+
+ auto& rootContainer = m_layoutState->root();
+
+ if (!rootContainer.firstChild())
+ return;
+
+ InvalidationState invalidationState;
+ // FIXME: Find some better way to do this.
+ invalidationState.markNeedsUpdate(*rootContainer.firstChild());
+
+ LayoutContext layoutContext(*m_layoutState);
+ layoutContext.layout(m_flow.contentSize(), invalidationState);
+
+ auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootContainer)).lineBoxes();
+ auto height = lineBoxes.last()->logicalBottom();
+
+ auto& displayBox = m_layoutState->displayBoxForLayoutBox(rootContainer);
+ displayBox.setContentBoxHeight(height);
+}
+
+LayoutUnit RenderBlockFlowLineLayout::contentBoxHeight() const
+{
+ return m_layoutState ? m_layoutState->displayBoxForLayoutBox(m_layoutState->root()).contentBoxHeight() : 0_lu;
+}
+
+void RenderBlockFlowLineLayout::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ auto& graphicsContext = paintInfo.context();
+
+ graphicsContext.save();
+ graphicsContext.translate(paintOffset);
+
+ Display::Painter::paintInlineFlow(*m_layoutState, paintInfo.context());
+
+ graphicsContext.restore();
+}
+
+}
+}
+
+#endif
Copied: trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h (from rev 252892, trunk/Source/WebCore/layout/displaytree/DisplayPainter.h) (0 => 252893)
--- trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h (rev 0)
+++ trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "LayoutPoint.h"
+
+namespace WebCore {
+
+class GraphicsContext;
+class RenderBlockFlow;
+struct PaintInfo;
+
+namespace Layout {
+
+class LayoutTreeContent;
+class LayoutState;
+
+class RenderBlockFlowLineLayout {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ RenderBlockFlowLineLayout(const RenderBlockFlow&);
+ ~RenderBlockFlowLineLayout();
+
+ static bool canUseFor(const RenderBlockFlow&);
+
+ void layout();
+
+ LayoutUnit contentBoxHeight() const;
+
+ void paint(PaintInfo&, const LayoutPoint& paintOffset);
+
+private:
+ const RenderBlockFlow& m_flow;
+ std::unique_ptr<LayoutTreeContent> m_treeContent;
+ std::unique_ptr<LayoutState> m_layoutState;
+};
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (252892 => 252893)
--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2019-11-26 20:15:39 UTC (rev 252893)
@@ -196,7 +196,18 @@
}
}
+void Painter::paintInlineFlow(const Layout::LayoutState& layoutState, GraphicsContext& context)
+{
+ auto& layoutRoot = layoutState.root();
+
+ ASSERT(layoutRoot.establishesInlineFormattingContext());
+
+ auto& displayBox = layoutState.displayBoxForLayoutBox(layoutRoot);
+
+ paintInlineContent(context, displayBox, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(layoutRoot)));
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.h (252892 => 252893)
--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.h 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -41,6 +41,7 @@
class Painter {
public:
static void paint(const Layout::LayoutState&, GraphicsContext&, const IntRect& dirtyRect);
+ static void paintInlineFlow(const Layout::LayoutState&, GraphicsContext&);
};
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (252892 => 252893)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-11-26 20:15:39 UTC (rev 252893)
@@ -140,6 +140,16 @@
return layoutTreeContent;
}
+std::unique_ptr<Layout::LayoutTreeContent> TreeBuilder::buildLayoutTree(const RenderBlockFlow& renderBlockFlow)
+{
+ PhaseScope scope(Phase::Type::TreeBuilding);
+
+ auto style = RenderStyle::clone(renderBlockFlow.style());
+ auto layoutTreeContent = makeUnique<LayoutTreeContent>(renderBlockFlow, makeUnique<Container>(WTF::nullopt, WTFMove(style)));
+ TreeBuilder(*layoutTreeContent).buildTree();
+ return layoutTreeContent;
+}
+
TreeBuilder::TreeBuilder(LayoutTreeContent& layoutTreeContent)
: m_layoutTreeContent(layoutTreeContent)
{
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (252892 => 252893)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -33,6 +33,7 @@
namespace WebCore {
+class RenderBlockFlow;
class RenderElement;
class RenderObject;
class RenderTable;
@@ -70,6 +71,7 @@
class TreeBuilder {
public:
static std::unique_ptr<Layout::LayoutTreeContent> buildLayoutTree(const RenderView&);
+ static std::unique_ptr<Layout::LayoutTreeContent> buildLayoutTree(const RenderBlockFlow&);
private:
TreeBuilder(LayoutTreeContent&);
Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (252892 => 252893)
--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -27,6 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "FormattingContext.h"
#include "IntPointHash.h"
#include <wtf/HashMap.h>
#include <wtf/IsoMalloc.h>
Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (252892 => 252893)
--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -188,6 +188,9 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
void setLayoutFormattingContextEnabled(bool isEnabled) { m_layoutFormattingContextEnabled = isEnabled; }
bool layoutFormattingContextEnabled() const { return m_layoutFormattingContextEnabled; }
+
+ void setLayoutFormattingContextRenderTreeIntegrationEnabled(bool isEnabled) { m_layoutFormattingContextRenderTreeIntegrationEnabled = isEnabled; }
+ bool layoutFormattingContextRenderTreeIntegrationEnabled() const { return m_layoutFormattingContextRenderTreeIntegrationEnabled; }
#endif
#if ENABLE(CSS_PAINTING_API)
@@ -443,6 +446,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
bool m_layoutFormattingContextEnabled { false };
+ bool m_layoutFormattingContextRenderTreeIntegrationEnabled { false };
#endif
#if ENABLE(CSS_PAINTING_API)
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (252892 => 252893)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-11-26 20:15:39 UTC (rev 252893)
@@ -37,6 +37,7 @@
#include "InlineTextBox.h"
#include "LayoutRepainter.h"
#include "Logging.h"
+#include "RenderBlockFlowLineLayout.h"
#include "RenderCombineText.h"
#include "RenderFlexibleBox.h"
#include "RenderInline.h"
@@ -667,8 +668,18 @@
void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
{
+ auto computeLineLayoutPath = [&] {
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (Layout::RenderBlockFlowLineLayout::canUseFor(*this))
+ return LFCPath;
+#endif
+ if (SimpleLineLayout::canUseFor(*this))
+ return SimpleLinesPath;
+ return LineBoxesPath;
+ };
+
if (lineLayoutPath() == UndeterminedPath)
- setLineLayoutPath(SimpleLineLayout::canUseFor(*this) ? SimpleLinesPath : LineBoxesPath);
+ setLineLayoutPath(computeLineLayoutPath());
if (lineLayoutPath() == SimpleLinesPath) {
layoutSimpleLines(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
@@ -675,6 +686,13 @@
return;
}
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (lineLayoutPath() == LFCPath) {
+ layoutLFCLines(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
+ return;
+ }
+#endif
+
if (!complexLineLayout())
m_lineLayout = makeUnique<ComplexLineLayout>(*this);
@@ -3530,6 +3548,13 @@
{
ASSERT(childrenInline());
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (lfcLineLayout()) {
+ lfcLineLayout()->paint(paintInfo, paintOffset);
+ return;
+ }
+#endif
+
if (auto simpleLineLayout = this->simpleLineLayout()) {
SimpleLineLayout::paintFlow(*this, *simpleLineLayout, paintInfo, paintOffset);
return;
@@ -3602,6 +3627,7 @@
ASSERT(!simpleLineLayout());
return;
case LineBoxesPath:
+ case LFCPath:
ASSERT(!simpleLineLayout());
setLineLayoutPath(UndeterminedPath);
return;
@@ -3641,6 +3667,27 @@
setLogicalHeight(lineLayoutTop + lineLayoutHeight + borderAndPaddingAfter());
}
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+void RenderBlockFlow::layoutLFCLines(bool, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
+{
+ if (!lfcLineLayout())
+ m_lineLayout = makeUnique<Layout::RenderBlockFlowLineLayout>(*this);
+
+ auto& lfcLineLayout = *this->lfcLineLayout();
+
+ for (auto& renderer : childrenOfType<RenderObject>(*this))
+ renderer.clearNeedsLayout();
+
+ lfcLineLayout.layout();
+
+ LayoutUnit lineLayoutHeight = lfcLineLayout.contentBoxHeight();
+ LayoutUnit lineLayoutTop = borderAndPaddingBefore();
+ repaintLogicalTop = lineLayoutTop;
+ repaintLogicalBottom = repaintLogicalTop + lineLayoutHeight + borderAndPaddingAfter();
+ setLogicalHeight(lineLayoutTop + lineLayoutHeight + borderAndPaddingAfter());
+}
+#endif
+
void RenderBlockFlow::ensureLineBoxes()
{
if (!childrenInline())
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (252892 => 252893)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h 2019-11-26 20:15:39 UTC (rev 252893)
@@ -37,6 +37,12 @@
class RenderMultiColumnFlow;
class RenderRubyRun;
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+namespace Layout {
+class RenderBlockFlowLineLayout;
+}
+#endif
+
#if ENABLE(TEXT_AUTOSIZING)
enum LineCount {
NOT_SET = 0, NO_LINE = 1, _ONE_LINE_ = 2, MULTI_LINE = 3
@@ -338,7 +344,7 @@
bool hasLines() const;
void invalidateLineLayoutPath() final;
- enum LineLayoutPath { UndeterminedPath = 0, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
+ enum LineLayoutPath { UndeterminedPath = 0, SimpleLinesPath, LineBoxesPath, LFCPath, ForceLineBoxesPath };
LineLayoutPath lineLayoutPath() const { return static_cast<LineLayoutPath>(renderBlockFlowLineLayoutPath()); }
void setLineLayoutPath(LineLayoutPath path) { setRenderBlockFlowLineLayoutPath(path); }
@@ -357,6 +363,10 @@
SimpleLineLayout::Layout* simpleLineLayout();
const ComplexLineLayout* complexLineLayout() const;
ComplexLineLayout* complexLineLayout();
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ const Layout::RenderBlockFlowLineLayout* lfcLineLayout() const;
+ Layout::RenderBlockFlowLineLayout* lfcLineLayout();
+#endif
void ensureLineBoxes();
void generateLineBoxTree();
@@ -535,6 +545,11 @@
void layoutSimpleLines(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ bool hasLFCLineLayout() const;
+ void layoutLFCLines(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
+#endif
+
void adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
void computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
void adjustInitialLetterPosition(RenderBox& childBox, LayoutUnit& logicalTopOffset, LayoutUnit& marginBeforeOffset);
@@ -572,7 +587,14 @@
std::unique_ptr<RenderBlockFlowRareData> m_rareBlockFlowData;
private:
- Variant<std::nullptr_t, std::unique_ptr<ComplexLineLayout>, Ref<SimpleLineLayout::Layout>> m_lineLayout;
+ Variant<
+ std::nullptr_t,
+ Ref<SimpleLineLayout::Layout>,
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ std::unique_ptr<Layout::RenderBlockFlowLineLayout>,
+#endif
+ std::unique_ptr<ComplexLineLayout>
+ > m_lineLayout;
friend class LineBreaker;
friend class LineWidth; // Needs to know FloatingObject
@@ -609,6 +631,23 @@
return hasSimpleLineLayout() ? WTF::get<Ref<SimpleLineLayout::Layout>>(m_lineLayout).ptr() : nullptr;
}
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+inline bool RenderBlockFlow::hasLFCLineLayout() const
+{
+ return WTF::holds_alternative<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout);
+}
+
+inline const Layout::RenderBlockFlowLineLayout* RenderBlockFlow::lfcLineLayout() const
+{
+ return hasLFCLineLayout() ? WTF::get<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout).get() : nullptr;
+}
+
+inline Layout::RenderBlockFlowLineLayout* RenderBlockFlow::lfcLineLayout()
+{
+ return hasLFCLineLayout() ? WTF::get<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout).get() : nullptr;
+}
+#endif
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBlockFlow, isRenderBlockFlow())
Modified: trunk/Source/WebKit/ChangeLog (252892 => 252893)
--- trunk/Source/WebKit/ChangeLog 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebKit/ChangeLog 2019-11-26 20:15:39 UTC (rev 252893)
@@ -1,3 +1,14 @@
+2019-11-26 Antti Koivisto <[email protected]>
+
+ [LFC][Render tree] Add LFC line layout path to RenderBlockFlow
+ https://bugs.webkit.org/show_bug.cgi?id=204613
+
+ Reviewed by Zalan Bujtas.
+
+ * Shared/WebPreferences.yaml:
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
+
2019-11-26 Carlos Garcia Campos <[email protected]>
Unreviewed. Update OptionsGTK.cmake and NEWS for 2.27.3 release
Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (252892 => 252893)
--- trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-11-26 20:15:39 UTC (rev 252893)
@@ -1642,12 +1642,21 @@
LayoutFormattingContextEnabled:
type: bool
defaultValue: false
- humanReadableName: "Next-gen layout"
- humanReadableDescription: "Enable next-gen layout"
+ humanReadableName: "Next-generation layout"
+ humanReadableDescription: "Enable next-generation layout"
category: internal
webcoreBinding: RuntimeEnabledFeatures
condition: ENABLE(LAYOUT_FORMATTING_CONTEXT)
+LayoutFormattingContextRenderTreeIntegrationEnabled:
+ type: bool
+ defaultValue: false
+ humanReadableName: "Next-generation inline layout in render tree"
+ humanReadableDescription: "Enable next-generation inline layout in render tree"
+ category: internal
+ webcoreBinding: RuntimeEnabledFeatures
+ condition: ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
CaptureAudioInUIProcessEnabled:
type: bool
defaultValue: DEFAULT_CAPTURE_AUDIO_IN_UIPROCESS
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp (252892 => 252893)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp 2019-11-26 19:44:20 UTC (rev 252892)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp 2019-11-26 20:15:39 UTC (rev 252893)
@@ -261,6 +261,8 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
if (preference == "LayoutFormattingContextEnabled")
RuntimeEnabledFeatures::sharedFeatures().setLayoutFormattingContextEnabled(enabled);
+ if (preference == "LayoutFormattingContextRenderTreeIntegrationEnabled")
+ RuntimeEnabledFeatures::sharedFeatures().setLayoutFormattingContextRenderTreeIntegrationEnabled(enabled);
#endif
#if ENABLE(CSS_PAINTING_API)