<rdar://problem/11928576> SVG-as-image (constrained) intrinsic size calculation is...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2012 21:54:31 +0000 (21:54 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2012 21:54:31 +0000 (21:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91918

Reviewed by Anders Carlsson.

Source/WebCore:

Test: svg/as-image/svg-intrinsic-size-rectangular-vertical.html

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox): When there is a content
renderer, it returns a physical intrinsic size and aspect ratio. The code was already
accounting for this by taking the reciprocal of the aspect ratio in the vertical case. Made
it also transpose the size itself, turning it from physical to logical. Moved this code
after setting m_intrinsicSize, since that member variable is always physical.

LayoutTests:

* svg/as-image/svg-intrinsic-size-rectangular-vertical-expected.html: Added.
* svg/as-image/svg-intrinsic-size-rectangular-vertical.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderReplaced.cpp

index 2b23005..d83bbc5 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-21  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/11928576> SVG-as-image (constrained) intrinsic size calculation is wrong in vertical writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=91918
+
+        Reviewed by Anders Carlsson.
+
+        * svg/as-image/svg-intrinsic-size-rectangular-vertical-expected.html: Added.
+        * svg/as-image/svg-intrinsic-size-rectangular-vertical.html: Added.
+
 2012-07-20  Tony Chang  <tony@chromium.org>
 
         [chromium] Mark anther test as needing a rebaseline due to r123285.
diff --git a/LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical-expected.html b/LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical-expected.html
new file mode 100644 (file)
index 0000000..adde32e
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+    div.container {
+        -webkit-writing-mode: vertical-rl;
+        -webkit-logical-width: 80px;
+        -webkit-logical-height: 200px;
+        outline: solid blue;
+    }
+</style>
+<div class="container">
+    <div style="width: 40px; background-color: green;"></div>
+</div>
+<div style="height: 25px;"></div>
+<div class="container">
+    <div style="width: 60px; background-color: green;"></div>
+</div>
diff --git a/LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical.html b/LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-vertical.html
new file mode 100644 (file)
index 0000000..77205ec
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<style>
+    div.container {
+        -webkit-writing-mode: vertical-rl;
+        -webkit-logical-width: 80px;
+        -webkit-logical-height: 200px;
+        outline: solid blue;
+    }
+
+    img {
+        background-color: red;
+        width: auto;
+        height: auto;
+        max-width: 100%;
+        max-height: 100%;
+    }
+</style>
+<div class="container">
+    <img src="data:image/svg+xml,<svg width='120' height='240' xmlns='http://www.w3.org/2000/svg'><rect x='0' y='0' fill='green' width='120' height='240'></rect></svg>">
+</div>
+<div style="height: 25px;"></div>
+<div class="container">
+    <img src="data:image/svg+xml,<svg width='60' height='80' xmlns='http://www.w3.org/2000/svg'><rect x='0' y='0' fill='green' width='60' height='80'></rect></svg>">
+</div>
index 715858d..dc3da3f 100644 (file)
@@ -1,3 +1,19 @@
+2012-07-21  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/11928576> SVG-as-image (constrained) intrinsic size calculation is wrong in vertical writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=91918
+
+        Reviewed by Anders Carlsson.
+
+        Test: svg/as-image/svg-intrinsic-size-rectangular-vertical.html
+
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox): When there is a content
+        renderer, it returns a physical intrinsic size and aspect ratio. The code was already
+        accounting for this by taking the reciprocal of the aspect ratio in the vertical case. Made
+        it also transpose the size itself, turning it from physical to logical. Moved this code
+        after setting m_intrinsicSize, since that member variable is always physical.
+
 2012-07-21  Patrick Gansterer  <paroga@webkit.org>
 
         Cleanup TextEncoding USE(XXX_UNICODE) macros
index 7afe356..18cdfc1 100644 (file)
@@ -281,9 +281,6 @@ void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
         if (!isPercentageIntrinsicSize)
             intrinsicSize.scale(style()->effectiveZoom());
 
-        if (intrinsicRatio && !isHorizontalWritingMode())
-            intrinsicRatio = 1 / intrinsicRatio;
-
         if (rendererHasAspectRatio(this) && isPercentageIntrinsicSize)
             intrinsicRatio = 1;
             
@@ -292,6 +289,12 @@ void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
         // min and max widths.
         if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty())
             m_intrinsicSize = flooredIntSize(intrinsicSize); // FIXME: This introduces precision errors. We should convert m_intrinsicSize to be a float.
+
+        if (!isHorizontalWritingMode()) {
+            if (intrinsicRatio)
+                intrinsicRatio = 1 / intrinsicRatio;
+            intrinsicSize = intrinsicSize.transposedSize();
+        }
     } else {
         computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
         if (intrinsicRatio)