[css-grid] Percentage columns should remove scrollbar's width
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 09:46:37 +0000 (09:46 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 09:46:37 +0000 (09:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149116

Reviewed by Sergio Villar Senin.

Source/WebCore:

Currently the calculation of percentage columns was not subtracting the
scrollbar's size.
Fixed RenderGrid::computeUsedBreadthOfSpecifiedLength()
to avoid this problem.

Test: fast/css-grid-layout/grid-percent-track-scrollbar.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeUsedBreadthOfSpecifiedLength):

LayoutTests:

Added test to check the behavior for both columns and rows.
Note that rows (height) were already working fine.

* fast/css-grid-layout/grid-percent-track-scrollbar-expected.txt: Added.
* fast/css-grid-layout/grid-percent-track-scrollbar.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp

index 7d42456..f264b16 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-14  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [css-grid] Percentage columns should remove scrollbar's width
+        https://bugs.webkit.org/show_bug.cgi?id=149116
+
+        Reviewed by Sergio Villar Senin.
+
+        Added test to check the behavior for both columns and rows.
+        Note that rows (height) were already working fine.
+
+        * fast/css-grid-layout/grid-percent-track-scrollbar-expected.txt: Added.
+        * fast/css-grid-layout/grid-percent-track-scrollbar.html: Added.
+
 2015-09-14  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
         [Streams API] pipe-to writable stream tests
diff --git a/LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar-expected.txt b/LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar-expected.txt
new file mode 100644 (file)
index 0000000..e42c1ba
--- /dev/null
@@ -0,0 +1,4 @@
+This test checks that percentage tracks reduce the grid's scrollbars if any in order to calculate their breadths.
+
+PASS
+PASS
diff --git a/LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar.html b/LayoutTests/fast/css-grid-layout/grid-percent-track-scrollbar.html
new file mode 100644 (file)
index 0000000..45b07cc
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link href="resources/grid.css" rel="stylesheet">
+<style>
+.grid {
+    width: 100px;
+    height: 100px;
+    -webkit-grid-template-columns: 20% 50% 30%;
+    -webkit-grid-template-rows: 40% 60%;
+}
+
+.scroll {
+    width: 115px;
+    height: 115px;
+    overflow: scroll;
+}
+
+</style>
+<script src="../../resources/check-layout.js"></script>
+</head>
+<body onload="checkLayout('.grid');">
+    <p>This test checks that percentage tracks reduce the grid's scrollbars if any in order to calculate their breadths.</p>
+
+    <div class="grid">
+        <div data-expected-width="20" data-expected-height="40"></div>
+        <div data-expected-width="50" data-expected-height="40"></div>
+        <div data-expected-width="30" data-expected-height="40"></div>
+        <div data-expected-width="20" data-expected-height="60"></div>
+        <div data-expected-width="50" data-expected-height="60"></div>
+        <div data-expected-width="30" data-expected-height="60"></div>
+    </div>
+
+    <div class="grid scroll">
+        <div data-expected-width="20" data-expected-height="40"></div>
+        <div data-expected-width="50" data-expected-height="40"></div>
+        <div data-expected-width="30" data-expected-height="40"></div>
+        <div data-expected-width="20" data-expected-height="60"></div>
+        <div data-expected-width="50" data-expected-height="60"></div>
+        <div data-expected-width="30" data-expected-height="60"></div>
+    </div>
+
+</body>
+</html>
index f78bc84..4674a95 100644 (file)
@@ -1,3 +1,20 @@
+2015-09-14  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [css-grid] Percentage columns should remove scrollbar's width
+        https://bugs.webkit.org/show_bug.cgi?id=149116
+
+        Reviewed by Sergio Villar Senin.
+
+        Currently the calculation of percentage columns was not subtracting the
+        scrollbar's size.
+        Fixed RenderGrid::computeUsedBreadthOfSpecifiedLength()
+        to avoid this problem.
+
+        Test: fast/css-grid-layout/grid-percent-track-scrollbar.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeUsedBreadthOfSpecifiedLength):
+
 2015-09-13  Chris Dumez  <cdumez@apple.com>
 
         Improve Node pre-insertion validation when the parent is a Document
index ebad131..2a2255d 100644 (file)
@@ -451,7 +451,7 @@ LayoutUnit RenderGrid::computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirect
 {
     ASSERT(trackLength.isSpecified());
     if (direction == ForColumns)
-        return valueForLength(trackLength, logicalWidth() - borderAndPaddingLogicalWidth());
+        return valueForLength(trackLength, contentLogicalWidth());
     return valueForLength(trackLength, computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0));
 }