Title: [111279] trunk
Revision
111279
Author
[email protected]
Date
2012-03-19 17:37:32 -0700 (Mon, 19 Mar 2012)

Log Message

Relative-height block SVG root not layed out on container height change
https://bugs.webkit.org/show_bug.cgi?id=81513

Patch by Florin Malita <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (111278 => 111279)


--- trunk/LayoutTests/ChangeLog	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/LayoutTests/ChangeLog	2012-03-20 00:37:32 UTC (rev 111279)
@@ -1,3 +1,13 @@
+2012-03-19  Florin Malita  <[email protected]>
+
+        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  <[email protected]>
 
         Four fast/canvas tests are flaky (fail on bots, not locally, or vice versa)

Added: trunk/LayoutTests/svg/custom/svg-percent-scale-block-expected.html (0 => 111279)


--- trunk/LayoutTests/svg/custom/svg-percent-scale-block-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-percent-scale-block-expected.html	2012-03-20 00:37:32 UTC (rev 111279)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <script src=""
+  <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>

Added: trunk/LayoutTests/svg/custom/svg-percent-scale-block.html (0 => 111279)


--- trunk/LayoutTests/svg/custom/svg-percent-scale-block.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-percent-scale-block.html	2012-03-20 00:37:32 UTC (rev 111279)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Test for https://bugs.webkit.org/show_bug.cgi?id=79490</title>
+  <script src=""
+  <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>

Modified: trunk/Source/WebCore/ChangeLog (111278 => 111279)


--- trunk/Source/WebCore/ChangeLog	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/ChangeLog	2012-03-20 00:37:32 UTC (rev 111279)
@@ -1,3 +1,39 @@
+2012-03-19  Florin Malita  <[email protected]>
+
+        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  <[email protected]>
 
         Assertion failure in RenderBlock::addChildIgnoringAnonymousColumnBlocks when running fullscreen/full-screen-twice-crash.html 

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (111278 => 111279)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-20 00:37:32 UTC (rev 111279)
@@ -2264,8 +2264,7 @@
         // 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.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (111278 => 111279)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-20 00:37:32 UTC (rev 111279)
@@ -4034,4 +4034,11 @@
             || style()->minHeight().isPercent() || style()->minWidth().isPercent();
 }
 
+bool RenderBox::hasRelativeLogicalHeight() const
+{
+    return style()->logicalHeight().isPercent()
+            || style()->logicalMinHeight().isPercent()
+            || style()->logicalMaxHeight().isPercent();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderBox.h (111278 => 111279)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-03-20 00:37:32 UTC (rev 111279)
@@ -461,6 +461,7 @@
     void clearCachedSizeForOverflowClip();
 
     virtual bool hasRelativeDimensions() const;
+    virtual bool hasRelativeLogicalHeight() const;
 
     bool hasHorizontalLayoutOverflow() const
     {

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (111278 => 111279)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2012-03-20 00:37:32 UTC (rev 111279)
@@ -117,7 +117,10 @@
     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);
         }
     }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (111278 => 111279)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2012-03-20 00:37:32 UTC (rev 111279)
@@ -429,6 +429,14 @@
     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)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h (111278 => 111279)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h	2012-03-20 00:33:00 UTC (rev 111278)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h	2012-03-20 00:37:32 UTC (rev 111279)
@@ -54,6 +54,7 @@
     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; }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to