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
--- 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)
{