Fixing bug 407959. Embedded SVG object disappears when zooming or in Print Preview. r=tor@acm.org, sr=roc@ocallahan.org

git-svn-id: svn://10.0.0.236/trunk@241830 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jwatt%jwatt.org 2007-12-20 06:48:20 +00:00
parent 6167bdc9e5
commit 110f86e726
4 changed files with 58 additions and 4 deletions

View File

@ -1,4 +1,5 @@
# XBL tests
== xbl-basic-01.svg pass.svg
== xbl-basic-02.svg pass.svg
== xbl-grad-ref--grad-in-binding-01.svg pass.svg
@ -7,3 +8,6 @@
fails == xbl-grad-ref--grad-in-bound-02.svg pass-black.svg
fails == xbl-grad-ref--grad-in-resources-01.svg pass.svg
fails == xbl-grad-ref--grad-in-resources-02.svg pass.svg
# Tests for zooming with the full page zoom UI
== zoomed-svg-with-viewBox-01.svg zoomed-svg-with-viewBox-01-ref.svg

View File

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="30">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=407959 -->
<title>Reference for zoomed-svg-with-viewBox-01.svg</title>
<ellipse cx="20" cy="15" rx="20" ry="15" fill="blue"/>
</svg>

After

Width:  |  Height:  |  Size: 380 B

View File

@ -0,0 +1,30 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg"
width="40" height="30" viewBox="20 20 40 30">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=407959 -->
<title>Test that zooming isn't broken when we have a viewBox</title>
<script>
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var shell = document.defaultView
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell);
var viewer = shell.contentViewer
.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer)
viewer.fullZoom = 3;
</script>
<ellipse cx="40" cy="35" rx="20" ry="15" fill="blue"/>
</svg>

After

Width:  |  Height:  |  Size: 892 B

View File

@ -54,6 +54,7 @@
#include "nsPIDOMWindow.h"
#include "nsIObjectLoadingContent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsSVGMatrix.h"
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
#include "nsIDeviceContext.h"
@ -713,15 +714,21 @@ already_AddRefed<nsIDOMSVGMatrix>
nsSVGOuterSVGFrame::GetCanvasTM()
{
if (!mCanvasTM) {
nsCOMPtr<nsIDOMSVGMatrix> vb2vp;
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(mContent);
svgElement->GetViewboxToViewportTransform(getter_AddRefs(vb2vp));
// Scale the transform from CSS pixel space to device pixel space
float devPxPerCSSPx =
1 / PresContext()->AppUnitsToFloatCSSPixels(
PresContext()->AppUnitsPerDevPixel());
vb2vp->Scale(devPxPerCSSPx, getter_AddRefs(mCanvasTM));
nsCOMPtr<nsIDOMSVGMatrix> devPxToCSSPxMatrix;
NS_NewSVGMatrix(getter_AddRefs(devPxToCSSPxMatrix),
devPxPerCSSPx, 0.0f,
0.0f, devPxPerCSSPx);
nsCOMPtr<nsIDOMSVGMatrix> viewBoxMatrix;
svgElement->GetViewboxToViewportTransform(getter_AddRefs(viewBoxMatrix));
// PRE-multiply px conversion!
devPxToCSSPxMatrix->Multiply(viewBoxMatrix, getter_AddRefs(mCanvasTM));
// our content is the document element so we must premultiply the values
// of its currentScale and currentTranslate properties