Title: [267026] trunk/Source/WebCore
Revision
267026
Author
[email protected]
Date
2020-09-14 11:47:05 -0700 (Mon, 14 Sep 2020)

Log Message

[LFC][FFC] Introduce flex formatting context
https://bugs.webkit.org/show_bug.cgi?id=216483

Reviewed by Antti Koivisto.

Add the basic class structure for the flex formatting context.
https://www.w3.org/TR/css-flexbox-1/

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/FormattingContext.h:
(WebCore::Layout::FormattingContext::isFlexFormattingContext const):
* layout/FormattingState.h:
(WebCore::Layout::FormattingState::isFlexFormattingState const):
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::establishedFormattingState const):
(WebCore::Layout::LayoutState::establishedFlexFormattingState const):
(WebCore::Layout::LayoutState::ensureFormattingState):
(WebCore::Layout::LayoutState::ensureFlexFormattingState):
* layout/LayoutState.h:
* layout/flexformatting/FlexFormattingContext.cpp: Added.
(WebCore::Layout::FlexFormattingContext::FlexFormattingContext):
(WebCore::Layout::FlexFormattingContext::layoutInFlowContent):
(WebCore::Layout::FlexFormattingContext::computedIntrinsicWidthConstraints):
* layout/flexformatting/FlexFormattingContext.h: Added.
* layout/flexformatting/FlexFormattingState.cpp: Added.
(WebCore::Layout::FlexFormattingState::FlexFormattingState):
(WebCore::Layout::FlexFormattingState::~FlexFormattingState):
* layout/flexformatting/FlexFormattingState.h: Added.
* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::establishesFormattingContext const):
(WebCore::Layout::Box::establishesFlexFormattingContext const):
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::isFlexBox const):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (267025 => 267026)


--- trunk/Source/WebCore/CMakeLists.txt	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-09-14 18:47:05 UTC (rev 267026)
@@ -105,6 +105,7 @@
     "${WEBCORE_DIR}/layout/blockformatting/tablewrapper"
     "${WEBCORE_DIR}/layout/display"
     "${WEBCORE_DIR}/layout/displaytree"
+    "${WEBCORE_DIR}/layout/flexformatting"
     "${WEBCORE_DIR}/layout/floats"
     "${WEBCORE_DIR}/layout/inlineformatting"
     "${WEBCORE_DIR}/layout/inlineformatting/text"

Modified: trunk/Source/WebCore/ChangeLog (267025 => 267026)


--- trunk/Source/WebCore/ChangeLog	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/ChangeLog	2020-09-14 18:47:05 UTC (rev 267026)
@@ -1,3 +1,40 @@
+2020-09-14  Zalan Bujtas  <[email protected]>
+
+        [LFC][FFC] Introduce flex formatting context
+        https://bugs.webkit.org/show_bug.cgi?id=216483
+
+        Reviewed by Antti Koivisto.
+
+        Add the basic class structure for the flex formatting context.
+        https://www.w3.org/TR/css-flexbox-1/
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/FormattingContext.h:
+        (WebCore::Layout::FormattingContext::isFlexFormattingContext const):
+        * layout/FormattingState.h:
+        (WebCore::Layout::FormattingState::isFlexFormattingState const):
+        * layout/LayoutState.cpp:
+        (WebCore::Layout::LayoutState::establishedFormattingState const):
+        (WebCore::Layout::LayoutState::establishedFlexFormattingState const):
+        (WebCore::Layout::LayoutState::ensureFormattingState):
+        (WebCore::Layout::LayoutState::ensureFlexFormattingState):
+        * layout/LayoutState.h:
+        * layout/flexformatting/FlexFormattingContext.cpp: Added.
+        (WebCore::Layout::FlexFormattingContext::FlexFormattingContext):
+        (WebCore::Layout::FlexFormattingContext::layoutInFlowContent):
+        (WebCore::Layout::FlexFormattingContext::computedIntrinsicWidthConstraints):
+        * layout/flexformatting/FlexFormattingContext.h: Added.
+        * layout/flexformatting/FlexFormattingState.cpp: Added.
+        (WebCore::Layout::FlexFormattingState::FlexFormattingState):
+        (WebCore::Layout::FlexFormattingState::~FlexFormattingState):
+        * layout/flexformatting/FlexFormattingState.h: Added.
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::establishesFormattingContext const):
+        (WebCore::Layout::Box::establishesFlexFormattingContext const):
+        * layout/layouttree/LayoutBox.h:
+        (WebCore::Layout::Box::isFlexBox const):
+
 2020-09-14  Simon Fraser  <[email protected]>
 
         First steps towards LFC painting in WebKit2

