Bug 1351783 part 17 - Do less work when apz.keyboard.enabled is false. r=kats draft
authorRyan Hunt <rhunt@eqrion.net>
Tue, 06 Jun 2017 11:08:45 -0500
changeset 599281 c31bc0f5c265b67271b14386f55151be3aa5e623
parent 599280 426e9a2b3d5eb9143f74e3881cc1a182ded5c1a6
child 599282 497bdf0e1d1287f0a9d71bb3037f008cf50f216b
push id65466
push userbmo:rhunt@eqrion.net
push dateThu, 22 Jun 2017 22:16:51 +0000
reviewerskats
bugs1351783
milestone56.0a1
Bug 1351783 part 17 - Do less work when apz.keyboard.enabled is false. r=kats When keyboard apz is disabled, we don't need to calculate focus targets and we don't need to update focus state. It should be harmless even if it's done, but I think it's good to not add something on this critical path that doesn't do anything. This commit also disable keyboard map generation in this case too for similar reasoning. This has the side effect that you can't turn on keyboard apz without doing a restart. MozReview-Commit-ID: LxmofT2g7qs
gfx/layers/apz/src/APZCTreeManager.cpp
layout/base/PresShell.cpp
widget/nsBaseWidget.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -393,16 +393,20 @@ APZCTreeManager::UpdateHitTestingTreeImp
 #endif
 }
 
 void
 APZCTreeManager::UpdateFocusState(uint64_t aRootLayerTreeId,
                                   uint64_t aOriginatingLayersId,
                                   const FocusTarget& aFocusTarget)
 {
+  if (!gfxPrefs::APZKeyboardEnabled()) {
+    return;
+  }
+
   mFocusState.Update(aRootLayerTreeId,
                      aOriginatingLayersId,
                      aFocusTarget);
 }
 
 void
 APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
                                       Layer* aRoot,
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6334,20 +6334,22 @@ PresShell::Paint(nsView*         aViewTo
   NS_ASSERTION(aViewToPaint, "null view");
 
   MOZ_ASSERT(!mApproximateFrameVisibilityVisited, "Should have been cleared");
 
   if (!mIsActive) {
     return;
   }
 
-  // Update the focus target for async keyboard scrolling. This will be forwarded
-  // to APZ by nsDisplayList::PaintRoot. We need to to do this before we enter
-  // the paint phase because dispatching eVoid events can cause layout to happen.
-  mAPZFocusTarget = FocusTarget(this, mAPZFocusSequenceNumber);
+  if (gfxPrefs::APZKeyboardEnabled()) {
+    // Update the focus target for async keyboard scrolling. This will be forwarded
+    // to APZ by nsDisplayList::PaintRoot. We need to to do this before we enter
+    // the paint phase because dispatching eVoid events can cause layout to happen.
+    mAPZFocusTarget = FocusTarget(this, mAPZFocusSequenceNumber);
+  }
 
   nsPresContext* presContext = GetPresContext();
   AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint);
 
   nsIFrame* frame = aViewToPaint->GetFrame();
 
   LayerManager* layerManager =
     aViewToPaint->GetWidget()->GetLayerManager();
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -914,17 +914,20 @@ nsBaseWidget::CreateRootContentControlle
 
 void nsBaseWidget::ConfigureAPZCTreeManager()
 {
   MOZ_ASSERT(mAPZC);
 
   ConfigureAPZControllerThread();
 
   mAPZC->SetDPI(GetDPI());
-  mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts());
+
+  if (gfxPrefs::APZKeyboardEnabled()) {
+    mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts());
+  }
 
   RefPtr<IAPZCTreeManager> treeManager = mAPZC;  // for capture by the lambdas
 
   ContentReceivedInputBlockCallback callback(
       [treeManager](const ScrollableLayerGuid& aGuid,
                     uint64_t aInputBlockId,
                     bool aPreventDefault)
       {