Bug 547596 - zoom events do not fire. r=jwatt
authorRobert Longson <longsonr@gmail.com>
Tue, 23 Feb 2010 20:39:15 +0000
changeset 38436 13489c44f99d24d00a8d7449da23609a06674420
parent 38435 a850c1102b6a4625b5a25fbc47e96ce3fb4923c6
child 38437 9d0a036ed2cbb7fe0005bd12e5153665329efe12
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs547596
milestone1.9.3a2pre
Bug 547596 - zoom events do not fire. r=jwatt
content/svg/content/src/nsSVGSVGElement.cpp
content/svg/content/test/Makefile.in
content/svg/content/test/test_zoom.xhtml
content/svg/content/test/zoom-helper.svg
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -868,17 +868,17 @@ nsSVGSVGElement::SetCurrentScaleTranslat
   mCurrentScale = s;
   mCurrentTranslate = nsSVGTranslatePoint(x, y);
 
   // now dispatch the appropriate event if we are the root element
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     nsCOMPtr<nsIPresShell> presShell = doc->GetPrimaryShell();
     if (presShell && IsRoot()) {
-      PRBool scaling = (s != mCurrentScale);
+      PRBool scaling = (mPreviousScale != mCurrentScale);
       nsEventStatus status = nsEventStatus_eIgnore;
       nsGUIEvent event(PR_TRUE, scaling ? NS_SVG_ZOOM : NS_SVG_SCROLL, 0);
       event.eventStructType = scaling ? NS_SVGZOOM_EVENT : NS_SVG_EVENT;
       presShell->HandleDOMEventWithTarget(this, &event, &status);
       InvalidateTransformNotifyFrame();
     }
   }
   return NS_OK;
--- a/content/svg/content/test/Makefile.in
+++ b/content/svg/content/test/Makefile.in
@@ -67,12 +67,14 @@ include $(topsrcdir)/config/rules.mk
 		switch-helper.svg \
 		test_text.html \
 		text-helper.svg \
 		test_transform.xhtml \
 		test_valueAsString.xhtml \
 		test_valueLeaks.xhtml \
 		viewport-helper.svg \
 		test_viewport.html \
+		zoom-helper.svg \
+		test_zoom.xhtml \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/svg/content/test/test_zoom.xhtml
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=547596
+-->  
+<head>
+  <title>Test for Bug 547596</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547596">Mozilla Bug 547596</a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+
+  <iframe id="svg" src="zoom-helper.svg"></iframe>
+
+  <script>
+    SimpleTest.waitForExplicitFinish();
+
+    function runTests() {
+      var doc = $("svg").contentWindow.document;
+      var root = doc.getElementById("root");
+      root.currentScale *= 2;
+    }
+
+    function zoomHandler(evt) {
+      ok(true, "zoom handler should be called on zoom");
+      SimpleTest.finish();
+    }
+
+    window.addEventListener("load", runTests, false);
+  </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/svg/content/test/zoom-helper.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<svg id="root" version="1.1" xmlns="http://www.w3.org/2000/svg" onzoom="parent.zoomHandler(evt)">
+  <rect x="10" y="10" width="10" height="10" fill="green" />
+</svg>