<svg> fails to use explicit width and height inside <html> inside IFRAME
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2011 18:56:16 +0000 (18:56 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2011 18:56:16 +0000 (18:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=64823

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Checking that embedded SVG is in an SVG document before negotiating size
with the host document.

Test: svg/as-object/svg-embedded-in-html-in-iframe.html

* rendering/svg/RenderSVGRoot.cpp:
(WebCore::isEmbeddedThroughFrameContainingSVGDocument):
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight):

LayoutTests:

Fixing a bug where SVG negotiated size when embedded in html inside an iframe.

* platform/chromium/test_expectations.txt: Will update with results on other platforms.
* platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png: Added.
* platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.txt: Added.
* svg/as-object/svg-embedded-in-html-in-iframe.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/svg/as-object/svg-embedded-in-html-in-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGRoot.cpp

index be564683b3708a00af24e31a8a68959fd01494aa..8e56b0c97e390b5c0b55fcf4b5e744ae20dd6f9a 100644 (file)
@@ -1,3 +1,17 @@
+2011-10-24  Levi Weintraub  <leviw@chromium.org>
+
+        <svg> fails to use explicit width and height inside <html> inside IFRAME
+        https://bugs.webkit.org/show_bug.cgi?id=64823
+
+        Reviewed by Nikolas Zimmermann.
+
+        Fixing a bug where SVG negotiated size when embedded in html inside an iframe.
+
+        * platform/chromium/test_expectations.txt: Will update with results on other platforms.
+        * platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png: Added.
+        * platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.txt: Added.
+        * svg/as-object/svg-embedded-in-html-in-iframe.html: Added.
+
 2011-10-24  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Unreviewed gardening rebaselining.
index 77aaad5ce54d2c1a63b71f4fddaa4052250aa0a0..e69bd047f68ddc0aab9ca3c4ee3e3555ce4f34a7 100644 (file)
@@ -3819,3 +3819,7 @@ BUGWK70704 SNOWLEOPARD : fast/css/focus-ring-multiline-writingmode-vertical.html
 BUGWK70704 SNOWLEOPARD : fast/ruby/base-shorter-than-text.html = IMAGE+TEXT PASS
 BUGWK70704 SNOWLEOPARD : fast/writing-mode/fallback-orientation.html = TEXT
 BUGWK70704 SNOWLEOPARD : fast/backgrounds/background-leakage-transforms.html = TEXT
+
+// Will rebaseline
+BUGLEVIW : svg/as-object/svg-embedded-in-html-in-iframe.html = FAIL
+
diff --git a/LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png b/LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png
new file mode 100644 (file)
index 0000000..b252262
Binary files /dev/null and b/LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.txt b/LayoutTests/platform/mac/svg/as-object/svg-embedded-in-html-in-iframe-expected.txt
new file mode 100644 (file)
index 0000000..d8c07ae
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x170
+  RenderBlock {HTML} at (0,0) size 800x170
+    RenderBody {BODY} at (8,8) size 784x154
+      RenderPartObject {IFRAME} at (0,0) size 784x150
+        layer at (0,0) size 784x150
+          RenderView at (0,0) size 784x150
+        layer at (0,0) size 784x120
+          RenderBlock {HTML} at (0,0) size 784x120
+            RenderBody {BODY} at (8,8) size 768x104
+              RenderSVGRoot {svg} at (8,8) size 100x100
+                RenderSVGPath {circle} at (8,8) size 100x100 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=50.00]
+              RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/svg/as-object/svg-embedded-in-html-in-iframe.html b/LayoutTests/svg/as-object/svg-embedded-in-html-in-iframe.html
new file mode 100644 (file)
index 0000000..74e1fd3
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+<script type="text/javascript">\r
+function CreateCircle(){\r
+var B="";\r
+B+="<!DOCTYPE html>";\r
+B+="<html>";\r
+B+="<body>";\r
+B+="<svg style=\"width:100px;height:100px;\">";\r
+B+="<circle cx=\"50%\" cy=\"50%\" r=\"50%\" fill=\"blue\" stroke=\"none\" />";\r
+B+="</svg>";\r
+B+="</body></html>";\r
+return B;\r
+}\r
+</script>\r
+</head>\r
+<body>\r
+<iframe src="javascript:parent.CreateCircle();" width="100%" height="100%" frameborder="0" scrolling="no"></iframe>\r
+</body>\r
+</html>\r
+\r
index 81a572dd7223a0f53ae5af355418b6f9d35c00fd..c928d7ebcd082fadedc245463eb380a6d6d70b78 100755 (executable)
@@ -1,3 +1,20 @@
+2011-10-24  Levi Weintraub  <leviw@chromium.org>
+
+        <svg> fails to use explicit width and height inside <html> inside IFRAME
+        https://bugs.webkit.org/show_bug.cgi?id=64823
+
+        Reviewed by Nikolas Zimmermann.
+
+        Checking that embedded SVG is in an SVG document before negotiating size
+        with the host document.
+
+        Test: svg/as-object/svg-embedded-in-html-in-iframe.html
+
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::isEmbeddedThroughFrameContainingSVGDocument):
+        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
+        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
+
 2011-10-24  Rafael Weinstein  <rafaelw@chromium.org>
 
         Node::registeredMutationObserversOfType should be prefixed by "get"
index 7d411da82c56e68b8c7d46020be0f4e60b77c0bc..1d4fc918690b349981c65a28cee31188317bdd86 100644 (file)
@@ -130,6 +130,15 @@ LayoutUnit RenderSVGRoot::computeIntrinsicHeight(LayoutUnit replacedHeight) cons
     return static_cast<int>(ceilf(replacedHeight * style()->effectiveZoom()));
 }
 
+static inline bool isEmbeddedThroughFrameContainingSVGDocument(const Frame* frame)
+{
+    ASSERT(frame);
+    ASSERT(frame->document());
+    // If our frame has an owner renderer, we're embedded through eg. object/embed/iframe,
+    // but we only negotiate if we're in an SVG document.
+    return !frame->ownerRenderer() || !frame->document()->isSVGDocument();
+}
+
 LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
 {
     LayoutUnit replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
@@ -137,11 +146,10 @@ LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) cons
     if (!frame)
         return computeIntrinsicWidth(replacedWidth);
 
-    // If our frame has an owner renderer, we're embedded through eg. object/embed.
-    RenderPart* ownerRenderer = frame->ownerRenderer();
-    if (!ownerRenderer)
+    if (isEmbeddedThroughFrameContainingSVGDocument(frame))
         return computeIntrinsicWidth(replacedWidth);
 
+    RenderPart* ownerRenderer = frame->ownerRenderer();
     RenderStyle* ownerRendererStyle = ownerRenderer->style();
     ASSERT(ownerRendererStyle);
     ASSERT(frame->contentRenderer());
@@ -179,11 +187,10 @@ LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
     if (!frame)
         return computeIntrinsicHeight(replacedHeight);
 
-    // If our frame has an owner renderer, we're embedded through eg. object/embed.
-    RenderPart* ownerRenderer = frame->ownerRenderer();
-    if (!ownerRenderer)
+    if (isEmbeddedThroughFrameContainingSVGDocument(frame))
         return computeIntrinsicHeight(replacedHeight);
 
+    RenderPart* ownerRenderer = frame->ownerRenderer();
     RenderStyle* ownerRendererStyle = ownerRenderer->style();
     ASSERT(ownerRendererStyle);
     ASSERT(frame->contentRenderer());