Title: [141492] trunk
Revision
141492
Author
[email protected]
Date
2013-01-31 15:12:05 -0800 (Thu, 31 Jan 2013)

Log Message

CSS3's vh attribute is not adjusting while browser resizes
https://bugs.webkit.org/show_bug.cgi?id=86418

Patch by Uday Kiran <[email protected]> on 2013-01-31
Reviewed by Antti Koivisto.

Source/WebCore:

Elements with viewport percentage units needs layout whenever
viewport size changes. Check for viewport percentage unit
was missing for height.

Test: css3/viewport-percentage-lengths/vh-resize.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::hasViewportPercentageLogicalHeight): Check if style
is specified in viewport percentage units.
(WebCore):
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderView.cpp:
(WebCore::RenderView::layout): Elements with viewport percentage units
needs relayout when viewport size changes.

LayoutTests:

Added test to check element with vh units gets resized when
viewport height is increased or decreased.

* css3/viewport-percentage-lengths/vh-resize-expected.html: Added.
* css3/viewport-percentage-lengths/vh-resize.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141491 => 141492)


--- trunk/LayoutTests/ChangeLog	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/LayoutTests/ChangeLog	2013-01-31 23:12:05 UTC (rev 141492)
@@ -1,3 +1,16 @@
+2013-01-31  Uday Kiran  <[email protected]>
+
+        CSS3's vh attribute is not adjusting while browser resizes
+        https://bugs.webkit.org/show_bug.cgi?id=86418
+
+        Reviewed by Antti Koivisto.
+
+        Added test to check element with vh units gets resized when
+        viewport height is increased or decreased.
+
+        * css3/viewport-percentage-lengths/vh-resize-expected.html: Added.
+        * css3/viewport-percentage-lengths/vh-resize.html: Added.
+
 2013-01-31  Jessie Berlin  <[email protected]>
 
         Rebaseline after r141459.

Added: trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize-expected.html (0 => 141492)


--- trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize-expected.html	2013-01-31 23:12:05 UTC (rev 141492)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Reference test for bug 86418</title>
+</head>
+<frameset rows="300px,*">
+<frame src=""
+    <style>
+    div {
+        width: 50vh;
+        height: 50vh;
+        background: #36C;
+    }</style>
+    <div></div>
+<p>Bug 86418: This tests that on resizing initial containing block vertically,
+ element with 'vh' length gets resized.</p>
+<p>Blue square should be half the height of frame height.</p>
+"></frame>
+<frame src=""
+</frameset>
+</html>

Added: trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize.html (0 => 141492)


--- trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize.html	                        (rev 0)
+++ trunk/LayoutTests/css3/viewport-percentage-lengths/vh-resize.html	2013-01-31 23:12:05 UTC (rev 141492)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function init() {
+      if (!window.testRunner)
+          return;
+      // Move the resizer 400 pixels down.
+      eventSender.mouseMoveTo(100, 400);
+      eventSender.mouseDown();
+      eventSender.mouseMoveTo(100, 200);
+      eventSender.mouseUp();
+
+      // Also test when frame height is increased.
+      eventSender.mouseMoveTo(100, 200);
+      eventSender.mouseDown();
+      eventSender.mouseMoveTo(100, 300);
+      eventSender.mouseUp();
+}
+window._onload_ = init;
+</script>
+</head>
+<frameset rows="400px,*">
+<frame src=""
+    <style>
+    div {
+        width: 50vh;
+        height: 50vh;
+        background: #36C;
+    }</style>
+<div></div>
+<p>Bug 86418: This tests that on resizing initial containing block vertically,
+ element with 'vh' length gets resized.</p>
+<p>Blue square should be half the height of frame height.</p>
+"></frame>
+<frame src=""
+</frameset>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (141491 => 141492)


--- trunk/Source/WebCore/ChangeLog	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/Source/WebCore/ChangeLog	2013-01-31 23:12:05 UTC (rev 141492)
@@ -1,3 +1,28 @@
+2013-01-31  Uday Kiran  <[email protected]>
+
+        CSS3's vh attribute is not adjusting while browser resizes
+        https://bugs.webkit.org/show_bug.cgi?id=86418
+
+        Reviewed by Antti Koivisto.
+
+        Elements with viewport percentage units needs layout whenever
+        viewport size changes. Check for viewport percentage unit
+        was missing for height.
+
+        Test: css3/viewport-percentage-lengths/vh-resize.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::hasViewportPercentageLogicalHeight): Check if style
+        is specified in viewport percentage units.
+        (WebCore):
+        * rendering/RenderBox.h:
+        (RenderBox):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout): Elements with viewport percentage units
+        needs relayout when viewport size changes.
+
 2013-01-31  Anton Vayvod  <[email protected]>
 
         TextAutosizing: refactor the cluster related method parameters into a single struct.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (141491 => 141492)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-31 23:12:05 UTC (rev 141492)
@@ -2334,7 +2334,7 @@
 {
     // FIXME: Technically percentage height objects only need a relayout if their percentage isn't going to be turned into
     // an auto value. Add a method to determine this, so that we can avoid the relayout.
-    if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView()))
+    if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView()) || child->hasViewportPercentageLogicalHeight())
         child->setChildNeedsLayout(true, MarkOnlyThis);
 
     // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (141491 => 141492)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-31 23:12:05 UTC (rev 141492)
@@ -4402,6 +4402,13 @@
             || style()->logicalMaxHeight().isPercent();
 }
 
+bool RenderBox::hasViewportPercentageLogicalHeight() const
+{
+    return style()->logicalHeight().isViewportPercentage()
+        || style()->logicalMinHeight().isViewportPercentage()
+        || style()->logicalMaxHeight().isViewportPercentage();
+}
+
 static void markBoxForRelayoutAfterSplit(RenderBox* box)
 {
     // FIXME: The table code should handle that automatically. If not,

Modified: trunk/Source/WebCore/rendering/RenderBox.h (141491 => 141492)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-01-31 23:12:05 UTC (rev 141492)
@@ -547,6 +547,7 @@
 
     virtual bool hasRelativeDimensions() const;
     virtual bool hasRelativeLogicalHeight() const;
+    virtual bool hasViewportPercentageLogicalHeight() const;
 
     bool hasHorizontalLayoutOverflow() const
     {

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (141491 => 141492)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2013-01-31 22:56:47 UTC (rev 141491)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2013-01-31 23:12:05 UTC (rev 141492)
@@ -187,10 +187,13 @@
     if (relayoutChildren) {
         setChildNeedsLayout(true, MarkOnlyThis);
         for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
-            if ((child->isBox() && toRenderBox(child)->hasRelativeLogicalHeight())
+            if ((child->isBox() && (toRenderBox(child)->hasRelativeLogicalHeight() || toRenderBox(child)->hasViewportPercentageLogicalHeight()))
                     || child->style()->logicalHeight().isPercent()
                     || child->style()->logicalMinHeight().isPercent()
-                    || child->style()->logicalMaxHeight().isPercent())
+                    || child->style()->logicalMaxHeight().isPercent()
+                    || child->style()->logicalHeight().isViewportPercentage()
+                    || child->style()->logicalMinHeight().isViewportPercentage()
+                    || child->style()->logicalMaxHeight().isViewportPercentage())
                 child->setChildNeedsLayout(true, MarkOnlyThis);
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to