Bug 1383662 - Only dispatch TextZoomChange events if the zoom level has changed. r?felipe
MozReview-Commit-ID: 8reTfu6R5s3
--- 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);