[LFC] Move geometry data structures to a dedicated file
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2018 14:47:55 +0000 (14:47 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2018 14:47:55 +0000 (14:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187939

Reviewed by Antti Koivisto.

* WebCore.xcodeproj/project.pbxproj:
* layout/FormattingContext.h:
(WebCore::Layout::FormattingContext::Geometry::Position::operator LayoutPoint const): Deleted.
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::computedBorder):
(WebCore::Layout::FormattingContext::Geometry::computedPadding):
(WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue):
(WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue):
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setVerticalNonCollapsedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/LayoutUnits.h [new file with mode: 0644]
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/displaytree/DisplayBox.h

index 48dc77a..bdc3dd1 100644 (file)
@@ -1,3 +1,48 @@
+2018-07-24  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Move geometry data structures to a dedicated file
+        https://bugs.webkit.org/show_bug.cgi?id=187939
+
+        Reviewed by Antti Koivisto.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/FormattingContext.h:
+        (WebCore::Layout::FormattingContext::Geometry::Position::operator LayoutPoint const): Deleted.
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::computedBorder):
+        (WebCore::Layout::FormattingContext::Geometry::computedPadding):
+        (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue):
+        (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::setHorizontalMargin):
+        (WebCore::Display::Box::setVerticalMargin):
+        (WebCore::Display::Box::setVerticalNonCollapsedMargin):
+        (WebCore::Display::Box::setBorder):
+        (WebCore::Display::Box::setPadding):
+
 2018-07-24  Thibault Saunier  <tsaunier@igalia.com>
 
         [GStreamer] Implement bitrate modulation support in GStreamer based libwebrtc Encoders
index b423b5a..22e1423 100644 (file)
                6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingContextGeometry.cpp; sourceTree = "<group>"; };
                6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
                6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
+               6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; };
                6F7CA3C4208C2956002F29AB /* LayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContext.h; sourceTree = "<group>"; };
                6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContext.cpp; sourceTree = "<group>"; };
                6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; };
                                115F7805209CBCBD00739C13 /* Invalidation.h */,
                                6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */,
                                6F7CA3C4208C2956002F29AB /* LayoutContext.h */,
+                               6F73918C2106CEDD006AF262 /* LayoutUnits.h */,
                                11FF02D520BA3C810083F25B /* Verification.cpp */,
                        );
                        path = layout;
index de4edf7..3b5b855 100644 (file)
@@ -85,36 +85,6 @@ protected:
     // This class implements generic positioning and sizing.
     class Geometry {
     public:
-        struct Position {
-            // FIXME: Use LayoutUnit<Horizontal> to avoid top/left vs. x/y confusion.
-            LayoutUnit x; // left
-            LayoutUnit y; // top
-            operator LayoutPoint() const { return { x, y }; }
-        };
-
-        struct WidthAndMargin {
-            LayoutUnit width;
-            Display::Box::HorizontalEdges margin;
-        };
-
-        struct HeightAndMargin {
-            LayoutUnit height;
-            Display::Box::VerticalEdges margin;
-            std::optional<Display::Box::VerticalEdges> collapsedMargin;
-        };
-
-         struct HorizontalGeometry {
-            LayoutUnit left;
-            LayoutUnit right;
-            WidthAndMargin widthAndMargin;
-         };
-
-        struct VerticalGeometry {
-            LayoutUnit top;
-            LayoutUnit bottom;
-            HeightAndMargin heightAndMargin;
-        };
-
         static VerticalGeometry outOfFlowVerticalGeometry(LayoutContext&, const Box&);
         static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutContext&, const FormattingContext&, const Box&);
 
@@ -125,11 +95,11 @@ protected:
         static WidthAndMargin inlineReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedMarginLeft = { },
             std::optional<LayoutUnit> precomputedMarginRight = { });
 
