[LFC] Add FormattingContext::computeWidth/computeHeight logic.
https://bugs.webkit.org/show_bug.cgi?id=185091

Reviewed by Antti Koivisto.

Inflow width and height can't really be computed without knowing the exact context.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeWidth const):
(WebCore::Layout::FormattingContext::computeHeight const):
(WebCore::Layout::FormattingContext::computeOutOfFlowWidth const):
(WebCore::Layout::FormattingContext::computeFloatingWidth const):
(WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
(WebCore::Layout::FormattingContext::computeFloatingHeight const):
* layout/FormattingContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeInFlowWidth const):
(WebCore::Layout::BlockFormattingContext::computeInFlowHeight const):
(WebCore::Layout::BlockFormattingContext::computeWidth const): Deleted.
(WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
* layout/blockformatting/BlockFormattingContext.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeInFlowWidth const):
(WebCore::Layout::InlineFormattingContext::computeInFlowHeight const):
* layout/inlineformatting/InlineFormattingContext.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 655d0a1..2f8f5a1 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2018-04-27  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Add FormattingContext::computeWidth/computeHeight logic.
+        https://bugs.webkit.org/show_bug.cgi?id=185091
+
+        Reviewed by Antti Koivisto.
+
+        Inflow width and height can't really be computed without knowing the exact context. 
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeWidth const):
+        (WebCore::Layout::FormattingContext::computeHeight const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowWidth const):
+        (WebCore::Layout::FormattingContext::computeFloatingWidth const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
+        (WebCore::Layout::FormattingContext::computeFloatingHeight const):
+        * layout/FormattingContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeInFlowWidth const):
+        (WebCore::Layout::BlockFormattingContext::computeInFlowHeight const):
+        (WebCore::Layout::BlockFormattingContext::computeWidth const): Deleted.
+        (WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeInFlowWidth const):
+        (WebCore::Layout::InlineFormattingContext::computeInFlowHeight const):
+        * layout/inlineformatting/InlineFormattingContext.h:
+
 2018-04-27  Chris Dumez  <cdumez@apple.com>
 
         Use WindowProxy instead of DOMWindow in our IDL
diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp
index 9840a3f..a81fa53 100644
--- a/Source/WebCore/layout/FormattingContext.cpp
+++ b/Source/WebCore/layout/FormattingContext.cpp
@@ -28,6 +28,7 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
+#include "LayoutBox.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -57,11 +58,37 @@
 {
 }
 
-void FormattingContext::computeWidth(const Box&) const
+void FormattingContext::computeWidth(const Box& layoutBox) const
+{
+    if (layoutBox.isOutOfFlowPositioned())
+        return computeOutOfFlowWidth(layoutBox);
+    if (layoutBox.isFloatingPositioned())
+        return computeFloatingWidth(layoutBox);
+    return computeInFlowWidth(layoutBox);
+}
+
+void FormattingContext::computeHeight(const Box& layoutBox) const
+{
+    if (layoutBox.isOutOfFlowPositioned())
+        return computeOutOfFlowHeight(layoutBox);
+    if (layoutBox.isFloatingPositioned())
+        return computeFloatingHeight(layoutBox);
+    return computeInFlowHeight(layoutBox);
+}
+
+void FormattingContext::computeOutOfFlowWidth(const Box&) const
 {
 }
 
-void FormattingContext::computeHeight(const Box&) const
+void FormattingContext::computeFloatingWidth(const Box&) const
+{
+}
+
+void FormattingContext::computeOutOfFlowHeight(const Box&) const
+{
+}
+
+void FormattingContext::computeFloatingHeight(const Box&) const
 {
 }
 
diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h
index c6c1461..3a4f570 100644
--- a/Source/WebCore/layout/FormattingContext.h
+++ b/Source/WebCore/layout/FormattingContext.h
@@ -62,6 +62,14 @@
     virtual void computeWidth(const Box&) const;
     virtual void computeHeight(const Box&) const;
 
+    virtual void computeOutOfFlowWidth(const Box&) const;
+    virtual void computeFloatingWidth(const Box&) const;
+    virtual void computeInFlowWidth(const Box&) const = 0;
+
+    virtual void computeOutOfFlowHeight(const Box&) const;
+    virtual void computeFloatingHeight(const Box&) const;
+    virtual void computeInFlowHeight(const Box&) const = 0;
+
     virtual LayoutUnit marginTop(const Box&) const;
     virtual LayoutUnit marginLeft(const Box&) const;
     virtual LayoutUnit marginBottom(const Box&) const;
diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
index b57f1e7..0809426 100644
--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
@@ -120,11 +120,11 @@
 {
 }
 
-void BlockFormattingContext::computeWidth(const Box&) const
+void BlockFormattingContext::computeInFlowWidth(const Box&) const
 {
 }
 
-void BlockFormattingContext::computeHeight(const Box&) const
+void BlockFormattingContext::computeInFlowHeight(const Box&) const
 {
 }
 
diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
index aade5a6..efbac24 100644
--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
@@ -51,9 +51,8 @@
 
 protected:
     void computeStaticPosition(const Box&) const override;
-
-    void computeWidth(const Box&) const override;
-    void computeHeight(const Box&) const override;
+    void computeInFlowWidth(const Box&) const override;
+    void computeInFlowHeight(const Box&) const override;
 
     LayoutUnit marginTop(const Box&) const override;
     LayoutUnit marginBottom(const Box&) const override;
diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
index 2235266b..50aa1c9 100644
--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
@@ -66,6 +66,14 @@
     return formattingState.floatingState();
 }
 
+void InlineFormattingContext::computeInFlowWidth(const Box&) const
+{
+}
+
+void InlineFormattingContext::computeInFlowHeight(const Box&) const
+{
+}
+
 }
 }
 
diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
index f2587f4..aa5c379 100644
--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
@@ -46,6 +46,11 @@
     void layout(LayoutContext&, FormattingState&) const override;
     std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const override;
     Ref<FloatingState> createOrFindFloatingState() const override;
+
+private:
+    void computeInFlowWidth(const Box&) const override;
+    void computeInFlowHeight(const Box&) const override;
+
 };
 
 }