Modified: trunk/Source/WebCore/Sources.txt (267025 => 267026)


--- trunk/Source/WebCore/Sources.txt	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/Sources.txt	2020-09-14 18:47:05 UTC (rev 267026)
@@ -1437,6 +1437,8 @@
 layout/displaytree/DisplayBox.cpp
 layout/displaytree/DisplayInlineContent.cpp
 layout/displaytree/DisplayPainter.cpp
+layout/flexformatting/FlexFormattingContext.cpp
+layout/flexformatting/FlexFormattingState.cpp
 layout/floats/FloatAvoider.cpp
 layout/floats/FloatingContext.cpp
 layout/floats/FloatingState.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (267025 => 267026)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-14 18:47:05 UTC (rev 267026)
@@ -2085,6 +2085,8 @@
 		6FB2400523DFF12800796458 /* InlineLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB2400323DFF12700796458 /* InlineLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FB47E632277425A00C7BCB0 /* DisplayLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* DisplayLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6FB7D2DD250FD828000207AA /* FlexFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB7D2D9250FD7FC000207AA /* FlexFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6FB7D2DE250FD82E000207AA /* FlexFormattingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB7D2DA250FD7FC000207AA /* FlexFormattingState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FCE1A1A22618ABD004F0343 /* DisplayRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* DisplayRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FD9CD54227E21C800E53957 /* DisplayRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FD9CD52227E21C800E53957 /* DisplayRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE198152178397C00446F08 /* InlineLineBreaker.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9639,6 +9641,10 @@
 		6FB2400323DFF12700796458 /* InlineLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBox.h; sourceTree = "<group>"; };
 		6FB47E612277425A00C7BCB0 /* DisplayLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayLine.h; sourceTree = "<group>"; };
 		6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
+		6FB7D2D7250FD7E5000207AA /* FlexFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FlexFormattingContext.cpp; sourceTree = "<group>"; };
+		6FB7D2D8250FD7EF000207AA /* FlexFormattingState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FlexFormattingState.cpp; sourceTree = "<group>"; };
+		6FB7D2D9250FD7FC000207AA /* FlexFormattingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlexFormattingContext.h; sourceTree = "<group>"; };
+		6FB7D2DA250FD7FC000207AA /* FlexFormattingState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlexFormattingState.h; sourceTree = "<group>"; };
 		6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
 		6FC53AEB24AF7A8E006059FE /* TableFormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingContextQuirks.cpp; sourceTree = "<group>"; };
 		6FC5CA9222E3599300B13E11 /* TableFormattingState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingState.cpp; sourceTree = "<group>"; };
@@ -17439,6 +17445,7 @@
 				115CFA99208BC09A001E6991 /* blockformatting */,
 				0FFB4DA0250E9FC40086B952 /* display */,
 				1199FA58208E3C4C002358CC /* displaytree */,
+				6FB7D2D5250FD7B5000207AA /* flexformatting */,
 				6FCFC055212DACC2007695D2 /* floats */,
 				115CFA9A208BC140001E6991 /* inlineformatting */,
 				E4FB4B1E2395356F003C336A /* integration */,
@@ -21778,6 +21785,17 @@
 			path = invalidation;
 			sourceTree = "<group>";
 		};
