iframes seem to occasionally doubly scale or scale incorrectly when pageScaleFactor...
authorfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2011 21:09:24 +0000 (21:09 +0000)
committerfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2011 21:09:24 +0000 (21:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70552

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/frames/iframe-double-scale-contents.html

The iframe's document style was using the page's scale factor, rather than the frame's (1.0).
If the page scale factor was set after layout was complete, then this would have no impact because the iframe's document style and layout is not recomputed,
but if the page scale factor is set prior to creating and laying out the iframe, the iframe's content would be doubly scaled.

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForDocument):

LayoutTests:

* fast/frames/iframe-double-scale-contents-expected.png: Added.
* fast/frames/iframe-double-scale-contents-expected.txt: Added.
* fast/frames/iframe-double-scale-contents.html: Added.
* fast/frames/resources/iframe-content-scaling-bug-iframe.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/frames/iframe-double-scale-contents-expected.png [new file with mode: 0644]
LayoutTests/fast/frames/iframe-double-scale-contents-expected.txt [new file with mode: 0644]
LayoutTests/fast/frames/iframe-double-scale-contents.html [new file with mode: 0644]
LayoutTests/fast/frames/resources/iframe-content-scaling-bug-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSelector.cpp

index 2768b6eddb2851a8a973fcd4fa0c2866b69dcfb0..653a9503ad2094dbe24826021981f6956529ee02 100755 (executable)
@@ -1,3 +1,15 @@
+2011-10-27  Fady Samuel  <fsamuel@chromium.org>
+
+        iframes seem to occasionally doubly scale or scale incorrectly when pageScaleFactor != 1.0
+        https://bugs.webkit.org/show_bug.cgi?id=70552
+
+        Reviewed by Simon Fraser.
+
+        * fast/frames/iframe-double-scale-contents-expected.png: Added.
+        * fast/frames/iframe-double-scale-contents-expected.txt: Added.
+        * fast/frames/iframe-double-scale-contents.html: Added.
+        * fast/frames/resources/iframe-content-scaling-bug-iframe.html: Added.
+
 2011-10-27  Mike Reed  <reed@google.com>
 
         test_rebaseline_expectations failing
 2011-10-27  Mike Reed  <reed@google.com>
 
         test_rebaseline_expectations failing
diff --git a/LayoutTests/fast/frames/iframe-double-scale-contents-expected.png b/LayoutTests/fast/frames/iframe-double-scale-contents-expected.png
new file mode 100644 (file)
index 0000000..fb5fba9
Binary files /dev/null and b/LayoutTests/fast/frames/iframe-double-scale-contents-expected.png differ
diff --git a/LayoutTests/fast/frames/iframe-double-scale-contents-expected.txt b/LayoutTests/fast/frames/iframe-double-scale-contents-expected.txt
new file mode 100644 (file)
index 0000000..43e5eee
--- /dev/null
@@ -0,0 +1,4 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/frames/iframe-double-scale-contents.html b/LayoutTests/fast/frames/iframe-double-scale-contents.html
new file mode 100644 (file)
index 0000000..915c0b5
--- /dev/null
@@ -0,0 +1,46 @@
+<html>
+<head>
+    <style>
+        ::-webkit-scrollbar {
+            width: 0px;
+            height: 0px;
+        }
+    </style>
+    <script src="../js/resources/js-test-pre.js"></script>
+    <script>
+      window.enablePixelTesting = true;
+
+      if (window.layoutTestController)
+        layoutTestController.waitUntilDone();
+
+      // Layout for the iframe will be scaled down to a quarter.
+      // It appears this bug will only manifest itself if layout for the
+      // iframe has not yet been computed. If we've already laid out
+      // the iframe, then CSSStyleSelector::styleForDocument does not appear
+      // to get called for the iframe.
+      scalePage(0.5);
+
+      function scalePage(scaleFactor) {
+          var scaleOffset = 0;
+          if (window.eventSender) {
+            eventSender.scalePageBy(scaleFactor, scaleOffset, scaleOffset);
+          }
+      }
+
+      function test() {
+          // Curiously, the document style for the iframe does not
+          // appear to be recalculated after this
+          scalePage(1.0);
+          document.body.offsetWidth;
+          if (window.layoutTestController)
+            layoutTestController.notifyDone();
+      }
+    </script>
+    <script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body onload="test();">
+  <iframe id="frame" src="resources/iframe-content-scaling-bug-iframe.html" style="position: absolute; left: 0px; top: 0px; border: none; width: 300px; height: 300px;"></iframe>
+  <div id="rightbox" style="position: absolute; left: 300px; top: 0px; width: 300px; height: 300px; background-color: green;"></div>
+  <script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/frames/resources/iframe-content-scaling-bug-iframe.html b/LayoutTests/fast/frames/resources/iframe-content-scaling-bug-iframe.html
new file mode 100644 (file)
index 0000000..12f68ae
--- /dev/null
@@ -0,0 +1,12 @@
+<html>
+<head>
+<style>
+body {
+margin: 0;
+}
+</style>
+</head>
+<body>
+<div style="position: absolute; left: 0px; top: 0px; width: 300px; height: 300px; background-color: green;"></div>
+</body>
+</html>
index 768db1158f54ca0613040ec8dc99efefb52166f0..9b2f5f6b5ba10afe5a693b8aadffe412f17c9757 100755 (executable)
@@ -1,3 +1,19 @@
+2011-10-27  Fady Samuel  <fsamuel@chromium.org>
+
+        iframes seem to occasionally doubly scale or scale incorrectly when pageScaleFactor != 1.0
+        https://bugs.webkit.org/show_bug.cgi?id=70552
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/frames/iframe-double-scale-contents.html
+
+        The iframe's document style was using the page's scale factor, rather than the frame's (1.0).
+        If the page scale factor was set after layout was complete, then this would have no impact because the iframe's document style and layout is not recomputed, 
+        but if the page scale factor is set prior to creating and laying out the iframe, the iframe's content would be doubly scaled.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::styleForDocument):
+
 2011-10-27  Nat Duca  <nduca@chromium.org>
 
         Unreviewed, fix CCSchedulerStateMachine build errors.
 2011-10-27  Nat Duca  <nduca@chromium.org>
 
         Unreviewed, fix CCSchedulerStateMachine build errors.
index f682298eac2f181b4f67e6adec3d4510c729354d..f6ad715bf0507c30b97bfc991f3b5951cc862bef 100644 (file)
@@ -1134,7 +1134,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
     documentStyle->setDisplay(BLOCK);
     documentStyle->setRTLOrdering(document->visuallyOrdered() ? VisualOrder : LogicalOrder);
     documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
     documentStyle->setDisplay(BLOCK);
     documentStyle->setRTLOrdering(document->visuallyOrdered() ? VisualOrder : LogicalOrder);
     documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
-    documentStyle->setPageScaleTransform(document->page() ? document->page()->pageScaleFactor() : 1);
+    documentStyle->setPageScaleTransform(frame ? frame->frameScaleFactor() : 1);
     documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
 
     Element* docElement = document->documentElement();
     documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
 
     Element* docElement = document->documentElement();