[css-flexbox] Don't include scrollbar extents when computing sizes for percentage resolution
https://bugs.webkit.org/show_bug.cgi?id=213739

Reviewed by Javier Fernandez.

Source/WebCore:

Content override sizes do include scrollbars so they must be substracted when using the override size
to compute percentages.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::crossSizeForPercentageResolution): Remove scrollbars.
(WebCore::RenderFlexibleBox::mainSizeForPercentageResolution): Ditto.

LayoutTests:

* TestExpectations: Unskipped percentage-heights-004.html.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b6df336..f8812f3 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,12 @@
+2020-06-29  Sergio Villar Senin  <svillar@igalia.com>
+
+        [css-flexbox] Don't include scrollbar extents when computing sizes for percentage resolution
+        https://bugs.webkit.org/show_bug.cgi?id=213739
+
+        Reviewed by Javier Fernandez.
+
+        * TestExpectations: Unskipped percentage-heights-004.html.
+
 2020-07-01  Diego Pino Garcia  <dpino@igalia.com>
 
         [GTK] Unreviewed test gardening. Garden flaky failures in EWS GTK-WK2 queue.
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 769c981..3d08430 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -4266,7 +4266,6 @@
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/overflow-area-001.html [ ImageOnlyFailure ]
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/overflow-area-002.html [ ImageOnlyFailure ]
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/overflow-auto-005.html [ ImageOnlyFailure ]
-webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/percentage-heights-004.html [ ImageOnlyFailure ]
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/percentage-heights-007.html [ ImageOnlyFailure ]
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/percentage-heights-014.html [ ImageOnlyFailure ]
 webkit.org/b/212046 imported/w3c/web-platform-tests/css/css-flexbox/percentage-size-subitems-001.html [ ImageOnlyFailure ]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2eb346b..e960e5a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2020-06-29  Sergio Villar Senin  <svillar@igalia.com>
+
+        [css-flexbox] Don't include scrollbar extents when computing sizes for percentage resolution
+        https://bugs.webkit.org/show_bug.cgi?id=213739
+
+        Reviewed by Javier Fernandez.
+
+        Content override sizes do include scrollbars so they must be substracted when using the override size
+        to compute percentages.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::crossSizeForPercentageResolution): Remove scrollbars.
+        (WebCore::RenderFlexibleBox::mainSizeForPercentageResolution): Ditto.
+
 2020-06-30  Sergio Villar Senin  <svillar@igalia.com>
 
         [css-flex] Remove death code paths when evaluating percentage resolution
diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp
index 2547b75..1028a0b 100644
--- a/Source/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp
@@ -1167,7 +1167,7 @@
 
     // Here we implement https://drafts.csswg.org/css-flexbox/#algo-stretch
     if (child.hasOverrideContentLogicalHeight())
-        return child.overrideContentLogicalHeight();
+        return child.overrideContentLogicalHeight() - child.scrollbarLogicalHeight();
     
     // We don't currently implement the optimization from
     // https://drafts.csswg.org/css-flexbox/#definite-sizes case 1. While that
@@ -1187,7 +1187,7 @@
     if (!mainAxisLengthIsDefinite(child, Length(0, Percent)))
         return WTF::nullopt;
 
-    return child.hasOverrideContentLogicalHeight() ? Optional<LayoutUnit>(child.overrideContentLogicalHeight()) : WTF::nullopt;
+    return child.hasOverrideContentLogicalHeight() ? Optional<LayoutUnit>(child.overrideContentLogicalHeight() - child.scrollbarLogicalHeight()) : WTF::nullopt;
 }
 
 Optional<LayoutUnit> RenderFlexibleBox::childLogicalHeightForPercentageResolution(const RenderBox& child)