2007-12-15 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2007 20:03:38 +0000 (20:03 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2007 20:03:38 +0000 (20:03 +0000)
        Reviewed by Oliver.

        Width of SVG elements not applied to container elements
        http://bugs.webkit.org/show_bug.cgi?id=16305
        Added calcPrefWidths for RenderSVGRoot (copied from RenderReplaced)
        This is caused by poor factoring in the render tree.  RenderContainer probably should be a template.

        svg/css/css-box-min-width.html

        * rendering/RenderSVGRoot.cpp:
        (WebCore::RenderSVGRoot::calcPrefWidths): Added.
        * rendering/RenderSVGRoot.h:
        * css/SVGCSSStyleSelector::applySVGProperty: fixed ASSERT in debug builds

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/css/css-box-min-width-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/css-box-min-width-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/css-box-min-width-expected.txt [new file with mode: 0644]
LayoutTests/svg/css/css-box-min-width.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/SVGCSSStyleSelector.cpp
WebCore/rendering/RenderSVGImage.cpp
WebCore/rendering/RenderSVGRoot.cpp
WebCore/rendering/RenderSVGRoot.h

index f56a95b..a692e60 100644 (file)
@@ -1,3 +1,15 @@
+2007-12-15  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Oliver.
+        
+        Width of SVG elements not applied to container elements
+        http://bugs.webkit.org/show_bug.cgi?id=16305
+
+        * platform/mac/svg/css/css-box-min-width-expected.checksum: Added.
+        * platform/mac/svg/css/css-box-min-width-expected.png: Added.
+        * platform/mac/svg/css/css-box-min-width-expected.txt: Added.
+        * svg/css/css-box-min-width.html: Added.
+
 2007-12-15  Alp Toker  <alp@atoker.com>
 
         http://bugs.webkit.org/show_bug.cgi?id=16449
diff --git a/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.checksum b/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.checksum
new file mode 100644 (file)
index 0000000..d45f9c6
--- /dev/null
@@ -0,0 +1 @@
+658bb899a309b09540fe1d7868835e58
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.png b/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.png
new file mode 100644 (file)
index 0000000..12d9a5f
Binary files /dev/null and b/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.txt b/LayoutTests/platform/mac/svg/css/css-box-min-width-expected.txt
new file mode 100644 (file)
index 0000000..09697f2
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (floating) {DIV} at (0,0) size 110x110 [border: (5px solid #000000)]
+        RenderSVGRoot {svg} at (13,13) size 100x100
+          RenderPath {rect} at (13,13) size 100x100 [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+      RenderBlock {P} at (0,110) size 784x18
+        RenderText {#text} at (0,0) size 435x18
+          text run at (0,0) width 435: "You should see a solid 5px black border around a 100x100 blue rect."
diff --git a/LayoutTests/svg/css/css-box-min-width.html b/LayoutTests/svg/css/css-box-min-width.html
new file mode 100644 (file)
index 0000000..a2c32db
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+  <script type="text/javascript">
+    function draw() {
+      var NS = "http://www.w3.org/2000/svg";
+      var s = document.createElementNS(NS, "svg");
+      s.setAttribute("width", 100);
+      s.setAttribute("height", 100);
+      
+      var rect = document.createElementNS(NS, "rect");
+      rect.setAttribute("width", "100%");
+      rect.setAttribute("height", "100%");
+      rect.setAttribute("fill", "blue");
+      
+      s.appendChild(rect);
+      
+      document.getElementById("d").appendChild(s);
+   }
+  </script>
+</head>
+
+<body onload="draw()">
+  <div style="border: 5px solid black; float: left;" id="d"></div>
+  <p style="clear: left;">You should see a solid 5px black border around a 100x100 blue rect.</p>
+</body>
+</html>
index 6221bc6..dcecb7f 100644 (file)
@@ -1,3 +1,19 @@
+2007-12-15  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Oliver.
+        
+        Width of SVG elements not applied to container elements
+        http://bugs.webkit.org/show_bug.cgi?id=16305
+        Added calcPrefWidths for RenderSVGRoot (copied from RenderReplaced)
+        This is caused by poor factoring in the render tree.  RenderContainer probably should be a template.
+
+        svg/css/css-box-min-width.html
+
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::calcPrefWidths): Added.
+        * rendering/RenderSVGRoot.h:
+        * css/SVGCSSStyleSelector::applySVGProperty: fixed ASSERT in debug builds
+
 2007-12-15  David Kilzer  <ddkilzer@apple.com>
 
         Fix comment after isSafeScript() was renamed to allowsAccessFrom().
index e3b5014..5da593f 100644 (file)
@@ -597,6 +597,10 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
 
             break;
         }
+        case CSS_PROP_ENABLE_BACKGROUND:
+            // Silently ignoring this property for now
+            // http://bugs.webkit.org/show_bug.cgi?id=6022
+            break;
         default:
             // If you crash here, it's because you added a css property and are not handling it
             // in either this switch statement or the one in CSSStyleSelector::applyProperty
index 6d8b4d6..3ed861c 100644 (file)
@@ -151,10 +151,10 @@ void RenderSVGImage::layout()
     
     calcWidth();
     calcHeight();
-        
+
     if (checkForRepaint)
         repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox);
-    
+
     setNeedsLayout(false);
 }
 
index aa2f2ca..0684b08 100644 (file)
@@ -61,6 +61,20 @@ short RenderSVGRoot::baselinePosition(bool b, bool isRootLineBox) const
     return height() + marginTop() + marginBottom();
 }
 
+void RenderSVGRoot::calcPrefWidths()
+{
+    ASSERT(prefWidthsDirty());
+
+    int width = calcReplacedWidth() + paddingLeft() + paddingRight() + borderLeft() + borderRight();
+    if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) {
+        m_minPrefWidth = 0;
+        m_maxPrefWidth = width;
+    } else
+        m_minPrefWidth = m_maxPrefWidth = width;
+
+    setPrefWidthsDirty(false);
+}
+
 void RenderSVGRoot::layout()
 {
     ASSERT(needsLayout());
index 5f4e4b0..1e136b3 100644 (file)
@@ -42,6 +42,7 @@ public:
 
     virtual short lineHeight(bool b, bool isRootLineBox = false) const;
     virtual short baselinePosition(bool b, bool isRootLineBox = false) const;
+    virtual void calcPrefWidths();
     
     virtual void layout();
     virtual void paint(PaintInfo&, int parentX, int parentY);