From 4f25d1180de6699d3c31d74f8e3d90e26128b43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 6 May 2024 11:30:34 +0000 Subject: [PATCH] Bug 1895229 - Remove nsIWebBrowserChromeFocus. r=hsivonen,dom-core It's only implemented by BrowserChild, we can do this more directly. Differential Revision: https://phabricator.services.mozilla.com/D209534 --- docshell/base/nsDocShell.cpp | 22 ------------- docshell/base/nsDocShellTreeOwner.cpp | 8 ----- docshell/base/nsIDocShell.idl | 10 ------ dom/base/nsFocusManager.cpp | 10 +++--- dom/ipc/BrowserChild.cpp | 13 -------- dom/ipc/BrowserChild.h | 3 -- toolkit/components/browser/moz.build | 1 - toolkit/components/browser/nsIWebBrowser.idl | 2 -- .../browser/nsIWebBrowserChromeFocus.idl | 32 ------------------- 9 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 toolkit/components/browser/nsIWebBrowserChromeFocus.idl diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 87a34cf5b2f2..65caf8a231a7 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -167,7 +167,6 @@ #include "nsIURILoader.h" #include "nsIViewSourceChannel.h" #include "nsIWebBrowserChrome.h" -#include "nsIWebBrowserChromeFocus.h" #include "nsIWebBrowserFind.h" #include "nsIWebProgress.h" #include "nsIWidget.h" @@ -2098,27 +2097,6 @@ nsDocShell::GetBusyFlags(BusyFlags* aBusyFlags) { return NS_OK; } -NS_IMETHODIMP -nsDocShell::TabToTreeOwner(bool aForward, bool aForDocumentNavigation, - bool* aTookFocus) { - NS_ENSURE_ARG_POINTER(aTookFocus); - - nsCOMPtr chromeFocus = do_GetInterface(mTreeOwner); - if (chromeFocus) { - if (aForward) { - *aTookFocus = - NS_SUCCEEDED(chromeFocus->FocusNextElement(aForDocumentNavigation)); - } else { - *aTookFocus = - NS_SUCCEEDED(chromeFocus->FocusPrevElement(aForDocumentNavigation)); - } - } else { - *aTookFocus = false; - } - - return NS_OK; -} - NS_IMETHODIMP nsDocShell::GetLoadURIDelegate(nsILoadURIDelegate** aLoadURIDelegate) { nsCOMPtr delegate = GetLoadURIDelegate(); diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index 6d8eb11cc695..6861c58b5328 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -39,7 +39,6 @@ #include "nsIRemoteTab.h" #include "nsIBrowserChild.h" #include "nsRect.h" -#include "nsIWebBrowserChromeFocus.h" #include "nsIContent.h" #include "nsServiceManagerUtils.h" #include "nsViewManager.h" @@ -196,13 +195,6 @@ nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink) { return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsIWebBrowserChromeFocus))) { - if (mWebBrowserChromeWeak != nullptr) { - return mWebBrowserChromeWeak->QueryReferent(aIID, aSink); - } - return mOwnerWin->QueryInterface(aIID, aSink); - } - if (aIID.Equals(NS_GET_IID(nsIPrompt))) { nsCOMPtr prompt; EnsurePrompter(); diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 024c0f544c54..fdc04f16c6f5 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -271,16 +271,6 @@ interface nsIDocShell : nsIDocShellTreeItem */ attribute float zoom; - /* - * Tells the docshell to offer focus to its tree owner. - * This is currently only necessary for embedding chrome. - * If forDocumentNavigation is true, then document navigation should be - * performed, where only the root of documents are selected. Otherwise, the - * next element in the parent should be returned. Returns true if focus was - * successfully taken by the tree owner. - */ - boolean tabToTreeOwner(in boolean forward, in boolean forDocumentNavigation); - /** * Current busy state for DocShell */ diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 474d6fe02133..f450c05d0192 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -3662,12 +3662,10 @@ nsresult nsFocusManager::DetermineElementToMoveFocus( } } else { if (aNavigateByKey) { - // There is no parent, so call the tree owner. This will tell the - // embedder or parent process that it should take the focus. - bool tookFocus; - docShell->TabToTreeOwner(forward, forDocumentNavigation, &tookFocus); - // If the tree owner took the focus, blur the current element. - if (tookFocus) { + // There is no parent, so move the focus to the parent process. + if (auto* child = BrowserChild::GetFrom(docShell)) { + child->SendMoveFocus(forward, forDocumentNavigation); + // Blur the current element. RefPtr focusedBC = GetFocusedBrowsingContext(); if (focusedBC && focusedBC->IsInProcess()) { Blur(focusedBC, nullptr, true, true, false, diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 4ae0f5e6fad9..ef348e0831f5 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -502,7 +502,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserChild) NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) - NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) NS_INTERFACE_MAP_ENTRY(nsIWindowProvider) NS_INTERFACE_MAP_ENTRY(nsIBrowserChild) @@ -627,18 +626,6 @@ BrowserChild::GetDimensions(DimensionKind aDimensionKind, int32_t* aX, NS_IMETHODIMP BrowserChild::Blur() { return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -BrowserChild::FocusNextElement(bool aForDocumentNavigation) { - SendMoveFocus(true, aForDocumentNavigation); - return NS_OK; -} - -NS_IMETHODIMP -BrowserChild::FocusPrevElement(bool aForDocumentNavigation) { - SendMoveFocus(false, aForDocumentNavigation); - return NS_OK; -} - NS_IMETHODIMP BrowserChild::GetInterface(const nsIID& aIID, void** aSink) { // XXXbz should we restrict the set of interfaces we hand out here? diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index 27bea5f37634..7e84b80be16b 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -12,7 +12,6 @@ #include "nsIWebNavigation.h" #include "nsCOMPtr.h" #include "nsIWebBrowserChrome.h" -#include "nsIWebBrowserChromeFocus.h" #include "nsIInterfaceRequestor.h" #include "nsIWindowProvider.h" #include "nsIDocShell.h" @@ -128,7 +127,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, public ipc::MessageManagerCallback, public PBrowserChild, public nsIWebBrowserChrome, - public nsIWebBrowserChromeFocus, public nsIInterfaceRequestor, public nsIWindowProvider, public nsSupportsWeakReference, @@ -185,7 +183,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_NSIWEBBROWSERCHROME - NS_DECL_NSIWEBBROWSERCHROMEFOCUS NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIWINDOWPROVIDER NS_DECL_NSIBROWSERCHILD diff --git a/toolkit/components/browser/moz.build b/toolkit/components/browser/moz.build index 903390a3c86b..848c135afcca 100644 --- a/toolkit/components/browser/moz.build +++ b/toolkit/components/browser/moz.build @@ -12,7 +12,6 @@ DIRS += ["build"] XPIDL_SOURCES += [ "nsIWebBrowser.idl", "nsIWebBrowserChrome.idl", - "nsIWebBrowserChromeFocus.idl", ] XPIDL_SOURCES += [ diff --git a/toolkit/components/browser/nsIWebBrowser.idl b/toolkit/components/browser/nsIWebBrowser.idl index a644dcd31eb2..40812ea429ad 100644 --- a/toolkit/components/browser/nsIWebBrowser.idl +++ b/toolkit/components/browser/nsIWebBrowser.idl @@ -38,7 +38,6 @@ interface nsIWebBrowser : nsISupports * window via the browser's nsIBaseWindow interface. * * The chrome may optionally implement nsIInterfaceRequestor, - * nsIWebBrowserChromeFocus, * nsIContextMenuListener and * nsITooltipListener to receive additional notifications * from the browser object. @@ -57,7 +56,6 @@ interface nsIWebBrowser : nsISupports * @see nsIBaseWindow * @see nsIWebBrowserChrome * @see nsIInterfaceRequestor - * @see nsIWebBrowserChromeFocus * @see nsIContextMenuListener * @see nsITooltipListener * @see nsIWeakReference diff --git a/toolkit/components/browser/nsIWebBrowserChromeFocus.idl b/toolkit/components/browser/nsIWebBrowserChromeFocus.idl deleted file mode 100644 index 077ce392016f..000000000000 --- a/toolkit/components/browser/nsIWebBrowserChromeFocus.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 0 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -/** - * The nsIWebBrowserChromeFocus is implemented by the same object as the - * nsIEmbeddingSiteWindow. It represents the focus up-calls from mozilla - * to the embedding chrome. See mozilla bug #70224 for gratuitous info. - */ - -[scriptable, uuid(947B2EE6-51ED-4C2B-9F45-426C27CA84C6)] -interface nsIWebBrowserChromeFocus : nsISupports -{ - /** - * Set the focus at the next focusable element in the chrome. If - * aForDocumentNavigation is true, this was a document navigation, so - * focus the parent window. - */ - - void focusNextElement(in boolean aForDocumentNavigation); - - /** - * Set the focus at the previous focusable element in the chrome. - */ - - void focusPrevElement(in boolean aForDocumentNavigation); - -};