Diff
Modified: trunk/Source/WebCore/ChangeLog (253041 => 253042)
--- trunk/Source/WebCore/ChangeLog 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/ChangeLog 2019-12-03 15:41:43 UTC (rev 253042)
@@ -1,5 +1,43 @@
2019-12-03 Antti Koivisto <an...@apple.com>
+ [LFC][Integration] Rename RenderBlockFlowLineLayout and move it to LayoutIntegration namespace
+ https://bugs.webkit.org/show_bug.cgi?id=204791
+
+ Reviewed by Sam Weinig.
+
+ Layout::RenderBlockFlowLineLayout -> LayoutIntegration::LineLayout
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/integration/LayoutIntegrationLineLayout.cpp: Renamed from Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp.
+ (WebCore::LayoutIntegration::LineLayout::LineLayout):
+ (WebCore::LayoutIntegration::LineLayout::canUseFor):
+ (WebCore::LayoutIntegration::LineLayout::layout):
+ (WebCore::LayoutIntegration::LineLayout::prepareRootGeometryForLayout):
+ (WebCore::LayoutIntegration::LineLayout::displayInlineContent const):
+ (WebCore::LayoutIntegration::LineLayout::paint):
+ (WebCore::LayoutIntegration::LineLayout::textBoxesFor const):
+ (WebCore::LayoutIntegration::LineLayout::elementBoxFor const):
+ (WebCore::LayoutIntegration::LineLayout::rootLayoutBox const):
+ * layout/integration/RenderBlockFlowLineLayout.h: Removed.
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutInlineChildren):
+ (WebCore::RenderBlockFlow::paintInlineChildren):
+ (WebCore::RenderBlockFlow::invalidateLineLayoutPath):
+ (WebCore::RenderBlockFlow::layoutLFCLines):
+ * rendering/RenderBlockFlow.h:
+ (WebCore::RenderBlockFlow::hasLayoutFormattingContextLineLayout const):
+ (WebCore::RenderBlockFlow::layoutFormattingContextLineLayout const):
+ (WebCore::RenderBlockFlow::layoutFormattingContextLineLayout):
+ (WebCore::RenderBlockFlow::hasLFCLineLayout const): Deleted.
+ (WebCore::RenderBlockFlow::lfcLineLayout const): Deleted.
+ (WebCore::RenderBlockFlow::lfcLineLayout): Deleted.
+ * rendering/line/LineLayoutTraversal.cpp:
+ (WebCore::LineLayoutTraversal::firstTextBoxFor):
+ (WebCore::LineLayoutTraversal::elementBoxFor):
+
+2019-12-03 Antti Koivisto <an...@apple.com>
+
[LFC][Integration] Shorten feature flag name
https://bugs.webkit.org/show_bug.cgi?id=204788
Modified: trunk/Source/WebCore/Sources.txt (253041 => 253042)
--- trunk/Source/WebCore/Sources.txt 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/Sources.txt 2019-12-03 15:41:43 UTC (rev 253042)
@@ -1444,7 +1444,7 @@
layout/inlineformatting/InlineTextItem.cpp
layout/inlineformatting/LineLayoutContext.cpp
layout/inlineformatting/text/TextUtil.cpp
-layout/integration/RenderBlockFlowLineLayout.cpp
+layout/integration/LayoutIntegrationLineLayout.cpp
layout/invalidation/InvalidationContext.cpp
layout/invalidation/InvalidationState.cpp
layout/layouttree/LayoutBox.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (253041 => 253042)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-03 15:41:43 UTC (rev 253042)
@@ -4856,7 +4856,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 */; };
+ E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
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 */; };
@@ -15223,8 +15223,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>"; };
+ E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationLineLayout.h; sourceTree = "<group>"; };
+ E4ABABDE2360893D00FA4345 /* LayoutIntegrationLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutIntegrationLineLayout.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>"; };
@@ -16690,7 +16690,6 @@
115CFA9A208BC140001E6991 /* inlineformatting */ = {
isa = PBXGroup;
children = (
- E435505223953457004829C0 /* integration */,
6FE7DDDD20EC6E8B008B5B4E /* text */,
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
@@ -27021,13 +27020,6 @@
path = domjit;
sourceTree = "<group>";
};
- E435505223953457004829C0 /* integration */ = {
- isa = PBXGroup;
- children = (
- );
- path = integration;
- sourceTree = "<group>";
- };
E46E97860DAAD61B0071E894 /* animation */ = {
isa = PBXGroup;
children = (
@@ -27154,8 +27146,8 @@
E4FB4B1E2395356F003C336A /* integration */ = {
isa = PBXGroup;
children = (
- E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */,
- E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */,
+ E4ABABDE2360893D00FA4345 /* LayoutIntegrationLineLayout.cpp */,
+ E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */,
);
path = integration;
sourceTree = "<group>";
@@ -31782,7 +31774,7 @@
7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */,
BCEA4860097D93020094C9E4 /* RenderBlock.h in Headers */,
BC10D76817D8EE71005E2626 /* RenderBlockFlow.h in Headers */,
- E4ABABDD236088FE00FA4345 /* RenderBlockFlowLineLayout.h in Headers */,
+ E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */,
BCEA4862097D93020094C9E4 /* RenderBox.h in Headers */,
BCEB179C143379F50052EAE9 /* RenderBoxFragmentInfo.h in Headers */,
BC96DB430F3A880E00573CB3 /* RenderBoxModelObject.h in Headers */,
Copied: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (from rev 253041, trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp) (0 => 253042)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2019-12-03 15:41:43 UTC (rev 253042)
@@ -0,0 +1,164 @@
+/*
+ * 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 "LayoutIntegrationLineLayout.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 "RenderLineBreak.h"
+#include "RuntimeEnabledFeatures.h"
+#include "SimpleLineLayout.h"
+
+namespace WebCore {
+namespace LayoutIntegration {
+
+LineLayout::LineLayout(const RenderBlockFlow& flow)
+ : m_flow(flow)
+{
+ m_treeContent = Layout::TreeBuilder::buildLayoutTree(flow);
+}
+
+LineLayout::~LineLayout() = default;
+
+bool LineLayout::canUseFor(const RenderBlockFlow& flow)
+{
+ if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled())
+ 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 LineLayout::layout()
+{
+ if (!m_layoutState)
+ m_layoutState = makeUnique<Layout::LayoutState>(*m_treeContent);
+
+ prepareRootGeometryForLayout();
+
+ auto layoutContext = Layout::LayoutContext { *m_layoutState };
+ auto invalidationState = Layout::InvalidationState { };
+
+ layoutContext.layoutWithPreparedRootGeometry(invalidationState);
+
+ auto& lineBoxes = downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent()->lineBoxes;
+ m_contentLogicalHeight = lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop();
+}
+
+void LineLayout::prepareRootGeometryForLayout()
+{
+ auto& displayBox = m_layoutState->displayBoxForRootLayoutBox();
+
+ // 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());
+}
+
+const Display::InlineContent* LineLayout::displayInlineContent() const
+{
+ return downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();
+}
+
+void LineLayout::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ auto& graphicsContext = paintInfo.context();
+
+ graphicsContext.save();
+ graphicsContext.translate(paintOffset);
+
+ Display::Painter::paintInlineFlow(*m_layoutState, paintInfo.context());
+
+ graphicsContext.restore();
+}
+
+LineLayoutTraversal::TextBoxIterator LineLayout::textBoxesFor(const RenderText& renderText) const
+{
+ auto* inlineContent = displayInlineContent();
+ if (!inlineContent)
+ return { };
+ auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderText);
+ ASSERT(layoutBox);
+
+ Optional<size_t> firstIndex = 0;
+ size_t lastIndex = 0;
+ for (size_t i = 0; i < inlineContent->runs.size(); ++i) {
+ auto& run = inlineContent->runs[i];
+ if (&run.layoutBox() == layoutBox) {
+ if (!firstIndex)
+ firstIndex = i;
+ lastIndex = i;
+ }
+ }
+ if (!firstIndex)
+ return { };
+
+ return { LineLayoutTraversal::DisplayRunPath(*inlineContent, *firstIndex, lastIndex + 1) };
+}
+
+LineLayoutTraversal::ElementBoxIterator LineLayout::elementBoxFor(const RenderLineBreak& renderLineBreak) const
+{
+ auto* inlineContent = displayInlineContent();
+ if (!inlineContent)
+ return { };
+ auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderLineBreak);
+ ASSERT(layoutBox);
+
+ for (size_t i = 0; i < inlineContent->runs.size(); ++i) {
+ auto& run = inlineContent->runs[i];
+ if (&run.layoutBox() == layoutBox)
+ return { LineLayoutTraversal::DisplayRunPath(*inlineContent, i, i + 1) };
+ }
+
+ return { };
+}
+
+const Layout::Container& LineLayout::rootLayoutBox() const
+{
+ return m_treeContent->rootLayoutBox();
+}
+
+}
+}
+
+#endif
Copied: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (from rev 253041, trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h) (0 => 253042)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2019-12-03 15:41:43 UTC (rev 253042)
@@ -0,0 +1,82 @@
+/*
+ * 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"
+#include "LineLayoutTraversal.h"
+
+namespace WebCore {
+
+class GraphicsContext;
+class RenderBlockFlow;
+class RenderLineBreak;
+struct PaintInfo;
+
+namespace Display {
+struct InlineContent;
+}
+
+namespace Layout {
+class LayoutTreeContent;
+class LayoutState;
+}
+
+namespace LayoutIntegration {
+
+class LineLayout {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ LineLayout(const RenderBlockFlow&);
+ ~LineLayout();
+
+ static bool canUseFor(const RenderBlockFlow&);
+
+ void layout();
+
+ LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; }
+ const Display::InlineContent* displayInlineContent() const;
+
+ void paint(PaintInfo&, const LayoutPoint& paintOffset);
+
+ LineLayoutTraversal::TextBoxIterator textBoxesFor(const RenderText&) const;
+ LineLayoutTraversal::ElementBoxIterator elementBoxFor(const RenderLineBreak&) const;
+
+private:
+ const Layout::Container& rootLayoutBox() const;
+ void prepareRootGeometryForLayout();
+
+ const RenderBlockFlow& m_flow;
+ std::unique_ptr<const Layout::LayoutTreeContent> m_treeContent;
+ std::unique_ptr<Layout::LayoutState> m_layoutState;
+ LayoutUnit m_contentLogicalHeight;
+};
+
+}
+}
+
+#endif
Deleted: trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp (253041 => 253042)
--- trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp 2019-12-03 15:41:43 UTC (rev 253042)
@@ -1,164 +0,0 @@
-/*
- * 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 "RenderLineBreak.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().layoutFormattingContextIntegrationEnabled())
- 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);
-
- prepareRootGeometryForLayout();
-
- auto layoutContext = LayoutContext { *m_layoutState };
- auto invalidationState = InvalidationState { };
-
- layoutContext.layoutWithPreparedRootGeometry(invalidationState);
-
- auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent()->lineBoxes;
- m_contentLogicalHeight = lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop();
-}
-
-void RenderBlockFlowLineLayout::prepareRootGeometryForLayout()
-{
- auto& displayBox = m_layoutState->displayBoxForRootLayoutBox();
-
- // 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());
-}
-
-const Display::InlineContent* RenderBlockFlowLineLayout::displayInlineContent() const
-{
- return downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();
-}
-
-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();
-}
-
-LineLayoutTraversal::TextBoxIterator RenderBlockFlowLineLayout::textBoxesFor(const RenderText& renderText) const
-{
- auto* inlineContent = displayInlineContent();
- if (!inlineContent)
- return { };
- auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderText);
- ASSERT(layoutBox);
-
- Optional<size_t> firstIndex = 0;
- size_t lastIndex = 0;
- for (size_t i = 0; i < inlineContent->runs.size(); ++i) {
- auto& run = inlineContent->runs[i];
- if (&run.layoutBox() == layoutBox) {
- if (!firstIndex)
- firstIndex = i;
- lastIndex = i;
- }
- }
- if (!firstIndex)
- return { };
-
- return { LineLayoutTraversal::DisplayRunPath(*inlineContent, *firstIndex, lastIndex + 1) };
-}
-
-LineLayoutTraversal::ElementBoxIterator RenderBlockFlowLineLayout::elementBoxFor(const RenderLineBreak& renderLineBreak) const
-{
- auto* inlineContent = displayInlineContent();
- if (!inlineContent)
- return { };
- auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderLineBreak);
- ASSERT(layoutBox);
-
- for (size_t i = 0; i < inlineContent->runs.size(); ++i) {
- auto& run = inlineContent->runs[i];
- if (&run.layoutBox() == layoutBox)
- return { LineLayoutTraversal::DisplayRunPath(*inlineContent, i, i + 1) };
- }
-
- return { };
-}
-
-const Container& RenderBlockFlowLineLayout::rootLayoutBox() const
-{
- return m_treeContent->rootLayoutBox();
-}
-
-}
-}
-
-#endif
Deleted: trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h (253041 => 253042)
--- trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h 2019-12-03 15:41:43 UTC (rev 253042)
@@ -1,80 +0,0 @@
-/*
- * 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"
-#include "LineLayoutTraversal.h"
-
-namespace WebCore {
-
-class GraphicsContext;
-class RenderBlockFlow;
-class RenderLineBreak;
-struct PaintInfo;
-
-namespace Display {
-struct InlineContent;
-}
-
-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 contentLogicalHeight() const { return m_contentLogicalHeight; }
- const Display::InlineContent* displayInlineContent() const;
-
- void paint(PaintInfo&, const LayoutPoint& paintOffset);
-
- LineLayoutTraversal::TextBoxIterator textBoxesFor(const RenderText&) const;
- LineLayoutTraversal::ElementBoxIterator elementBoxFor(const RenderLineBreak&) const;
-
-private:
- const Container& rootLayoutBox() const;
- void prepareRootGeometryForLayout();
-
- const RenderBlockFlow& m_flow;
- std::unique_ptr<const LayoutTreeContent> m_treeContent;
- std::unique_ptr<LayoutState> m_layoutState;
- LayoutUnit m_contentLogicalHeight;
-};
-
-}
-}
-
-#endif
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253041 => 253042)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-03 15:41:43 UTC (rev 253042)
@@ -35,9 +35,9 @@
#include "HTMLTextAreaElement.h"
#include "HitTestLocation.h"
#include "InlineTextBox.h"
+#include "LayoutIntegrationLineLayout.h"
#include "LayoutRepainter.h"
#include "Logging.h"
-#include "RenderBlockFlowLineLayout.h"
#include "RenderCombineText.h"
#include "RenderFlexibleBox.h"
#include "RenderInline.h"
@@ -670,8 +670,8 @@
{
auto computeLineLayoutPath = [&] {
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (Layout::RenderBlockFlowLineLayout::canUseFor(*this))
- return LFCPath;
+ if (LayoutIntegration::LineLayout::canUseFor(*this))
+ return LayoutFormattingContextPath;
#endif
if (SimpleLineLayout::canUseFor(*this))
return SimpleLinesPath;
@@ -687,7 +687,7 @@
}
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (lineLayoutPath() == LFCPath) {
+ if (lineLayoutPath() == LayoutFormattingContextPath) {
layoutLFCLines(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
return;
}
@@ -3549,8 +3549,8 @@
ASSERT(childrenInline());
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (lfcLineLayout()) {
- lfcLineLayout()->paint(paintInfo, paintOffset);
+ if (layoutFormattingContextLineLayout()) {
+ layoutFormattingContextLineLayout()->paint(paintInfo, paintOffset);
return;
}
#endif
@@ -3630,7 +3630,7 @@
ASSERT(!simpleLineLayout());
setLineLayoutPath(UndeterminedPath);
return;
- case LFCPath: // FIXME: Not all clients of invalidateLineLayoutPath() actually need to wipe the layout.
+ case LayoutFormattingContextPath: // FIXME: Not all clients of invalidateLineLayoutPath() actually need to wipe the layout.
case SimpleLinesPath:
// The simple line layout may have become invalid.
m_lineLayout = WTF::Monostate();
@@ -3670,17 +3670,17 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
void RenderBlockFlow::layoutLFCLines(bool, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
{
- if (!lfcLineLayout())
- m_lineLayout = makeUnique<Layout::RenderBlockFlowLineLayout>(*this);
+ if (!layoutFormattingContextLineLayout())
+ m_lineLayout = makeUnique<LayoutIntegration::LineLayout>(*this);
- auto& lfcLineLayout = *this->lfcLineLayout();
+ auto& layoutFormattingContextLineLayout = *this->layoutFormattingContextLineLayout();
for (auto& renderer : childrenOfType<RenderObject>(*this))
renderer.clearNeedsLayout();
- lfcLineLayout.layout();
+ layoutFormattingContextLineLayout.layout();
- auto contentHeight = lfcLineLayout.contentLogicalHeight();
+ auto contentHeight = layoutFormattingContextLineLayout.contentLogicalHeight();
auto contentTop = borderAndPaddingBefore();
auto contentBottom = contentTop + contentHeight;
auto totalHeight = contentBottom + borderAndPaddingAfter();
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (253041 => 253042)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h 2019-12-03 15:41:43 UTC (rev 253042)
@@ -38,8 +38,8 @@
class RenderRubyRun;
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-namespace Layout {
-class RenderBlockFlowLineLayout;
+namespace LayoutIntegration {
+class LineLayout;
}
#endif
@@ -344,7 +344,7 @@
bool hasLines() const;
void invalidateLineLayoutPath() final;
- enum LineLayoutPath { UndeterminedPath = 0, SimpleLinesPath, LineBoxesPath, LFCPath, ForceLineBoxesPath };
+ enum LineLayoutPath { UndeterminedPath = 0, SimpleLinesPath, LineBoxesPath, LayoutFormattingContextPath, ForceLineBoxesPath };
LineLayoutPath lineLayoutPath() const { return static_cast<LineLayoutPath>(renderBlockFlowLineLayoutPath()); }
void setLineLayoutPath(LineLayoutPath path) { setRenderBlockFlowLineLayoutPath(path); }
@@ -364,8 +364,8 @@
const ComplexLineLayout* complexLineLayout() const;
ComplexLineLayout* complexLineLayout();
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- const Layout::RenderBlockFlowLineLayout* lfcLineLayout() const;
- Layout::RenderBlockFlowLineLayout* lfcLineLayout();
+ const LayoutIntegration::LineLayout* layoutFormattingContextLineLayout() const;
+ LayoutIntegration::LineLayout* layoutFormattingContextLineLayout();
#endif
void ensureLineBoxes();
@@ -547,7 +547,7 @@
void layoutSimpleLines(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- bool hasLFCLineLayout() const;
+ bool hasLayoutFormattingContextLineLayout() const;
void layoutLFCLines(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
#endif
@@ -592,7 +592,7 @@
WTF::Monostate,
Ref<SimpleLineLayout::Layout>,
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- std::unique_ptr<Layout::RenderBlockFlowLineLayout>,
+ std::unique_ptr<LayoutIntegration::LineLayout>,
#endif
std::unique_ptr<ComplexLineLayout>
> m_lineLayout;
@@ -638,19 +638,19 @@
}
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-inline bool RenderBlockFlow::hasLFCLineLayout() const
+inline bool RenderBlockFlow::hasLayoutFormattingContextLineLayout() const
{
- return WTF::holds_alternative<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout);
+ return WTF::holds_alternative<std::unique_ptr<LayoutIntegration::LineLayout>>(m_lineLayout);
}
-inline const Layout::RenderBlockFlowLineLayout* RenderBlockFlow::lfcLineLayout() const
+inline const LayoutIntegration::LineLayout* RenderBlockFlow::layoutFormattingContextLineLayout() const
{
- return hasLFCLineLayout() ? WTF::get<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout).get() : nullptr;
+ return hasLayoutFormattingContextLineLayout() ? WTF::get<std::unique_ptr<LayoutIntegration::LineLayout>>(m_lineLayout).get() : nullptr;
}
-inline Layout::RenderBlockFlowLineLayout* RenderBlockFlow::lfcLineLayout()
+inline LayoutIntegration::LineLayout* RenderBlockFlow::layoutFormattingContextLineLayout()
{
- return hasLFCLineLayout() ? WTF::get<std::unique_ptr<Layout::RenderBlockFlowLineLayout>>(m_lineLayout).get() : nullptr;
+ return hasLayoutFormattingContextLineLayout() ? WTF::get<std::unique_ptr<LayoutIntegration::LineLayout>>(m_lineLayout).get() : nullptr;
}
#endif
Modified: trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp (253041 => 253042)
--- trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp 2019-12-03 15:20:46 UTC (rev 253041)
+++ trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp 2019-12-03 15:41:43 UTC (rev 253042)
@@ -26,7 +26,7 @@
#include "config.h"
#include "LineLayoutTraversal.h"
-#include "RenderBlockFlowLineLayout.h"
+#include "LayoutIntegrationLineLayout.h"
#include "RenderLineBreak.h"
namespace WebCore {
@@ -85,8 +85,8 @@
}
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (auto* lfcLineLayout = flow.lfcLineLayout())
- return lfcLineLayout->textBoxesFor(text);
+ if (auto* layoutFormattingContextLineLayout = flow.layoutFormattingContextLineLayout())
+ return layoutFormattingContextLineLayout->textBoxesFor(text);
#endif
return { ComplexPath { text.firstTextBox() } };
@@ -139,8 +139,8 @@
}
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (auto* lfcLineLayout = flow.lfcLineLayout())
- return lfcLineLayout->elementBoxFor(renderElement);
+ if (auto* layoutFormattingContextLineLayout = flow.layoutFormattingContextLineLayout())
+ return layoutFormattingContextLineLayout->elementBoxFor(renderElement);
#endif
return { ComplexPath(renderElement.inlineBoxWrapper()) };