-        static Display::Box::Edges computedBorder(LayoutContext&, const Box&);
-        static std::optional<Display::Box::Edges> computedPadding(LayoutContext&, const Box&);
+        static Edges computedBorder(LayoutContext&, const Box&);
+        static std::optional<Edges> computedPadding(LayoutContext&, const Box&);
 
-        static Display::Box::HorizontalEdges computedNonCollapsedHorizontalMarginValue(const LayoutContext&, const Box&);
-        static Display::Box::VerticalEdges computedNonCollapsedVerticalMarginValue(const LayoutContext&, const Box&);
+        static HorizontalEdges computedNonCollapsedHorizontalMarginValue(const LayoutContext&, const Box&);
+        static VerticalEdges computedNonCollapsedVerticalMarginValue(const LayoutContext&, const Box&);
 
         static std::optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth);
         static std::optional<LayoutUnit> fixedValue(const Length& geometryProperty);
index ec2c051..414b364 100644 (file)
@@ -145,7 +145,7 @@ LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutContext& layoutCo
     return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum);
 }
 
-FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
+VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
 
@@ -261,7 +261,7 @@ FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOf
     return { *top, *bottom, { *height, { *marginTop, *marginBottom }, { } } };
 }
 
-FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
     
@@ -405,7 +405,7 @@ FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::out
     return { *left, *right, { *width, { *marginLeft, *marginRight } } };
 }
 
-FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
+VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
 
@@ -474,7 +474,7 @@ FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOf
     return { *top, *bottom, { height, { *marginTop, *marginBottom }, { } } };
 }
 
-FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
 
@@ -570,7 +570,7 @@ FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::out
     return { *left, *right, { width, { *marginLeft, *marginRight } } };
 }
 
-FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin FormattingContext::Geometry::floatingNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
 
@@ -601,10 +601,10 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floati
         height = contentHeightForFormattingContextRoot(layoutContext, layoutBox);
 
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << *marginTop << "px, " << *marginBottom << "px) -> layoutBox(" << &layoutBox << ")");
-    return FormattingContext::Geometry::HeightAndMargin { *height, { *marginTop, *marginBottom }, { } };
+    return HeightAndMargin { *height, { *marginTop, *marginBottom }, { } };
 }
 
-FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
+WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
 
@@ -624,10 +624,10 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin
         width = shrinkToFitWidth(layoutContext, formattingContext, layoutBox);
 
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << margin.left << "px, " << margin.right << "px) -> layoutBox(" << &layoutBox << ")");
-    return FormattingContext::Geometry::WidthAndMargin { *width, margin };
+    return WidthAndMargin { *width, margin };
 }
 
-FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
 
@@ -637,7 +637,7 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floati
     return inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
 
@@ -651,7 +651,7 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin
     return inlineReplacedWidthAndMargin(layoutContext, layoutBox, margin.left, margin.right);
 }
 
-FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
+VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
@@ -660,7 +660,7 @@ FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOf
     return outOfFlowReplacedVerticalGeometry(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
@@ -669,7 +669,7 @@ FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::out
     return outOfFlowReplacedHorizontalGeometry(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned());
 
@@ -678,7 +678,7 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floati
     return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
+WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutContext& layoutContext, const FormattingContext& formattingContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned());
 
@@ -687,7 +687,7 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin
     return floatingReplacedWidthAndMargin(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
 
@@ -733,7 +733,7 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inline
     return { *height, margin, { } };
 }
 
-FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
+WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
     std::optional<LayoutUnit> precomputedMarginLeft, std::optional<LayoutUnit> precomputedMarginRight)
 {
     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
@@ -809,7 +809,7 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineR
     return { *width, { marginLeft, marginRight } };
 }
 
-Display::Box::Edges FormattingContext::Geometry::computedBorder(LayoutContext&, const Box& layoutBox)
+Edges FormattingContext::Geometry::computedBorder(LayoutContext&, const Box& layoutBox)
 {
     auto& style = layoutBox.style();
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Border] -> layoutBox: " << &layoutBox);
@@ -819,7 +819,7 @@ Display::Box::Edges FormattingContext::Geometry::computedBorder(LayoutContext&,
     };
 }
 
