зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1248772 - Trigger a OS window focus in ServiceWorkerClients::OpenWindow. r=ehsan
This commit is contained in:
Родитель
1ea26e16ac
Коммит
5082e816d8
|
@ -3829,6 +3829,22 @@ nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
|
|||
return rv;
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsContentUtils::DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
|
||||
if (!doc) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return DispatchChromeEvent(doc, aWindow,
|
||||
NS_LITERAL_STRING("DOMServiceWorkerFocusClient"),
|
||||
true, true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentUtils::DispatchEventOnlyToChrome(nsIDocument* aDoc,
|
||||
nsISupports* aTarget,
|
||||
|
|
|
@ -1125,6 +1125,13 @@ public:
|
|||
bool aCancelable,
|
||||
bool *aDefaultAction = nullptr);
|
||||
|
||||
/**
|
||||
* Helper function for dispatching a "DOMServiceWorkerFocusClient" event to
|
||||
* the chrome event handler of the given DOM Window. This has the effect
|
||||
* of focusing the corresponding tab and bringing the browser window
|
||||
* to the foreground.
|
||||
*/
|
||||
static nsresult DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow);
|
||||
|
||||
/**
|
||||
* This method creates and dispatches a trusted event.
|
||||
|
|
|
@ -503,6 +503,11 @@ public:
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
rv = nsContentUtils::DispatchFocusChromeEvent(window);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
WorkerPrivate* workerPrivate = mPromiseProxy->GetWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
|
|
|
@ -95,10 +95,7 @@ public:
|
|||
if (window) {
|
||||
nsCOMPtr<nsIDocument> doc = window->GetDocument();
|
||||
if (doc) {
|
||||
nsContentUtils::DispatchChromeEvent(doc,
|
||||
window->GetOuterWindow(),
|
||||
NS_LITERAL_STRING("DOMServiceWorkerFocusClient"),
|
||||
true, true);
|
||||
nsContentUtils::DispatchFocusChromeEvent(window->GetOuterWindow());
|
||||
clientInfo.reset(new ServiceWorkerClientInfo(doc));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче