LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2006 04:53:11 +0000 (04:53 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2006 04:53:11 +0000 (04:53 +0000)
        Reviewed by Maciej.

        Test case for
        <http://bugzilla.opendarwin.org/show_bug.cgi?id=9753>
        SVG with width and height 100% leaves room for scrollbar on the right.

        * svg/custom/width-full-percentage-expected.txt: Added.
        * svg/custom/width-full-percentage-expected.checksum: Added.
        * svg/custom/width-full-percentage-expected.png: Added.
        * svg/custom/width-full-percentage.svg: Added.

WebCore:

        Reviewed by Maciej.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9753
        SVG with width and height 100% leaves room for scrollbar on the right.

        Relayout children of svg containers, except svg shapes that do not depend on percentages.

        * kcanvas/RenderPath.cpp: (WebCore::RenderPath::hasPercentageValues):
        * kcanvas/RenderPath.h:
        * kcanvas/RenderSVGContainer.cpp: (WebCore::RenderSVGContainer::layout):
        * ksvg2/svg/SVGCircleElement.cpp: (SVGCircleElement::hasPercentageValues):
        * ksvg2/svg/SVGCircleElement.h:
        * ksvg2/svg/SVGEllipseElement.cpp: (WebCore::SVGEllipseElement::hasPercentageValues):
        * ksvg2/svg/SVGEllipseElement.h:
        * ksvg2/svg/SVGLineElement.cpp: (SVGLineElement::hasPercentageValues):
        * ksvg2/svg/SVGLineElement.h:
        * ksvg2/svg/SVGRectElement.cpp: (WebCore::SVGRectElement::hasPercentageValues):
        * ksvg2/svg/SVGRectElement.h:
        * ksvg2/svg/SVGStyledElement.h: (WebCore::SVGStyledElement::hasPercentageValues):

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/custom/width-full-percentage-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/width-full-percentage-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/width-full-percentage-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/width-full-percentage.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/kcanvas/RenderPath.cpp
WebCore/kcanvas/RenderPath.h
WebCore/kcanvas/RenderSVGContainer.cpp
WebCore/ksvg2/svg/SVGCircleElement.cpp
WebCore/ksvg2/svg/SVGCircleElement.h
WebCore/ksvg2/svg/SVGEllipseElement.cpp
WebCore/ksvg2/svg/SVGEllipseElement.h
WebCore/ksvg2/svg/SVGLineElement.cpp
WebCore/ksvg2/svg/SVGLineElement.h
WebCore/ksvg2/svg/SVGRectElement.cpp
WebCore/ksvg2/svg/SVGRectElement.h
WebCore/ksvg2/svg/SVGStyledElement.h

index 272da63e22a6f0b5a42dc8a4f5c1b800323e5143..9ab1e5f5bbb07d2a71e7be1693768d47de951ceb 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-10  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        Test case for
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=9753>
+        SVG with width and height 100% leaves room for scrollbar on the right.
+
+        * svg/custom/width-full-percentage-expected.txt: Added.
+        * svg/custom/width-full-percentage-expected.checksum: Added.
+        * svg/custom/width-full-percentage-expected.png: Added.
+        * svg/custom/width-full-percentage.svg: Added.
+
 2006-07-27  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/svg/custom/width-full-percentage-expected.checksum b/LayoutTests/svg/custom/width-full-percentage-expected.checksum
new file mode 100644 (file)
index 0000000..7f80576
--- /dev/null
@@ -0,0 +1 @@
+ddfd89ec76d0749be2458ad13421bd5e
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/width-full-percentage-expected.png b/LayoutTests/svg/custom/width-full-percentage-expected.png
new file mode 100644 (file)
index 0000000..adfa98b
Binary files /dev/null and b/LayoutTests/svg/custom/width-full-percentage-expected.png differ
diff --git a/LayoutTests/svg/custom/width-full-percentage-expected.txt b/LayoutTests/svg/custom/width-full-percentage-expected.txt
new file mode 100644 (file)
index 0000000..8a284d0
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (-0.90,-54.05) size 801.80x708.11
+      KCanvasItem {rect} at (0,0) size 800x600 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L800.00,0.00L800.00,600.00L0.00,600.00"]
+      KCanvasItem {circle} at (45.95,-54.05) size 708.11x708.11 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#FF0000]}] [data="M753.55,300.00L752.86,322.20L750.77,344.31L747.29,366.25L742.45,387.93L736.25,409.25L728.73,430.15L719.90,450.54L709.82,470.33L698.52,489.44L686.03,507.81L672.42,525.36L657.73,542.02L642.02,557.73L625.36,572.42L607.81,586.03L589.44,598.52L570.33,609.82L550.54,619.90L530.15,628.73L509.25,636.25L487.93,642.45L466.25,647.29L444.31,650.77L422.20,652.86L400.00,653.55L377.80,652.86L355.69,650.77L333.75,647.29L312.07,642.45L290.75,636.25L269.85,628.73L249.46,619.90L229.67,609.82L210.56,598.52L192.19,586.03L174.64,572.42L157.98,557.73L142.27,542.02L127.58,525.36L113.97,507.81L101.48,489.44L90.18,470.33L80.10,450.54L71.27,430.15L63.75,409.25L57.55,387.93L52.71,366.25L49.23,344.31L47.14,322.20L46.45,300.00L47.14,277.80L49.23,255.69L52.71,233.75L57.55,212.07L63.75,190.75L71.27,169.85L80.10,149.46L90.18,129.67L101.48,110.56L113.97,92.19L127.58,74.64L142.27,57.98L157.98,42.27L174.64,27.58L192.19,13.97L210.56,1.48L229.67,-9.82L249.46,-19.90L269.85,-28.73L290.75,-36.25L312.07,-42.45L333.75,-47.29L355.69,-50.77L377.80,-52.86L400.00,-53.55L422.20,-52.86L444.31,-50.77L466.25,-47.29L487.93,-42.45L509.25,-36.25L530.15,-28.73L550.54,-19.90L570.33,-9.82L589.44,1.48L607.81,13.97L625.36,27.58L642.02,42.27L657.73,57.98L672.42,74.64L686.03,92.19L698.52,110.56L709.82,129.67L719.90,149.46L728.73,169.85L736.25,190.75L742.45,212.07L747.29,233.75L750.77,255.69L752.86,277.80"]
+      KCanvasItem {ellipse} at (-0.50,-0.50) size 801.00x601.00 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#FF0000]}] [data="M800.00,300.00L799.21,318.84L796.85,337.60L792.91,356.21L787.43,374.61L780.42,392.71L771.91,410.44L761.93,427.73L750.52,444.53L737.73,460.75L723.61,476.34L708.21,491.23L691.59,505.36L673.82,518.69L654.97,531.15L635.11,542.71L614.33,553.30L592.70,562.89L570.31,571.45L547.25,578.93L523.61,585.32L499.48,590.57L474.95,594.69L450.13,597.63L425.12,599.41L400.00,600.00L374.88,599.41L349.87,597.63L325.05,594.69L300.52,590.57L276.39,585.32L252.75,578.93L229.69,571.45L207.30,562.89L185.67,553.30L164.89,542.71L145.03,531.15L126.18,518.69L108.41,505.36L91.79,491.23L76.39,476.34L62.27,460.75L49.48,444.53L38.07,427.73L28.09,410.44L19.58,392.71L12.57,374.61L7.09,356.21L3.15,337.60L0.79,318.84L0.00,300.00L0.79,281.16L3.15,262.40L7.09,243.79L12.57,225.39L19.58,207.29L28.09,189.56L38.07,172.27L49.48,155.47L62.27,139.25L76.39,123.66L91.79,108.77L108.41,94.64L126.18,81.31L145.03,68.85L164.89,57.29L185.67,46.70L207.30,37.11L229.69,28.55L252.75,21.07L276.39,14.68L300.52,9.43L325.05,5.31L349.87,2.37L374.88,0.59L400.00,0.00L425.12,0.59L450.13,2.37L474.95,5.31L499.48,9.43L523.61,14.68L547.25,21.07L570.31,28.55L592.70,37.11L614.33,46.70L635.11,57.29L654.97,68.85L673.82,81.31L691.59,94.64L708.21,108.77L723.61,123.66L737.73,139.25L750.52,155.47L761.93,172.27L771.91,189.56L780.42,207.29L787.43,225.39L792.91,243.79L796.85,262.40L799.21,281.16"]
+      KCanvasItem {line} at (-0.90,-1.20) size 801.80x602.40 [stroke={[type=SOLID] [color=#000000] [stroke width=3.00]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L800.00,600.00"]
diff --git a/LayoutTests/svg/custom/width-full-percentage.svg b/LayoutTests/svg/custom/width-full-percentage.svg
new file mode 100644 (file)
index 0000000..b12a8fc
--- /dev/null
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+       <rect fill="green" height="100%" width="100%"/>
+       <circle stroke="blue" fill="red" r="50%" cx="50%" cy="50%"/>
+       <ellipse stroke="blue" fill="red" rx="50%" ry="50%" cx="50%" cy="50%"/>
+        <line stroke="black" fill="black" stroke-width="3" x1="0" y1="0" x2="100%" y2="100%" />
+</svg>
index 195199d2b76d2ae33d576e36735a7c5b4276aa21..34dbde3d3ca022c9e1f475d03be7c6294f055ede 100644 (file)
@@ -1,3 +1,25 @@
+2006-07-27  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9753
+        SVG with width and height 100% leaves room for scrollbar on the right.
+
+        Relayout children of svg containers, except svg shapes that do not depend on percentages.
+
+        * kcanvas/RenderPath.cpp: (WebCore::RenderPath::hasPercentageValues):
+        * kcanvas/RenderPath.h:
+        * kcanvas/RenderSVGContainer.cpp: (WebCore::RenderSVGContainer::layout):
+        * ksvg2/svg/SVGCircleElement.cpp: (SVGCircleElement::hasPercentageValues):
+        * ksvg2/svg/SVGCircleElement.h:
+        * ksvg2/svg/SVGEllipseElement.cpp: (WebCore::SVGEllipseElement::hasPercentageValues):
+        * ksvg2/svg/SVGEllipseElement.h:
+        * ksvg2/svg/SVGLineElement.cpp: (SVGLineElement::hasPercentageValues):
+        * ksvg2/svg/SVGLineElement.h:
+        * ksvg2/svg/SVGRectElement.cpp: (WebCore::SVGRectElement::hasPercentageValues):
+        * ksvg2/svg/SVGRectElement.h:
+        * ksvg2/svg/SVGStyledElement.h: (WebCore::SVGStyledElement::hasPercentageValues):
+
 2006-07-27  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
index 1db716b1b219a8b59ebd89ef1279d225061bb10d..9dfa0c0ec89db3e6b2be90dac24378476b01c5e3 100644 (file)
@@ -43,7 +43,7 @@ public:
     FloatRect strokeBbox;
     AffineTransform matrix;
     IntRect absoluteBounds;
-};        
+};
 
 // RenderPath
 RenderPath::RenderPath(RenderStyle* style, SVGStyledElement* node)
@@ -276,6 +276,11 @@ bool RenderPath::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, H
     return false;
 }
 
+bool RenderPath::hasPercentageValues() const
+{
+    return static_cast<SVGStyledElement*>(element())->hasPercentageValues();
+}
+
 }
 
 // vim:ts=4:noet
