Title: [160159] trunk
Revision
160159
Author
[email protected]
Date
2013-12-04 21:11:06 -0800 (Wed, 04 Dec 2013)

Log Message

% unit heights don't work if parent block height is set in vh
https://bugs.webkit.org/show_bug.cgi?id=118516

Patch by Gurpreet Kaur <[email protected]> on 2013-12-04
Reviewed by Simon Fraser.

>From Blink r156449 by <[email protected]>

Source/WebCore:

An element having height as percentage needs to have the
containingblock's height or availableheight to calculate its
own height. The containing block having a height set in vh
unit was not being considered for calculating the child's
height.

Tests: fast/css/viewport-percentage-compute-box-height.html
       fast/css/viewport-percentage-compute-box-width.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computePercentageLogicalHeight):
Correct child's height(in pecentage) was not being calculated
incase of parent having height set in vh unit. Added condition
to calculate the containing block height in terms of viewport size.

LayoutTests:

* fast/css/viewport-percentage-compute-box-height-expected.html: Added.
* fast/css/viewport-percentage-compute-box-height.html: Added.
* fast/css/viewport-percentage-compute-box-width-expected.html: Added.
* fast/css/viewport-percentage-compute-box-width.html: Added.
Added new tests for verifying that percentage unit height/width works
if parent block height/width is set in vh/vw units.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160158 => 160159)


--- trunk/LayoutTests/ChangeLog	2013-12-05 04:35:49 UTC (rev 160158)
+++ trunk/LayoutTests/ChangeLog	2013-12-05 05:11:06 UTC (rev 160159)
@@ -1,3 +1,19 @@
+2013-12-04  Gurpreet Kaur  <[email protected]>
+
+        % unit heights don't work if parent block height is set in vh
+        https://bugs.webkit.org/show_bug.cgi?id=118516
+
+        Reviewed by Simon Fraser.
+
+        From Blink r156449 by <[email protected]>
+
+        * fast/css/viewport-percentage-compute-box-height-expected.html: Added.
+        * fast/css/viewport-percentage-compute-box-height.html: Added.
+        * fast/css/viewport-percentage-compute-box-width-expected.html: Added.
+        * fast/css/viewport-percentage-compute-box-width.html: Added.
+        Added new tests for verifying that percentage unit height/width works
+        if parent block height/width is set in vh/vw units.
+
 2013-12-04  Filip Pizlo  <[email protected]>
 
         Fold constant typed arrays

Added: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height-expected.html (0 => 160159)


--- trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height-expected.html	2013-12-05 05:11:06 UTC (rev 160159)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>The height of innerdiv should be 50% of the height of the outerdiv.</p>
+        <div id="outer" style="height: 300px; width: 400px; background-color: lightcyan;">
+            <div id="inner" style="width: 50%; height: 50%; background-color: lightseagreen;"></div>
+        </div>    
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height-expected.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height.html (0 => 160159)


--- trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height.html	2013-12-05 05:11:06 UTC (rev 160159)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>The height of innerdiv should be 50% of the height of the outerdiv.</p>
+        <div id="outer" style="height: 50vh; width: 400px; background-color: lightcyan;">
+            <div id="inner" style="width: 50%; height: 50%; background-color: lightseagreen;"></div>
+        </div>    
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-height.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width-expected.html (0 => 160159)


--- trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width-expected.html	2013-12-05 05:11:06 UTC (rev 160159)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>The width of innerdiv should be 50% of the width of the outerdiv.</p>
+        <div id="outer" style="height: 300px; width: 400px; background-color: lightcyan;">
+            <div id="inner" style="width: 50%; height: 50%; background-color: lightseagreen;"></div>
+        </div>    
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width-expected.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width.html (0 => 160159)


--- trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width.html	2013-12-05 05:11:06 UTC (rev 160159)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>The width of innerdiv should be 50% of the width of the outerdiv.</p>
+        <div id="outer" style="height: 300px; width: 50vw; background-color: lightcyan;">
+            <div id="inner" style="width: 50%; height: 50%; background-color: lightseagreen;"></div>
+        </div>    
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/viewport-percentage-compute-box-width.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (160158 => 160159)


--- trunk/Source/WebCore/ChangeLog	2013-12-05 04:35:49 UTC (rev 160158)
+++ trunk/Source/WebCore/ChangeLog	2013-12-05 05:11:06 UTC (rev 160159)
@@ -1,3 +1,27 @@
+2013-12-04  Gurpreet Kaur  <[email protected]>
+
+        % unit heights don't work if parent block height is set in vh
+        https://bugs.webkit.org/show_bug.cgi?id=118516
+
+        Reviewed by Simon Fraser.
+
+        From Blink r156449 by <[email protected]>
+
+        An element having height as percentage needs to have the
+        containingblock's height or availableheight to calculate its
+        own height. The containing block having a height set in vh
+        unit was not being considered for calculating the child's
+        height.
+
+        Tests: fast/css/viewport-percentage-compute-box-height.html
+               fast/css/viewport-percentage-compute-box-width.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        Correct child's height(in pecentage) was not being calculated
+        incase of parent having height set in vh unit. Added condition
+        to calculate the containing block height in terms of viewport size.
+
 2013-12-04  Roger Fong  <[email protected]>
 
         [Windows] Unreviewed build fix. Copy headers from rendering/line to build directory.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (160158 => 160159)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-12-05 04:35:49 UTC (rev 160158)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-12-05 05:11:06 UTC (rev 160159)
@@ -2729,6 +2729,17 @@
             LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
             availableHeight = std::max<LayoutUnit>(0, contentBoxHeight);
         }
+    } else if (cbstyle.logicalHeight().isViewportPercentage()) {
+        LayoutUnit heightWithScrollbar = valueForLength(cbstyle.logicalHeight(), 0, &view());
+        if (heightWithScrollbar != -1) {
+            LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(heightWithScrollbar);
+            // We need to adjust for min/max height because this method does 
+            // not handle the min/max of the current block, its caller does.
+            // So the return value from the recursive call will not have been
+            // adjusted yet.
+            LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
+            availableHeight = std::max<LayoutUnit>(0, contentBoxHeight);
+        }
     } else if (isOutOfFlowPositionedWithSpecifiedHeight) {
         // Don't allow this to affect the block' height() member variable, since this
         // can get called while the block is still laying out its kids.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to