Bug 1383662 - Only dispatch TextZoomChange events if the zoom level has changed. r?felipe draft
authorJared Wein <jwein@mozilla.com>
Mon, 24 Jul 2017 11:15:03 -0400
changeset 614484 91afe4901e59889aba8fc948c9314719b1d2c797
parent 614015 5928d905c0bc0b28f5488b236444c7d7991cf8d4
child 614485 a3cbc7308cd95d5a1956594008cdc76c911c83f2
push id70015
push userbmo:jaws@mozilla.com
push dateMon, 24 Jul 2017 15:26:37 +0000
reviewersfelipe
bugs1383662
milestone56.0a1
Bug 1383662 - Only dispatch TextZoomChange events if the zoom level has changed. r?felipe MozReview-Commit-ID: 8reTfu6R5s3
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3099,16 +3099,17 @@ nsDocumentViewer::SetTextZoom(float aTex
   if (!mDocument) {
     return NS_ERROR_FAILURE;
   }
 
   if (GetIsPrintPreview()) {
     return NS_OK;
   }
 
+  bool textZoomChange = (mTextZoom != aTextZoom);
   mTextZoom = aTextZoom;
 
   // Set the text zoom on all children of mContainer (even if our zoom didn't
   // change, our children's zoom may be different, though it would be unusual).
   // Do this first, in case kids are auto-sizing and post reflow commands on
   // our presshell (which should be subsumed into our own style change reflow).
   struct ZoomInfo ZoomInfo = { aTextZoom };
   CallChildren(SetChildTextZoom, &ZoomInfo);
@@ -3117,19 +3118,22 @@ nsDocumentViewer::SetTextZoom(float aTex
   nsPresContext* pc = GetPresContext();
   if (pc && aTextZoom != mPresContext->TextZoom()) {
       pc->SetTextZoom(aTextZoom);
   }
 
   // And do the external resources
   mDocument->EnumerateExternalResources(SetExtResourceTextZoom, &ZoomInfo);
 
-  nsContentUtils::DispatchChromeEvent(mDocument, static_cast<nsIDocument*>(mDocument),
-                                      NS_LITERAL_STRING("TextZoomChange"),
-                                      true, true);
+  // Dispatch TextZoomChange event only if text zoom value has changed.
+  if (textZoomChange) {
+    nsContentUtils::DispatchChromeEvent(mDocument, static_cast<nsIDocument*>(mDocument),
+                                        NS_LITERAL_STRING("TextZoomChange"),
+                                        true, true);
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetTextZoom(float* aTextZoom)
 {
   NS_ENSURE_ARG_POINTER(aTextZoom);