-std::optional<Display::Box::Edges> FormattingContext::Geometry::computedPadding(LayoutContext& layoutContext, const Box& layoutBox)
+std::optional<Edges> FormattingContext::Geometry::computedPadding(LayoutContext& layoutContext, const Box& layoutBox)
 {
     if (!layoutBox.isPaddingApplicable())
         return std::nullopt;
@@ -827,13 +827,13 @@ std::optional<Display::Box::Edges> FormattingContext::Geometry::computedPadding(
     auto& style = layoutBox.style();
     auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth();
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Padding] -> layoutBox: " << &layoutBox);
-    return Display::Box::Edges {
+    return Edges {
         { valueForLength(style.paddingLeft(), containingBlockWidth), valueForLength(style.paddingRight(), containingBlockWidth) },
         { valueForLength(style.paddingTop(), containingBlockWidth), valueForLength(style.paddingBottom(), containingBlockWidth) }
     };
 }
 
-Display::Box::HorizontalEdges FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox)
+HorizontalEdges FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     auto& style = layoutBox.style();
     auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth();
@@ -845,7 +845,7 @@ Display::Box::HorizontalEdges FormattingContext::Geometry::computedNonCollapsedH
     return { marginLeft, marginRight };
 }
 
-Display::Box::VerticalEdges FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox)
+VerticalEdges FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     auto& style = layoutBox.style();
     auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth();
diff --git a/Source/WebCore/layout/LayoutUnits.h b/Source/WebCore/layout/LayoutUnits.h
new file mode 100644 (file)
index 0000000..e2a8375
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2018 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 "LayoutUnit.h"
+#include "LayoutPoint.h"
+#include "LayoutRect.h"
+
+namespace WebCore {
+namespace Layout {
+
+struct Position {
+    // FIXME: Use LayoutUnit<Horizontal> to avoid top/left vs. x/y confusion.
+    LayoutUnit x; // left
+    LayoutUnit y; // top
+    operator LayoutPoint() const { return { x, y }; }
+};
+
+// Margin, border, padding
+struct HorizontalEdges {
+    LayoutUnit left;
+    LayoutUnit right;
+};
+
+struct VerticalEdges {
+    LayoutUnit top;
+    LayoutUnit bottom;
+};
+
+struct Edges {
+    HorizontalEdges horizontal;
+    VerticalEdges vertical;
+};
+
+struct WidthAndMargin {
+    LayoutUnit width;
+    HorizontalEdges margin;
+};
+
+struct HeightAndMargin {
+    LayoutUnit height;
+    VerticalEdges margin;
+    std::optional<VerticalEdges> collapsedMargin;
+};
+
+struct HorizontalGeometry {
+    LayoutUnit left;
+    LayoutUnit right;
+    WidthAndMargin widthAndMargin;
+};
+
+struct VerticalGeometry {
+    LayoutUnit top;
+    LayoutUnit bottom;
+    HeightAndMargin heightAndMargin;
+};
+
+}
+}
+#endif
index 4d4fb9e..7564f38 100644 (file)
@@ -64,20 +64,20 @@ private:
     // This class implements positioning and sizing for boxes participating in a block formatting context.
     class Geometry {
     public:
-        static FormattingContext::Geometry::HeightAndMargin inFlowHeightAndMargin(LayoutContext&, const Box&);
-        static FormattingContext::Geometry::WidthAndMargin inFlowWidthAndMargin(LayoutContext&, const Box&);
+        static HeightAndMargin inFlowHeightAndMargin(LayoutContext&, const Box&);
+        static WidthAndMargin inFlowWidthAndMargin(LayoutContext&, const Box&);
 
-        static FormattingContext::Geometry::Position staticPosition(LayoutContext&, const Box&);
-        static FormattingContext::Geometry::Position inFlowPositionedPosition(LayoutContext&, const Box&);
+        static Position staticPosition(LayoutContext&, const Box&);
+        static Position inFlowPositionedPosition(LayoutContext&, const Box&);
 
         static bool instrinsicWidthConstraintsNeedChildrenWidth(const Box&);
         static FormattingContext::InstrinsicWidthConstraints instrinsicWidthConstraints(LayoutContext&, const Box&);
 
     private:
-        static FormattingContext::Geometry::HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
-        static FormattingContext::Geometry::WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
-        static FormattingContext::Geometry::WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
-        static FormattingContext::Geometry::Position staticPositionForOutOfFlowPositioned(const LayoutContext&, const Box&);
+        static HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
+        static WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
+        static WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
+        static Position staticPositionForOutOfFlowPositioned(const LayoutContext&, const Box&);
     };
     
     // This class implements margin collapsing for block formatting context.
