[LFC][BCF] Add support for block level non-replaced inflow height percentage
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 15:44:57 +0000 (15:44 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 15:44:57 +0000 (15:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191229

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/block/basic/child-block-level-box-with-height-percent.html

* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::computedHeightValue):
(WebCore::Layout::computedHeightValue): Deleted.
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/block/basic/child-block-level-box-with-height-percent-expected.txt: Added.
* fast/block/basic/child-block-level-box-with-height-percent.html: Added.
* platform/ios/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/fast/block/basic/child-block-level-box-with-height-percent-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/basic/child-block-level-box-with-height-percent.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index 8189be4..e0afd9d 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-04  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BCF] Add support for block level non-replaced inflow height percentage
+        https://bugs.webkit.org/show_bug.cgi?id=191229
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/basic/child-block-level-box-with-height-percent-expected.txt: Added.
+        * fast/block/basic/child-block-level-box-with-height-percent.html: Added.
+        * platform/ios/TestExpectations:
+
 2018-11-03  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: capture changes to <canvas> that would affect the recorded context
diff --git a/LayoutTests/fast/block/basic/child-block-level-box-with-height-percent-expected.txt b/LayoutTests/fast/block/basic/child-block-level-box-with-height-percent-expected.txt
new file mode 100644 (file)
index 0000000..5a8fbae
--- /dev/null
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 300x300
+        RenderBlock (anonymous) at (0,0) size 300x18
+          RenderText {#text} at (0,0) size 132x18
+            text run at (0,0) width 132: "block level box with"
+        RenderBlock {DIV} at (0,18) size 152x152 [border: (1px solid #FF0000)]
+          RenderText {#text} at (1,1) size 40x18
+            text run at (1,1) width 40: "height"
+        RenderBlock (anonymous) at (0,170) size 300x36
+          RenderText {#text} at (0,0) size 259x36
+            text run at (0,0) width 259: "percent when containing block has fixed"
+            text run at (0,18) width 44: "height."
diff --git a/LayoutTests/fast/block/basic/child-block-level-box-with-height-percent.html b/LayoutTests/fast/block/basic/child-block-level-box-with-height-percent.html
new file mode 100644 (file)
index 0000000..2037cf4
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+#main {
+       width: 300px;
+       height: 300px;
+}
+
+#nested {
+       border: 1px solid red;
+       display: block;
+       height: 50%;
+       width: 50%;
+}
+
+</style>
+
+<div id=main>block level box with<div id=nested>height </div>percent when containing block has fixed height.</div>
index cc65cd3..c81f0a2 100644 (file)
@@ -3116,6 +3116,7 @@ fast/inline/simple-intruding-floats3.html [ Failure ]
 fast/inline/simple-inline-block.html [ Failure ]
 fast/inline/simple-shrink-to-fit-inline-block.html [ Failure ]
 fast/block/basic/height-percentage-simple.html [ Failure ]
+fast/block/basic/child-block-level-box-with-height-percent.html [ Failure ]
 
 # Datalist
 webkit.org/b/186714 fast/forms/datalist/datalist-textinput-keydown.html [ Skip ]
index c00a2c9..a0c5884 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-04  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BCF] Add support for block level non-replaced inflow height percentage
+        https://bugs.webkit.org/show_bug.cgi?id=191229
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/block/basic/child-block-level-box-with-height-percent.html
+
+        * layout/FormattingContext.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::computedHeightValue):
+        (WebCore::Layout::computedHeightValue): Deleted.
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+
 2018-11-04  Youenn Fablet  <youenn@apple.com>
 
         RealtimeOutgoingAudioSource should use DestructionThread::Main
index d78f97f..16c764a 100644 (file)
@@ -108,6 +108,10 @@ protected:
         static std::optional<LayoutUnit> computedMinHeight(const LayoutState&, const Box&);
         static std::optional<LayoutUnit> computedMaxHeight(const LayoutState&, const Box&);
 
+    protected:
+        enum class HeightType { Min, Max, Normal };
+        static std::optional<LayoutUnit> computedHeightValue(const LayoutState&, const Box&, HeightType);
+
     private:
         static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
         static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
index 00c366e..dca9c08 100644 (file)
@@ -57,8 +57,7 @@ static inline bool isHeightAuto(const Box& layoutBox)
     return false;
 }
 
-enum class HeightType { Min, Max, Normal };
-static inline std::optional<LayoutUnit> computedHeightValue(const LayoutState& layoutState, const Box& layoutBox, HeightType heightType)
+std::optional<LayoutUnit> FormattingContext::Geometry::computedHeightValue(const LayoutState& layoutState, const Box& layoutBox, HeightType heightType)
 {
     auto& style = layoutBox.style();
     auto height = heightType == HeightType::Normal ? style.logicalHeight() : heightType == HeightType::Min ? style.logicalMinHeight() : style.logicalMaxHeight();
index 6d602b5..8b88ef7 100644 (file)
@@ -107,14 +107,9 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
         VerticalEdges collapsedMargin = { MarginCollapse::marginTop(layoutState, layoutBox), MarginCollapse::marginBottom(layoutState, layoutBox) };
         auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop().value_or(0);
         
-        auto height = usedHeight ? Length { usedHeight.value(), Fixed } : style.logicalHeight();
-        if (!height.isAuto()) {
-            if (height.isFixed())
-                return { height.value(), nonCollapsedMargin, collapsedMargin };
-
-            // Most notably height percentage.
-            ASSERT_NOT_IMPLEMENTED_YET();
-        }
+        auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
+        if (height)
+            return { height.value(), nonCollapsedMargin, collapsedMargin };
 
         if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild())
             return { 0, nonCollapsedMargin, collapsedMargin };
index f98da80..2e03a0d 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-04  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BCF] Add support for block level non-replaced inflow height percentage
+        https://bugs.webkit.org/show_bug.cgi?id=191229
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-11-02  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][BFC] Resolve percentage height values.
index b62cc1a..d848e16 100644 (file)
@@ -70,3 +70,4 @@ fast/inline/simple-intruding-floats3.html
 fast/inline/simple-inline-block.html
 fast/inline/simple-shrink-to-fit-inline-block.html
 fast/block/basic/height-percentage-simple.html
+fast/block/basic/child-block-level-box-with-height-percent.html