+		6FB7D2D5250FD7B5000207AA /* flexformatting */ = {
+			isa = PBXGroup;
+			children = (
+				6FB7D2D7250FD7E5000207AA /* FlexFormattingContext.cpp */,
+				6FB7D2D9250FD7FC000207AA /* FlexFormattingContext.h */,
+				6FB7D2D8250FD7EF000207AA /* FlexFormattingState.cpp */,
+				6FB7D2DA250FD7FC000207AA /* FlexFormattingState.h */,
+			);
+			path = flexformatting;
+			sourceTree = "<group>";
+		};
 		6FC5CA9122E3593300B13E11 /* tableformatting */ = {
 			isa = PBXGroup;
 			children = (
@@ -31299,6 +31317,8 @@
 				49ECEB701499790D00CDD3A4 /* FilterOperations.h in Headers */,
 				372C00D9129619F8005C9575 /* FindOptions.h in Headers */,
 				A8CFF04F0A154F09000A4234 /* FixedTableLayout.h in Headers */,
+				6FB7D2DD250FD828000207AA /* FlexFormattingContext.h in Headers */,
+				6FB7D2DE250FD82E000207AA /* FlexFormattingState.h in Headers */,
 				6FFDC442212EFF1700A9CA91 /* FloatAvoider.h in Headers */,
 				BC073BAA0C399B1F000F5979 /* FloatConversion.h in Headers */,
 				115CFA86208B9066001E6991 /* FloatingContext.h in Headers */,

Modified: trunk/Source/WebCore/layout/FormattingContext.h (267025 => 267026)


--- trunk/Source/WebCore/layout/FormattingContext.h	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -95,6 +95,7 @@
     bool isInlineFormattingContext() const { return root().establishesInlineFormattingContext(); }
     bool isTableFormattingContext() const { return root().establishesTableFormattingContext(); }
     bool isTableWrapperBlockFormattingContext() const { return isBlockFormattingContext() && root().isTableWrapperBox(); }
+    bool isFlexFormattingContext() const { return root().establishesFlexFormattingContext(); }
 
     enum class EscapeReason {
         NeedsGeometryFromEstablishedFormattingContext,

Modified: trunk/Source/WebCore/layout/FormattingState.h (267025 => 267026)


--- trunk/Source/WebCore/layout/FormattingState.h	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/FormattingState.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -57,6 +57,7 @@
     bool isBlockFormattingState() const { return m_type == Type::Block; }
     bool isInlineFormattingState() const { return m_type == Type::Inline; }
     bool isTableFormattingState() const { return m_type == Type::Table; }
+    bool isFlexFormattingState() const { return m_type == Type::Flex; }
 
     LayoutState& layoutState() const { return m_layoutState; }
 
@@ -68,7 +69,7 @@
     const OutOfFlowBoxList& outOfFlowBoxes() const { return m_outOfFlowBoxes; }
 
 protected:
-    enum class Type { Block, Inline, Table };
+    enum class Type { Block, Inline, Table, Flex };
     FormattingState(Ref<FloatingState>&&, Type, LayoutState&);
     ~FormattingState();
 

Modified: trunk/Source/WebCore/layout/LayoutState.cpp (267025 => 267026)


--- trunk/Source/WebCore/layout/LayoutState.cpp	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/LayoutState.cpp	2020-09-14 18:47:05 UTC (rev 267026)
@@ -30,6 +30,7 @@
 
 #include "BlockFormattingState.h"
 #include "DisplayBox.h"
+#include "FlexFormattingState.h"
 #include "FloatingState.h"
 #include "InlineFormattingState.h"
 #include "LayoutBox.h"
@@ -100,8 +101,13 @@
     if (auto* formattingState = m_blockFormattingStates.get(&formattingContextRoot))
         return *formattingState;
 
-    ASSERT(m_tableFormattingStates.contains(&formattingContextRoot));
-    return *m_tableFormattingStates.get(&formattingContextRoot);
+    if (auto* formattingState = m_tableFormattingStates.get(&formattingContextRoot))
+        return *formattingState;
+
+    if (auto* formattingState = m_flexFormattingStates.get(&formattingContextRoot))
+        return *formattingState;
+
+    CRASH();
 }
 
 InlineFormattingState& LayoutState::establishedInlineFormattingState(const ContainerBox& formattingContextRoot) const
@@ -128,6 +134,12 @@
     return *m_tableFormattingStates.get(&formattingContextRoot);
 }
 
+FlexFormattingState& LayoutState::establishedFlexFormattingState(const ContainerBox& formattingContextRoot) const
+{
+    ASSERT(formattingContextRoot.establishesFlexFormattingContext());
+    return *m_flexFormattingStates.get(&formattingContextRoot);
+}
+
 FormattingState& LayoutState::ensureFormattingState(const ContainerBox& formattingContextRoot)
 {
     if (formattingContextRoot.establishesInlineFormattingContext())
@@ -136,7 +148,13 @@
     if (formattingContextRoot.establishesBlockFormattingContext())
         return ensureBlockFormattingState(formattingContextRoot);
 
-    return ensureTableFormattingState(formattingContextRoot);
+    if (formattingContextRoot.establishesTableFormattingContext())
+        return ensureTableFormattingState(formattingContextRoot);
+
+    if (formattingContextRoot.establishesFlexFormattingContext())
+        return ensureFlexFormattingState(formattingContextRoot);
+
+    CRASH();
 }
 
 InlineFormattingState& LayoutState::ensureInlineFormattingState(const ContainerBox& formattingContextRoot)
@@ -191,6 +209,18 @@
     return *m_tableFormattingStates.ensure(&formattingContextRoot, create).iterator->value;
 }
 