index 1a66adf..a01f046 100644 (file)
@@ -57,11 +57,11 @@ static const Container& initialContainingBlock(const Box& layoutBox)
     return *containingBlock;
 }
 
-FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
 
-    auto compute = [&]() -> FormattingContext::Geometry::HeightAndMargin {
+    auto compute = [&]() -> HeightAndMargin {
 
         // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
         //
@@ -80,9 +80,9 @@ FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::i
         auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth();
         auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
 
-        Display::Box::VerticalEdges nonCollapsedMargin = { FormattingContext::Geometry::computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(0),
+        VerticalEdges nonCollapsedMargin = { FormattingContext::Geometry::computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(0),
             FormattingContext::Geometry::computedValueIfNotAuto(style.marginBottom(), containingBlockWidth).value_or(0) }; 
-        Display::Box::VerticalEdges collapsedMargin = { MarginCollapse::marginTop(layoutContext, layoutBox), MarginCollapse::marginBottom(layoutContext, layoutBox) };
+        VerticalEdges collapsedMargin = { MarginCollapse::marginTop(layoutContext, layoutBox), MarginCollapse::marginBottom(layoutContext, layoutBox) };
         auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop();
         
         if (!style.logicalHeight().isAuto())
@@ -136,7 +136,7 @@ FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::i
     return heightAndMargin;
 }
 
-FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
+WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
     std::optional<LayoutUnit> precomputedWidth)
 {
     ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
@@ -219,7 +219,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
         ASSERT(marginLeft);
         ASSERT(marginRight);
 
-        return FormattingContext::Geometry::WidthAndMargin { *width, { *marginLeft, *marginRight } };
+        return WidthAndMargin { *width, { *marginLeft, *marginRight } };
     };
 
     auto widthAndMargin = compute();
@@ -238,7 +238,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
     return widthAndMargin;
 }
 
-FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow() && layoutBox.replaced());
 
@@ -256,7 +256,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
     return { width, margin };
 }
 
-FormattingContext::Geometry::Position BlockFormattingContext::Geometry::staticPosition(LayoutContext& layoutContext, const Box& layoutBox)
+Position BlockFormattingContext::Geometry::staticPosition(LayoutContext& layoutContext, const Box& layoutBox)
 {
     // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
     // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
@@ -277,7 +277,7 @@ FormattingContext::Geometry::Position BlockFormattingContext::Geometry::staticPo
     return { left, top };
 }
 
-FormattingContext::Geometry::Position BlockFormattingContext::Geometry::inFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox)
+Position BlockFormattingContext::Geometry::inFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlowPositioned());
 
@@ -354,7 +354,7 @@ FormattingContext::Geometry::Position BlockFormattingContext::Geometry::inFlowPo
     return { newLeftPosition, newTopPosition };
 }
 
-FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow());
 
@@ -365,7 +365,7 @@ FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::i
     return FormattingContext::Geometry::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
-FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow());
 