index e6c2addf6c17db2b2f915f7d28c3a6974d00e2d2..35dc2b87c119b1245fdec1056d43903a3bcc6447 100644 (file)
@@ -73,6 +73,8 @@ public:
 
     virtual bool nodeAtPoint(NodeInfo&, int x, int y, int tx, int ty, HitTestAction);
 
+    bool hasPercentageValues() const;
+
 protected:
     virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const = 0;
 
index f15daf42a2175f398570b61f729a1cf5a5f69f03..700a23c2085aca134a89d8e5ceeba4a3d4e08636 100644 (file)
@@ -115,6 +115,13 @@ void RenderSVGContainer::layout()
     if (selfNeedsLayout() && checkForRepaint)
         oldBounds = d->absoluteBounds;
 
+    RenderObject* child = firstChild();
+    while (child) {
+        if (!child->isRenderPath() || static_cast<RenderPath*>(child)->hasPercentageValues())
+            child->setNeedsLayout(true);
+        child = child->nextSibling();
+    }
+    RenderContainer::layout();
     calcWidth();
     calcHeight();
 
@@ -122,8 +129,6 @@ void RenderSVGContainer::layout()
 
     if (selfNeedsLayout() && checkForRepaint)
         repaintAfterLayoutIfNeeded(oldBounds, oldBounds);
