Skip to content

Commit

Permalink
Bug 1937603 - Do not handle screen orientation on windowless browser;…
Browse files Browse the repository at this point in the history
… r=smaug

This patch reuses the existing but unused `mWindowless` flag. The flag is now
propagated to the BrowsingContext created under the windowless browser.

Differential Revision: https://phabricator.services.mozilla.com/D238584
  • Loading branch information
EdgarChen committed Feb 19, 2025
1 parent 8294a4c commit 4b25c4e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docshell/base/BrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
new BrowsingContext(parentWC, group, id, aType, std::move(fields));
}

context->mWindowless = aOptions.windowless;
context->mEmbeddedByThisProcess = XRE_IsParentProcess() || aParent;
context->mCreatedDynamically = aOptions.createdDynamically;
if (inherit) {
Expand All @@ -517,13 +518,13 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
}

already_AddRefed<BrowsingContext> BrowsingContext::CreateIndependent(
Type aType) {
Type aType, bool aWindowless) {
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
"BCs created in the content process must be related to "
"some BrowserChild");
RefPtr<BrowsingContext> bc(
CreateDetached(nullptr, nullptr, nullptr, u""_ns, aType, {}));
bc->mWindowless = bc->IsContent();
bc->mWindowless = aWindowless;
bc->mEmbeddedByThisProcess = true;
bc->EnsureAttached();
return bc.forget();
Expand Down
4 changes: 3 additions & 1 deletion docshell/base/BrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,16 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
//
// The process which created this BrowsingContext is responsible for detaching
// it.
static already_AddRefed<BrowsingContext> CreateIndependent(Type aType);
static already_AddRefed<BrowsingContext> CreateIndependent(Type aType,
bool aWindowless);

// Options which can be passed to CreateDetached.
struct CreateDetachedOptions {
bool isPopupRequested = false;
bool createdDynamically = false;
bool topLevelCreatedByWebContent = false;
bool isForPrinting = false;
bool windowless = false;
};

// Create a brand-new BrowsingContext object, but does not immediately attach
Expand Down
3 changes: 2 additions & 1 deletion docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4741,7 +4741,8 @@ void nsDocShell::ActivenessMaybeChanged() {
mScriptGlobal->SetIsBackground(!isActive);
if (RefPtr<Document> doc = mScriptGlobal->GetExtantDoc()) {
// Update orientation when the top-level browsing context becomes active.
if (isActive && mBrowsingContext->IsTop()) {
if (isActive && mBrowsingContext->IsTop() &&
!mBrowsingContext->Windowless()) {
// We only care about the top-level browsing context.
auto orientation = mBrowsingContext->GetOrientationLock();
ScreenOrientation::UpdateActiveOrientationLock(orientation);
Expand Down
4 changes: 3 additions & 1 deletion dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
options.topLevelCreatedByWebContent =
aOpenWindowInfo->GetIsTopLevelCreatedByWebContent();
}
options.windowless = parentBC->Windowless();

// Create toplevel context without a parent & as Type::Content.
return BrowsingContext::CreateDetached(
Expand All @@ -358,7 +359,8 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
"Can't force BrowsingContextGroup for non-toplevel context");
return BrowsingContext::CreateDetached(
parentInner, nullptr, nullptr, frameName, parentBC->GetType(),
{.createdDynamically = !aNetworkCreated});
{.createdDynamically = !aNetworkCreated,
.windowless = parentBC->Windowless()});
}

static bool InitialLoadIsRemote(Element* aOwner) {
Expand Down
2 changes: 1 addition & 1 deletion xpfe/appshell/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ nsresult AppWindow::Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener,
// to pass in the opener window here. The opener is set later, if needed, by
// nsWindowWatcher.
RefPtr<BrowsingContext> browsingContext =
BrowsingContext::CreateIndependent(BrowsingContext::Type::Chrome);
BrowsingContext::CreateIndependent(BrowsingContext::Type::Chrome, false);

// Create web shell
mDocShell = nsDocShell::Create(browsingContext);
Expand Down
3 changes: 2 additions & 1 deletion xpfe/appshell/nsAppShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, uint32_t aChromeMask,
// Create a BrowsingContext for our windowless browser.
RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateIndependent(
aIsChrome ? BrowsingContext::Type::Chrome
: BrowsingContext::Type::Content);
: BrowsingContext::Type::Content,
true);

if (aChromeMask & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW) {
browsingContext->SetRemoteTabs(true);
Expand Down

0 comments on commit 4b25c4e

Please sign in to comment.