[LFC] Add FormattingContext::computeWidth/computeHeight logic.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2018 23:46:31 +0000 (23:46 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2018 23:46:31 +0000 (23:46 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@231117 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h

index 655d0a1..2f8f5a1 100644 (file)
@@ -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
index 9840a3f..a81fa53 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
+#include "LayoutBox.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -57,11 +58,37 @@ void FormattingContext::computeOutOfFlowPosition(const Box&) const
 {
 }
 
-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&) const
+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::computeFloatingWidth(const Box&) const
+{
+}
+
+void FormattingContext::computeOutOfFlowHeight(const Box&) const
+{
+}
+
+void FormattingContext::computeFloatingHeight(const Box&) const
 {
 }
 
index c6c1461..3a4f570 100644 (file)
@@ -62,6 +62,14 @@ protected:
     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;
index b57f1e7..0809426 100644 (file)
@@ -120,11 +120,11 @@ void BlockFormattingContext::computeStaticPosition(const Box&) const
 {
 }
 
-void BlockFormattingContext::computeWidth(const Box&) const
+void BlockFormattingContext::computeInFlowWidth(const Box&) const
 {
 }
 
-void BlockFormattingContext::computeHeight(const Box&) const
+void BlockFormattingContext::computeInFlowHeight(const Box&) const
 {
 }
 
index aade5a6..efbac24 100644 (file)
@@ -51,9 +51,8 @@ public:
 
 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;
index 2235266..50aa1c9 100644 (file)
@@ -66,6 +66,14 @@ Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState() const
     return formattingState.floatingState();
 }
 
+void InlineFormattingContext::computeInFlowWidth(const Box&) const
+{
+}
+
+void InlineFormattingContext::computeInFlowHeight(const Box&) const
+{
+}
+
 }
 }
 
index f2587f4..aa5c379 100644 (file)
@@ -46,6 +46,11 @@ public:
     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;
+
 };
 
 }