index d34cddd..13a3c74 100644 (file)
@@ -27,9 +27,7 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#include "LayoutPoint.h"
-#include "LayoutRect.h"
-#include "LayoutUnit.h"
+#include "LayoutUnits.h"
 #include "RenderStyleConstants.h"
 #include <wtf/IsoMalloc.h>
 
@@ -176,27 +174,12 @@ private:
     void setContentBoxHeight(LayoutUnit);
     void setContentBoxWidth(LayoutUnit);
 
-    struct HorizontalEdges {
-        LayoutUnit left;
-        LayoutUnit right;
-    };
-
-    struct VerticalEdges {
-        LayoutUnit top;
-        LayoutUnit bottom;
-    };
-
-    struct Edges {
-        HorizontalEdges horizontal;
-        VerticalEdges vertical;
-    };
-
-    void setHorizontalMargin(HorizontalEdges);
-    void setVerticalMargin(VerticalEdges);
-    void setVerticalNonCollapsedMargin(VerticalEdges);
+    void setHorizontalMargin(Layout::HorizontalEdges);
+    void setVerticalMargin(Layout::VerticalEdges);
+    void setVerticalNonCollapsedMargin(Layout::VerticalEdges);
 
-    void setBorder(Edges);
-    void setPadding(Edges);
+    void setBorder(Layout::Edges);
+    void setPadding(Layout::Edges);
 
 #if !ASSERT_DISABLED
     void invalidateMargin();
@@ -220,11 +203,11 @@ private:
     LayoutUnit m_contentWidth;
     LayoutUnit m_contentHeight;
 
-    Edges m_margin;
-    VerticalEdges m_verticalNonCollapsedMargin;
+    Layout::Edges m_margin;
+    Layout::VerticalEdges m_verticalNonCollapsedMargin;
 
-    Edges m_border;
-    Edges m_padding;
+    Layout::Edges m_border;
+    Layout::Edges m_padding;
 
 #if !ASSERT_DISABLED
     bool m_hasValidHorizontalMargin { false };
@@ -454,7 +437,7 @@ inline LayoutUnit Box::contentBoxWidth() const
     return m_contentWidth;
 }
 
-inline void Box::setHorizontalMargin(HorizontalEdges margin)
+inline void Box::setHorizontalMargin(Layout::HorizontalEdges margin)
 {
 #if !ASSERT_DISABLED
     setHasValidHorizontalMargin();
@@ -462,7 +445,7 @@ inline void Box::setHorizontalMargin(HorizontalEdges margin)
     m_margin.horizontal = margin;
 }
 
-inline void Box::setVerticalMargin(VerticalEdges margin)
+inline void Box::setVerticalMargin(Layout::VerticalEdges margin)
 {
 #if !ASSERT_DISABLED
     setHasValidVerticalMargin();
@@ -470,7 +453,7 @@ inline void Box::setVerticalMargin(VerticalEdges margin)
     m_margin.vertical = margin;
 }
 
-inline void Box::setVerticalNonCollapsedMargin(VerticalEdges margin)
+inline void Box::setVerticalNonCollapsedMargin(Layout::VerticalEdges margin)
 {
 #if !ASSERT_DISABLED
     setHasValidVerticalNonCollapsedMargin();
@@ -478,7 +461,7 @@ inline void Box::setVerticalNonCollapsedMargin(VerticalEdges margin)
     m_verticalNonCollapsedMargin = margin;
 }
 
-inline void Box::setBorder(Edges border)
+inline void Box::setBorder(Layout::Edges border)
 {
 #if !ASSERT_DISABLED
     setHasValidBorder();
@@ -486,7 +469,7 @@ inline void Box::setBorder(Edges border)
     m_border = border;
 }
 
-inline void Box::setPadding(Edges padding)
+inline void Box::setPadding(Layout::Edges padding)
 {
 #if !ASSERT_DISABLED
     setHasValidPadding();