From 51681eda824074d646ca6368e94930a24ccc3dd7 Mon Sep 17 00:00:00 2001 From: Randall Barker Date: Thu, 9 Mar 2017 15:35:04 -0800 Subject: [PATCH] Bug 1334676: Prevent nsDOMWindowUtils::ZoomToFocusedInput from panning and zooming when focused element is fixed position r=tnikkel --- dom/base/nsDOMWindowUtils.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 7cda066c2a14..f8fc3046123b 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2652,6 +2652,28 @@ nsDOMWindowUtils::ZoomToFocusedInput() return NS_OK; } + nsIFrame* currentFrame = content->GetPrimaryFrame(); + nsIFrame* rootFrame = shell->GetRootFrame(); + nsIFrame* scrolledFrame = rootScrollFrame->GetScrolledFrame(); + bool isFixedPos = true; + + while (currentFrame) { + if (currentFrame == rootFrame) { + break; + } else if (currentFrame == scrolledFrame) { + // we are in the rootScrollFrame so this element is not fixed + isFixedPos = false; + break; + } + currentFrame = nsLayoutUtils::GetCrossDocParentFrame(currentFrame); + } + + if (isFixedPos) { + // We didn't find the scrolledFrame in our parent frames so this content must be fixed position. + // Zooming into fixed position content doesn't make sense so just return with out panning and zooming. + return NS_OK; + } + nsIDocument* document = shell->GetDocument(); if (!document) { return NS_OK;