From bb5749ccf11d8428539bab92bdf4c17aeda6ec1b Mon Sep 17 00:00:00 2001 From: Ryan Hunt Date: Tue, 6 Jun 2017 11:08:45 -0500 Subject: [PATCH] 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 --HG-- extra : rebase_source : 719d29efd80498b824fee03a5be1c1fd05c83074 extra : histedit_source : 7ad71a19782fc6dd203207afbdc7a73a936b3e04 --- gfx/layers/apz/src/APZCTreeManager.cpp | 4 ++++ layout/base/PresShell.cpp | 10 ++++++---- widget/nsBaseWidget.cpp | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 46892474496b..079245ef2bb0 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -399,6 +399,10 @@ APZCTreeManager::UpdateFocusState(uint64_t aRootLayerTreeId, uint64_t aOriginatingLayersId, const FocusTarget& aFocusTarget) { + if (!gfxPrefs::APZKeyboardEnabled()) { + return; + } + mFocusState.Update(aRootLayerTreeId, aOriginatingLayersId, aFocusTarget); diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 600837fbdc8e..074d3fd67d67 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -6338,10 +6338,12 @@ PresShell::Paint(nsView* aViewToPaint, 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); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 25ee54f1b851..c10b554870fd 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -920,7 +920,10 @@ void nsBaseWidget::ConfigureAPZCTreeManager() ConfigureAPZControllerThread(); mAPZC->SetDPI(GetDPI()); - mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts()); + + if (gfxPrefs::APZKeyboardEnabled()) { + mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts()); + } RefPtr treeManager = mAPZC; // for capture by the lambdas