-        
-    RenderContainer::layout();
 }
 
 void RenderSVGContainer::paint(PaintInfo &paintInfo, int parentX, int parentY)
index b689a63b500877d4c48eae276d806ae459487cab..5a3f6add849b52d7651d0c1e8a1279151d6298e8 100644 (file)
@@ -96,6 +96,16 @@ const SVGStyledElement *SVGCircleElement::pushAttributeContext(const SVGStyledEl
     return restore;
 }
 
+bool SVGCircleElement::hasPercentageValues() const
+{
+    if (cx()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        cy()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        r()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
+        return true;
+
+    return false;
+}
+
 // vim:ts=4:noet
 #endif // SVG_SUPPORT
 
index dd5d6ad998168a409e22b34e20da853d9c3c19d8..243c05f7920cf0a6ab1ec9257b5cf9b91b0f31d1 100644 (file)
@@ -55,6 +55,8 @@ namespace WebCore
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
+        virtual bool hasPercentageValues() const;
+
     private:
         mutable RefPtr<SVGAnimatedLength> m_cx;
         mutable RefPtr<SVGAnimatedLength> m_cy;
index fc36a540e12496bb6c6da98f9ddeb4061b5494a5..3d8fb49a65752d93a07ee79767d49d1b7c4844dc 100644 (file)
@@ -104,6 +104,17 @@ const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledE
     return restore;
 }
 
