diff --git a/docshell/base/nsWebNavigationInfo.cpp b/docshell/base/nsWebNavigationInfo.cpp index c4d81ba813..2d1e196656 100644 --- a/docshell/base/nsWebNavigationInfo.cpp +++ b/docshell/base/nsWebNavigationInfo.cpp @@ -51,6 +51,13 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, return NS_OK; } + // We want to claim that the type for SWF movies is unsupported, + // so that the internal SWF player's stream converter will get used. + if (aType.LowerCaseEqualsLiteral("application/x-shockwave-flash") && + nsContentUtils::IsSWFPlayerEnabled()) { + return NS_OK; + } + const nsCString& flatType = PromiseFlatCString(aType); nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/base/BarProps.cpp b/dom/base/BarProps.cpp index 4d0e36bfe3..2b826265ca 100644 --- a/dom/base/BarProps.cpp +++ b/dom/base/BarProps.cpp @@ -287,23 +287,7 @@ ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv) and because embedding apps have no interface for implementing this themselves, and therefore the implementation must be internal. */ - nsCOMPtr scroller = - do_QueryInterface(mDOMWindow->GetDocShell()); - - if (scroller) { - int32_t prefValue; - - if (aVisible) { - prefValue = nsIScrollable::Scrollbar_Auto; - } else { - prefValue = nsIScrollable::Scrollbar_Never; - } - - scroller->SetDefaultScrollbarPreferences( - nsIScrollable::ScrollOrientation_Y, prefValue); - scroller->SetDefaultScrollbarPreferences( - nsIScrollable::ScrollOrientation_X, prefValue); - } + nsContentUtils::SetScrollbarsVisibility(mDOMWindow->GetDocShell(), aVisible); /* Notably absent is the part where we notify the chrome window using GetBrowserChrome()->SetChromeFlags(). Given the possibility of multiple diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 20c7cb7d5c..8e1dd31daf 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -154,6 +154,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIScriptObjectPrincipal.h" #include "nsIScriptSecurityManager.h" +#include "nsIScrollable.h" #include "nsIStreamConverterService.h" #include "nsIStringBundle.h" #include "nsIURI.h" @@ -6582,6 +6583,20 @@ nsContentUtils::IsPDFJSEnabled() return NS_SUCCEEDED(rv) && canConvert; } +bool +nsContentUtils::IsSWFPlayerEnabled() +{ + nsCOMPtr convServ = + do_GetService("@mozilla.org/streamConverters;1"); + nsresult rv = NS_ERROR_FAILURE; + bool canConvert = false; + if (convServ) { + rv = convServ->CanConvert("application/x-shockwave-flash", + "text/html", &canConvert); + } + return NS_SUCCEEDED(rv) && canConvert; +} + already_AddRefed nsContentUtils::FindInternalContentViewer(const nsACString& aType, ContentViewerType* aLoaderType) @@ -8924,3 +8939,24 @@ nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri) uri->GetSpec(spec); return spec.EqualsASCII(aUri); } + +/* static */ void +nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible) +{ + nsCOMPtr scroller = do_QueryInterface(aDocShell); + + if (scroller) { + int32_t prefValue; + + if (aVisible) { + prefValue = nsIScrollable::Scrollbar_Auto; + } else { + prefValue = nsIScrollable::Scrollbar_Never; + } + + scroller->SetDefaultScrollbarPreferences( + nsIScrollable::ScrollOrientation_Y, prefValue); + scroller->SetDefaultScrollbarPreferences( + nsIScrollable::ScrollOrientation_X, prefValue); + } +} diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 4ee7ea452e..3ca3ce809f 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2137,6 +2137,11 @@ public: */ static bool IsPDFJSEnabled(); + /** + * Checks if internal SWF player is enabled. + */ + static bool IsSWFPlayerEnabled(); + enum ContentViewerType { TYPE_UNSUPPORTED, @@ -2570,6 +2575,8 @@ public: */ static bool IsSpecificAboutPage(JSObject* aGlobal, const char* aUri); + static void SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible); + private: static bool InitializeEventTable(); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 00af743e0a..881654e519 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -6,7 +6,7 @@ #include "nsDOMWindowUtils.h" -#include "mozilla/layers/CompositorChild.h" +#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/LayerTransactionChild.h" #include "nsPresContext.h" #include "nsDOMClassInfoID.h" diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index b832b01bfc..2eef06ea4b 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -92,7 +92,7 @@ #include "jsapi.h" #include "mozilla/dom/HTMLIFrameElement.h" #include "nsSandboxFlags.h" -#include "mozilla/layers/CompositorChild.h" +#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/dom/ipc/StructuredCloneData.h" @@ -1687,7 +1687,7 @@ nsFrameLoader::ShouldUseRemoteProcess() // Don't try to launch nested children if we don't have OMTC. // They won't render! if (XRE_IsContentProcess() && - !CompositorChild::ChildProcessHasCompositor()) { + !CompositorBridgeChild::ChildProcessHasCompositor()) { return false; } diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 7100eeccfb..dd28e606d0 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -557,6 +557,11 @@ IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType) return false; } + // Disables any native SWF plugins, when internal SWF player is enabled. + if (ext.EqualsIgnoreCase("swf") && nsContentUtils::IsSWFPlayerEnabled()) { + return false; + } + RefPtr pluginHost = nsPluginHost::GetInst(); if (!pluginHost) { @@ -2648,8 +2653,8 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType, EventStates newState = ObjectState(); if (newState != aOldState) { + NS_ASSERTION(thisContent->IsInComposedDoc(), "Something is confused"); // This will trigger frame construction - NS_ASSERTION(InActiveDocument(thisContent), "Something is confused"); EventStates changedBits = aOldState ^ newState; { @@ -2657,6 +2662,7 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType, doc->ContentStateChanged(thisContent, changedBits); } if (aSync) { + NS_ASSERTION(InActiveDocument(thisContent), "Something is confused"); // Make sure that frames are actually constructed immediately. doc->FlushPendingNotifications(Flush_Frames); } @@ -2690,6 +2696,13 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType) return eType_Document; } + // Faking support of the SWF content as a document for EMBED tags + // when internal SWF player is enabled. + if (aMIMEType.LowerCaseEqualsLiteral("application/x-shockwave-flash") && + nsContentUtils::IsSWFPlayerEnabled()) { + return eType_Document; + } + if ((caps & eSupportDocuments) && IsSupportedDocument(aMIMEType)) { return eType_Document; } @@ -2752,8 +2765,10 @@ nsObjectLoadingContent::PluginDestroyed() // plugins in plugin host. Invalidate instance owner / prototype but otherwise // don't take any action. TeardownProtoChain(); - mInstanceOwner->Destroy(); - mInstanceOwner = nullptr; + if (mInstanceOwner) { + mInstanceOwner->Destroy(); + mInstanceOwner = nullptr; + } return NS_OK; } @@ -2814,8 +2829,7 @@ nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx, aCx == nsContentUtils::GetCurrentJSContext()); bool callerIsContentJS = (nsContentUtils::GetCurrentJSContext() && !nsContentUtils::IsCallerChrome() && - !nsContentUtils::IsCallerContentXBL() && - JS_IsRunning(aCx)); + !nsContentUtils::IsCallerContentXBL()); nsCOMPtr thisContent = do_QueryInterface(static_cast(this)); @@ -2947,7 +2961,8 @@ nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) { aType = eFallbackAlternate; } - if (thisContent->IsHTMLElement(nsGkAtoms::object) && + if ((thisContent->IsHTMLElement(nsGkAtoms::object) || + thisContent->IsHTMLElement(nsGkAtoms::applet)) && (aType == eFallbackUnsupported || aType == eFallbackDisabled || aType == eFallbackBlocklisted)) diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index edec3586a8..60296d1556 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -265,6 +265,7 @@ support-files = [test_anonymousContent_insert.html] [test_anonymousContent_manipulate_content.html] [test_anonymousContent_style_csp.html] +[test_applet_alternate_content.html] [test_appname_override.html] [test_async_setTimeout_stack.html] [test_async_setTimeout_stack_across_globals.html] diff --git a/dom/base/test/test_applet_alternate_content.html b/dom/base/test/test_applet_alternate_content.html new file mode 100644 index 0000000000..88cb12f1fb --- /dev/null +++ b/dom/base/test/test_applet_alternate_content.html @@ -0,0 +1,42 @@ + + + + + + Test for Bug 1200602 + + + + + +Mozilla Bug 1200602 +
+
+
+ + diff --git a/dom/html/test/test_fullscreen-api.html b/dom/html/test/test_fullscreen-api.html index bc47604e96..d405f0482a 100644 --- a/dom/html/test/test_fullscreen-api.html +++ b/dom/html/test/test_fullscreen-api.html @@ -75,7 +75,7 @@ function nextTest() { function runNextTest() { if (gTestIndex < gTestWindows.length) { - testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500"); + testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500,scrollbars=yes"); // We'll wait for the window to load, then make sure our window is refocused // before starting the test, which will get kicked off on "focus". // This ensures that we're essentially back on the primary "desktop" on diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index d0a5a6fbea..0c78bec9f9 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -45,9 +45,8 @@ #include "mozilla/ipc/TestShellChild.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/layers/APZChild.h" -#include "mozilla/layers/CompositorChild.h" +#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/ImageBridgeChild.h" -#include "mozilla/layers/PCompositorBridgeChild.h" #include "mozilla/layers/SharedBufferManagerChild.h" #include "mozilla/layout/RenderFrameChild.h" #include "mozilla/net/NeckoChild.h" @@ -596,9 +595,6 @@ ReinitTaskTracer(void* /*aUnused*/) ContentChild::ContentChild() : mID(uint64_t(-1)) -#ifdef ANDROID - , mScreenSize(0, 0) -#endif , mCanOverrideProcessName(true) , mIsAlive(true) { @@ -1278,7 +1274,7 @@ PCompositorBridgeChild* ContentChild::AllocPCompositorBridgeChild(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherProcess) { - return CompositorChild::Create(aTransport, aOtherProcess); + return CompositorBridgeChild::Create(aTransport, aOtherProcess); } PSharedBufferManagerChild* @@ -2499,17 +2495,6 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission) return true; } -bool -ContentChild::RecvScreenSizeChanged(const gfx::IntSize& size) -{ -#ifdef ANDROID - mScreenSize = size; -#else - NS_RUNTIMEABORT("Message currently only expected on android"); -#endif - return true; -} - bool ContentChild::RecvFlushMemory(const nsString& reason) { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 2d10509265..7b569b59e6 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -431,8 +431,6 @@ public: virtual bool RecvAddPermission(const IPC::Permission& permission) override; - virtual bool RecvScreenSizeChanged(const gfx::IntSize &size) override; - virtual bool RecvFlushMemory(const nsString& reason) override; virtual bool RecvActivateA11y() override; @@ -534,10 +532,6 @@ public: RecvPushSubscriptionChange(const nsCString& aScope, const IPC::Principal& aPrincipal) override; -#ifdef ANDROID - gfx::IntSize GetScreenSize() { return mScreenSize; } -#endif - // Get the directory for IndexedDB files. We query the parent for this and // cache the value nsString &GetIndexedDBPath(); @@ -636,10 +630,6 @@ private: AppInfo mAppInfo; -#ifdef ANDROID - gfx::IntSize mScreenSize; -#endif - bool mIsForApp; bool mIsForBrowser; bool mCanOverrideProcessName; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index a0c4fbfa8b..50c593d6c0 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -82,7 +82,7 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/layers/PAPZParent.h" -#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/ImageBridgeParent.h" #include "mozilla/layers/SharedBufferManagerParent.h" #include "mozilla/LookAndFeel.h" @@ -1912,7 +1912,7 @@ ContentParent::AllocateLayerTreeId(ContentParent* aContent, TabParent* aTopLevel, const TabId& aTabId, uint64_t* aId) { - *aId = CompositorParent::AllocateLayerTreeId(); + *aId = CompositorBridgeParent::AllocateLayerTreeId(); if (!gfxPlatform::AsyncPanZoomEnabled()) { return true; @@ -1922,7 +1922,7 @@ ContentParent::AllocateLayerTreeId(ContentParent* aContent, return false; } - return CompositorParent::UpdateRemoteContentController(*aId, aContent, + return CompositorBridgeParent::UpdateRemoteContentController(*aId, aContent, aTabId, aTopLevel); } @@ -1970,7 +1970,7 @@ ContentParent::RecvDeallocateLayerTreeId(const uint64_t& aId) auto iter = NestedBrowserLayerIds().find(this); if (iter != NestedBrowserLayerIds().end() && iter->second.find(aId) != iter->second.end()) { - CompositorParent::DeallocateLayerTreeId(aId); + CompositorBridgeParent::DeallocateLayerTreeId(aId); } else { // You can't deallocate layer tree ids that you didn't allocate KillHard("DeallocateLayerTreeId"); @@ -2534,14 +2534,14 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, if (aSetupOffMainThreadCompositing) { // NB: internally, this will send an IPC message to the child - // process to get it to create the CompositorChild. This + // process to get it to create the CompositorBridgeChild. This // message goes through the regular IPC queue for this // channel, so delivery will happen-before any other messages - // we send. The CompositorChild must be created before any + // we send. The CompositorBridgeChild must be created before any // PBrowsers are created, because they rely on the Compositor // already being around. (Creation is async, so can't happen // on demand.) - bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop(); + bool useOffMainThreadCompositing = !!CompositorBridgeParent::CompositorLoop(); if (useOffMainThreadCompositing) { DebugOnly opened = PCompositorBridge::Open(this); MOZ_ASSERT(opened); @@ -3349,7 +3349,7 @@ PCompositorBridgeParent* ContentParent::AllocPCompositorBridgeParent(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherProcess) { - return CompositorParent::Create(aTransport, aOtherProcess); + return CompositorBridgeParent::Create(aTransport, aOtherProcess); } gfx::PVRManagerParent* diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 6c0f9f21a0..1509c18609 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -530,6 +530,7 @@ child: async UpdateDimensions(CSSRect rect, CSSSize size, ScreenOrientationInternal orientation, + LayoutDeviceIntPoint clientOffset, LayoutDeviceIntPoint chromeDisp) compressall; async SizeModeChanged(nsSizeMode sizeMode); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index c57d835124..ee1e057d50 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -603,8 +603,6 @@ child: // nsIPermissionManager messages async AddPermission(Permission permission); - async ScreenSizeChanged(IntSize size); - async Volumes(VolumeInfo[] volumes); async FlushMemory(nsString reason); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index a99c70d8ca..57cf7e4fd8 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -33,7 +33,7 @@ #include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/APZEventState.h" -#include "mozilla/layers/CompositorChild.h" +#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/DoubleTapToZoom.h" #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/InputAPZContext.h" @@ -840,6 +840,9 @@ TabChild::Init() do_QueryInterface(window->GetChromeEventHandler()); docShell->SetChromeEventHandler(chromeHandler); + nsContentUtils::SetScrollbarsVisibility(window->GetDocShell(), + !!(mChromeFlags & nsIWebBrowserChrome::CHROME_SCROLLBARS)); + nsWeakPtr weakPtrThis = do_GetWeakReference(static_cast(this)); // for capture by the lambda ContentReceivedInputBlockCallback callback( [weakPtrThis](const ScrollableLayerGuid& aGuid, @@ -1210,7 +1213,7 @@ TabChild::ActorDestroy(ActorDestroyReason why) mTabChildGlobal->mMessageManager = nullptr; } - CompositorChild* compositorChild = static_cast(CompositorChild::Get()); + CompositorBridgeChild* compositorChild = static_cast(CompositorBridgeChild::Get()); compositorChild->CancelNotifyAfterRemotePaint(this); if (GetTabId() != 0) { @@ -1634,6 +1637,7 @@ TabChild::RecvShow(const ScreenIntSize& aSize, bool TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, const ScreenOrientationInternal& orientation, + const LayoutDeviceIntPoint& clientOffset, const LayoutDeviceIntPoint& chromeDisp) { if (!mRemoteFrame) { @@ -1641,6 +1645,7 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, } mUnscaledOuterRect = rect; + mClientOffset = clientOffset; mChromeDisp = chromeDisp; mOrientation = orientation; @@ -1659,8 +1664,8 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, true); - mPuppetWidget->Resize(screenRect.x + chromeDisp.x, - screenRect.y + chromeDisp.y, + mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x, + screenRect.y + clientOffset.y + chromeDisp.y, screenSize.width, screenSize.height, true); return true; @@ -1752,9 +1757,8 @@ TabChild::NotifyAPZStateChange(const ViewID& aViewId, if (aChange == layers::GeckoContentController::APZStateChange::TransformEnd) { // This is used by tests to determine when the APZ is done doing whatever // it's doing. XXX generify this as needed when writing additional tests. - DispatchMessageManagerMessage( - NS_LITERAL_STRING("APZ:TransformEnd"), - NS_LITERAL_STRING("{}")); + nsCOMPtr observerService = mozilla::services::GetObserverService(); + observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr); } return true; } @@ -2534,9 +2538,9 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden // Pushing layers transactions directly to a separate // compositor context. - PCompositorBridgeChild* compositorChild = CompositorChild::Get(); + PCompositorBridgeChild* compositorChild = CompositorBridgeChild::Get(); if (!compositorChild) { - NS_WARNING("failed to get CompositorChild instance"); + NS_WARNING("failed to get CompositorBridgeChild instance"); PRenderFrameChild::Send__delete__(remoteFrame); return false; } @@ -2642,7 +2646,7 @@ TabChild::NotifyPainted() void TabChild::MakeVisible() { - CompositorChild* compositor = CompositorChild::Get(); + CompositorBridgeChild* compositor = CompositorBridgeChild::Get(); if (UsingCompositorLRU()) { compositor->SendNotifyVisible(mLayersId); } @@ -2655,12 +2659,12 @@ TabChild::MakeVisible() void TabChild::MakeHidden() { - CompositorChild* compositor = CompositorChild::Get(); + CompositorBridgeChild* compositor = CompositorBridgeChild::Get(); if (UsingCompositorLRU()) { compositor->SendNotifyHidden(mLayersId); } else { // Clear cached resources directly. This avoids one extra IPC - // round-trip from CompositorChild to CompositorParent when + // round-trip from CompositorBridgeChild to CompositorBridgeParent when // CompositorLRU is not used. compositor->RecvClearCachedResources(mLayersId); } @@ -2814,8 +2818,7 @@ TabChild::DidComposite(uint64_t aTransactionId, MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT); - ClientLayerManager *manager = - static_cast(mPuppetWidget->GetLayerManager()); + ClientLayerManager *manager = mPuppetWidget->GetLayerManager()->AsClientLayerManager(); manager->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd); } @@ -2895,10 +2898,10 @@ TabChild::OnHideTooltip() bool TabChild::RecvRequestNotifyAfterRemotePaint() { - // Get the CompositorChild instance for this content thread. - CompositorChild* compositor = CompositorChild::Get(); + // Get the CompositorBridgeChild instance for this content thread. + CompositorBridgeChild* compositor = CompositorBridgeChild::Get(); - // Tell the CompositorChild that, when it gets a RemotePaintIsReady + // Tell the CompositorBridgeChild that, when it gets a RemotePaintIsReady // message that it should forward it us so that we can bounce it to our // RenderFrameParent. compositor->RequestNotifyAfterRemotePaint(this); @@ -2924,8 +2927,8 @@ TabChild::RecvUIResolutionChanged(const float& aDpi, const double& aScale) ScreenIntSize screenSize = GetInnerSize(); if (mHasValidInnerSize && oldScreenSize != screenSize) { ScreenIntRect screenRect = GetOuterRect(); - mPuppetWidget->Resize(screenRect.x + mChromeDisp.x, - screenRect.y + mChromeDisp.y, + mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeDisp.x, + screenRect.y + mClientOffset.y + mChromeDisp.y, screenSize.width, screenSize.height, true); nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 8d5f298959..70d1a16c3d 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -326,6 +326,7 @@ public: virtual bool RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, const ScreenOrientationInternal& orientation, + const LayoutDeviceIntPoint& aClientOffset, const LayoutDeviceIntPoint& chromeDisp) override; virtual bool @@ -551,6 +552,7 @@ public: nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut); + LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; } LayoutDeviceIntPoint GetChromeDisplacement() { return mChromeDisp; }; bool IPCOpen() { return mIPCOpen; } @@ -698,6 +700,8 @@ private: SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback; bool mHasValidInnerSize; bool mDestroyed; + // Position of client area relative to the outer window + LayoutDeviceIntPoint mClientOffset; // Position of tab, relative to parent widget (typically the window) LayoutDeviceIntPoint mChromeDisp; TabId mUniqueId; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index fb696ddeae..f24d1c2095 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -29,7 +29,7 @@ #include "mozilla/ipc/DocumentRendererParent.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/layers/AsyncDragMetrics.h" -#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layout/RenderFrameParent.h" #include "mozilla/LookAndFeel.h" @@ -941,28 +941,28 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) if (mIsDestroyed) { return; } - hal::ScreenConfiguration config; - hal::GetCurrentScreenConfiguration(&config); - ScreenOrientationInternal orientation = config.orientation(); - LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset(); - nsCOMPtr widget = GetWidget(); if (!widget) { NS_WARNING("No widget found in TabParent::UpdateDimensions"); return; } - nsIntRect contentRect = rect; - contentRect.x += widget->GetClientOffset().x; - contentRect.y += widget->GetClientOffset().y; + + hal::ScreenConfiguration config; + hal::GetCurrentScreenConfiguration(&config); + ScreenOrientationInternal orientation = config.orientation(); + LayoutDeviceIntPoint clientOffset = widget->GetClientOffset(); + LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset(); if (!mUpdatedDimensions || mOrientation != orientation || - mDimensions != size || !mRect.IsEqualEdges(contentRect) || + mDimensions != size || !mRect.IsEqualEdges(rect) || + clientOffset != mClientOffset || chromeOffset != mChromeOffset) { mUpdatedDimensions = true; - mRect = contentRect; + mRect = rect; mDimensions = size; mOrientation = orientation; + mClientOffset = clientOffset; mChromeOffset = chromeOffset; CSSToLayoutDeviceScale widgetScale = widget->GetDefaultScale(); @@ -977,7 +977,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) CSSRect unscaledRect = devicePixelRect / widgetScale; CSSSize unscaledSize = devicePixelSize / widgetScale; Unused << SendUpdateDimensions(unscaledRect, unscaledSize, - orientation, chromeOffset); + orientation, clientOffset, chromeOffset); } } @@ -2874,8 +2874,9 @@ TabParent::RequestNotifyLayerTreeReady() if (!frame) { mNeedLayerTreeReadyNotification = true; } else { - CompositorParent::RequestNotifyLayerTreeReady(frame->GetLayersId(), - new LayerTreeUpdateObserver()); + CompositorBridgeParent::RequestNotifyLayerTreeReady( + frame->GetLayersId(), + new LayerTreeUpdateObserver()); } return true; } @@ -2888,8 +2889,9 @@ TabParent::RequestNotifyLayerTreeCleared() return false; } - CompositorParent::RequestNotifyLayerTreeCleared(frame->GetLayersId(), - new LayerTreeUpdateObserver()); + CompositorBridgeParent::RequestNotifyLayerTreeCleared( + frame->GetLayersId(), + new LayerTreeUpdateObserver()); return true; } @@ -2924,12 +2926,13 @@ TabParent::SwapLayerTreeObservers(TabParent* aOther) RenderFrameParent* rfp = GetRenderFrame(); RenderFrameParent* otherRfp = aOther->GetRenderFrame(); - if(!rfp || !otherRfp) { + if (!rfp || !otherRfp) { return; } - CompositorParent::SwapLayerTreeObservers(rfp->GetLayersId(), - otherRfp->GetLayersId()); + CompositorBridgeParent::SwapLayerTreeObservers( + rfp->GetLayersId(), + otherRfp->GetLayersId()); } bool diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 943d1e119a..8daf458d71 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -602,6 +602,7 @@ protected: CSSToLayoutDeviceScale mDefaultScale; bool mUpdatedDimensions; nsSizeMode mSizeMode; + LayoutDeviceIntPoint mClientOffset; LayoutDeviceIntPoint mChromeOffset; private: diff --git a/dom/media/systemservices/MediaSystemResourceService.cpp b/dom/media/systemservices/MediaSystemResourceService.cpp index 1c07e34cfa..c7f01fb375 100644 --- a/dom/media/systemservices/MediaSystemResourceService.cpp +++ b/dom/media/systemservices/MediaSystemResourceService.cpp @@ -5,7 +5,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaSystemResourceManagerParent.h" -#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/unused.h" #include "MediaSystemResourceService.h" @@ -46,7 +46,7 @@ MediaSystemResourceService::Shutdown() MediaSystemResourceService::MediaSystemResourceService() : mDestroyed(false) { - MOZ_ASSERT(CompositorParent::IsInCompositorThread()); + MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread()); #ifdef MOZ_WIDGET_GONK // The maximum number of hardware resoureces available. // XXX need to hange to a dynamic way. @@ -82,7 +82,7 @@ MediaSystemResourceService::Acquire(media::MediaSystemResourceManagerParent* aPa MediaSystemResourceType aResourceType, bool aWillWait) { - MOZ_ASSERT(CompositorParent::IsInCompositorThread()); + MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread()); MOZ_ASSERT(aParent); if (mDestroyed) { @@ -123,7 +123,7 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar uint32_t aId, MediaSystemResourceType aResourceType) { - MOZ_ASSERT(CompositorParent::IsInCompositorThread()); + MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread()); MOZ_ASSERT(aParent); if (mDestroyed) { diff --git a/dom/tests/mochitest/bugs/mochitest.ini b/dom/tests/mochitest/bugs/mochitest.ini index 486c5e878e..018e5db535 100644 --- a/dom/tests/mochitest/bugs/mochitest.ini +++ b/dom/tests/mochitest/bugs/mochitest.ini @@ -168,7 +168,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1 skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #Windows can't change size on Android # b2g(Windows can't change size on B2G) b2g-debug(Windows can't change size on B2G) b2g-desktop(Windows can't change size on B2G) [test_toJSON.html] [test_window_bar.html] -skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s +skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' [test_bug1022869.html] [test_bug1112040.html] [test_bug1171215.html] diff --git a/dom/tests/mochitest/bugs/test_window_bar.html b/dom/tests/mochitest/bugs/test_window_bar.html index e7af0a7481..f31b170faa 100644 --- a/dom/tests/mochitest/bugs/test_window_bar.html +++ b/dom/tests/mochitest/bugs/test_window_bar.html @@ -48,7 +48,8 @@ function testWindow(w) } else { // w.location.search == '?true' if we expect the bars to be on, and - // '?false' otherwise. + // '?false' otherwise. By default, no bars are enabled, so '?default' + // can be handled the same way as '?false'. var enabled = w.location.search == '?true'; is(w[feature].visible, enabled, feature + ' should follow window.open settings.'); } @@ -64,7 +65,7 @@ function testWindow(w) w.close(); numWindows++; - if (numWindows == 2) { + if (numWindows == 3) { // We're done! SimpleTest.finish(); } @@ -87,6 +88,10 @@ var noBarsWindow = 'personalbar=no,status=no,scrollbars=no', false); +var defaultWindow = + window.open('file_window_bar.html?default', 'default-bars', + 'width=500,height=500', false); + diff --git a/gfx/doc/Silk.md b/gfx/doc/Silk.md index 05fe70e62d..76d376661d 100644 --- a/gfx/doc/Silk.md +++ b/gfx/doc/Silk.md @@ -54,18 +54,18 @@ On Windows, it should be through **DwmGetCompositionTimingInfo**. #Compositor When the **CompositorVsyncDispatcher** is notified of the vsync event, the **CompositorVsyncObserver** associated with the **CompositorVsyncDispatcher** begins execution. Since the **CompositorVsyncDispatcher** executes on the *Hardware Vsync Thread* and the **Compositor** composites on the *CompositorThread*, the **CompositorVsyncObserver** posts a task to the *CompositorThread*. -The **CompositorParent** then composites. +The **CompositorBridgeParent** then composites. The model where the **CompositorVsyncDispatcher** notifies components on the *Hardware Vsync Thread*, and the component schedules the task on the appropriate thread is used everywhere. The **CompositorVsyncObserver** listens to vsync events as needed and stops listening to vsync when composites are no longer scheduled or required. -Every **CompositorParent** is associated and tied to one **CompositorVsyncObserver**, which is associated with the **CompositorVsyncDispatcher**. -Each **CompositorParent** is associated with one widget and is created when a new platform window or **nsBaseWidget** is created. -The **CompositorParent**, **CompositorVsyncDispatcher**, **CompositorVsyncObserver**, and **nsBaseWidget** all have the same lifetimes, which are created and destroyed together. +Every **CompositorBridgeParent** is associated and tied to one **CompositorVsyncObserver**, which is associated with the **CompositorVsyncDispatcher**. +Each **CompositorBridgeParent** is associated with one widget and is created when a new platform window or **nsBaseWidget** is created. +The **CompositorBridgeParent**, **CompositorVsyncDispatcher**, **CompositorVsyncObserver**, and **nsBaseWidget** all have the same lifetimes, which are created and destroyed together. ###CompositorVsyncDispatcher The **CompositorVsyncDispatcher** executes on the *Hardware Vsync Thread*. It contains references to the **nsBaseWidget** it is associated with and has a lifetime equal to the **nsBaseWidget**. -The **CompositorVsyncDispatcher** is responsible for notifying the **CompositorParent** that a vsync event has occured. +The **CompositorVsyncDispatcher** is responsible for notifying the **CompositorBridgeParent** that a vsync event has occured. There can be multiple **CompositorVsyncDispatchers** per **Display**, one **CompositorVsyncDispatcher** per window. The only responsibility of the **CompositorVsyncDispatcher** is to notify components when a vsync event has occured, and to stop listening to vsync when no components require vsync events. We require one **CompositorVsyncDispatcher** per window so that we can handle multiple **Displays**. @@ -112,29 +112,29 @@ The **GeckoTouchDispatcher** handles this case by always forcing the **Composito ###Widget, Compositor, CompositorVsyncDispatcher, GeckoTouchDispatcher Shutdown Procedure When the [nsBaseWidget shuts down](http://hg.mozilla.org/mozilla-central/file/0df249a0e4d3/widget/nsBaseWidget.cpp#l182) - It calls nsBaseWidget::DestroyCompositor on the *Gecko Main Thread*. -During nsBaseWidget::DestroyCompositor, it first destroys the CompositorChild. -CompositorChild sends a sync IPC call to CompositorParent::RecvStop, which calls [CompositorParent::Destroy](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/gfx/layers/ipc/CompositorParent.cpp#l509). +During nsBaseWidget::DestroyCompositor, it first destroys the CompositorBridgeChild. +CompositorBridgeChild sends a sync IPC call to CompositorBridgeParent::RecvStop, which calls [CompositorBridgeParent::Destroy](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/gfx/layers/ipc/CompositorBridgeParent.cpp#l509). During this time, the *main thread* is blocked on the parent process. -CompositorParent::RecvStop runs on the *Compositor thread* and cleans up some resources, including setting the **CompositorVsyncObserver** to nullptr. -CompositorParent::RecvStop also explicitly keeps the CompositorParent alive and posts another task to run CompositorParent::DeferredDestroy on the Compositor loop so that all ipdl code can finish executing. +CompositorBridgeParent::RecvStop runs on the *Compositor thread* and cleans up some resources, including setting the **CompositorVsyncObserver** to nullptr. +CompositorBridgeParent::RecvStop also explicitly keeps the CompositorBridgeParent alive and posts another task to run CompositorBridgeParent::DeferredDestroy on the Compositor loop so that all ipdl code can finish executing. The **CompositorVsyncObserver** also unobserves from vsync and cancels any pending composite tasks. -Once CompositorParent::RecvStop finishes, the *main thread* in the parent process continues shutting down the nsBaseWidget. +Once CompositorBridgeParent::RecvStop finishes, the *main thread* in the parent process continues shutting down the nsBaseWidget. -At the same time, the *Compositor thread* is executing tasks until CompositorParent::DeferredDestroy runs, which flushes the compositor message loop. -Now we have two tasks as both the nsBaseWidget releases a reference to the Compositor on the *main thread* during destruction and the CompositorParent::DeferredDestroy releases a reference to the CompositorParent on the *Compositor Thread*. -Finally, the CompositorParent itself is destroyed on the *main thread* once both references are gone due to explicit [main thread destruction](http://hg.mozilla.org/mozilla-central/file/50b95032152c/gfx/layers/ipc/CompositorParent.h#l148). +At the same time, the *Compositor thread* is executing tasks until CompositorBridgeParent::DeferredDestroy runs, which flushes the compositor message loop. +Now we have two tasks as both the nsBaseWidget releases a reference to the Compositor on the *main thread* during destruction and the CompositorBridgeParent::DeferredDestroy releases a reference to the CompositorBridgeParent on the *Compositor Thread*. +Finally, the CompositorBridgeParent itself is destroyed on the *main thread* once both references are gone due to explicit [main thread destruction](http://hg.mozilla.org/mozilla-central/file/50b95032152c/gfx/layers/ipc/CompositorBridgeParent.h#l148). With the **CompositorVsyncObserver**, any accesses to the widget after nsBaseWidget::DestroyCompositor executes are invalid. Any accesses to the compositor between the time the nsBaseWidget::DestroyCompositor runs and the CompositorVsyncObserver's destructor runs aren't safe yet a hardware vsync event could occur between these times. -Since any tasks posted on the Compositor loop after CompositorParent::DeferredDestroy is posted are invalid, we make sure that no vsync tasks can be posted once CompositorParent::RecvStop executes and DeferredDestroy is posted on the Compositor thread. -When the sync call to CompositorParent::RecvStop executes, we explicitly set the CompositorVsyncObserver to null to prevent vsync notifications from occurring. -If vsync notifications were allowed to occur, since the **CompositorVsyncObserver**'s vsync notification executes on the *hardware vsync thread*, it would post a task to the Compositor loop and may execute after CompositorParent::DeferredDestroy. -Thus, we explicitly shut down vsync events in the **CompositorVsyncDispatcher** and **CompositorVsyncObserver** during nsBaseWidget::Shutdown to prevent any vsync tasks from executing after CompositorParent::DeferredDestroy. +Since any tasks posted on the Compositor loop after CompositorBridgeParent::DeferredDestroy is posted are invalid, we make sure that no vsync tasks can be posted once CompositorBridgeParent::RecvStop executes and DeferredDestroy is posted on the Compositor thread. +When the sync call to CompositorBridgeParent::RecvStop executes, we explicitly set the CompositorVsyncObserver to null to prevent vsync notifications from occurring. +If vsync notifications were allowed to occur, since the **CompositorVsyncObserver**'s vsync notification executes on the *hardware vsync thread*, it would post a task to the Compositor loop and may execute after CompositorBridgeParent::DeferredDestroy. +Thus, we explicitly shut down vsync events in the **CompositorVsyncDispatcher** and **CompositorVsyncObserver** during nsBaseWidget::Shutdown to prevent any vsync tasks from executing after CompositorBridgeParent::DeferredDestroy. The **CompositorVsyncDispatcher** may be destroyed on either the *main thread* or *Compositor Thread*, since both the nsBaseWidget and **CompositorVsyncObserver** race to destroy on different threads. nsBaseWidget is destroyed on the *main thread* and releases a reference to the **CompositorVsyncDispatcher** during destruction. -The **CompositorVsyncObserver** has a race to be destroyed either during CompositorParent shutdown or from the **GeckoTouchDispatcher** which is destroyed on the main thread with [ClearOnShutdown](http://hg.mozilla.org/mozilla-central/file/21567e9a6e40/xpcom/base/ClearOnShutdown.h#l15). -Whichever object, the CompositorParent or the **GeckoTouchDispatcher** is destroyed last will hold the last reference to the **CompositorVsyncDispatcher**, which destroys the object. +The **CompositorVsyncObserver** has a race to be destroyed either during CompositorBridgeParent shutdown or from the **GeckoTouchDispatcher** which is destroyed on the main thread with [ClearOnShutdown](http://hg.mozilla.org/mozilla-central/file/21567e9a6e40/xpcom/base/ClearOnShutdown.h#l15). +Whichever object, the CompositorBridgeParent or the **GeckoTouchDispatcher** is destroyed last will hold the last reference to the **CompositorVsyncDispatcher**, which destroys the object. #Refresh Driver The Refresh Driver is ticked from a [single active timer](http://hg.mozilla.org/mozilla-central/file/ab0490972e1e/layout/base/nsRefreshDriver.cpp#l11). @@ -212,7 +212,7 @@ There is still only one **VsyncParent/VsyncChild** pair, just each vsync notific #Object Lifetime 1. CompositorVsyncDispatcher - Lives as long as the nsBaseWidget associated with the VsyncDispatcher -2. CompositorVsyncObserver - Lives and dies the same time as the CompositorParent. +2. CompositorVsyncObserver - Lives and dies the same time as the CompositorBridgeParent. 3. RefreshTimerVsyncDispatcher - As long as the associated display object, which is the lifetime of Firefox. 4. VsyncSource - Lives as long as the gfxPlatform on the chrome process, which is the lifetime of Firefox. 5. VsyncParent/VsyncChild - Lives as long as the content process diff --git a/gfx/layers/Compositor.cpp b/gfx/layers/Compositor.cpp index e10b20a1ac..b04c8c3df1 100644 --- a/gfx/layers/Compositor.cpp +++ b/gfx/layers/Compositor.cpp @@ -5,7 +5,7 @@ #include "mozilla/layers/Compositor.h" #include "base/message_loop.h" // for MessageLoop -#include "mozilla/layers/CompositorParent.h" // for CompositorParent +#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent #include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc #include "mozilla/mozalloc.h" // for operator delete, etc #include "gfx2DGlue.h" @@ -25,8 +25,8 @@ namespace layers { /* static */ void Compositor::AssertOnCompositorThread() { - MOZ_ASSERT(!CompositorParent::CompositorLoop() || - CompositorParent::CompositorLoop() == MessageLoop::current(), + MOZ_ASSERT(!CompositorBridgeParent::CompositorLoop() || + CompositorBridgeParent::CompositorLoop() == MessageLoop::current(), "Can only call this from the compositor thread!"); } diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 5d24570e46..f810ffc4ed 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -125,7 +125,7 @@ class Layer; class TextureSource; class DataTextureSource; class CompositingRenderTarget; -class CompositorParent; +class CompositorBridgeParent; class LayerManagerComposite; enum SurfaceInitMode @@ -184,7 +184,7 @@ protected: public: NS_INLINE_DECL_REFCOUNTING(Compositor) - explicit Compositor(CompositorParent* aParent = nullptr) + explicit Compositor(CompositorBridgeParent* aParent = nullptr) : mCompositorID(0) , mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC) , mParent(aParent) @@ -549,7 +549,7 @@ protected: uint32_t mCompositorID; DiagnosticTypes mDiagnosticTypes; - CompositorParent* mParent; + CompositorBridgeParent* mParent; /** * We keep track of the total number of pixels filled as we composite the diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index 8a1e47582a..1faedd0f58 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -17,7 +17,7 @@ #include "TexturePoolOGL.h" #include "mozilla/layers/CompositorOGL.h" -#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/TextureHostOGL.h" @@ -1900,7 +1900,7 @@ bool LayerScope::CheckSendable() { // Only compositor threads check LayerScope status - MOZ_ASSERT(CompositorParent::IsInCompositorThread() || gIsGtest); + MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread() || gIsGtest); if (!gfxPrefs::LayerScopeEnabled()) { return false; diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 0f9c026e09..60594d69c1 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1710,7 +1710,8 @@ void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget) #endif void -Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) +Layer::Dump(std::stringstream& aStream, const char* aPrefix, + bool aDumpHtml, bool aSorted) { #ifdef MOZ_DUMP_PAINTING bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() && AsLayerComposite() && @@ -1777,13 +1778,25 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) } #endif - if (Layer* kid = GetFirstChild()) { + if (ContainerLayer* container = AsContainerLayer()) { + AutoTArray children; + if (aSorted) { + container->SortChildrenBy3DZOrder(children); + } else { + for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) { + children.AppendElement(l); + } + } nsAutoCString pfx(aPrefix); pfx += " "; if (aDumpHtml) { aStream << "
    "; } - kid->Dump(aStream, pfx.get(), aDumpHtml); + + for (Layer* child : children) { + child->Dump(aStream, pfx.get(), aDumpHtml, aSorted); + } + if (aDumpHtml) { aStream << "
"; } @@ -1792,8 +1805,6 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) if (aDumpHtml) { aStream << ""; } - if (Layer* next = GetNextSibling()) - next->Dump(aStream, aPrefix, aDumpHtml); } void @@ -1927,6 +1938,15 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix) if (GetContentFlags() & CONTENT_BACKFACE_HIDDEN) { aStream << " [backfaceHidden]"; } + if (Extend3DContext()) { + aStream << " [extend3DContext]"; + } + if (Combines3DTransformWithAncestors()) { + aStream << " [combines3DTransformWithAncestors]"; + } + if (Is3DContextLeaf()) { + aStream << " [is3DContextLeaf]"; + } if (GetScrollbarDirection() == VERTICAL) { aStream << nsPrintfCString(" [vscrollbar=%lld]", GetScrollbarTargetContainerId()).get(); } @@ -2317,14 +2337,15 @@ ReadbackLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent // LayerManager void -LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) +LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, + bool aDumpHtml, bool aSorted) { #ifdef MOZ_DUMP_PAINTING if (aDumpHtml) { aStream << "
  • "; } #endif - DumpSelf(aStream, aPrefix); + DumpSelf(aStream, aPrefix, aSorted); nsAutoCString pfx(aPrefix); pfx += " "; @@ -2347,17 +2368,18 @@ LayerManager::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHt } void -LayerManager::DumpSelf(std::stringstream& aStream, const char* aPrefix) +LayerManager::DumpSelf(std::stringstream& aStream, const char* aPrefix, bool aSorted) { PrintInfo(aStream, aPrefix); + aStream << " --- in " << (aSorted ? "3D-sorted rendering order" : "content order"); aStream << "\n"; } void -LayerManager::Dump() +LayerManager::Dump(bool aSorted) { std::stringstream ss; - Dump(ss); + Dump(ss, "", false, aSorted); print_stderr(ss); } diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 97fbfe10bc..a07fe2e63c 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -564,12 +564,13 @@ public: * Dump information about this layer manager and its managed tree to * aStream. */ - void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false); + void Dump(std::stringstream& aStream, const char* aPrefix="", + bool aDumpHtml=false, bool aSorted=false); /** * Dump information about just this layer manager itself to aStream */ - void DumpSelf(std::stringstream& aStream, const char* aPrefix=""); - void Dump(); + void DumpSelf(std::stringstream& aStream, const char* aPrefix="", bool aSorted=false); + void Dump(bool aSorted=false); /** * Dump information about this layer manager and its managed tree to @@ -1587,7 +1588,8 @@ public: * Dump information about this layer manager and its managed tree to * aStream. */ - void Dump(std::stringstream& aStream, const char* aPrefix="", bool aDumpHtml=false); + void Dump(std::stringstream& aStream, const char* aPrefix="", + bool aDumpHtml=false, bool aSorted=false); /** * Dump information about just this layer manager itself to aStream. */ diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index e2ca990433..b5ab0c5ce5 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -18,7 +18,7 @@ #include "mozilla/layers/APZThreadUtils.h" // for AssertOnCompositorThread, etc #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform #include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics -#include "mozilla/layers/CompositorParent.h" // for CompositorParent, etc +#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/MouseEvents.h" #include "mozilla/mozalloc.h" // for operator new @@ -54,7 +54,7 @@ typedef mozilla::gfx::Matrix4x4 Matrix4x4; float APZCTreeManager::sDPI = 160.0; struct APZCTreeManager::TreeBuildingState { - TreeBuildingState(CompositorParent* aCompositor, + TreeBuildingState(CompositorBridgeParent* aCompositor, bool aIsFirstPaint, uint64_t aOriginatingLayersId, APZTestData* aTestData, uint32_t aPaintSequence) : mCompositor(aCompositor) @@ -65,7 +65,7 @@ struct APZCTreeManager::TreeBuildingState { } // State that doesn't change as we recurse in the tree building - CompositorParent* const mCompositor; + CompositorBridgeParent* const mCompositor; const bool mIsFirstPaint; const uint64_t mOriginatingLayersId; const APZPaintLogHelper mPaintLogger; @@ -130,7 +130,7 @@ APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId, } void -APZCTreeManager::UpdateHitTestingTree(CompositorParent* aCompositor, +APZCTreeManager::UpdateHitTestingTree(CompositorBridgeParent* aCompositor, Layer* aRoot, bool aIsFirstPaint, uint64_t aOriginatingLayersId, @@ -144,7 +144,7 @@ APZCTreeManager::UpdateHitTestingTree(CompositorParent* aCompositor, // the layers id that originated this update. APZTestData* testData = nullptr; if (gfxPrefs::APZTestLoggingEnabled()) { - if (CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aOriginatingLayersId)) { + if (CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aOriginatingLayersId)) { testData = &state->mApzTestData; testData->StartNewPaint(aPaintSequenceNumber); } @@ -350,7 +350,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, needsApzc = false; } - const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId); + const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId); if (!(state && state->mController.get())) { needsApzc = false; } @@ -437,7 +437,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, bool newApzc = (apzc == nullptr || apzc->IsDestroyed()); if (newApzc) { apzc = NewAPZCInstance(aLayersId, state->mController); - apzc->SetCompositorParent(aState.mCompositor); + apzc->SetCompositorBridgeParent(aState.mCompositor); if (state->mCrossProcessParent != nullptr) { apzc->ShareFrameMetricsAcrossProcesses(); } @@ -642,7 +642,8 @@ APZCTreeManager::FlushApzRepaints(uint64_t aLayersId) // ensure any pending paints were flushed. Now, paints are flushed // immediately, so it is safe to simply send a notification now. APZCTM_LOG("Flushing repaints for layers id %" PRIu64, aLayersId); - const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId); + const CompositorBridgeParent::LayerTreeState* state = + CompositorBridgeParent::GetIndirectShadowTree(aLayersId); MOZ_ASSERT(state && state->mController); NS_DispatchToMainThread(NS_NewRunnableMethod( state->mController.get(), &GeckoContentController::NotifyFlushComplete)); diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 56e70ead86..d0c470435d 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -50,7 +50,7 @@ enum ZoomToRectBehavior : uint32_t { class Layer; class AsyncDragMetrics; class AsyncPanZoomController; -class CompositorParent; +class CompositorBridgeParent; class OverscrollHandoffChain; struct OverscrollHandoffState; struct FlingHandoffState; @@ -77,7 +77,7 @@ class HitTestingTreeNode; /** * This class manages the tree of AsyncPanZoomController instances. There is one - * instance of this class owned by each CompositorParent, and it contains as + * instance of this class owned by each CompositorBridgeParent, and it contains as * many AsyncPanZoomController instances as there are scrollable container layers. * This class generally lives on the compositor thread, although some functions * may be called from other threads as noted; thread safety is ensured internally. @@ -136,7 +136,7 @@ public: * process' layer subtree has its own sequence * numbers. */ - void UpdateHitTestingTree(CompositorParent* aCompositor, + void UpdateHitTestingTree(CompositorBridgeParent* aCompositor, Layer* aRoot, bool aIsFirstPaint, uint64_t aOriginatingLayersId, diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 018502010e..890a746f72 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -51,9 +51,8 @@ #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform #include "mozilla/layers/AxisPhysicsModel.h" // for AxisPhysicsModel #include "mozilla/layers/AxisPhysicsMSDModel.h" // for AxisPhysicsMSDModel -#include "mozilla/layers/CompositorParent.h" // for CompositorParent +#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent #include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent -#include "mozilla/layers/PCompositorBridgeParent.h" // for PCompositorBridgeParent #include "mozilla/layers/ScrollInputMethods.h" // for ScrollInputMethod #include "mozilla/mozalloc.h" // for operator new, etc #include "mozilla/unused.h" // for unused @@ -890,13 +889,13 @@ AsyncPanZoomController::GetSharedFrameMetricsCompositor() APZThreadUtils::AssertOnCompositorThread(); if (mSharingFrameMetricsAcrossProcesses) { - // |state| may be null here if the CrossProcessCompositorParent has already been destroyed. - if (const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(mLayersId)) { + // |state| may be null here if the CrossProcessCompositorBridgeParent has already been destroyed. + if (const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(mLayersId)) { return state->CrossProcessPCompositorBridge(); } return nullptr; } - return mCompositorParent.get(); + return mCompositorBridgeParent.get(); } already_AddRefed @@ -2668,8 +2667,8 @@ void AsyncPanZoomController::ClearOverscroll() { mY.ClearOverscroll(); } -void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorParent) { - mCompositorParent = aCompositorParent; +void AsyncPanZoomController::SetCompositorBridgeParent(CompositorBridgeParent* aCompositorBridgeParent) { + mCompositorBridgeParent = aCompositorBridgeParent; } void AsyncPanZoomController::ShareFrameMetricsAcrossProcesses() { @@ -2810,8 +2809,8 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort( } void AsyncPanZoomController::ScheduleComposite() { - if (mCompositorParent) { - mCompositorParent->ScheduleRenderOnCompositorThread(); + if (mCompositorBridgeParent) { + mCompositorBridgeParent->ScheduleRenderOnCompositorThread(); } } @@ -3684,16 +3683,16 @@ void AsyncPanZoomController::DispatchStateChangeNotification(PanZoomState aOldSt #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) // Let the compositor know about scroll state changes so it can manage // windowed plugins. - if (mCompositorParent) { - mCompositorParent->ScheduleHideAllPluginWindows(); + if (mCompositorBridgeParent) { + mCompositorBridgeParent->ScheduleHideAllPluginWindows(); } #endif } else if (IsTransformingState(aOldState) && !IsTransformingState(aNewState)) { controller->NotifyAPZStateChange( GetGuid(), APZStateChange::TransformEnd); #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) - if (mCompositorParent) { - mCompositorParent->ScheduleShowAllPluginWindows(); + if (mCompositorBridgeParent) { + mCompositorBridgeParent->ScheduleShowAllPluginWindows(); } #endif } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 7b69405232..c7b2d36d99 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -42,7 +42,7 @@ namespace layers { class AsyncDragMetrics; struct ScrollableLayerGuid; -class CompositorParent; +class CompositorBridgeParent; class GestureEventListener; class PCompositorBridgeParent; struct AsyncTransform; @@ -191,7 +191,7 @@ public: * The platform implementation must set the compositor parent so that we can * request composites. */ - void SetCompositorParent(CompositorParent* aCompositorParent); + void SetCompositorBridgeParent(CompositorBridgeParent* aCompositorBridgeParent); /** * Inform this APZC that it will be sharing its FrameMetrics with a cross-process @@ -508,7 +508,7 @@ protected: /** * Schedules a composite on the compositor thread. Wrapper for - * CompositorParent::ScheduleRenderOnCompositorThread(). + * CompositorBridgeParent::ScheduleRenderOnCompositorThread(). */ void ScheduleComposite(); @@ -650,7 +650,7 @@ protected: void RequestSnapToDestination(); uint64_t mLayersId; - RefPtr mCompositorParent; + RefPtr mCompositorBridgeParent; /* Access to the following two fields is protected by the mRefPtrMonitor, since they are accessed on the UI thread but can be cleared on the diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index b9288591b9..141bfd346b 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -18,7 +18,7 @@ #include "mozilla/Attributes.h" #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform #include "mozilla/layers/GeckoContentController.h" -#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/layers/APZThreadUtils.h" diff --git a/gfx/layers/apz/test/mochitest/helper_basic_pan.html b/gfx/layers/apz/test/mochitest/helper_basic_pan.html index 07b46ee2e8..631bfc64e1 100644 --- a/gfx/layers/apz/test/mochitest/helper_basic_pan.html +++ b/gfx/layers/apz/test/mochitest/helper_basic_pan.html @@ -10,10 +10,12 @@