Diff
Modified: trunk/Source/WebCore/ChangeLog (258819 => 258820)
--- trunk/Source/WebCore/ChangeLog 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/ChangeLog 2020-03-22 17:41:12 UTC (rev 258820)
@@ -1,5 +1,32 @@
2020-03-22 Zalan Bujtas <[email protected]>
+ [LFC] Introduce InitialContainingBox class
+ https://bugs.webkit.org/show_bug.cgi?id=209399
+ <rdar://problem/60741767>
+
+ Reviewed by Antti Koivisto.
+
+ ICB is the top level containing block. This helps to make sure we don't accidentally call parent() on the ICB.
+ This is also a preparation for "const Box& Layout::Box::parent()".
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::BoxTree):
+ (): Deleted.
+ * layout/integration/LayoutIntegrationBoxTree.h:
+ (WebCore::LayoutIntegration::BoxTree::rootLayoutBox const):
+ (WebCore::LayoutIntegration::BoxTree::rootLayoutBox):
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::isInitialContainingBlock const): Deleted.
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::isInitialContainingBlock const):
+ * layout/layouttree/LayoutContainerBox.h:
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::TreeBuilder::buildLayoutTree):
+
+2020-03-22 Zalan Bujtas <[email protected]>
+
[LFC] Layout::Box::containingBlock should return a const ContainerBox&
https://bugs.webkit.org/show_bug.cgi?id=209381
<rdar://problem/60732278>
Modified: trunk/Source/WebCore/Sources.txt (258819 => 258820)
--- trunk/Source/WebCore/Sources.txt 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/Sources.txt 2020-03-22 17:41:12 UTC (rev 258820)
@@ -1481,6 +1481,7 @@
layout/invalidation/InvalidationState.cpp
layout/layouttree/LayoutBox.cpp
layout/layouttree/LayoutContainerBox.cpp
+layout/layouttree/LayoutInitialContainingBlock.cpp
layout/layouttree/LayoutInlineTextBox.cpp
layout/layouttree/LayoutLineBreakBox.cpp
layout/layouttree/LayoutReplacedBox.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258819 => 258820)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-22 17:41:12 UTC (rev 258820)
@@ -2051,6 +2051,7 @@
6F26EB48234004A5006906E2 /* LineLayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26EB46234004A5006906E2 /* LineLayoutContext.h */; };
6F360E5023999421001512A7 /* InlineSoftLineBreakItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F360E4E23999420001512A7 /* InlineSoftLineBreakItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F3E1F622136142000A65A08 /* FloatBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F3E1F612136141700A65A08 /* FloatBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6F6383F62427AF4A00DABA53 /* LayoutInitialContainingBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F6383F42427AF4900DABA53 /* LayoutInitialContainingBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F77868823491AD8004D9636 /* DisplayPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F77868723491AD7004D9636 /* DisplayPainter.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C4208C2956002F29AB /* LayoutState.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F7CA3CA208C2B2E002F29AB /* InlineFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9395,6 +9396,7 @@
6F3E1F612136141700A65A08 /* FloatBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; };
6F4A5BD522F9F16B00A80F25 /* LayoutPhase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutPhase.cpp; sourceTree = "<group>"; };
6F5B7EAA2300A79E0067D9C3 /* TableGrid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableGrid.cpp; sourceTree = "<group>"; };
+ 6F6383F42427AF4900DABA53 /* LayoutInitialContainingBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutInitialContainingBlock.h; sourceTree = "<group>"; };
6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; };
6F77868523491AC6004D9636 /* DisplayPainter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayPainter.cpp; sourceTree = "<group>"; };
6F77868723491AD7004D9636 /* DisplayPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayPainter.h; sourceTree = "<group>"; };
@@ -9433,6 +9435,7 @@
6F995A2F1A70833700A735F4 /* JSWebGLVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObject.cpp; sourceTree = "<group>"; };
6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
6FAE16BA2406DE7E00A48414 /* PrecomputedBlockMarginCollapse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PrecomputedBlockMarginCollapse.cpp; sourceTree = "<group>"; };
+ 6FB0ED112427B6C6002737E6 /* LayoutInitialContainingBlock.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutInitialContainingBlock.cpp; sourceTree = "<group>"; };
6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
6FB22E30230097E300C20866 /* TableGrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableGrid.h; sourceTree = "<group>"; };
@@ -16958,6 +16961,8 @@
1199FA45208E35A3002358CC /* LayoutContainerBox.cpp */,
1199FA44208E35A3002358CC /* LayoutContainerBox.h */,
11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */,
+ 6FB0ED112427B6C6002737E6 /* LayoutInitialContainingBlock.cpp */,
+ 6F6383F42427AF4900DABA53 /* LayoutInitialContainingBlock.h */,
6F0B98B623F2690600EEC2F2 /* LayoutInlineTextBox.cpp */,
6F0B98B323F268EB00EEC2F2 /* LayoutInlineTextBox.h */,
11100FC72092764C0081AA6C /* LayoutIterator.h */,
@@ -31677,6 +31682,7 @@
1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */,
6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */,
11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */,
+ 6F6383F62427AF4A00DABA53 /* LayoutInitialContainingBlock.h in Headers */,
6F0B98B523F268EC00EEC2F2 /* LayoutInlineTextBox.h in Headers */,
E418025523D4549B00FFB071 /* LayoutIntegrationBoxTree.h in Headers */,
E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */,
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (258819 => 258820)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-03-22 17:41:12 UTC (rev 258820)
@@ -47,7 +47,7 @@
}
BoxTree::BoxTree(const RenderBlockFlow& flow)
- : m_root({ }, rootBoxStyle(flow.style()))
+ : m_root(rootBoxStyle(flow.style()))
{
if (flow.isAnonymous())
m_root.setIsAnonymous();
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h (258819 => 258820)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2020-03-22 17:41:12 UTC (rev 258820)
@@ -27,7 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "LayoutContainerBox.h"
+#include "LayoutInitialContainingBlock.h"
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
@@ -41,8 +41,8 @@
public:
BoxTree(const RenderBlockFlow&);
- const Layout::ContainerBox& rootLayoutBox() const { return m_root; }
- Layout::ContainerBox& rootLayoutBox() { return m_root; }
+ const Layout::InitialContainingBlock& rootLayoutBox() const { return m_root; }
+ Layout::InitialContainingBlock& rootLayoutBox() { return m_root; }
const Layout::Box* layoutBoxForRenderer(const RenderObject&) const;
const RenderObject* rendererForLayoutBox(const Layout::Box&) const;
@@ -50,7 +50,7 @@
private:
void buildTree(const RenderBlockFlow&);
- Layout::ContainerBox m_root;
+ Layout::InitialContainingBlock m_root;
struct BoxAndRenderer {
std::unique_ptr<const Layout::Box> box;
const RenderObject* renderer { nullptr };
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (258819 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-03-22 17:41:12 UTC (rev 258820)
@@ -311,11 +311,6 @@
return display == DisplayType::Block || display == DisplayType::ListItem || isInlineBlockBox() || isTableWrapperBox() || isTableCell() || isTableCaption(); // TODO && !replaced element
}
-bool Box::isInitialContainingBlock() const
-{
- return !parent();
-}
-
const Box* Box::nextInFlowSibling() const
{
auto* nextSibling = this->nextSibling();
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (258819 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-03-22 17:41:12 UTC (rev 258820)
@@ -65,7 +65,8 @@
InlineTextBox = 1 << 1,
LineBreakBox = 1 << 2,
ReplacedBox = 1 << 3,
- ContainerBoxFlag = 1 << 4
+ InitialContainingBlock = 1 << 4,
+ ContainerBoxFlag = 1 << 5
};
typedef unsigned BaseTypeFlags;
@@ -108,7 +109,7 @@
bool isInlineBlockBox() const;
bool isInlineTableBox() const;
bool isBlockContainerBox() const;
- bool isInitialContainingBlock() const;
+ bool isInitialContainingBlock() const { return m_baseTypeFlags & InitialContainingBlock; }
bool isDocumentBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Document; }
bool isBodyBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Body; }
Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainerBox.h (258819 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutContainerBox.h 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainerBox.h 2020-03-22 17:41:12 UTC (rev 258820)
@@ -36,7 +36,7 @@
namespace Layout {
-class ContainerBox final : public Box {
+class ContainerBox : public Box {
WTF_MAKE_ISO_ALLOCATED(ContainerBox);
public:
ContainerBox(Optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags = Box::ContainerBoxFlag);
Copied: trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp (from rev 258819, trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h) (0 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp 2020-03-22 17:41:12 UTC (rev 258820)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 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 "LayoutInitialContainingBlock.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InitialContainingBlock);
+
+InitialContainingBlock::InitialContainingBlock(RenderStyle&& style)
+ : ContainerBox({ }, WTFMove(style), Box::InitialContainingBlock)
+{
+}
+
+}
+}
+
+#endif
Copied: trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.h (from rev 258819, trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h) (0 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.h (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.h 2020-03-22 17:41:12 UTC (rev 258820)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018-2020 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 "LayoutContainerBox.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+namespace Layout {
+
+class InitialContainingBlock final : public ContainerBox {
+ WTF_MAKE_ISO_ALLOCATED(InitialContainingBlock);
+public:
+ InitialContainingBlock(RenderStyle&&);
+ virtual ~InitialContainingBlock() = default;
+
+private:
+ const ContainerBox* parent() const = delete;
+ const Box* nextSibling() const = delete;
+ const Box* nextInFlowSibling() const = delete;
+ const Box* nextInFlowOrFloatingSibling() const = delete;
+ const Box* previousSibling() const = delete;
+ const Box* previousInFlowSibling() const = delete;
+ const Box* previousInFlowOrFloatingSibling() const = delete;
+ Box* nextSibling() = delete;
+};
+
+}
+}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(InitialContainingBlock, isInitialContainingBlock())
+
+#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (258819 => 258820)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-03-22 14:02:37 UTC (rev 258819)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-03-22 17:41:12 UTC (rev 258820)
@@ -42,6 +42,7 @@
#include "LayoutContainerBox.h"
#include "LayoutContext.h"
#include "LayoutDescendantIterator.h"
+#include "LayoutInitialContainingBlock.h"
#include "LayoutInlineTextBox.h"
#include "LayoutLineBreakBox.h"
#include "LayoutPhase.h"
@@ -130,7 +131,7 @@
style.setLogicalWidth(Length(renderView.width(), Fixed));
style.setLogicalHeight(Length(renderView.height(), Fixed));
- auto layoutTreeContent = makeUnique<LayoutTreeContent>(renderView, makeUnique<ContainerBox>(WTF::nullopt, WTFMove(style)));
+ auto layoutTreeContent = makeUnique<LayoutTreeContent>(renderView, makeUnique<InitialContainingBlock>(WTFMove(style)));
TreeBuilder(*layoutTreeContent).buildTree();
return layoutTreeContent;
}