Relative-height block SVG root not layed out on container height change
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 00:37:32 +0000 (00:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 00:37:32 +0000 (00:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81513

Patch by Florin Malita <fmalita@google.com> on 2012-03-19
Reviewed by Dirk Schulze.

Source/WebCore:

Tests: svg/custom/svg-percent-scale-block-expected.html
       svg/custom/svg-percent-scale-block.html

A couple of places still have style()->logical{Min,Max,}Height percent checks,
which do not work for SVG elements. This patch adds a virtual hasRelativeLogicalHeight()
RenderBox method to replace the explicit style checks.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::layoutBlockChildren):
Use virtual hasRelativeLogicalHeight() instead of logical height style checks.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::hasRelativeLogicalHeight):
(WebCore):
* rendering/RenderBox.h:
(RenderBox):
Add virtual hasRelativeLogicalHeight().

* rendering/RenderView.cpp:
(WebCore::RenderView::layout):
Use virtual hasRelativeLogicalHeight() instead of logical height style checks, if possible.

* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::hasRelativeLogicalHeight):
(WebCore):
* rendering/svg/RenderSVGRoot.h:
(RenderSVGRoot):
Add hasRelativeLogicalHeight() override.

LayoutTests:

* svg/custom/svg-percent-scale-block-expected.html: Added.
* svg/custom/svg-percent-scale-block.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/svg-percent-scale-block-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/svg-percent-scale-block.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h

index 47bd6dcc42355641e81c7a0e7303c8f5ece93f79..36e905afb6bbc6e1908bfc338d2d8c74f9508269 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-19  Florin Malita  <fmalita@google.com>
+
+        Relative-height block SVG root not layed out on container height change
+        https://bugs.webkit.org/show_bug.cgi?id=81513
+
+        Reviewed by Dirk Schulze.
+
+        * svg/custom/svg-percent-scale-block-expected.html: Added.
+        * svg/custom/svg-percent-scale-block.html: Added.
+
 2012-03-19  Tim Horton  <timothy_horton@apple.com>
 
         Four fast/canvas tests are flaky (fail on bots, not locally, or vice versa)
diff --git a/LayoutTests/svg/custom/svg-percent-scale-block-expected.html b/LayoutTests/svg/custom/svg-percent-scale-block-expected.html
new file mode 100644 (file)
index 0000000..b9b5b6e
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <script src="../../fast/repaint/resources/repaint.js"></script>
+  <script>
+    function repaintTest()
+    {
+      document.getElementById('resize-target').style.height = '200px';
+    }
+  </script>
+</head>
+
+<body style="margin: 0; padding: 0; overflow: hidden;" onload="runRepaintTest()">
+  <div id="resize-target" style="width: 400px; height: 400px; position: absolute;"></div>  
+  <div style="width: 100px; height: 100px; position: absolute; background-color: green;"></div>
+</body>
+</html>
diff --git a/LayoutTests/svg/custom/svg-percent-scale-block.html b/LayoutTests/svg/custom/svg-percent-scale-block.html
new file mode 100644 (file)
index 0000000..d0e2207
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Test for https://bugs.webkit.org/show_bug.cgi?id=79490</title>
+  <script src="../../fast/repaint/resources/repaint.js"></script>
+  <script>
+    function repaintTest()
+    {
+      document.getElementById('resize-target').style.height = '200px';
+    }
+  </script>
+</head>
+
+<body style="margin: 0; padding: 0; overflow: hidden;" onload="runRepaintTest()">
+  <div id="resize-target" style="width: 400px; height: 400px; position: absolute;">
+    <!-- After vertical window resizing, this SVG element should not be visible -->
+    <svg width="25%" height="50%" xmlns="http://www.w3.org/2000/svg" style="display: block;">
+      <rect fill="red" width="100%" height="100%"></rect>
+    </svg>
+  </div>
+
+  <div style="width: 100px; height: 100px; position: absolute; background-color: green;"></div>
+</body>
+</html>
index 688db0c13b85045c8db2943395e01854939b624a..6051729aac8420aeeb7c134f56e44c38d91a174e 100644 (file)
@@ -1,3 +1,39 @@
+2012-03-19  Florin Malita  <fmalita@google.com>
+
+        Relative-height block SVG root not layed out on container height change
+        https://bugs.webkit.org/show_bug.cgi?id=81513
+
+        Reviewed by Dirk Schulze.
+
+        Tests: svg/custom/svg-percent-scale-block-expected.html
+               svg/custom/svg-percent-scale-block.html
+
+        A couple of places still have style()->logical{Min,Max,}Height percent checks,
+        which do not work for SVG elements. This patch adds a virtual hasRelativeLogicalHeight()
+        RenderBox method to replace the explicit style checks.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::layoutBlockChildren):
+        Use virtual hasRelativeLogicalHeight() instead of logical height style checks.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::hasRelativeLogicalHeight):
+        (WebCore):
+        * rendering/RenderBox.h:
+        (RenderBox):
+        Add virtual hasRelativeLogicalHeight().
+
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout):
+        Use virtual hasRelativeLogicalHeight() instead of logical height style checks, if possible.
+
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::hasRelativeLogicalHeight):
+        (WebCore):
+        * rendering/svg/RenderSVGRoot.h:
+        (RenderSVGRoot):
+        Add hasRelativeLogicalHeight() override.
+
 2012-03-19  Jer Noble  <jer.noble@apple.com>
 
         Assertion failure in RenderBlock::addChildIgnoringAnonymousColumnBlocks when running fullscreen/full-screen-twice-crash.html 
