Bug 621253: Transfer a document's zoom levels to its external resources when they're created. r=bz a=blocking-final+
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 14 Jan 2011 13:29:29 -0800
changeset 60612 0609193325c9eb082e323370847295c20fba939a
parent 60611 c9420f27b9dcdb9e3aa9d6114f63199fa599ab4c
child 60613 60cbff9cbab0238b48f49d7003edf64640ebc0e3
push idunknown
push userunknown
push dateunknown
reviewersbz, blocking-final
bugs621253
milestone2.0b10pre
Bug 621253: Transfer a document's zoom levels to its external resources when they're created. r=bz a=blocking-final+
content/base/src/nsDocument.cpp
layout/reftests/bugs/621253-1-helper.svg
layout/reftests/bugs/621253-1-ref.xhtml
layout/reftests/bugs/621253-1.xhtml
layout/reftests/bugs/reftest.list
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -850,16 +850,40 @@ ExternalResourceShower(nsIURI* aKey,
 }
 
 void
 nsExternalResourceMap::ShowViewers()
 {
   mMap.EnumerateRead(ExternalResourceShower, nsnull);
 }
 
+void
+TransferZoomLevels(nsIDocument* aFromDoc,
+                   nsIDocument* aToDoc)
+{
+  nsIPresShell* fromShell = aFromDoc->GetShell();
+  if (!fromShell)
+    return;
+
+  nsPresContext* fromCtxt = fromShell->GetPresContext();
+  if (!fromCtxt)
+    return;
+
+  nsIPresShell* toShell = aToDoc->GetShell();
+  if (!toShell)
+    return;
+
+  nsPresContext* toCtxt = toShell->GetPresContext();
+  if (!toCtxt)
+    return;
+
+  toCtxt->SetFullZoom(fromCtxt->GetFullZoom());
+  toCtxt->SetTextZoom(fromCtxt->TextZoom());
+}
+
 nsresult
 nsExternalResourceMap::AddExternalResource(nsIURI* aURI,
                                            nsIDocumentViewer* aViewer,
                                            nsILoadGroup* aLoadGroup,
                                            nsIDocument* aDisplayDocument)
 {
   NS_PRECONDITION(aURI, "Unexpected call");
   NS_PRECONDITION((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup),
@@ -907,16 +931,17 @@ nsExternalResourceMap::AddExternalResour
       rv = NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   if (newResource) {
     newResource->mDocument = doc;
     newResource->mViewer = aViewer;
     newResource->mLoadGroup = aLoadGroup;
+    TransferZoomLevels(aDisplayDocument, doc);
   }
 
   const nsTArray< nsCOMPtr<nsIObserver> > & obs = load->Observers();
   for (PRUint32 i = 0; i < obs.Length(); ++i) {
     obs[i]->Observe(doc, "external-resource-document-created", nsnull);
   }
 
   return rv;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/621253-1-helper.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+  <filter id="greyscale">
+    <feColorMatrix values="0.5 0.5 0.5 0 0
+                           0.5 0.5 0.5 0 0
+                           0.5 0.5 0.5 0 0
+                           0   0   0   1 0"/>
+  </filter>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/621253-1-ref.xhtml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+     reftest-zoom="0.5">
+<body style="margin: 0px">
+  <svg xmlns="http://www.w3.org/2000/svg" style="display: block; height: 0px">
+    <defs>
+      <filter id="greyscale">
+        <feColorMatrix values="0.5 0.5 0.5 0 0
+                               0.5 0.5 0.5 0 0
+                               0.5 0.5 0.5 0 0
+                               0   0   0   1 0"/>
+      </filter>
+    </defs>
+  </svg>
+  <div style="filter: url(#greyscale);
+              background: lime;
+              height: 100px; width: 100px">
+  </div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/621253-1.xhtml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+      reftest-zoom="0.5">
+<body style="margin: 0px">
+  <div style="filter: url(621253-1-helper.svg#greyscale);
+              background: lime;
+              height: 100px; width: 100px">
+  </div>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1555,11 +1555,12 @@ fails-if(!haveTestPlugin) == 599476.html
 == 613433-3.html 613433-1-ref.html
 == 613433-3.html 613433-2-ref.html
 == 613433-3.html 613433-3-ref.html
 == 614272-1.svg  614272-1-ref.svg
 HTTP(..) == 615121-1.html 615121-1-ref.html
 HTTP(..) != 615121-2.html 615121-2-notref.html
 == 617242-1.html 617242-1-ref.html
 != 618071.html 618071-notref.html
+== 621253-1.xhtml 621253-1-ref.xhtml
 HTTP(..) == 619511-1.html 619511-1-ref.html
 random-if(winWidget) == 621918-1.svg 621918-1-ref.svg # 1-pixel diacritic positioning discrepancy in rotated text (may depend on platform fonts)
 HTTP(..) == 621918-2.svg 621918-2-ref.svg # http(..) for filters.svg, used to mask antialiasing issues where glyphs touch