Diff
Modified: trunk/LayoutTests/ChangeLog (253031 => 253032)
--- trunk/LayoutTests/ChangeLog 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/LayoutTests/ChangeLog 2019-12-03 10:51:46 UTC (rev 253032)
@@ -1,3 +1,13 @@
+2019-12-03 Antti Koivisto <an...@apple.com>
+
+ [LFC][Integration] Setup root box properties
+ https://bugs.webkit.org/show_bug.cgi?id=204743
+
+ Reviewed by Zalan Bujtas.
+
+ * fast/layoutformattingcontext/flow-integration-basic.html: Added.
+ * platform/mac/fast/layoutformattingcontext/flow-integration-basic-expected.txt: Added.
+
2019-12-03 Zan Dobersek <zdober...@igalia.com>
Implement createImageBitmap(OffscreenCanvas)
Added: trunk/LayoutTests/fast/layoutformattingcontext/flow-integration-basic.html (0 => 253032)
--- trunk/LayoutTests/fast/layoutformattingcontext/flow-integration-basic.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/flow-integration-basic.html 2019-12-03 10:51:46 UTC (rev 253032)
@@ -0,0 +1,11 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextRenderTreeIntegrationEnabled=true ] -->
+<html>
+<style>
+.margin { margin: 10px 400px 20px 5px; }
+.border { border-left: 10px solid black; border-top: 5px solid black; border-right: 15px solid black; border-bottom: 20px solid black; }
+.padding { padding: 10px 50px 20px 5px; }
+</style>
+<div class="margin">Text text text text text text text text text text text text text text text text text </div>
+<div class="margin border">Text text text text text text text text text text text text text text text text text </div>
+<div class="margin border padding">Text text text text text text text text text text text text text text text text text </div>
+</html>
Added: trunk/LayoutTests/platform/ios-simulator/fast/layoutformattingcontext/flow-integration-basic-expected.txt (0 => 253032)
--- trunk/LayoutTests/platform/ios-simulator/fast/layoutformattingcontext/flow-integration-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/layoutformattingcontext/flow-integration-basic-expected.txt 2019-12-03 10:51:46 UTC (rev 253032)
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x270
+ RenderBlock {HTML} at (0,0) size 800x270
+ RenderBody {BODY} at (8,10) size 784x240
+ RenderBlock {DIV} at (5,0) size 379x40
+ RenderText {#text} at (0,0) size 365x39
+ text run at (0,0) width 365: "Text text text text text text text text text text text text text"
+ text run at (0,20) width 108: "text text text text"
+ RenderBlock {DIV} at (5,60) size 379x65 [border: (5px solid #000000) (15px solid #000000) (20px solid #000000) (10px solid #000000)]
+ RenderText {#text} at (10,5) size 337x39
+ text run at (10,5) width 337: "Text text text text text text text text text text text text"
+ text run at (10,25) width 136: "text text text text text"
+ RenderBlock {DIV} at (5,145) size 379x95 [border: (5px solid #000000) (15px solid #000000) (20px solid #000000) (10px solid #000000)]
+ RenderText {#text} at (15,15) size 281x39
+ text run at (15,15) width 281: "Text text text text text text text text text text"
+ text run at (15,35) width 192: "text text text text text text text"
Added: trunk/LayoutTests/platform/mac/fast/layoutformattingcontext/flow-integration-basic-expected.txt (0 => 253032)
--- trunk/LayoutTests/platform/mac/fast/layoutformattingcontext/flow-integration-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/layoutformattingcontext/flow-integration-basic-expected.txt 2019-12-03 10:51:46 UTC (rev 253032)
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x258
+ RenderBlock {HTML} at (0,0) size 800x258
+ RenderBody {BODY} at (8,10) size 784x228
+ RenderBlock {DIV} at (5,0) size 379x36
+ RenderText {#text} at (0,0) size 365x36
+ text run at (0,0) width 365: "Text text text text text text text text text text text text text"
+ text run at (0,18) width 108: "text text text text"
+ RenderBlock {DIV} at (5,56) size 379x61 [border: (5px solid #000000) (15px solid #000000) (20px solid #000000) (10px solid #000000)]
+ RenderText {#text} at (10,5) size 337x36
+ text run at (10,5) width 337: "Text text text text text text text text text text text text"
+ text run at (10,23) width 136: "text text text text text"
+ RenderBlock {DIV} at (5,137) size 379x91 [border: (5px solid #000000) (15px solid #000000) (20px solid #000000) (10px solid #000000)]
+ RenderText {#text} at (15,15) size 281x36
+ text run at (15,15) width 281: "Text text text text text text text text text text"
+ text run at (15,33) width 192: "text text text text text text text"
Modified: trunk/Source/WebCore/CMakeLists.txt (253031 => 253032)
--- trunk/Source/WebCore/CMakeLists.txt 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/CMakeLists.txt 2019-12-03 10:51:46 UTC (rev 253032)
@@ -105,6 +105,7 @@
"${WEBCORE_DIR}/layout/floats"
"${WEBCORE_DIR}/layout/inlineformatting"
"${WEBCORE_DIR}/layout/inlineformatting/text"
+ "${WEBCORE_DIR}/layout/integration"
"${WEBCORE_DIR}/layout/layouttree"
"${WEBCORE_DIR}/loader"
"${WEBCORE_DIR}/loader/appcache"
Modified: trunk/Source/WebCore/ChangeLog (253031 => 253032)
--- trunk/Source/WebCore/ChangeLog 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/ChangeLog 2019-12-03 10:51:46 UTC (rev 253032)
@@ -1,3 +1,58 @@
+2019-12-03 Antti Koivisto <an...@apple.com>
+
+ [LFC][Integration] Setup root box properties
+ https://bugs.webkit.org/show_bug.cgi?id=204743
+
+ Reviewed by Zalan Bujtas.
+
+ Test: fast/layoutformattingcontext/flow-integration-basic.html
+
+ Line layout needs to know about flow borders and padding so that boxes are offset correctly.
+
+ * CMakeLists.txt:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/LayoutContext.cpp:
+ (WebCore::Layout::LayoutContext::layout):
+ (WebCore::Layout::LayoutContext::layoutWithPreparedRootGeometry):
+
+ Split setup and layout into separate functions.
+
+ * layout/LayoutContext.h:
+ * layout/LayoutState.cpp:
+ (WebCore::Layout::LayoutState::displayBoxForLayoutRoot):
+ * layout/LayoutState.h:
+ * layout/displaytree/DisplayPainter.cpp:
+ (WebCore::Display::paintInlineContent):
+ (WebCore::Display::Painter::paint):
+ (WebCore::Display::Painter::paintInlineFlow):
+
+ Avoid accessing tree root box properties when painting (since margins are not set up).
+
+ * layout/integration/RenderBlockFlowLineLayout.cpp: Renamed from Source/WebCore/layout/RenderBlockFlowLineLayout.cpp.
+
+ Moved to integration subdirectory.
+
+ (WebCore::Layout::RenderBlockFlowLineLayout::layout):
+
+ Drop the content size paramater, the caller is responsible of setting up the root display box.
+
+ (WebCore::Layout::RenderBlockFlowLineLayout::prepareRootDisplayBoxForLayout):
+
+ Setup padding and borders.
+
+ (WebCore::Layout::RenderBlockFlowLineLayout::displayInlineContent const):
+ (WebCore::Layout::RenderBlockFlowLineLayout::rootLayoutBox const):
+ * layout/integration/RenderBlockFlowLineLayout.h: Renamed from Source/WebCore/layout/RenderBlockFlowLineLayout.h.
+ (WebCore::Layout::RenderBlockFlowLineLayout::contentLogicalHeight const):
+
+ Use a member to pass content height.
+
+ * layout/layouttree/LayoutTreeBuilder.h:
+ (WebCore::Layout::LayoutTreeContent::layoutBoxForRenderer const):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutLFCLines):
+
2019-12-03 Zan Dobersek <zdober...@igalia.com>
Implement createImageBitmap(OffscreenCanvas)
Modified: trunk/Source/WebCore/Sources.txt (253031 => 253032)
--- trunk/Source/WebCore/Sources.txt 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/Sources.txt 2019-12-03 10:51:46 UTC (rev 253032)
@@ -1422,7 +1422,6 @@
layout/LayoutPhase.cpp
layout/LayoutState.cpp
layout/LayoutUnits.cpp
-layout/RenderBlockFlowLineLayout.cpp
layout/Verification.cpp
layout/blockformatting/BlockFormattingContext.cpp
layout/blockformatting/BlockFormattingContextGeometry.cpp
@@ -1445,6 +1444,7 @@
layout/inlineformatting/InlineTextItem.cpp
layout/inlineformatting/LineLayoutContext.cpp
layout/inlineformatting/text/TextUtil.cpp
+layout/integration/RenderBlockFlowLineLayout.cpp
layout/invalidation/InvalidationContext.cpp
layout/invalidation/InvalidationState.cpp
layout/layouttree/LayoutBox.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (253031 => 253032)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-03 10:51:46 UTC (rev 253032)
@@ -16629,6 +16629,7 @@
1199FA58208E3C4C002358CC /* displaytree */,
6FCFC055212DACC2007695D2 /* floats */,
115CFA9A208BC140001E6991 /* inlineformatting */,
+ E4FB4B1E2395356F003C336A /* integration */,
6F95DE4A237B883000E517E1 /* invalidation */,
115CFA90208B9441001E6991 /* layouttree */,
6FC5CA9122E3593300B13E11 /* tableformatting */,
@@ -16647,8 +16648,6 @@
115CA83023328B1E00FD3B08 /* LayoutUnits.cpp */,
6F73918C2106CEDD006AF262 /* LayoutUnits.h */,
6FE7AA2621C37B6300296DCD /* MarginTypes.h */,
- E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */,
- E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */,
11FF02D520BA3C810083F25B /* Verification.cpp */,
);
path = layout;
@@ -16691,6 +16690,7 @@
115CFA9A208BC140001E6991 /* inlineformatting */ = {
isa = PBXGroup;
children = (
+ E435505223953457004829C0 /* integration */,
6FE7DDDD20EC6E8B008B5B4E /* text */,
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
@@ -27021,6 +27021,13 @@
path = domjit;
sourceTree = "<group>";
};
+ E435505223953457004829C0 /* integration */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ path = integration;
+ sourceTree = "<group>";
+ };
E46E97860DAAD61B0071E894 /* animation */ = {
isa = PBXGroup;
children = (
@@ -27144,6 +27151,15 @@
path = updating;
sourceTree = "<group>";
};
+ E4FB4B1E2395356F003C336A /* integration */ = {
+ isa = PBXGroup;
+ children = (
+ E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */,
+ E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */,
+ );
+ path = integration;
+ sourceTree = "<group>";
+ };
ED501DC90B249F3900AE18D9 /* mac */ = {
isa = PBXGroup;
children = (
Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (253031 => 253032)
--- trunk/Source/WebCore/layout/LayoutContext.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -58,12 +58,11 @@
void LayoutContext::layout(const LayoutSize& rootContentBoxSize, InvalidationState& invalidationState)
{
- PhaseScope scope(Phase::Type::Layout);
// Set the geometry on the root.
// Note that we never layout the root box. It has to have an already computed geometry (in case of ICB, it's the view geometry).
// ICB establishes the initial BFC, but it does not live in a formatting context and while a non-ICB root(subtree layout) has to have a formatting context,
// we could not lay it out even if we wanted to since it's outside of this LayoutContext.
- auto& displayBox = layoutState().displayBoxForLayoutBox(layoutState().root());
+ auto& displayBox = layoutState().displayBoxForRootLayoutBox();
displayBox.setHorizontalMargin({ });
displayBox.setHorizontalComputedMargin({ });
displayBox.setVerticalMargin({ });
@@ -73,6 +72,13 @@
displayBox.setContentBoxHeight(rootContentBoxSize.height());
displayBox.setContentBoxWidth(rootContentBoxSize.width());
+ layoutWithPreparedRootGeometry(invalidationState);
+}
+
+void LayoutContext::layoutWithPreparedRootGeometry(InvalidationState& invalidationState)
+{
+ PhaseScope scope(Phase::Type::Layout);
+
auto& formattingContextRootsForLayout = invalidationState.formattingContextRoots();
// When invalidation is empty, we assume constraint mutation and start running layout on the context root. Layout logic should be able to figure out the damage.
if (formattingContextRootsForLayout.computesEmpty())
@@ -82,6 +88,7 @@
layoutFormattingContextSubtree(formattingContextRoot, invalidationState);
}
+
void LayoutContext::layoutFormattingContextSubtree(const Container& formattingContextRoot, InvalidationState& invalidationState)
{
RELEASE_ASSERT(formattingContextRoot.establishesFormattingContext());
Modified: trunk/Source/WebCore/layout/LayoutContext.h (253031 => 253032)
--- trunk/Source/WebCore/layout/LayoutContext.h 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/LayoutContext.h 2019-12-03 10:51:46 UTC (rev 253032)
@@ -52,7 +52,9 @@
WTF_MAKE_ISO_ALLOCATED(LayoutContext);
public:
LayoutContext(LayoutState&);
+
void layout(const LayoutSize& rootContentBoxSize, InvalidationState&);
+ void layoutWithPreparedRootGeometry(InvalidationState&);
static std::unique_ptr<FormattingContext> createFormattingContext(const Container& formattingContextRoot, LayoutState&);
Modified: trunk/Source/WebCore/layout/LayoutState.cpp (253031 => 253032)
--- trunk/Source/WebCore/layout/LayoutState.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/LayoutState.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -57,6 +57,11 @@
LayoutState::~LayoutState() = default;
+Display::Box& LayoutState::displayBoxForRootLayoutBox()
+{
+ return displayBoxForLayoutBox(m_layoutTreeContent->rootLayoutBox());
+}
+
Display::Box& LayoutState::displayBoxForLayoutBox(const Box& layoutBox)
{
return *m_layoutToDisplayBox.ensure(&layoutBox, [] {
Modified: trunk/Source/WebCore/layout/LayoutState.h (253031 => 253032)
--- trunk/Source/WebCore/layout/LayoutState.h 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/LayoutState.h 2019-12-03 10:51:46 UTC (rev 253032)
@@ -62,6 +62,7 @@
void deregisterFormattingContext(const FormattingContext& formattingContext) { m_formattingContextList.remove(&formattingContext); }
#endif
+ Display::Box& displayBoxForRootLayoutBox();
Display::Box& displayBoxForLayoutBox(const Box& layoutBox);
const Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const;
bool hasDisplayBox(const Box& layoutBox) const { return m_layoutToDisplayBox.contains(&layoutBox); }
Deleted: trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp (253031 => 253032)
--- trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -1,155 +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().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();
- auto layoutContext = LayoutContext { *m_layoutState };
- auto invalidationState = InvalidationState { };
- layoutContext.layout(m_flow.contentSize(), invalidationState);
-
- auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootContainer)).displayInlineContent()->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;
-}
-
-const Display::InlineContent* RenderBlockFlowLineLayout::displayInlineContent() const
-{
- return downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(m_treeContent->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 { };
-}
-
-}
-}
-
-#endif
Deleted: trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h (253031 => 253032)
--- trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h 2019-12-03 10:51:46 UTC (rev 253032)
@@ -1,75 +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 contentBoxHeight() const;
- 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 RenderBlockFlow& m_flow;
- std::unique_ptr<LayoutTreeContent> m_treeContent;
- std::unique_ptr<LayoutState> m_layoutState;
-};
-
-}
-}
-
-#endif
Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (253031 => 253032)
--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -110,7 +110,7 @@
}
}
-static void paintInlineContent(GraphicsContext& context, const Box& rootAbsoluteDisplayBox, const Layout::InlineFormattingState& formattingState)
+static void paintInlineContent(GraphicsContext& context, LayoutPoint absoluteOffset, const Layout::InlineFormattingState& formattingState)
{
auto* displayInlineContent = formattingState.displayInlineContent();
if (!displayInlineContent)
@@ -126,16 +126,16 @@
context.setStrokeColor(style.color());
context.setFillColor(style.color());
- auto logicalLeft = rootAbsoluteDisplayBox.left() + run.logicalLeft();
+ auto logicalLeft = absoluteOffset.x() + run.logicalLeft();
// FIXME: Add non-baseline align painting
auto& lineBox = displayInlineContent->lineBoxForRun(run);
- auto baselineOffset = rootAbsoluteDisplayBox.top() + lineBox.logicalTop() + lineBox.baselineOffset();
+ auto baselineOffset = absoluteOffset.y() + lineBox.logicalTop() + lineBox.baselineOffset();
if (auto expansionContext = textContext->expansion())
context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft, expansionContext->horizontalExpansion, expansionContext->behavior }, { logicalLeft, baselineOffset });
else
context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft }, { logicalLeft, baselineOffset });
} else if (auto* cachedImage = run.image()) {
- auto runAbsoluteRect = FloatRect { rootAbsoluteDisplayBox.left() + run.logicalLeft(), rootAbsoluteDisplayBox.top() + run.logicalTop(), run.logicalWidth(), run.logicalHeight() };
+ auto runAbsoluteRect = FloatRect { absoluteOffset.x() + run.logicalLeft(), absoluteOffset.y() + run.logicalTop(), run.logicalWidth(), run.logicalHeight() };
context.drawImage(*cachedImage->image(), runAbsoluteRect);
}
}
@@ -194,7 +194,7 @@
continue;
if (layoutBox.establishesInlineFormattingContext()) {
auto& container = downcast<Layout::Container>(layoutBox);
- paintInlineContent(context, absoluteDisplayBox, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(container)));
+ paintInlineContent(context, absoluteDisplayBox.topLeft(), downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(container)));
continue;
}
}
@@ -206,9 +206,7 @@
ASSERT(layoutRoot.establishesInlineFormattingContext());
- auto& displayBox = layoutState.displayBoxForLayoutBox(layoutRoot);
-
- paintInlineContent(context, displayBox, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(layoutRoot)));
+ paintInlineContent(context, { }, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(layoutRoot)));
}
}
Copied: trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp (from rev 253031, trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp) (0 => 253032)
--- trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp (rev 0)
+++ trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -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 "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().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);
+
+ 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
Copied: trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h (from rev 253031, trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h) (0 => 253032)
--- trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h (rev 0)
+++ trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h 2019-12-03 10:51:46 UTC (rev 253032)
@@ -0,0 +1,80 @@
+/*
+ * 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/layout/layouttree/LayoutTreeBuilder.cpp (253031 => 253032)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -454,6 +454,7 @@
auto& layoutRoot = layoutState.root();
auto invalidationState = InvalidationState { };
+
LayoutContext(layoutState).layout(renderView.size(), invalidationState);
showLayoutTree(layoutRoot, &layoutState);
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (253031 => 253032)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-12-03 10:51:46 UTC (rev 253032)
@@ -57,8 +57,9 @@
void addBox(std::unique_ptr<Box> box) { m_boxes.add(WTFMove(box)); }
- using RenderObjectToLayoutBoxMap = HashMap<const RenderObject*, Box*>;
Box* layoutBoxForRenderer(const RenderObject& renderer) { return m_renderObjectToLayoutBox.get(&renderer); }
+ const Box* layoutBoxForRenderer(const RenderObject& renderer) const { return m_renderObjectToLayoutBox.get(&renderer); }
+
void addLayoutBoxForRenderer(const RenderObject& renderer, Box& layoutBox) { m_renderObjectToLayoutBox.add(&renderer, &layoutBox); }
private:
@@ -65,7 +66,8 @@
const RenderBox& m_rootRenderer;
std::unique_ptr<Container> m_rootLayoutBox;
HashSet<std::unique_ptr<Box>> m_boxes;
- RenderObjectToLayoutBoxMap m_renderObjectToLayoutBox;
+
+ HashMap<const RenderObject*, Box*> m_renderObjectToLayoutBox;
};
class TreeBuilder {
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253031 => 253032)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-03 10:30:55 UTC (rev 253031)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-03 10:51:46 UTC (rev 253032)
@@ -3680,11 +3680,15 @@
lfcLineLayout.layout();
- LayoutUnit lineLayoutHeight = lfcLineLayout.contentBoxHeight();
- LayoutUnit lineLayoutTop = borderAndPaddingBefore();
- repaintLogicalTop = lineLayoutTop;
- repaintLogicalBottom = repaintLogicalTop + lineLayoutHeight + borderAndPaddingAfter();
- setLogicalHeight(lineLayoutTop + lineLayoutHeight + borderAndPaddingAfter());
+ auto contentHeight = lfcLineLayout.contentLogicalHeight();
+ auto contentTop = borderAndPaddingBefore();
+ auto contentBottom = contentTop + contentHeight;
+ auto totalHeight = contentBottom + borderAndPaddingAfter();
+
+ repaintLogicalTop = contentTop;
+ repaintLogicalBottom = contentBottom;
+
+ setLogicalHeight(totalHeight);
}
#endif