diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 7e65b33c997..2e39f3bb51f 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13858,14 +13858,7 @@ nsDocShell::GetAppManifestURL(nsAString& aAppManifestURL) NS_IMETHODIMP nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) { - if (nsIPresShell* presShell = GetPresShell()) { - if (layers::LayerManager* lm = presShell->GetLayerManager()) { - *aOut = lm->AsyncPanZoomEnabled(); - return NS_OK; - } - } - - *aOut = false; + *aOut = Preferences::GetBool("layers.async-pan-zoom.enabled", false); return NS_OK; } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 8bb5626c789..c29abfe7056 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -375,12 +375,9 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx, new DisplayPortPropertyData(displayport, aPriority), nsINode::DeleteProperty); - if (gfxPrefs::LayoutUseContainersForRootFrames()) { + if (nsLayoutUtils::UsesAsyncScrolling() && gfxPrefs::LayoutUseContainersForRootFrames()) { nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame(); - if (rootScrollFrame && - content == rootScrollFrame->GetContent() && - nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame)) - { + if (rootScrollFrame && content == rootScrollFrame->GetContent()) { // We are setting a root displayport for a document. // The pres shell needs a special flag set. presShell->SetIgnoreViewportScrolling(true); @@ -861,7 +858,7 @@ nsDOMWindowUtils::SendWheelEvent(float aX, widget->DispatchAPZAwareEvent(&wheelEvent); - if (widget->AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { // Computing overflow deltas is not compatible with APZ, so if APZ is // enabled, we skip testing it. return NS_OK; diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index c9a7d9e4589..9121c23f88b 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -515,8 +515,7 @@ parent: sync GetRenderFrameInfo(PRenderFrame aRenderFrame) returns (TextureFactoryIdentifier textureFactoryIdentifier, - uint64_t layersId, - bool asyncPanZoomEnabled); + uint64_t layersId); /** * Sent by the child to the parent to inform it that an update to the @@ -546,8 +545,7 @@ child: TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, nullable PRenderFrame renderFrame, - bool parentIsActive, - bool asyncPanZoomEnabled); + bool parentIsActive); LoadURL(nsCString uri, BrowserConfiguration config); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 465c396e847..0389bd7d494 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -268,8 +268,7 @@ CSSToParentLayerScale ConvertScaleForRoot(CSSToScreenScale aScale) { bool TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) { - nsIWidget* widget = WebWidget(); - if (!widget || !widget->AsyncPanZoomEnabled()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { return false; } @@ -876,7 +875,6 @@ TabChild::TabChild(nsIContentChild* aManager, , mDefaultScale(0) , mIPCOpen(true) , mParentIsActive(false) - , mAsyncPanZoomEnabled(false) { // preloaded TabChild should not be added to child map if (mUniqueId) { @@ -923,7 +921,7 @@ TabChild::Observe(nsISupports *aSubject, } } } else if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) { - if (AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { nsCOMPtr subject(do_QueryInterface(aSubject)); nsCOMPtr doc(GetDocument()); @@ -981,7 +979,7 @@ TabChild::OnLocationChange(nsIWebProgress* aWebProgress, nsIURI *aLocation, uint32_t aFlags) { - if (!AsyncPanZoomEnabled()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { return NS_OK; } @@ -1539,11 +1537,9 @@ TabChild::ProvideWindowCommon(nsIDOMWindow* aOpener, TextureFactoryIdentifier textureFactoryIdentifier; uint64_t layersId = 0; PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor(); - bool asyncPanZoomEnabled = false; newChild->SendGetRenderFrameInfo(renderFrame, &textureFactoryIdentifier, - &layersId, - &asyncPanZoomEnabled); + &layersId); if (layersId == 0) { // if renderFrame is invalid. PRenderFrameChild::Send__delete__(renderFrame); renderFrame = nullptr; @@ -1551,8 +1547,7 @@ TabChild::ProvideWindowCommon(nsIDOMWindow* aOpener, // Unfortunately we don't get a window unless we've shown the frame. That's // pretty bogus; see bug 763602. - newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame, - asyncPanZoomEnabled); + newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame); for (size_t i = 0; i < frameScripts.Length(); i++) { FrameScriptInfo& info = frameScripts[i]; @@ -1880,12 +1875,11 @@ TabChild::CancelCachedFileDescriptorCallback( void TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, - PRenderFrameChild* aRenderFrame, - bool aAsyncPanZoomEnabled) + PRenderFrameChild* aRenderFrame) { ShowInfo info(EmptyString(), false, false, 0, 0); RecvShow(ScreenIntSize(0, 0), info, aTextureFactoryIdentifier, - aLayersId, aRenderFrame, mParentIsActive, aAsyncPanZoomEnabled); + aLayersId, aRenderFrame, mParentIsActive); mDidFakeShow = true; } @@ -1987,8 +1981,7 @@ TabChild::RecvShow(const ScreenIntSize& aSize, const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame, - const bool& aParentIsActive, - const bool& aAsyncPanZoomEnabled) + const bool& aParentIsActive) { MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame)); @@ -2021,8 +2014,6 @@ TabChild::RecvShow(const ScreenIntSize& aSize, bool res = InitTabChildGlobal(); ApplyShowInfo(aInfo); RecvParentActivated(aParentIsActive); - - mAsyncPanZoomEnabled = aAsyncPanZoomEnabled; return res; } @@ -2208,7 +2199,7 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId) { - if (AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { nsCOMPtr document(GetDocument()); APZCCallbackHelper::SendSetTargetAPZCNotification(WebWidget(), document, aEvent, aGuid, aInputBlockId); @@ -2218,7 +2209,7 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent, event.widget = mWidget; APZCCallbackHelper::DispatchWidgetEvent(event); - if (AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { mAPZEventState->ProcessWheelEvent(event, aGuid, aInputBlockId); } return true; @@ -2400,7 +2391,7 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid, mWidget->GetDefaultScale(), GetPresShellResolution()); - if (localEvent.message == NS_TOUCH_START && AsyncPanZoomEnabled()) { + if (localEvent.message == NS_TOUCH_START && gfxPrefs::AsyncPanZoomEnabled()) { if (gfxPrefs::TouchActionEnabled()) { APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(WebWidget(), localEvent, aInputBlockId, mSetAllowedTouchBehaviorCallback); @@ -2413,7 +2404,7 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, // Dispatch event to content (potentially a long-running operation) nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent); - if (!AsyncPanZoomEnabled()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { UpdateTapState(localEvent, status); return true; } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 1b095553953..ba38d95ddb1 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -319,8 +319,7 @@ public: const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame, - const bool& aParentIsActive, - const bool& aAsyncPanZoomEnabled) override; + const bool& aParentIsActive) override; virtual bool RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size, const ScreenOrientation& orientation, @@ -505,7 +504,6 @@ public: { return mParentIsActive; } - bool AsyncPanZoomEnabled() { return mAsyncPanZoomEnabled; } protected: virtual ~TabChild(); @@ -562,8 +560,7 @@ private: // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow(). void DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, - PRenderFrameChild* aRenderFrame, - bool aAsyncPanZoomEnabled); + PRenderFrameChild* aRenderFrame); void ApplyShowInfo(const ShowInfo& aInfo); @@ -643,7 +640,6 @@ private: double mDefaultScale; bool mIPCOpen; bool mParentIsActive; - bool mAsyncPanZoomEnabled; DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 1f27e9ae95e..a4f5bb8047f 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -888,8 +888,7 @@ TabParent::Show(const ScreenIntSize& size, bool aParentIsActive) } unused << SendShow(size, info, textureFactoryIdentifier, - layersId, renderFrame, aParentIsActive, - AsyncPanZoomEnabled()); + layersId, renderFrame, aParentIsActive); } bool @@ -2649,15 +2648,12 @@ TabParent::DeallocPRenderFrameParent(PRenderFrameParent* aFrame) bool TabParent::RecvGetRenderFrameInfo(PRenderFrameParent* aRenderFrame, TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId, - bool* aAsyncPanZoomEnabled) + uint64_t* aLayersId) { RenderFrameParent* renderFrame = static_cast(aRenderFrame); renderFrame->GetTextureFactoryIdentifier(aTextureFactoryIdentifier); *aLayersId = renderFrame->GetLayersId(); - *aAsyncPanZoomEnabled = AsyncPanZoomEnabled(); - if (mNeedLayerTreeReadyNotification) { RequestNotifyLayerTreeReady(); mNeedLayerTreeReadyNotification = false; @@ -2735,7 +2731,7 @@ TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId, nsEventStatus* aOutApzResponse) { - if (AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { if (aOutTargetGuid) { *aOutTargetGuid = InputAPZContext::GetTargetLayerGuid(); @@ -2915,7 +2911,7 @@ TabParent::InjectTouchEvent(const nsAString& aType, NS_IMETHODIMP TabParent::GetUseAsyncPanZoom(bool* useAsyncPanZoom) { - *useAsyncPanZoom = AsyncPanZoomEnabled(); + *useAsyncPanZoom = gfxPrefs::AsyncPanZoomEnabled(); return NS_OK; } @@ -3322,13 +3318,6 @@ TabParent::TakeDragVisualization(RefPtr& aSurface, aDragAreaY = mDragAreaY; } -bool -TabParent::AsyncPanZoomEnabled() const -{ - nsCOMPtr widget = GetWidget(); - return widget && widget->AsyncPanZoomEnabled(); -} - NS_IMETHODIMP FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index bc3a452e248..1063e8e8034 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -448,8 +448,7 @@ protected: virtual bool RecvGetRenderFrameInfo(PRenderFrameParent* aRenderFrame, TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId, - bool* aAsyncPanZoomEnabled) override; + uint64_t* aLayersId) override; virtual bool RecvSetDimensions(const uint32_t& aFlags, const int32_t& aX, const int32_t& aY, @@ -501,8 +500,6 @@ private: CSSPoint AdjustTapToChildWidget(const CSSPoint& aPoint); - bool AsyncPanZoomEnabled() const; - // Update state prior to routing an APZ-aware event to the child process. // |aOutTargetGuid| will contain the identifier // of the APZC instance that handled the event. aOutTargetGuid may be null. diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 5ad75692691..4ce0bb5a39b 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -669,10 +669,6 @@ public: return mAnimationReadyTime; } - virtual bool AsyncPanZoomEnabled() const { - return false; - } - protected: nsRefPtr mRoot; gfx::UserData mUserData; diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 2a45dce1385..dc8ba1a98f4 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -213,7 +213,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) // platforms. #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) if (mWidget && mWidget->GetOwningTabChild()) { - mCompositorMightResample = AsyncPanZoomEnabled(); + mCompositorMightResample = gfxPrefs::AsyncPanZoomEnabled(); } #endif @@ -782,12 +782,6 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, #endif } -bool -ClientLayerManager::AsyncPanZoomEnabled() const -{ - return mWidget && mWidget->AsyncPanZoomEnabled(); -} - ClientLayer::~ClientLayer() { if (HasShadow()) { diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 43ffa28578e..65f2c3ed730 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -250,9 +250,6 @@ public: void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) { mTransactionIdAllocator = aAllocator; } float RequestProperty(const nsAString& aProperty) override; - - bool AsyncPanZoomEnabled() const override; - protected: enum TransactionPhase { PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index ea70921f1cb..7d2169905a0 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -257,7 +257,7 @@ ClientTiledPaintedLayer::UseProgressiveDraw() { return false; } - if (ClientManager()->AsyncPanZoomEnabled()) { + if (gfxPrefs::AsyncPanZoomEnabled()) { LayerMetricsWrapper scrollAncestor; GetAncestorLayers(&scrollAncestor, nullptr, nullptr); MOZ_ASSERT(scrollAncestor); // because mPaintData.mCriticalDisplayPort is non-empty diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index e49250517b1..0e8744a2491 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -1329,12 +1329,6 @@ LayerComposite::SetLayerManager(LayerManagerComposite* aManager) mCompositor = aManager->GetCompositor(); } -bool -LayerManagerComposite::AsyncPanZoomEnabled() const -{ - return mCompositor->GetWidget()->AsyncPanZoomEnabled(); -} - nsIntRegion LayerComposite::GetFullyRenderedRegion() { if (TiledLayerComposer* tiled = GetTiledLayerComposer()) { diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 5cfbe7c4244..b6a0de1618e 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -249,8 +249,6 @@ public: bool LastFrameMissedHWC() { return mLastFrameMissedHWC; } - bool AsyncPanZoomEnabled() const override; - private: /** Region we're clipping our current drawing to. */ nsIntRegion mClippingRegion; diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index a9997ac21cc..03b269eb618 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -662,9 +662,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget, sIndirectLayerTrees[mRootLayerTreeID].mParent = this; } - // The Compositor uses the APZ pref directly since it needs to know whether - // to attempt to create the APZ machinery at all. - if (gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly() && + if (gfxPrefs::AsyncPanZoomEnabled() && #if !defined(MOZ_B2G) && !defined(MOZ_WIDGET_ANDROID) // For XUL applications (everything but B2G on mobile and desktop, and // Firefox on Android) we only want to use APZ when E10S is enabled. If diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 99a5cd430cf..10fe98fcbf1 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2444,9 +2444,7 @@ DetectBadApzWheelInputPrefs() void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) { - // This is only a diagnostic so we use the low-level pref to see whether - // C++ APZ is enabled at all. - if (!gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { return; } diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index b8b7e9c7936..8e3622c688e 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -269,7 +269,7 @@ private: DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false); DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabled, bool, false); - DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true); + DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabled, bool, false); DECL_GFX_PREF(Once, "layers.async-pan-zoom.separate-event-thread", AsyncPanZoomSeparateEventThread, bool, false); DECL_GFX_PREF(Once, "layers.async-video.enabled", AsyncVideoEnabled, bool, true); DECL_GFX_PREF(Once, "layers.async-video-oop.enabled", AsyncVideoOOPEnabled, bool, true); diff --git a/image/ImageFactory.cpp b/image/ImageFactory.cpp index b61d538af81..ddd1a3df25e 100644 --- a/image/ImageFactory.cpp +++ b/image/ImageFactory.cpp @@ -47,16 +47,11 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart) // We default to the static globals. bool isDiscardable = gfxPrefs::ImageMemDiscardable(); + bool doDecodeOnlyOnDraw = gfxPrefs::ImageDecodeOnlyOnDrawEnabled() && + gfxPrefs::AsyncPanZoomEnabled(); bool doDecodeImmediately = gfxPrefs::ImageDecodeImmediatelyEnabled(); bool doDownscaleDuringDecode = gfxPrefs::ImageDownscaleDuringDecodeEnabled(); - // We use the compositor APZ pref here since we don't have a widget to test. - // It's safe since this is an optimization, and the only platform - // ImageDecodeOnlyOnDraw is disabled on is B2G (where APZ is enabled in all - // widgets anyway). - bool doDecodeOnlyOnDraw = gfxPrefs::ImageDecodeOnlyOnDrawEnabled() && - gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly(); - // We want UI to be as snappy as possible and not to flicker. Disable // discarding and decode-only-on-draw for chrome URLS. bool isChrome = false; diff --git a/layout/base/AccessibleCaretEventHub.cpp b/layout/base/AccessibleCaretEventHub.cpp index 2148995cff9..a269f1a0da9 100644 --- a/layout/base/AccessibleCaretEventHub.cpp +++ b/layout/base/AccessibleCaretEventHub.cpp @@ -8,7 +8,6 @@ #include "AccessibleCaretLogger.h" #include "AccessibleCaretManager.h" -#include "Layers.h" #include "gfxPrefs.h" #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" @@ -412,9 +411,7 @@ AccessibleCaretEventHub::Init(nsIPresShell* aPresShell) } #if defined(MOZ_WIDGET_GONK) - if (layers::LayerManager* lm = mPresShell->GetLayerManager()) { - mUseAsyncPanZoom = lm->AsyncPanZoomEnabled(); - } + mUseAsyncPanZoom = gfxPrefs::AsyncPanZoomEnabled(); #endif docShell->AddWeakReflowObserver(this); diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 525001e9cdc..9a73ddfee30 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -4751,7 +4751,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, if ((aContainerFrame->GetStateBits() & NS_FRAME_NO_COMPONENT_ALPHA) && mRetainingManager && mRetainingManager->ShouldAvoidComponentAlphaLayers() && - !nsLayoutUtils::AsyncPanZoomEnabled(aContainerFrame)) + !gfxPrefs::AsyncPanZoomEnabled()) { flattenToSingleLayer = true; } @@ -4783,7 +4783,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, mRetainingManager->ShouldAvoidComponentAlphaLayers() && containerLayer->HasMultipleChildren() && !flattenToSingleLayer && - !nsLayoutUtils::AsyncPanZoomEnabled(aContainerFrame)) + !gfxPrefs::AsyncPanZoomEnabled()) { // Since we don't want any component alpha layers on BasicLayers, we repeat // the layer building process with this explicitely forced off. diff --git a/layout/base/SelectionCarets.cpp b/layout/base/SelectionCarets.cpp index affb133c555..1209a903193 100644 --- a/layout/base/SelectionCarets.cpp +++ b/layout/base/SelectionCarets.cpp @@ -33,7 +33,6 @@ #include "mozilla/dom/TreeWalker.h" #include "mozilla/Preferences.h" #include "mozilla/TouchEvents.h" -#include "Layers.h" #include "TouchCaret.h" #include "nsFrameSelection.h" @@ -117,9 +116,7 @@ SelectionCarets::Init() } #if defined(MOZ_WIDGET_GONK) - if (layers::LayerManager* lm = mPresShell->GetLayerManager()) { - mUseAsyncPanZoom = lm->AsyncPanZoomEnabled(); - } + mUseAsyncPanZoom = gfxPrefs::AsyncPanZoomEnabled(); #endif docShell->AddWeakReflowObserver(this); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 766a1ddd0f1..084a3fdfd82 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -634,8 +634,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame, mHaveScrollableDisplayPort(false), mWindowDraggingAllowed(false), mIsBuildingForPopup(nsLayoutUtils::IsPopup(aReferenceFrame)), - mForceLayerForScrollParent(false), - mAsyncPanZoomEnabled(nsLayoutUtils::AsyncPanZoomEnabled(aReferenceFrame)) + mForceLayerForScrollParent(false) { MOZ_COUNT_CTOR(nsDisplayListBuilder); PL_InitArenaPool(&mPool, "displayListArena", 1024, @@ -2285,7 +2284,7 @@ nsDisplayBackgroundImage::ShouldFixToViewport(LayerManager* aManager) { // APZ doesn't (yet) know how to scroll the visible region for these type of // items, so don't layerize them if it's enabled. - if (nsLayoutUtils::UsesAsyncScrolling(mFrame) || + if (nsLayoutUtils::UsesAsyncScrolling() || (aManager && aManager->ShouldAvoidComponentAlphaLayers())) { return false; } @@ -4210,7 +4209,7 @@ nsDisplaySubDocument::ComputeVisibility(nsDisplayListBuilder* aBuilder, // If APZ is enabled then don't allow this computation to influence // aVisibleRegion, on the assumption that the layer can be asynchronously // scrolled so we'll definitely need all the content under it. - if (!nsLayoutUtils::UsesAsyncScrolling(mFrame)) { + if (!nsLayoutUtils::UsesAsyncScrolling()) { bool snap; nsRect bounds = GetBounds(aBuilder, &snap); nsRegion removed; diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 02e7a14104a..4a678edc566 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -350,8 +350,8 @@ public: if (mMode == PAINTING) { // Note: this is the only place that gets to query LayoutEventRegionsEnabled // 'directly' - other code should call this function. - return gfxPrefs::LayoutEventRegionsEnabledDoNotUseDirectly() || - mAsyncPanZoomEnabled; + return (gfxPrefs::LayoutEventRegionsEnabledDoNotUseDirectly() || + gfxPrefs::AsyncPanZoomEnabled()); } return false; } @@ -976,7 +976,6 @@ private: bool mWindowDraggingAllowed; bool mIsBuildingForPopup; bool mForceLayerForScrollParent; - bool mAsyncPanZoomEnabled; }; class nsDisplayItem; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d8678cba870..e9194c10491 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -814,34 +814,6 @@ ApplyRectMultiplier(nsRect aRect, float aMultiplier) return nsRect(ceil(newX), ceil(newY), floor(newWidth), floor(newHeight)); } -bool -nsLayoutUtils::UsesAsyncScrolling(nsIFrame* aFrame) -{ -#ifdef MOZ_WIDGET_ANDROID - // We always have async scrolling for android - return true; -#endif - - return AsyncPanZoomEnabled(aFrame); -} - -bool -nsLayoutUtils::AsyncPanZoomEnabled(nsIFrame* aFrame) -{ - // We use this as a shortcut, since if the compositor will never use APZ, - // no widget will either. - if (!gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly()) { - return false; - } - - nsIFrame *frame = nsLayoutUtils::GetDisplayRootFrame(aFrame); - nsIWidget* widget = frame->GetNearestWidget(); - if (!widget) { - return false; - } - return widget->AsyncPanZoomEnabled(); -} - // Return the maximum displayport size, based on the LayerManager's maximum // supported texture size. The result is in app units. static nscoord @@ -1113,12 +1085,9 @@ nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent, aMargins, aPriority), nsINode::DeleteProperty); - if (gfxPrefs::LayoutUseContainersForRootFrames()) { + if (nsLayoutUtils::UsesAsyncScrolling() && gfxPrefs::LayoutUseContainersForRootFrames()) { nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame(); - if (rootScrollFrame && - aContent == rootScrollFrame->GetContent() && - nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame)) - { + if (rootScrollFrame && aContent == rootScrollFrame->GetContent()) { // We are setting a root displayport for a document. // If we have APZ, then set a special flag on the pres shell so // that we don't get scrollbars drawn. @@ -3006,7 +2975,7 @@ nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder, // Note: we only do this in processes where we do subframe scrolling to // begin with (i.e., not in the parent process on B2G). if (aBuilder.IsPaintingToWindow() && - nsLayoutUtils::AsyncPanZoomEnabled(aScrollFrame) && + gfxPrefs::AsyncPanZoomEnabled() && !aBuilder.HaveScrollableDisplayPort() && scrollableFrame->WantAsyncScroll()) { @@ -7853,6 +7822,17 @@ nsLayoutUtils::CalculateExpandedScrollableRect(nsIFrame* aFrame) return scrollableRect; } +/* static */ bool +nsLayoutUtils::UsesAsyncScrolling() +{ +#ifdef MOZ_WIDGET_ANDROID + // We always have async scrolling for android + return true; +#endif + + return gfxPrefs::AsyncPanZoomEnabled(); +} + /* static */ void nsLayoutUtils::DoLogTestDataForPaint(LayerManager* aManager, ViewID aScrollId, diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index d5d10c2386b..ed72c122fcc 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2514,16 +2514,10 @@ public: CalculateExpandedScrollableRect(nsIFrame* aFrame); /** - * Returns true if the widget owning the given frame uses asynchronous - * scrolling. + * Returns true if we're using asynchronous scrolling (either through + * APZ or the android frontend). */ - static bool UsesAsyncScrolling(nsIFrame* aFrame); - - /** - * Returns true if the widget owning the given frame has builtin APZ support - * enabled. - */ - static bool AsyncPanZoomEnabled(nsIFrame* aFrame); + static bool UsesAsyncScrolling(); /** * Log a key/value pair for APZ testing during a paint. diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index a50ab8ea49f..f1542d02372 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -11041,10 +11041,10 @@ nsIPresShell::RecomputeFontSizeInflationEnabled() // Force-enabling font inflation always trumps the heuristics here. if (!FontSizeInflationForceEnabled()) { - if (TabChild* tab = TabChild::GetFrom(this)) { + if (TabChild::GetFrom(this)) { // We're in a child process. Cancel inflation if we're not // async-pan zoomed. - if (!tab->AsyncPanZoomEnabled()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { mFontSizeInflationEnabled = false; return; } diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 82c53dc5c5e..d6aa1a960a2 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1824,7 +1824,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter, if (IsAlwaysActive() && gfxPrefs::LayersTilesEnabled() && - !nsLayoutUtils::UsesAsyncScrolling(mOuter) && + !nsLayoutUtils::UsesAsyncScrolling() && mOuter->GetContent()) { // If we have tiling but no APZ, then set a 0-margin display port on // active scroll containers so that we paint by whole tile increments @@ -2028,7 +2028,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition, mAsyncScroll = nullptr; } - if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) { + if (gfxPrefs::AsyncPanZoomEnabled()) { // The animation will be handled in the compositor, pass the // information needed to start the animation and skip the main-thread // animation for this scroll. @@ -2909,7 +2909,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, shouldBuildLayer = true; } else { shouldBuildLayer = - nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && + gfxPrefs::AsyncPanZoomEnabled() && WantAsyncScroll() && // If we are using containers for root frames, and we are the root // scroll frame for the display root, then we don't need a scroll @@ -3051,7 +3051,7 @@ ScrollFrameHelper::ComputeFrameMetrics(Layer* aLayer, // above the first one on a given layer. They will be applied by the // compositor instead, with async transforms for the scrollframes interspersed // between them. - bool omitClip = nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && aOutput->Length() > 0; + bool omitClip = gfxPrefs::AsyncPanZoomEnabled() && aOutput->Length() > 0; if (!omitClip && (!gfxPrefs::LayoutUseContainersForRootFrames() || mAddClipRectToLayer)) { nsRect clip = nsRect(mScrollPort.TopLeft() + toReferenceFrame, nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter)); @@ -3355,8 +3355,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, } if (aUnit == nsIScrollableFrame::DEVICE_PIXELS && - !nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) - { + !gfxPrefs::AsyncPanZoomEnabled()) { // When APZ is disabled, we must track the velocity // on the main thread; otherwise, the APZC will manage this. mVelocityQueue.Sample(GetScrollPosition()); diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index acc6ecd8926..52097f26fbf 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -299,7 +299,6 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, , mFrameLoader(aFrameLoader) , mFrameLoaderDestroyed(false) , mBackgroundColor(gfxRGBA(1, 1, 1)) - , mAsyncPanZoomEnabled(false) { *aSuccess = false; if (!mFrameLoader) { @@ -309,9 +308,6 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, *aId = 0; nsRefPtr lm = GetFrom(mFrameLoader); - - mAsyncPanZoomEnabled = lm && lm->AsyncPanZoomEnabled(); - // Perhaps the document containing this frame currently has no presentation? if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { *aTextureFactoryIdentifier = @@ -329,7 +325,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, static_cast(lm.get()); clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId); } - if (mAsyncPanZoomEnabled) { + if (gfxPrefs::AsyncPanZoomEnabled()) { mContentController = new RemoteContentController(this); CompositorParent::SetControllerForLayerTree(mLayersId, mContentController); } @@ -350,7 +346,7 @@ RenderFrameParent::GetApzcTreeManager() // created and the static getter knows which CompositorParent is // instantiated with this layers ID. That's why try to fetch it when // we first need it and cache the result. - if (!mApzcTreeManager && mAsyncPanZoomEnabled) { + if (!mApzcTreeManager && gfxPrefs::AsyncPanZoomEnabled()) { mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mLayersId); } return mApzcTreeManager.get(); diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index 64abba21db1..9114dddf508 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -151,8 +151,6 @@ private: gfxRGBA mBackgroundColor; nsRegion mTouchRegion; - - bool mAsyncPanZoomEnabled; }; } // namespace layout diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index b183bb53bd6..659aa8d4741 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -744,7 +744,7 @@ function BuildConditionSandbox(aURL) { sandbox.Mulet = gB2GisMulet; try { - sandbox.asyncPanZoom = gContainingWindow.document.docShell.asyncPanZoomEnabled; + sandbox.asyncPanZoom = prefs.getBoolPref("layers.async-pan-zoom.enabled"); } catch (e) { sandbox.asyncPanZoom = false; } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index ae39dbdcc04..20ed9e34525 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -354,7 +354,7 @@ PuppetWidget::DispatchInputEvent(WidgetInputEvent* aEvent) nsEventStatus PuppetWidget::DispatchAPZAwareEvent(WidgetInputEvent* aEvent) { - if (!AsyncPanZoomEnabled()) { + if (!gfxPrefs::AsyncPanZoomEnabled()) { nsEventStatus status = nsEventStatus_eIgnore; DispatchEvent(aEvent, status); return status; @@ -493,12 +493,6 @@ PuppetWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId, } } -bool -PuppetWidget::AsyncPanZoomEnabled() const -{ - return mTabChild && mTabChild->AsyncPanZoomEnabled(); -} - NS_IMETHODIMP_(bool) PuppetWidget::ExecuteNativeKeyBinding(NativeKeyBindingsType aType, const mozilla::WidgetKeyboardEvent& aEvent, diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 0a7edd0bee8..6ddcaceacfd 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -135,7 +135,6 @@ public: nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override; void SetConfirmedTargetAPZC(uint64_t aInputBlockId, const nsTArray& aTargets) const override; - bool AsyncPanZoomEnabled() const override; NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) override diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index fd7aca77586..b7bb55867f5 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1007,12 +1007,6 @@ nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId, mAPZC.get(), setTargetApzcFunc, aInputBlockId, mozilla::Move(aTargets))); } -bool -nsBaseWidget::AsyncPanZoomEnabled() const -{ - return !!mAPZC; -} - nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent, const ScrollableLayerGuid& aGuid, diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index a1ccd1357db..97e57223ee2 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -242,8 +242,6 @@ public: void SetConfirmedTargetAPZC(uint64_t aInputBlockId, const nsTArray& aTargets) const override; - bool AsyncPanZoomEnabled() const override; - void NotifyWindowDestroyed(); void NotifySizeMoveDone(); void NotifyWindowMoved(int32_t aX, int32_t aY); diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 27b0257ad0b..78310e4423b 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1807,11 +1807,6 @@ class nsIWidget : public nsISupports { virtual void SetConfirmedTargetAPZC(uint64_t aInputBlockId, const nsTArray& aTargets) const = 0; - /** - * Returns true if APZ is in use, false otherwise. - */ - virtual bool AsyncPanZoomEnabled() const = 0; - /** * Enables the dropping of files to a widget (XXX this is temporary) *