Bug 1334676 - Prevent nsDOMWindowUtils::ZoomToFocusedInput from panning and zooming when focused element is fixed position. r=tnikkel, a=lizzard
authorRandall Barker <rbarker@mozilla.com>
Thu, 09 Mar 2017 15:35:04 -0800
changeset 396061 a50606fb0f31674b301ce317d974747c7f4f42f7
parent 396060 a2ca894588bc2ef89ed56bacfdb3f292a84928da
child 396062 a13f60339131a212a7d259f33e1b68cf918da422
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, lizzard
bugs1334676
milestone54.0
Bug 1334676 - Prevent nsDOMWindowUtils::ZoomToFocusedInput from panning and zooming when focused element is fixed position. r=tnikkel, a=lizzard
dom/base/nsDOMWindowUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2647,16 +2647,38 @@ nsDOMWindowUtils::ZoomToFocusedInput()
     return NS_OK;
   }
 
   nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable();
   if (!rootScrollFrame) {
     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;
   }
 
   uint32_t presShellId;
   FrameMetrics::ViewID viewId;
   if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(document->GetDocumentElement(), &presShellId, &viewId)) {