index bdcc1645c585452aeec1fc9fe3ab870c66749ee9..9a4220ceafce5eb8f31e472c1bbed00213fe62f5 100755 (executable)
@@ -2264,8 +2264,7 @@ void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloa
         // Make sure we layout children if they need it.
         // 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.
-        RenderStyle* childStyle = child->style();
-        if (relayoutChildren || ((childStyle->logicalHeight().isPercent() || childStyle->logicalMinHeight().isPercent() || childStyle->logicalMaxHeight().isPercent()) && !isRenderView()))
+        if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView()))
             child->setChildNeedsLayout(true, false);
 
         // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
index ab2a449d21941f8d4201e588fd8837192ee8f409..1fb573b44c953ac383fbe0f716d62ffd65ac2a9b 100644 (file)
@@ -4034,4 +4034,11 @@ bool RenderBox::hasRelativeDimensions() const
             || style()->minHeight().isPercent() || style()->minWidth().isPercent();
 }
 
+bool RenderBox::hasRelativeLogicalHeight() const
+{
+    return style()->logicalHeight().isPercent()
+            || style()->logicalMinHeight().isPercent()
+            || style()->logicalMaxHeight().isPercent();
+}
+
 } // namespace WebCore
index 0af3f6d60f05bd6333e6ecaba249e253ebe75c42..d6e680f211b230744ed43decd4311c10af11b45a 100644 (file)
@@ -461,6 +461,7 @@ public:
     void clearCachedSizeForOverflowClip();
 
     virtual bool hasRelativeDimensions() const;
+    virtual bool hasRelativeLogicalHeight() const;
 
     bool hasHorizontalLayoutOverflow() const
     {
index cd3893a555d60f1ab89f26163e70e427a258dca4..33396d6d5f6450656c9c90fbc52d7f453cc0e559 100644 (file)
@@ -117,7 +117,10 @@ void RenderView::layout()
     if (relayoutChildren) {
         setChildNeedsLayout(true, false);
         for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
-            if (child->style()->logicalHeight().isPercent() || child->style()->logicalMinHeight().isPercent() || child->style()->logicalMaxHeight().isPercent())
+            if ((child->isBox() && toRenderBox(child)->hasRelativeLogicalHeight())
+                    || child->style()->logicalHeight().isPercent()
+                    || child->style()->logicalMinHeight().isPercent()
+                    || child->style()->logicalMaxHeight().isPercent())
                 child->setChildNeedsLayout(true, false);
         }
     }
index ce32c787660e8693d8630770345786a4711c0a83..d6c30c7cf4ff1bba219be7b24964dff95a7e88d4 100644 (file)
@@ -429,6 +429,14 @@ bool RenderSVGRoot::hasRelativeDimensions() const
     return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent() || svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties).isPercent();
 }
 
+bool RenderSVGRoot::hasRelativeLogicalHeight() const
+{
+    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
+    ASSERT(svg);
+
+    return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent();
+}
+
 }
 
 #endif // ENABLE(SVG)
index e2cdeb5ccdf2f70d3e2f04f768422d7991492130..0ce32573a65392e57e0ef37247c0fcf7004a9772 100644 (file)
@@ -54,6 +54,7 @@ public:
     void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; }
 
     virtual bool hasRelativeDimensions() const;
+    virtual bool hasRelativeLogicalHeight() const;
 
     // localToBorderBoxTransform maps local SVG viewport coordinates to local CSS box coordinates.  
     const AffineTransform& localToBorderBoxTransform() const { return m_localToBorderBoxTransform; }