+bool SVGEllipseElement::hasPercentageValues() const
+{
+    if (cx()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        cy()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        rx()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        ry()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
+        return true;
+
+    return false;
+}
+
 }
 
 // vim:ts=4:noet
index 613bb27bddbfe7b2bdc9f6c352350904965e0645..46d5d60367b86f4697c61c46174387bd4e1f77ce 100644 (file)
@@ -56,6 +56,8 @@ namespace WebCore
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
+        virtual bool hasPercentageValues() const;
+
     private:
         mutable RefPtr<SVGAnimatedLength> m_cx;
         mutable RefPtr<SVGAnimatedLength> m_cy;
index c97ffd2b9a3d886f982ecb7b061b43f239666123..54ae1cfe85bb5c5109f37acf8a23eee0656f87d1 100644 (file)
@@ -104,6 +104,17 @@ const SVGStyledElement *SVGLineElement::pushAttributeContext(const SVGStyledElem
     return restore;
 }
 
+bool SVGLineElement::hasPercentageValues() const
+{
+    if (x1()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        y1()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        x2()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        y2()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
+        return true;
+
+    return false;
+}
+
 // vim:ts=4:noet
 #endif // SVG_SUPPORT
 
index d24f8a57b7815168ae7cb1f129f0f058083b9c85..8dd404d1975e966ac951914a10fb05456144c18b 100644 (file)
@@ -56,6 +56,8 @@ namespace WebCore
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
+        virtual bool hasPercentageValues() const;
+
     private:
         mutable RefPtr<SVGAnimatedLength> m_x1;
         mutable RefPtr<SVGAnimatedLength> m_y1;
index c3671a4071d840936ff6ac9a7978ae15b1c6b9e5..33a239effd7a1ed87547d24e9486863e35a0be5e 100644 (file)
@@ -131,6 +131,19 @@ const SVGStyledElement *SVGRectElement::pushAttributeContext(const SVGStyledElem
     return restore;
 }
 
+bool SVGRectElement::hasPercentageValues() const
+{
+    if (x()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        y()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        width()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        height()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        rx()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
+        ry()->baseVal()->unitType() == SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
+        return true;
+
+    return false;
+}
+
 }
 
 // vim:ts=4:noet
index a99678c13b0d059d0e6c819e54aeef458c6b9286..7100596632235d679b4b2f5032d9a252d9ef0c76 100644 (file)
@@ -60,6 +60,8 @@ namespace WebCore
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
+        virtual bool hasPercentageValues() const;
+
     private:
         mutable RefPtr<SVGAnimatedLength> m_x;
         mutable RefPtr<SVGAnimatedLength> m_y;
index 690905f7ced1b877b01b731d9445bd1b80097f4d..6fec6c27687e80a92ef8f4f3e94507059081a726 100644 (file)
@@ -68,6 +68,8 @@ namespace WebCore
         // of the 'rect'. This function also returns the old attribute context, to be able to restore it...
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
+        virtual bool hasPercentageValues() const { return false; }
+
     protected:
         void updateCanvasItem(); // Handles "path data" object changes... (not for style/transform!)