+FlexFormattingState& LayoutState::ensureFlexFormattingState(const ContainerBox& formattingContextRoot)
+{
+    ASSERT(formattingContextRoot.establishesFlexFormattingContext());
+
+    auto create = [&] {
+        // Flex formatting context always establishes a new floating state -and it stays empty.
+        return makeUnique<FlexFormattingState>(FloatingState::create(*this, formattingContextRoot), *this);
+    };
+
+    return *m_flexFormattingStates.ensure(&formattingContextRoot, create).iterator->value;
+}
+
 void LayoutState::setViewportSize(const LayoutSize& viewportSize)
 {
     ASSERT(RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled());

Modified: trunk/Source/WebCore/layout/LayoutState.h (267025 => 267026)


--- trunk/Source/WebCore/layout/LayoutState.h	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/LayoutState.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -41,6 +41,7 @@
 
 namespace Layout {
 
+class FlexFormattingState;
 class FormattingContext;
 class FormattingState;
 class BlockFormattingState;
@@ -57,11 +58,13 @@
     InlineFormattingState& ensureInlineFormattingState(const ContainerBox& formattingContextRoot);
     BlockFormattingState& ensureBlockFormattingState(const ContainerBox& formattingContextRoot);
     TableFormattingState& ensureTableFormattingState(const ContainerBox& formattingContextRoot);
+    FlexFormattingState& ensureFlexFormattingState(const ContainerBox& formattingContextRoot);
 
     FormattingState& establishedFormattingState(const ContainerBox& formattingRoot) const;
     InlineFormattingState& establishedInlineFormattingState(const ContainerBox& formattingContextRoot) const;
     BlockFormattingState& establishedBlockFormattingState(const ContainerBox& formattingContextRoot) const;
     TableFormattingState& establishedTableFormattingState(const ContainerBox& formattingContextRoot) const;
+    FlexFormattingState& establishedFlexFormattingState(const ContainerBox& formattingContextRoot) const;
 
     FormattingState& formattingStateForBox(const Box&) const;
     bool hasInlineFormattingState(const ContainerBox& formattingRoot) const { return m_inlineFormattingStates.contains(&formattingRoot); }
@@ -98,6 +101,7 @@
     HashMap<const ContainerBox*, std::unique_ptr<InlineFormattingState>> m_inlineFormattingStates;
     HashMap<const ContainerBox*, std::unique_ptr<BlockFormattingState>> m_blockFormattingStates;
     HashMap<const ContainerBox*, std::unique_ptr<TableFormattingState>> m_tableFormattingStates;
+    HashMap<const ContainerBox*, std::unique_ptr<FlexFormattingState>> m_flexFormattingStates;
 
     std::unique_ptr<InlineFormattingState> m_rootInlineFormattingStateForIntegration;
 

Added: trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.cpp (0 => 267026)


--- trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.cpp	2020-09-14 18:47:05 UTC (rev 267026)
@@ -0,0 +1,56 @@
+/*
+ * 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 "FlexFormattingContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FlexFormattingState.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(FlexFormattingContext);
+
+FlexFormattingContext::FlexFormattingContext(const ContainerBox& formattingContextRoot, FlexFormattingState& formattingState)
+    : FormattingContext(formattingContextRoot, formattingState)
+{
+}
+
+void FlexFormattingContext::layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent&)
+{
+}
+
+FormattingContext::IntrinsicWidthConstraints FlexFormattingContext::computedIntrinsicWidthConstraints()
+{
+    return { };
+}
+
+}
+}
+
+#endif

Added: trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.h (0 => 267026)


--- trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/flexformatting/FlexFormattingContext.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FlexFormattingState.h"
+#include "FormattingContext.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+namespace Layout {
+
+class InvalidationState;
+// This class implements the layout logic for flex formatting contexts.
+// https://www.w3.org/TR/css-flexbox-1/
+class FlexFormattingContext final : public FormattingContext {
+    WTF_MAKE_ISO_ALLOCATED(FlexFormattingContext);
+public:
+    FlexFormattingContext(const ContainerBox& formattingContextRoot, FlexFormattingState&);
+    void layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent&) override;
+
+    IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
+
+private:
+    const FlexFormattingState& formattingState() const { return downcast<FlexFormattingState>(FormattingContext::formattingState()); }
+    FlexFormattingState& formattingState() { return downcast<FlexFormattingState>(FormattingContext::formattingState()); }
+};
+
+}
+}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(FlexFormattingContext, isFlexFormattingContext())
+
+#endif

Added: trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.cpp (0 => 267026)


--- trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.cpp	2020-09-14 18:47:05 UTC (rev 267026)
@@ -0,0 +1,49 @@
+/*
+ * 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 "FlexFormattingState.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(FlexFormattingState);
+
+FlexFormattingState::FlexFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState)
+    : FormattingState(WTFMove(floatingState), Type::Flex, layoutState)
+{
+}
+
+FlexFormattingState::~FlexFormattingState()
+{
+}
+
+}
+}
+#endif

Added: trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.h (0 => 267026)


--- trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/flexformatting/FlexFormattingState.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FormattingState.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+namespace Layout {
+
+class FlexFormattingState : public FormattingState {
+    WTF_MAKE_ISO_ALLOCATED(FlexFormattingState);
+public:
+    FlexFormattingState(Ref<FloatingState>&&, LayoutState&);
+    ~FlexFormattingState();
+};
+
+}
+}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_STATE(FlexFormattingState, isFlexFormattingState())
+
+#endif

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (267025 => 267026)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2020-09-14 18:47:05 UTC (rev 267026)
@@ -65,7 +65,11 @@
 {
     // We need the final tree structure to tell whether a box establishes a certain formatting context. 
     ASSERT(!Phase::isInTreeBuilding());
-    return establishesBlockFormattingContext() || establishesInlineFormattingContext() || establishesTableFormattingContext() || establishesIndependentFormattingContext();
+    return establishesBlockFormattingContext()
+        || establishesInlineFormattingContext()
+        || establishesTableFormattingContext()
+        || establishesFlexFormattingContext()
+        || establishesIndependentFormattingContext();
 }
 
 bool Box::establishesBlockFormattingContext() const
@@ -119,6 +123,11 @@
     return isTableBox();
 }
 
+bool Box::establishesFlexFormattingContext() const
+{
+    return isFlexBox();
+}
+
 bool Box::establishesIndependentFormattingContext() const
 {
     // FIXME: This is where we would check for 'contain' property.

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (267025 => 267026)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2020-09-14 18:39:59 UTC (rev 267025)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2020-09-14 18:47:05 UTC (rev 267026)
@@ -77,6 +77,7 @@
     bool establishesBlockFormattingContext() const;
     bool establishesInlineFormattingContext() const;
     bool establishesTableFormattingContext() const;
+    bool establishesFlexFormattingContext() const;
     bool establishesIndependentFormattingContext() const;
 
     bool isInFlow() const { return !isFloatingOrOutOfFlowPositioned(); }
@@ -124,6 +125,7 @@
     bool isTableColumnGroup() const { return style().display() == DisplayType::TableColumnGroup; }
     bool isTableColumn() const { return style().display() == DisplayType::TableColumn; }
     bool isTableCell() const { return style().display() == DisplayType::TableCell; }
+    bool isFlexBox() const { return style().display() == DisplayType::Flex; }
     bool isIFrame() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::IFrame; }
     bool isImage() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Image; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to