mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1432856 - Extended focus methods in Window.webidl, Client.webidl and Element.webidl to pass CallerType. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D55811 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
59e04ed99e
commit
70e1dba79e
@ -949,7 +949,7 @@ nsresult BrowsingContext::InternalLoad(BrowsingContext* aAccessor,
|
||||
// the same as how the tab first opened.
|
||||
nsCOMPtr<nsPIDOMWindowOuter> domWin = GetDOMWindow();
|
||||
if (isActive && domWin) {
|
||||
nsFocusManager::FocusWindow(domWin);
|
||||
nsFocusManager::FocusWindow(domWin, CallerType::System);
|
||||
}
|
||||
|
||||
// Else we ran out of memory, or were a popup and got blocked,
|
||||
@ -1023,11 +1023,11 @@ void BrowsingContext::Close(CallerType aCallerType, ErrorResult& aError) {
|
||||
}
|
||||
}
|
||||
|
||||
void BrowsingContext::Focus(ErrorResult& aError) {
|
||||
void BrowsingContext::Focus(CallerType aCallerType, ErrorResult& aError) {
|
||||
if (ContentChild* cc = ContentChild::GetSingleton()) {
|
||||
cc->SendWindowFocus(this);
|
||||
cc->SendWindowFocus(this, aCallerType);
|
||||
} else if (ContentParent* cp = Canonical()->GetContentParent()) {
|
||||
Unused << cp->SendWindowFocus(this);
|
||||
Unused << cp->SendWindowFocus(this, aCallerType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ class BrowsingContext : public nsISupports,
|
||||
ErrorResult& aError);
|
||||
void Close(CallerType aCallerType, ErrorResult& aError);
|
||||
bool GetClosed(ErrorResult&) { return mClosed; }
|
||||
void Focus(ErrorResult& aError);
|
||||
void Focus(CallerType aCallerType, ErrorResult& aError);
|
||||
void Blur(ErrorResult& aError);
|
||||
WindowProxyHolder GetFrames(ErrorResult& aError);
|
||||
int32_t Length() const { return mChildren.Length(); }
|
||||
|
@ -190,7 +190,7 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType,
|
||||
nsCOMPtr<nsPIDOMWindowOuter> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
domWindow->Focus();
|
||||
domWindow->Focus(mozilla::dom::CallerType::System);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -11739,7 +11739,7 @@ class nsAutoFocusEvent : public Runnable {
|
||||
|
||||
FocusOptions options;
|
||||
ErrorResult rv;
|
||||
mElement->Focus(options, rv);
|
||||
mElement->Focus(options, CallerType::System, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,8 @@ int32_t Element::TabIndex() {
|
||||
return TabIndexDefault();
|
||||
}
|
||||
|
||||
void Element::Focus(const FocusOptions& aOptions, ErrorResult& aError) {
|
||||
void Element::Focus(const FocusOptions& aOptions, CallerType aCallerType,
|
||||
ErrorResult& aError) {
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
// Also other browsers seem to have the hack to not re-focus (and flush) when
|
||||
// the element is already focused.
|
||||
@ -348,9 +349,13 @@ void Element::Focus(const FocusOptions& aOptions, ErrorResult& aError) {
|
||||
if (fm->CanSkipFocus(this)) {
|
||||
fm->NeedsFlushBeforeEventHandling(this);
|
||||
} else {
|
||||
aError = fm->SetFocus(
|
||||
this, nsIFocusManager::FLAG_BYELEMENTFOCUS |
|
||||
nsFocusManager::FocusOptionsToFocusManagerFlags(aOptions));
|
||||
uint32_t fmFlags =
|
||||
nsIFocusManager::FLAG_BYELEMENTFOCUS |
|
||||
nsFocusManager::FocusOptionsToFocusManagerFlags(aOptions);
|
||||
if (aCallerType == CallerType::NonSystem) {
|
||||
fmFlags = nsIFocusManager::FLAG_NONSYSTEMCALLER | fmFlags;
|
||||
}
|
||||
aError = fm->SetFocus(this, fmFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,8 @@ class Element : public FragmentOrElement {
|
||||
/**
|
||||
* Make focus on this element.
|
||||
*/
|
||||
virtual void Focus(const FocusOptions& aOptions, ErrorResult& aError);
|
||||
virtual void Focus(const FocusOptions& aOptions, const CallerType aCallerType,
|
||||
ErrorResult& aError);
|
||||
|
||||
/**
|
||||
* Show blur and clear focus.
|
||||
|
@ -4339,7 +4339,8 @@ nsresult nsContentUtils::DispatchChromeEvent(
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
void nsContentUtils::RequestFrameFocus(Element& aFrameElement, bool aCanRaise) {
|
||||
void nsContentUtils::RequestFrameFocus(Element& aFrameElement, bool aCanRaise,
|
||||
CallerType aCallerType) {
|
||||
RefPtr<Element> target = &aFrameElement;
|
||||
bool defaultAction = true;
|
||||
if (aCanRaise) {
|
||||
@ -4361,6 +4362,10 @@ void nsContentUtils::RequestFrameFocus(Element& aFrameElement, bool aCanRaise) {
|
||||
flags |= nsIFocusManager::FLAG_RAISE;
|
||||
}
|
||||
|
||||
if (aCallerType == CallerType::NonSystem) {
|
||||
flags |= nsIFocusManager::FLAG_NONSYSTEMCALLER;
|
||||
}
|
||||
|
||||
fm->SetFocus(target, flags);
|
||||
}
|
||||
|
||||
|
@ -1580,7 +1580,8 @@ class nsContentUtils {
|
||||
* Helper to dispatch a "framefocusrequested" event to chrome, which will only
|
||||
* bring the window to the foreground and switch tabs if aCanRaise is true.
|
||||
*/
|
||||
static void RequestFrameFocus(Element& aFrameElement, bool aCanRaise);
|
||||
static void RequestFrameFocus(Element& aFrameElement, bool aCanRaise,
|
||||
mozilla::dom::CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* This method creates and dispatches a trusted event.
|
||||
|
@ -351,21 +351,27 @@ nsFocusManager::GetActiveWindow(mozIDOMWindowProxy** aWindow) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsFocusManager::FocusWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
void nsFocusManager::FocusWindow(nsPIDOMWindowOuter* aWindow,
|
||||
CallerType aCallerType) {
|
||||
if (RefPtr<nsFocusManager> fm = sInstance) {
|
||||
fm->SetFocusedWindow(aWindow);
|
||||
fm->SetFocusedWindowWithCallerType(aWindow, aCallerType);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFocusManager::SetActiveWindow(mozIDOMWindowProxy* aWindow) {
|
||||
return SetActiveWindowWithCallerType(aWindow, CallerType::System);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFocusManager::SetActiveWindow(mozIDOMWindowProxy* aWindow) {
|
||||
nsFocusManager::SetActiveWindowWithCallerType(mozIDOMWindowProxy* aWindow,
|
||||
CallerType aCallerType) {
|
||||
NS_ENSURE_STATE(aWindow);
|
||||
|
||||
// only top-level windows can be made active
|
||||
nsCOMPtr<nsPIDOMWindowOuter> piWindow = nsPIDOMWindowOuter::From(aWindow);
|
||||
NS_ENSURE_TRUE(piWindow == piWindow->GetPrivateRoot(), NS_ERROR_INVALID_ARG);
|
||||
|
||||
RaiseWindow(piWindow);
|
||||
RaiseWindow(piWindow, aCallerType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -375,8 +381,8 @@ nsFocusManager::GetFocusedWindow(mozIDOMWindowProxy** aFocusedWindow) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFocusManager::SetFocusedWindow(
|
||||
mozIDOMWindowProxy* aWindowToFocus) {
|
||||
NS_IMETHODIMP nsFocusManager::SetFocusedWindowWithCallerType(
|
||||
mozIDOMWindowProxy* aWindowToFocus, CallerType aCallerType) {
|
||||
LOGFOCUS(("<<SetFocusedWindow begin>>"));
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> windowToFocus =
|
||||
@ -401,13 +407,18 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> rootWindow = windowToFocus->GetPrivateRoot();
|
||||
if (rootWindow) RaiseWindow(rootWindow);
|
||||
if (rootWindow) RaiseWindow(rootWindow, aCallerType);
|
||||
|
||||
LOGFOCUS(("<<SetFocusedWindow end>>"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFocusManager::SetFocusedWindow(
|
||||
mozIDOMWindowProxy* aWindowToFocus) {
|
||||
return SetFocusedWindowWithCallerType(aWindowToFocus, CallerType::System);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFocusManager::GetFocusedElement(Element** aFocusedElement) {
|
||||
RefPtr<Element> focusedElement = mFocusedElement;
|
||||
@ -629,7 +640,7 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
|
||||
// of the child we want. We solve this by calling SetFocus to ensure that
|
||||
// what the focus manager thinks should be the current widget is actually
|
||||
// focused.
|
||||
EnsureCurrentWidgetFocused();
|
||||
EnsureCurrentWidgetFocused(CallerType::System);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -844,7 +855,7 @@ nsFocusManager::WindowShown(mozIDOMWindowProxy* aWindow, bool aNeedsFocus) {
|
||||
// Sometimes, an element in a window can be focused before the window is
|
||||
// visible, which would mean that the widget may not be properly focused.
|
||||
// When the window becomes visible, make sure the right widget is focused.
|
||||
EnsureCurrentWidgetFocused();
|
||||
EnsureCurrentWidgetFocused(CallerType::System);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1058,7 +1069,7 @@ void nsFocusManager::NotifyFocusStateChange(nsIContent* aContent,
|
||||
}
|
||||
|
||||
// static
|
||||
void nsFocusManager::EnsureCurrentWidgetFocused() {
|
||||
void nsFocusManager::EnsureCurrentWidgetFocused(CallerType aCallerType) {
|
||||
if (!mFocusedWindow || sTestMode) return;
|
||||
|
||||
// get the main child widget for the focused window and ensure that the
|
||||
@ -1080,7 +1091,7 @@ void nsFocusManager::EnsureCurrentWidgetFocused() {
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
widget->SetFocus(nsIWidget::Raise::No);
|
||||
widget->SetFocus(nsIWidget::Raise::No, aCallerType);
|
||||
}
|
||||
|
||||
void nsFocusManager::ActivateOrDeactivate(nsPIDOMWindowOuter* aWindow,
|
||||
@ -1202,7 +1213,8 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
|
||||
}
|
||||
|
||||
// Exit fullscreen if a website focuses another window
|
||||
if (!isElementInActiveWindow && aFlags & FLAG_RAISE) {
|
||||
if (!isElementInActiveWindow &&
|
||||
aFlags & (FLAG_RAISE | FLAG_NONSYSTEMCALLER)) {
|
||||
if (Document* doc = mActiveWindow ? mActiveWindow->GetDoc() : nullptr) {
|
||||
if (doc->GetFullscreenElement()) {
|
||||
Document::AsyncExitFullscreen(doc);
|
||||
@ -1316,7 +1328,10 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
|
||||
if (allowFrameSwitch)
|
||||
newWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
|
||||
|
||||
if (aFlags & FLAG_RAISE) RaiseWindow(newRootWindow);
|
||||
if (aFlags & FLAG_RAISE)
|
||||
RaiseWindow(newRootWindow, aFlags & FLAG_NONSYSTEMCALLER
|
||||
? CallerType::NonSystem
|
||||
: CallerType::System);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1616,7 +1631,7 @@ bool nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
|
||||
vm->GetRootWidget(getter_AddRefs(widget));
|
||||
if (widget) {
|
||||
// set focus to the top level window but don't raise it.
|
||||
widget->SetFocus(nsIWidget::Raise::No);
|
||||
widget->SetFocus(nsIWidget::Raise::No, CallerType::System);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1809,7 +1824,10 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
|
||||
if (nsViewManager* vm = presShell->GetViewManager()) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
vm->GetRootWidget(getter_AddRefs(widget));
|
||||
if (widget) widget->SetFocus(nsIWidget::Raise::No);
|
||||
if (widget)
|
||||
widget->SetFocus(nsIWidget::Raise::No, aFlags & FLAG_NONSYSTEMCALLER
|
||||
? CallerType::NonSystem
|
||||
: CallerType::System);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1863,7 +1881,10 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
|
||||
// fired above when aIsNewDocument.
|
||||
if (presShell->GetDocument() == aElement->GetComposedDoc()) {
|
||||
if (aAdjustWidgets && objectFrameWidget && !sTestMode) {
|
||||
objectFrameWidget->SetFocus(nsIWidget::Raise::No);
|
||||
objectFrameWidget->SetFocus(nsIWidget::Raise::No,
|
||||
aFlags & FLAG_NONSYSTEMCALLER
|
||||
? CallerType::NonSystem
|
||||
: CallerType::System);
|
||||
}
|
||||
|
||||
// if the object being focused is a remote browser, activate remote
|
||||
@ -1900,7 +1921,9 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
vm->GetRootWidget(getter_AddRefs(widget));
|
||||
if (widget) {
|
||||
widget->SetFocus(nsIWidget::Raise::No);
|
||||
widget->SetFocus(nsIWidget::Raise::No, aFlags & FLAG_NONSYSTEMCALLER
|
||||
? CallerType::NonSystem
|
||||
: CallerType::System);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2133,7 +2156,8 @@ void nsFocusManager::ScrollIntoView(PresShell* aPresShell, nsIContent* aContent,
|
||||
}
|
||||
}
|
||||
|
||||
void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow,
|
||||
CallerType aCallerType) {
|
||||
// don't raise windows that are already raised or are in the process of
|
||||
// being lowered
|
||||
if (!aWindow || aWindow == mActiveWindow || aWindow == mWindowBeingLowered)
|
||||
@ -2178,7 +2202,7 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
if (nsViewManager* vm = presShell->GetViewManager()) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
vm->GetRootWidget(getter_AddRefs(widget));
|
||||
if (widget) widget->SetFocus(nsIWidget::Raise::Yes);
|
||||
if (widget) widget->SetFocus(nsIWidget::Raise::Yes, aCallerType);
|
||||
}
|
||||
#else
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin =
|
||||
@ -2186,7 +2210,7 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
|
||||
if (treeOwnerAsWin) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
|
||||
if (widget) widget->SetFocus(nsIWidget::Raise::Yes);
|
||||
if (widget) widget->SetFocus(nsIWidget::Raise::Yes, aCallerType);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ class nsFocusManager final : public nsIFocusManager,
|
||||
// Simple helper to call SetFocusedWindow on the instance.
|
||||
//
|
||||
// This raises the window and switches to the tab as needed.
|
||||
static void FocusWindow(nsPIDOMWindowOuter* aWindow);
|
||||
static void FocusWindow(nsPIDOMWindowOuter* aWindow,
|
||||
mozilla::dom::CallerType aCallerType);
|
||||
|
||||
static void PrefChanged(const char* aPref, void* aSelf);
|
||||
void PrefChanged(const char* aPref);
|
||||
@ -202,7 +203,7 @@ class nsFocusManager final : public nsIFocusManager,
|
||||
* Ensure that the widget associated with the currently focused window is
|
||||
* focused at the widget level.
|
||||
*/
|
||||
void EnsureCurrentWidgetFocused();
|
||||
void EnsureCurrentWidgetFocused(mozilla::dom::CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* Activate or deactivate the window and send the activate/deactivate events.
|
||||
@ -350,7 +351,6 @@ class nsFocusManager final : public nsIFocusManager,
|
||||
Document* aDocument, nsISupports* aTarget, uint32_t aFocusMethod,
|
||||
bool aWindowRaised, bool aIsRefocus = false,
|
||||
mozilla::dom::EventTarget* aRelatedTarget = nullptr);
|
||||
|
||||
/**
|
||||
* Fire a focus or blur event at aTarget.
|
||||
*
|
||||
@ -397,7 +397,8 @@ class nsFocusManager final : public nsIFocusManager,
|
||||
/**
|
||||
* Raises the top-level window aWindow at the widget level.
|
||||
*/
|
||||
void RaiseWindow(nsPIDOMWindowOuter* aWindow);
|
||||
void RaiseWindow(nsPIDOMWindowOuter* aWindow,
|
||||
mozilla::dom::CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* Updates the caret positon and visibility to match the focus.
|
||||
|
@ -3451,13 +3451,13 @@ void nsGlobalWindowInner::Prompt(const nsAString& aMessage,
|
||||
aError, );
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::Focus(ErrorResult& aError) {
|
||||
FORWARD_TO_OUTER_OR_THROW(FocusOuter, (), aError, );
|
||||
void nsGlobalWindowInner::Focus(CallerType aCallerType, ErrorResult& aError) {
|
||||
FORWARD_TO_OUTER_OR_THROW(FocusOuter, (aCallerType), aError, );
|
||||
}
|
||||
|
||||
nsresult nsGlobalWindowInner::Focus() {
|
||||
nsresult nsGlobalWindowInner::Focus(CallerType aCallerType) {
|
||||
ErrorResult rv;
|
||||
Focus(rv);
|
||||
Focus(aCallerType, rv);
|
||||
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
@ -601,8 +601,9 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
nsresult Close() override;
|
||||
bool GetClosed(mozilla::ErrorResult& aError);
|
||||
void Stop(mozilla::ErrorResult& aError);
|
||||
void Focus(mozilla::ErrorResult& aError);
|
||||
nsresult Focus() override;
|
||||
void Focus(mozilla::dom::CallerType aCallerType,
|
||||
mozilla::ErrorResult& aError);
|
||||
nsresult Focus(mozilla::dom::CallerType aCallerType) override;
|
||||
void Blur(mozilla::ErrorResult& aError);
|
||||
mozilla::dom::WindowProxyHolder GetFrames(mozilla::ErrorResult& aError);
|
||||
uint32_t Length();
|
||||
|
@ -4830,7 +4830,7 @@ void nsGlobalWindowOuter::PromptOuter(const nsAString& aMessage,
|
||||
}
|
||||
}
|
||||
|
||||
void nsGlobalWindowOuter::FocusOuter() {
|
||||
void nsGlobalWindowOuter::FocusOuter(CallerType aCallerType) {
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (!fm) {
|
||||
return;
|
||||
@ -4899,7 +4899,7 @@ void nsGlobalWindowOuter::FocusOuter() {
|
||||
}
|
||||
|
||||
if (Element* frame = parentdoc->FindContentForSubDocument(mDoc)) {
|
||||
nsContentUtils::RequestFrameFocus(*frame, canFocus);
|
||||
nsContentUtils::RequestFrameFocus(*frame, canFocus, aCallerType);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -4908,15 +4908,17 @@ void nsGlobalWindowOuter::FocusOuter() {
|
||||
// if there is no parent, this must be a toplevel window, so raise the
|
||||
// window if canFocus is true. If this is a child process, the raise
|
||||
// window request will get forwarded to the parent by the puppet widget.
|
||||
DebugOnly<nsresult> rv = fm->SetActiveWindow(this);
|
||||
DebugOnly<nsresult> rv =
|
||||
fm->SetActiveWindowWithCallerType(this, aCallerType);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"SetActiveWindow only fails if passed null or a non-toplevel "
|
||||
"SetActiveWindowWithCallerType only fails if passed null or a "
|
||||
"non-toplevel "
|
||||
"window, which is not the case here.");
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsGlobalWindowOuter::Focus() {
|
||||
FORWARD_TO_INNER(Focus, (), NS_ERROR_UNEXPECTED);
|
||||
nsresult nsGlobalWindowOuter::Focus(CallerType aCallerType) {
|
||||
FORWARD_TO_INNER(Focus, (aCallerType), NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
void nsGlobalWindowOuter::BlurOuter() {
|
||||
|
@ -542,8 +542,8 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
||||
bool GetClosedOuter();
|
||||
bool Closed() override;
|
||||
void StopOuter(mozilla::ErrorResult& aError);
|
||||
void FocusOuter();
|
||||
nsresult Focus() override;
|
||||
void FocusOuter(mozilla::dom::CallerType aCallerType);
|
||||
nsresult Focus(mozilla::dom::CallerType aCallerType) override;
|
||||
void BlurOuter();
|
||||
mozilla::dom::WindowProxyHolder GetFramesOuter();
|
||||
uint32_t Length();
|
||||
|
@ -544,7 +544,7 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
|
||||
|
||||
virtual bool GetFullScreen() = 0;
|
||||
|
||||
virtual nsresult Focus() = 0;
|
||||
virtual nsresult Focus(mozilla::dom::CallerType aCallerType) = 0;
|
||||
virtual nsresult Close() = 0;
|
||||
|
||||
mozilla::dom::DocGroup* GetDocGroup() const;
|
||||
@ -1033,7 +1033,7 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
|
||||
virtual bool GetFullScreen() = 0;
|
||||
virtual nsresult SetFullScreen(bool aFullscreen) = 0;
|
||||
|
||||
virtual nsresult Focus() = 0;
|
||||
virtual nsresult Focus(mozilla::dom::CallerType aCallerType) = 0;
|
||||
virtual nsresult Close() = 0;
|
||||
|
||||
virtual nsresult MoveBy(int32_t aXDif, int32_t aYDif) = 0;
|
||||
|
19
dom/bindings/BindingIPCUtils.h
Normal file
19
dom/bindings/BindingIPCUtils.h
Normal file
@ -0,0 +1,19 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
#ifndef _mozilla_dom_BindingIPCUtils_h
|
||||
#define _mozilla_dom_BindingIPCUtils_h
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
|
||||
namespace IPC {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::CallerType>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::dom::CallerType, mozilla::dom::CallerType::System,
|
||||
mozilla::dom::CallerType::NonSystem> {};
|
||||
} // namespace IPC
|
||||
#endif // _mozilla_dom_BindingIPCUtils_h
|
@ -28,6 +28,7 @@ EXPORTS.mozilla += [
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AtomList.h',
|
||||
'BindingDeclarations.h',
|
||||
'BindingIPCUtils.h',
|
||||
'BindingUtils.h',
|
||||
'CallbackFunction.h',
|
||||
'CallbackInterface.h',
|
||||
|
@ -126,7 +126,8 @@ bool Client::Focused() const {
|
||||
return mData->state().get_IPCClientWindowState().focused();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> Client::Focus(ErrorResult& aRv) {
|
||||
already_AddRefed<Promise> Client::Focus(CallerType aCallerType,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
||||
@ -149,7 +150,7 @@ already_AddRefed<Promise> Client::Focus(ErrorResult& aRv) {
|
||||
auto holder =
|
||||
MakeRefPtr<DOMMozPromiseRequestHolder<ClientStatePromise>>(mGlobal);
|
||||
|
||||
mHandle->Focus()
|
||||
mHandle->Focus(aCallerType)
|
||||
->Then(
|
||||
mGlobal->EventTargetFor(TaskCategory::Other), __func__,
|
||||
[ipcClientInfo, holder, outerPromise](const ClientState& aResult) {
|
||||
|
@ -69,7 +69,7 @@ class Client final : public nsISupports, public nsWrapperCache {
|
||||
|
||||
bool Focused() const;
|
||||
|
||||
already_AddRefed<Promise> Focus(ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Focus(CallerType aCallerType, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Navigate(const nsAString& aURL, ErrorResult& aRv);
|
||||
|
||||
|
@ -122,12 +122,12 @@ RefPtr<GenericPromise> ClientHandle::Control(
|
||||
return outerPromise.forget();
|
||||
}
|
||||
|
||||
RefPtr<ClientStatePromise> ClientHandle::Focus() {
|
||||
RefPtr<ClientStatePromise> ClientHandle::Focus(CallerType aCallerType) {
|
||||
RefPtr<ClientStatePromise::Private> outerPromise =
|
||||
new ClientStatePromise::Private(__func__);
|
||||
|
||||
StartOp(
|
||||
ClientFocusArgs(),
|
||||
ClientFocusArgs(aCallerType),
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(
|
||||
ClientState::FromIPC(aResult.get_IPCClientState()), __func__);
|
||||
|
@ -76,7 +76,7 @@ class ClientHandle final : public ClientThing<ClientHandleChild> {
|
||||
// Focus the Client if possible. If successful the promise will resolve with
|
||||
// a new ClientState snapshot after focus has completed. If focusing fails
|
||||
// for any reason then the promise will reject.
|
||||
RefPtr<ClientStatePromise> Focus();
|
||||
RefPtr<ClientStatePromise> Focus(CallerType aCallerType);
|
||||
|
||||
// Send a postMessage() call to the target Client. Currently this only
|
||||
// supports sending from a ServiceWorker source and the MessageEvent is
|
||||
|
@ -12,6 +12,7 @@ using ClientType from "mozilla/dom/ClientIPCUtils.h";
|
||||
using FrameType from "mozilla/dom/ClientIPCUtils.h";
|
||||
using mozilla::StorageAccess from "mozilla/dom/ClientIPCUtils.h";
|
||||
using VisibilityState from "mozilla/dom/ClientIPCUtils.h";
|
||||
using CallerType from "mozilla/dom/BindingIPCUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -75,6 +76,7 @@ struct ClientControlledArgs
|
||||
|
||||
struct ClientFocusArgs
|
||||
{
|
||||
CallerType callerType;
|
||||
};
|
||||
|
||||
struct ClientNavigateArgs
|
||||
|
@ -262,7 +262,7 @@ void WaitForLoad(const ClientOpenWindowArgs& aArgs,
|
||||
|
||||
RefPtr<ClientOpPromise::Private> promise = aPromise;
|
||||
|
||||
nsFocusManager::FocusWindow(aOuterWindow);
|
||||
nsFocusManager::FocusWindow(aOuterWindow, CallerType::NonSystem);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(baseURI), aArgs.baseURL());
|
||||
|
@ -555,7 +555,7 @@ RefPtr<ClientOpPromise> ClientSource::Focus(const ClientFocusArgs& aArgs) {
|
||||
}
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
nsFocusManager::FocusWindow(outer);
|
||||
nsFocusManager::FocusWindow(outer, aArgs.callerType());
|
||||
|
||||
ClientState state;
|
||||
nsresult rv = SnapshotState(&state);
|
||||
|
@ -1080,7 +1080,7 @@ bool EventStateManager::LookForAccessKeyAndExecute(
|
||||
nsCOMPtr<nsIBrowserChild> child =
|
||||
docShell ? docShell->GetBrowserChild() : nullptr;
|
||||
if (child) {
|
||||
child->SendRequestFocus(false);
|
||||
child->SendRequestFocus(false, CallerType::System);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2932,7 +2932,7 @@ void HTMLInputElement::Blur(ErrorResult& aError) {
|
||||
}
|
||||
|
||||
void HTMLInputElement::Focus(const FocusOptions& aOptions,
|
||||
ErrorResult& aError) {
|
||||
CallerType aCallerType, ErrorResult& aError) {
|
||||
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
|
||||
!IsExperimentalMobileType(mType)) {
|
||||
if (Element* dateTimeBoxElement = GetDateTimeBoxElement()) {
|
||||
@ -2944,7 +2944,7 @@ void HTMLInputElement::Focus(const FocusOptions& aOptions,
|
||||
}
|
||||
}
|
||||
|
||||
nsGenericHTMLElement::Focus(aOptions, aError);
|
||||
nsGenericHTMLElement::Focus(aOptions, aCallerType, aError);
|
||||
}
|
||||
|
||||
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
||||
@ -3798,7 +3798,8 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
||||
FocusOptions options;
|
||||
ErrorResult error;
|
||||
|
||||
selectedRadioButton->Focus(options, error);
|
||||
selectedRadioButton->Focus(options, CallerType::System,
|
||||
error);
|
||||
rv = error.StealNSResult();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = DispatchSimulatedClick(selectedRadioButton,
|
||||
|
@ -142,7 +142,7 @@ class HTMLInputElement final : public TextControlElement,
|
||||
virtual int32_t TabIndexDefault() override;
|
||||
using nsGenericHTMLElement::Focus;
|
||||
virtual void Blur(ErrorResult& aError) override;
|
||||
virtual void Focus(const FocusOptions& aOptions,
|
||||
virtual void Focus(const FocusOptions& aOptions, const CallerType aCallerType,
|
||||
ErrorResult& aError) override;
|
||||
|
||||
// nsINode
|
||||
|
@ -51,6 +51,7 @@ HTMLFormElement* HTMLLabelElement::GetForm() const {
|
||||
}
|
||||
|
||||
void HTMLLabelElement::Focus(const FocusOptions& aOptions,
|
||||
const CallerType aCallerType,
|
||||
ErrorResult& aError) {
|
||||
// retarget the focus method at the for content
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
|
@ -44,6 +44,7 @@ class HTMLLabelElement final : public nsGenericHTMLElement {
|
||||
|
||||
using nsGenericHTMLElement::Focus;
|
||||
virtual void Focus(const FocusOptions& aOptions,
|
||||
const mozilla::dom::CallerType aCallerType,
|
||||
ErrorResult& aError) override;
|
||||
|
||||
// nsIContent
|
||||
|
@ -67,6 +67,7 @@ void HTMLLegendElement::UnbindFromTree(bool aNullParent) {
|
||||
}
|
||||
|
||||
void HTMLLegendElement::Focus(const FocusOptions& aOptions,
|
||||
const mozilla::dom::CallerType aCallerType,
|
||||
ErrorResult& aError) {
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
@ -75,7 +76,7 @@ void HTMLLegendElement::Focus(const FocusOptions& aOptions,
|
||||
|
||||
int32_t tabIndex;
|
||||
if (frame->IsFocusable(&tabIndex, false)) {
|
||||
nsGenericHTMLElement::Focus(aOptions, aError);
|
||||
nsGenericHTMLElement::Focus(aOptions, aCallerType, aError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -100,7 +101,7 @@ bool HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
FocusOptions options;
|
||||
ErrorResult rv;
|
||||
|
||||
Focus(options, rv);
|
||||
Focus(options, CallerType::System, rv);
|
||||
return NS_SUCCEEDED(rv.StealNSResult());
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class HTMLLegendElement final : public nsGenericHTMLElement {
|
||||
|
||||
using nsGenericHTMLElement::Focus;
|
||||
virtual void Focus(const FocusOptions& aOptions,
|
||||
const mozilla::dom::CallerType aCallerType,
|
||||
ErrorResult& aError) override;
|
||||
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
|
@ -10,6 +10,8 @@ interface nsIWebBrowserChrome3;
|
||||
|
||||
webidl ContentFrameMessageManager;
|
||||
|
||||
|
||||
native CallerType(mozilla::dom::CallerType);
|
||||
native CommandsArray(nsTArray<nsCString>);
|
||||
[ref] native CommandsArrayRef(nsTArray<nsCString>);
|
||||
|
||||
@ -20,7 +22,7 @@ interface nsIBrowserChild : nsISupports
|
||||
|
||||
attribute nsIWebBrowserChrome3 webBrowserChrome;
|
||||
|
||||
[notxpcom] void sendRequestFocus(in boolean canFocus);
|
||||
[notxpcom] void sendRequestFocus(in boolean canFocus, in CallerType aCallerType);
|
||||
|
||||
[noscript, notxpcom] void enableDisableCommands(in AString action,
|
||||
in CommandsArrayRef enabledCommands,
|
||||
|
@ -10,6 +10,8 @@ interface mozIDOMWindowProxy;
|
||||
webidl Document;
|
||||
webidl Element;
|
||||
|
||||
native CallerType(mozilla::dom::CallerType);
|
||||
|
||||
/**
|
||||
* The focus manager deals with all focus related behaviour. Only one element
|
||||
* in the entire application may have the focus at a time; this element
|
||||
@ -47,9 +49,15 @@ interface nsIFocusManager : nsISupports
|
||||
* focuses the current child window's current element, if any. Setting this
|
||||
* to null or to a non-top-level window throws an NS_ERROR_INVALID_ARG
|
||||
* exception.
|
||||
* The setter for this attribute defaults to CallerType::System.
|
||||
*/
|
||||
attribute mozIDOMWindowProxy activeWindow;
|
||||
|
||||
/**
|
||||
* Setter for activeWindow with CallerType
|
||||
*/
|
||||
[noscript] void SetActiveWindowWithCallerType(in mozIDOMWindowProxy aWindow, in CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* The child window within the activeWindow that is focused. This will
|
||||
* always be activeWindow, a child window of activeWindow or null if no
|
||||
@ -59,9 +67,15 @@ interface nsIFocusManager : nsISupports
|
||||
* will actually be set to the child window and the current element within
|
||||
* that set as the focused element. This process repeats downwards until a
|
||||
* non-frame element is found.
|
||||
* The setter for this attribute defaults to CallerType::System.
|
||||
*/
|
||||
attribute mozIDOMWindowProxy focusedWindow;
|
||||
|
||||
/**
|
||||
* Setter for focusedWindow with CallerType
|
||||
*/
|
||||
[noscript] void SetFocusedWindowWithCallerType(in mozIDOMWindowProxy aWindow, in CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* The element that is currently focused. This will always be an element
|
||||
* within the document loaded in focusedWindow or null if no element in that
|
||||
@ -176,6 +190,12 @@ interface nsIFocusManager : nsISupports
|
||||
*/
|
||||
const unsigned long FLAG_NOPARENTFRAME = 8;
|
||||
|
||||
/**
|
||||
* This flag is used for window and element focus operations to signal
|
||||
* wether the caller is system or non system.
|
||||
*/
|
||||
const unsigned long FLAG_NONSYSTEMCALLER = 16;
|
||||
|
||||
/**
|
||||
* Focus is changing due to a mouse operation, for instance the mouse was
|
||||
* clicked on an element.
|
||||
|
@ -117,13 +117,13 @@ IPCResult BrowserBridgeChild::RecvSetLayersId(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserBridgeChild::RecvRequestFocus(
|
||||
const bool& aCanRaise) {
|
||||
const bool& aCanRaise, const CallerType aCallerType) {
|
||||
// Adapted from BrowserParent
|
||||
RefPtr<Element> owner = mFrameLoader->GetOwnerContent();
|
||||
if (!owner) {
|
||||
return IPC_OK();
|
||||
}
|
||||
nsContentUtils::RequestFrameFocus(*owner, aCanRaise);
|
||||
nsContentUtils::RequestFrameFocus(*owner, aCanRaise, aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,8 @@ class BrowserBridgeChild : public PBrowserBridgeChild {
|
||||
mozilla::ipc::IPCResult RecvSetLayersId(
|
||||
const mozilla::layers::LayersId& aLayersId);
|
||||
|
||||
mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise);
|
||||
mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise,
|
||||
const CallerType aCallerType);
|
||||
|
||||
mozilla::ipc::IPCResult RecvMoveFocus(const bool& aForward,
|
||||
const bool& aForDocumentNavigation);
|
||||
|
@ -2652,7 +2652,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvNavigateByKey(
|
||||
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
|
||||
}
|
||||
|
||||
SendRequestFocus(false);
|
||||
SendRequestFocus(false, CallerType::System);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
@ -2981,8 +2981,8 @@ BrowserChild::SetWebBrowserChrome(nsIWebBrowserChrome3* aWebBrowserChrome) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void BrowserChild::SendRequestFocus(bool aCanFocus) {
|
||||
PBrowserChild::SendRequestFocus(aCanFocus);
|
||||
void BrowserChild::SendRequestFocus(bool aCanFocus, CallerType aCallerType) {
|
||||
PBrowserChild::SendRequestFocus(aCanFocus, aCallerType);
|
||||
}
|
||||
|
||||
void BrowserChild::EnableDisableCommands(
|
||||
|
@ -2229,10 +2229,11 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnWindowedPluginKeyEvent(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserParent::RecvRequestFocus(const bool& aCanRaise) {
|
||||
mozilla::ipc::IPCResult BrowserParent::RecvRequestFocus(
|
||||
const bool& aCanRaise, const CallerType aCallerType) {
|
||||
LOGBROWSERFOCUS(("RecvRequestFocus %p, aCanRaise: %d", this, aCanRaise));
|
||||
if (BrowserBridgeParent* bridgeParent = GetBrowserBridgeParent()) {
|
||||
mozilla::Unused << bridgeParent->SendRequestFocus(aCanRaise);
|
||||
mozilla::Unused << bridgeParent->SendRequestFocus(aCanRaise, aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -2240,7 +2241,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvRequestFocus(const bool& aCanRaise) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsContentUtils::RequestFrameFocus(*mFrameElement, aCanRaise);
|
||||
nsContentUtils::RequestFrameFocus(*mFrameElement, aCanRaise, aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -3138,7 +3139,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvSetNativeChildOfShareableWindow(
|
||||
|
||||
mozilla::ipc::IPCResult BrowserParent::RecvDispatchFocusToTopLevelWindow() {
|
||||
if (nsCOMPtr<nsIWidget> widget = GetTopLevelWidget()) {
|
||||
widget->SetFocus(nsIWidget::Raise::No);
|
||||
widget->SetFocus(nsIWidget::Raise::No, CallerType::System);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -424,7 +424,8 @@ class BrowserParent final : public PBrowserParent,
|
||||
mozilla::ipc::IPCResult RecvOnWindowedPluginKeyEvent(
|
||||
const NativeEventData& aKeyEventData);
|
||||
|
||||
mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise);
|
||||
mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise,
|
||||
const CallerType aCallerType);
|
||||
|
||||
mozilla::ipc::IPCResult RecvLookUpDictionary(
|
||||
const nsString& aText, nsTArray<mozilla::FontRange>&& aFontRangeArray,
|
||||
|
@ -4047,8 +4047,8 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowClose(BrowsingContext* aContext,
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(
|
||||
BrowsingContext* aContext) {
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(BrowsingContext* aContext,
|
||||
CallerType aCallerType) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to dead or detached context"));
|
||||
@ -4062,7 +4062,7 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(
|
||||
("ChildIPC: Trying to send a message to a context without a window"));
|
||||
return IPC_OK();
|
||||
}
|
||||
nsGlobalWindowOuter::Cast(window)->FocusOuter();
|
||||
nsGlobalWindowOuter::Cast(window)->FocusOuter(aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -4213,7 +4213,7 @@ mozilla::ipc::IPCResult ContentChild::RecvInternalLoad(
|
||||
|
||||
if (aTakeFocus) {
|
||||
if (nsCOMPtr<nsPIDOMWindowOuter> domWin = aContext->GetDOMWindow()) {
|
||||
nsFocusManager::FocusWindow(domWin);
|
||||
nsFocusManager::FocusWindow(domWin, CallerType::System);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,7 +751,8 @@ class ContentChild final
|
||||
|
||||
mozilla::ipc::IPCResult RecvWindowClose(BrowsingContext* aContext,
|
||||
bool aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext,
|
||||
CallerType aCallerType);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowPostMessage(
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
|
@ -6289,7 +6289,7 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowClose(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvWindowFocus(
|
||||
BrowsingContext* aContext) {
|
||||
BrowsingContext* aContext, CallerType aCallerType) {
|
||||
if (!aContext || aContext->IsDiscarded()) {
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
@ -6300,7 +6300,7 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowFocus(
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
ContentParent* cp = cpm->GetContentProcessById(
|
||||
ContentParentId(aContext->Canonical()->OwnerProcessId()));
|
||||
Unused << cp->SendWindowFocus(aContext);
|
||||
Unused << cp->SendWindowFocus(aContext, aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,8 @@ class ContentParent final
|
||||
|
||||
mozilla::ipc::IPCResult RecvWindowClose(BrowsingContext* aContext,
|
||||
bool aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext,
|
||||
CallerType aCallerType);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowPostMessage(
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
|
@ -97,6 +97,7 @@ using struct InputFormData from "mozilla/dom/SessionStoreMessageUtils.h";
|
||||
using struct CollectedInputDataValue from "mozilla/dom/SessionStoreMessageUtils.h";
|
||||
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
|
||||
using mozilla::AntiTrackingCommon::StorageAccessGrantedReason from "mozilla/AntiTrackingCommon.h";
|
||||
using CallerType from "mozilla/dom/BindingDeclarations.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -410,7 +411,7 @@ parent:
|
||||
* Request that the parent process move focus to the browser's frame. If
|
||||
* canRaise is true, the window can be raised if it is inactive.
|
||||
*/
|
||||
async RequestFocus(bool canRaise);
|
||||
async RequestFocus(bool canRaise, CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* Indicate, based on the current state, that some commands are enabled and
|
||||
|
@ -19,6 +19,7 @@ using mozilla::dom::EffectsInfo from "mozilla/dom/TabMessageUtils.h";
|
||||
using mozilla::ScrollAxis from "mozilla/PresShellForwards.h";
|
||||
using mozilla::ScrollFlags from "mozilla/PresShellForwards.h";
|
||||
using struct nsRect from "nsRect.h";
|
||||
using CallerType from "mozilla/dom/BindingDeclarations.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -41,7 +42,7 @@ child:
|
||||
* browser's frame. If canRaise is true, the window can be raised if
|
||||
* it is inactive.
|
||||
*/
|
||||
async RequestFocus(bool canRaise);
|
||||
async RequestFocus(bool canRaise, CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* When IPC parent / Web child sends this message, the IPC child / Web parent
|
||||
|
@ -1590,7 +1590,7 @@ both:
|
||||
BrowsingContext[] aChildren);
|
||||
|
||||
async WindowClose(BrowsingContext aContext, bool aTrustedCaller);
|
||||
async WindowFocus(BrowsingContext aContext);
|
||||
async WindowFocus(BrowsingContext aContext, CallerType aCallerType);
|
||||
async WindowBlur(BrowsingContext aContext);
|
||||
async WindowPostMessage(BrowsingContext aContext, ClonedMessageData aMessage,
|
||||
PostMessageData aData);
|
||||
|
@ -6,6 +6,7 @@ include protocol PBrowser;
|
||||
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using mozilla::dom::CallerType from "mozilla/dom/BindingDeclarations.h";
|
||||
using nsIntRect from "nsRect.h";
|
||||
|
||||
namespace mozilla {
|
||||
@ -14,7 +15,7 @@ namespace plugins {
|
||||
/**
|
||||
* PPluginWidget - a nsIWidget'ish protocol for windowed plugins in e10s.
|
||||
* On windows we create native widgets in chrome which we then manage
|
||||
* from content. On the content side there's PluginWidgetProxy which
|
||||
* from content. On the566595 content side there's PluginWidgetProxy which
|
||||
* implements nsIWidget. We hand this around layout and plugins code. Anything
|
||||
* not dealt with via PluginWidgetProxy falls through to PuppetWidget. Native
|
||||
* widget exists on the chrome side (PluginWidgetParent) attached to the
|
||||
@ -40,7 +41,7 @@ parent:
|
||||
*/
|
||||
sync Create() returns (nsresult aResult, uint64_t aScrollCaptureId,
|
||||
uintptr_t aPluginInstanceId);
|
||||
async SetFocus(bool aRaise);
|
||||
async SetFocus(bool aRaise, CallerType aCallerType);
|
||||
|
||||
/**
|
||||
* Returns NS_NATIVE_PLUGIN_PORT and its variants: a sharable native
|
||||
|
@ -290,7 +290,7 @@ class FocusWindowRunnable final : public Runnable {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsFocusManager::FocusWindow(mWindow->GetOuterWindow());
|
||||
nsFocusManager::FocusWindow(mWindow->GetOuterWindow(), CallerType::System);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
@ -1116,7 +1116,7 @@ MainThreadNotificationObserver::Observe(nsISupports* aSubject,
|
||||
|
||||
bool doDefaultAction = notification->DispatchClickEvent();
|
||||
if (doDefaultAction) {
|
||||
nsFocusManager::FocusWindow(window->GetOuterWindow());
|
||||
nsFocusManager::FocusWindow(window->GetOuterWindow(), CallerType::System);
|
||||
}
|
||||
} else if (!strcmp("alertfinished", aTopic)) {
|
||||
notification->UnpersistNotification();
|
||||
|
@ -138,10 +138,12 @@ void PluginWidgetParent::ParentDestroy() {
|
||||
PWLOG("PluginWidgetParent::ParentDestroy()\n");
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult PluginWidgetParent::RecvSetFocus(const bool& aRaise) {
|
||||
mozilla::ipc::IPCResult PluginWidgetParent::RecvSetFocus(
|
||||
const bool& aRaise, const mozilla::dom::CallerType& aCallerType) {
|
||||
ENSURE_CHANNEL;
|
||||
PWLOG("PluginWidgetParent::RecvSetFocus(%d)\n", aRaise);
|
||||
mWidget->SetFocus(aRaise ? nsIWidget::Raise::Yes : nsIWidget::Raise::No);
|
||||
mWidget->SetFocus(aRaise ? nsIWidget::Raise::Yes : nsIWidget::Raise::No,
|
||||
aCallerType);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,8 @@ class PluginWidgetParent : public PPluginWidgetParent {
|
||||
virtual mozilla::ipc::IPCResult RecvCreate(
|
||||
nsresult* aResult, uint64_t* aScrollCaptureId,
|
||||
uintptr_t* aPluginInstanceId) override;
|
||||
virtual mozilla::ipc::IPCResult RecvSetFocus(const bool& aRaise) override;
|
||||
virtual mozilla::ipc::IPCResult RecvSetFocus(
|
||||
const bool& aRaise, const mozilla::dom::CallerType& aCallerType) override;
|
||||
virtual mozilla::ipc::IPCResult RecvGetNativePluginPort(
|
||||
uintptr_t* value) override;
|
||||
mozilla::ipc::IPCResult RecvSetNativeChildWindow(
|
||||
|
@ -37,7 +37,7 @@ interface WindowClient : Client {
|
||||
// Implement ancestorOrigins in bug 1264180
|
||||
// [SameObject] readonly attribute FrozenArray<USVString> ancestorOrigins;
|
||||
|
||||
[Throws, NewObject]
|
||||
[Throws, NewObject, NeedsCallerType]
|
||||
Promise<WindowClient> focus();
|
||||
|
||||
[Throws, NewObject]
|
||||
|
@ -173,7 +173,7 @@ interface mixin HTMLOrForeignElement {
|
||||
// See bug 1575154
|
||||
// [CEReactions] attribute boolean autofocus;
|
||||
[CEReactions, SetterThrows, Pure] attribute long tabIndex;
|
||||
[Throws] void focus(optional FocusOptions options = {});
|
||||
[Throws, NeedsCallerType] void focus(optional FocusOptions options = {});
|
||||
[Throws] void blur();
|
||||
};
|
||||
|
||||
|
@ -225,7 +225,7 @@ typedef OfflineResourceList ApplicationCache;
|
||||
[Throws, CrossOriginCallable, NeedsCallerType] void close();
|
||||
[Throws, CrossOriginReadable] readonly attribute boolean closed;
|
||||
[Throws] void stop();
|
||||
[Throws, CrossOriginCallable] void focus();
|
||||
[Throws, CrossOriginCallable, NeedsCallerType] void focus();
|
||||
[Throws, CrossOriginCallable] void blur();
|
||||
[Replaceable, Pref="dom.window.event.enabled"] readonly attribute any event;
|
||||
|
||||
|
@ -61,7 +61,7 @@ class MockWidget : public nsBaseWidget {
|
||||
|
||||
virtual void Enable(bool aState) override {}
|
||||
virtual bool IsEnabled() const override { return true; }
|
||||
virtual void SetFocus(Raise) override {}
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override {}
|
||||
virtual nsresult ConfigureChildren(
|
||||
const nsTArray<Configuration>& aConfigurations) override {
|
||||
return NS_OK;
|
||||
|
@ -161,10 +161,11 @@ void PluginWidgetProxy::SetNativeData(uint32_t aDataType, uintptr_t aVal) {
|
||||
}
|
||||
}
|
||||
|
||||
void PluginWidgetProxy::SetFocus(Raise aRaise) {
|
||||
void PluginWidgetProxy::SetFocus(Raise aRaise,
|
||||
mozilla::dom::CallerType aCallerType) {
|
||||
if (mActor) {
|
||||
PWLOG("PluginWidgetProxy::SetFocus(%d)\n", aRaise == Raise::Yes);
|
||||
mActor->SendSetFocus(aRaise == Raise::Yes);
|
||||
mActor->SendSetFocus(aRaise == Raise::Yes, aCallerType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class PluginWidgetProxy final : public PuppetWidget {
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) override;
|
||||
virtual void Destroy() override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual void SetParent(nsIWidget* aNewParent) override;
|
||||
|
||||
virtual nsIWidget* GetParent(void) override;
|
||||
|
@ -252,9 +252,9 @@ nsresult PuppetWidget::ConfigureChildren(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void PuppetWidget::SetFocus(Raise aRaise) {
|
||||
void PuppetWidget::SetFocus(Raise aRaise, CallerType aCallerType) {
|
||||
if (aRaise == Raise::Yes && mBrowserChild) {
|
||||
mBrowserChild->SendRequestFocus(true);
|
||||
mBrowserChild->SendRequestFocus(true, aCallerType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ class PuppetWidget : public nsBaseWidget,
|
||||
virtual void Enable(bool aState) override { mEnabled = aState; }
|
||||
virtual bool IsEnabled() const override { return mEnabled; }
|
||||
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
|
||||
virtual nsresult ConfigureChildren(
|
||||
const nsTArray<Configuration>& aConfigurations) override;
|
||||
|
@ -1805,8 +1805,7 @@ nsWindow* nsWindow::FindTopLevel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void nsWindow::SetFocus(Raise) {
|
||||
// FIXME: Shouldn't this account for the argument?
|
||||
void nsWindow::SetFocus(Raise, mozilla::dom::CallerType aCallerType) {
|
||||
FindTopLevel()->BringToFront();
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ class nsWindow final : public nsBaseWidget {
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual bool IsEnabled() const override;
|
||||
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
|
@ -307,7 +307,7 @@ class nsChildView final : public nsBaseWidget {
|
||||
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual bool IsEnabled() const override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntRect GetBounds() override;
|
||||
virtual LayoutDeviceIntRect GetClientBounds() override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
|
@ -633,7 +633,7 @@ void nsChildView::Enable(bool aState) {}
|
||||
|
||||
bool nsChildView::IsEnabled() const { return true; }
|
||||
|
||||
void nsChildView::SetFocus(Raise) {
|
||||
void nsChildView::SetFocus(Raise, mozilla::dom::CallerType aCallerType) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
NSWindow* window = [mView window];
|
||||
|
@ -232,7 +232,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
||||
virtual void SetFakeModal(bool aState) override;
|
||||
virtual bool IsRunningAppModal() override;
|
||||
virtual bool IsVisible() const override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
virtual LayoutDeviceIntPoint GetClientOffset() override;
|
||||
virtual LayoutDeviceIntSize ClientToWindowSize(const LayoutDeviceIntSize& aClientSize) override;
|
||||
|
@ -1875,11 +1875,11 @@ void nsCocoaWindow::SetMenuBar(nsMenuBarX* aMenuBar) {
|
||||
mMenuBar->Paint();
|
||||
}
|
||||
|
||||
void nsCocoaWindow::SetFocus(Raise aRaise) {
|
||||
void nsCocoaWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
|
||||
if (!mWindow) return;
|
||||
|
||||
if (mPopupContentView) {
|
||||
return mPopupContentView->SetFocus(aRaise);
|
||||
return mPopupContentView->SetFocus(aRaise, aCallerType);
|
||||
}
|
||||
|
||||
if (aRaise == Raise::Yes && ([mWindow isVisible] || [mWindow isMiniaturized])) {
|
||||
|
@ -1625,7 +1625,7 @@ guint32 nsWindow::GetLastUserInputTime() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
void nsWindow::SetFocus(Raise aRaise) {
|
||||
void nsWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
|
||||
// Make sure that our owning widget has focus. If it doesn't try to
|
||||
// grab it. Note that we don't set our focus flag in this case.
|
||||
|
||||
|
@ -152,7 +152,7 @@ class nsWindow final : public nsBaseWidget {
|
||||
void SetZIndex(int32_t aZIndex) override;
|
||||
virtual void SetSizeMode(nsSizeMode aMode) override;
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
virtual LayoutDeviceIntRect GetClientBounds() override;
|
||||
virtual LayoutDeviceIntSize GetClientSize() override;
|
||||
|
@ -200,7 +200,8 @@ void HeadlessWidget::Show(bool aState) {
|
||||
|
||||
bool HeadlessWidget::IsVisible() const { return mVisible; }
|
||||
|
||||
void HeadlessWidget::SetFocus(Raise aRaise) {
|
||||
void HeadlessWidget::SetFocus(Raise aRaise,
|
||||
mozilla::dom::CallerType aCallerType) {
|
||||
LOGFOCUS((" SetFocus %d [%p]\n", aRaise == Raise::Yes, (void*)this));
|
||||
|
||||
// This means we request activation of our toplevel window.
|
||||
|
@ -89,7 +89,7 @@ class HeadlessWidget : public nsBaseWidget {
|
||||
nsIScreen* aTargetScreen = nullptr) override;
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual bool IsEnabled() const override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual nsresult ConfigureChildren(
|
||||
const nsTArray<Configuration>& aConfigurations) override {
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
#include "Units.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
|
||||
// forward declarations
|
||||
class nsIBidiKeyboard;
|
||||
@ -877,7 +878,7 @@ class nsIWidget : public nsISupports {
|
||||
/**
|
||||
* Request activation of this window or give focus to this widget.
|
||||
*/
|
||||
virtual void SetFocus(Raise) = 0;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
|
||||
|
||||
/**
|
||||
* Get this widget's outside dimensions relative to its parent widget. For
|
||||
|
@ -35,7 +35,7 @@ class nsWindow final : public nsBaseWidget {
|
||||
virtual void Enable(bool aState) override {}
|
||||
virtual bool IsEnabled() const override { return true; }
|
||||
virtual bool IsVisible() const override { return mVisible; }
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
|
||||
virtual void SetBackgroundColor(const nscolor& aColor) override;
|
||||
|
@ -2183,7 +2183,7 @@ bool nsWindow::IsEnabled() const {
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
void nsWindow::SetFocus(Raise aRaise) {
|
||||
void nsWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
|
||||
if (mWnd) {
|
||||
#ifdef WINSTATE_DEBUG_OUTPUT
|
||||
if (mWnd == WinUtils::GetTopLevelHWND(mWnd)) {
|
||||
|
@ -144,7 +144,7 @@ class nsWindow final : public nsWindowBase {
|
||||
virtual void SuppressAnimation(bool aSuppress) override;
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual bool IsEnabled() const override;
|
||||
virtual void SetFocus(Raise) override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntRect GetBounds() override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
virtual MOZ_MUST_USE nsresult
|
||||
|
@ -824,7 +824,7 @@ nsSiteWindow::Blur(void) {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> domWindow = docshell->GetWindow();
|
||||
if (domWindow) domWindow->Focus();
|
||||
if (domWindow) domWindow->Focus(mozilla::dom::CallerType::System);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user