зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ac6d8297cdc4 (bug 1581925) for test_bug89419.xul & test_MozDomFullscreen_event.xul failures CLOSED TREE
This commit is contained in:
Родитель
04851f6503
Коммит
9adecce6d4
|
@ -23,30 +23,11 @@
|
||||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||||
#include "mozilla/dom/ScriptLoader.h"
|
#include "mozilla/dom/ScriptLoader.h"
|
||||||
#include "mozilla/dom/WindowProxyHolder.h"
|
#include "mozilla/dom/WindowProxyHolder.h"
|
||||||
#include "mozilla/dom/JSWindowActorService.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
using namespace mozilla::dom::ipc;
|
using namespace mozilla::dom::ipc;
|
||||||
|
|
||||||
/* static */
|
|
||||||
already_AddRefed<InProcessBrowserChildMessageManager>
|
|
||||||
InProcessBrowserChildMessageManager::Create(nsDocShell* aShell,
|
|
||||||
nsIContent* aOwner,
|
|
||||||
nsFrameMessageManager* aChrome) {
|
|
||||||
RefPtr<InProcessBrowserChildMessageManager> mm =
|
|
||||||
new InProcessBrowserChildMessageManager(aShell, aOwner, aChrome);
|
|
||||||
|
|
||||||
NS_ENSURE_TRUE(mm->Init(), nullptr);
|
|
||||||
|
|
||||||
if (XRE_IsParentProcess()) {
|
|
||||||
RefPtr<JSWindowActorService> wasvc = JSWindowActorService::GetSingleton();
|
|
||||||
wasvc->RegisterChromeEventTarget(mm);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mm.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InProcessBrowserChildMessageManager::DoSendBlockingMessage(
|
bool InProcessBrowserChildMessageManager::DoSendBlockingMessage(
|
||||||
JSContext* aCx, const nsAString& aMessage, StructuredCloneData& aData,
|
JSContext* aCx, const nsAString& aMessage, StructuredCloneData& aData,
|
||||||
JS::Handle<JSObject*> aCpows, nsIPrincipal* aPrincipal,
|
JS::Handle<JSObject*> aCpows, nsIPrincipal* aPrincipal,
|
||||||
|
@ -120,10 +101,6 @@ InProcessBrowserChildMessageManager::InProcessBrowserChildMessageManager(
|
||||||
}
|
}
|
||||||
|
|
||||||
InProcessBrowserChildMessageManager::~InProcessBrowserChildMessageManager() {
|
InProcessBrowserChildMessageManager::~InProcessBrowserChildMessageManager() {
|
||||||
if (XRE_IsParentProcess()) {
|
|
||||||
JSWindowActorService::UnregisterChromeEventTarget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
mAnonymousGlobalScopes.Clear();
|
mAnonymousGlobalScopes.Clear();
|
||||||
mozilla::DropJSObjects(this);
|
mozilla::DropJSObjects(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,14 @@ class InProcessBrowserChildMessageManager final
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static already_AddRefed<InProcessBrowserChildMessageManager> Create(
|
static already_AddRefed<InProcessBrowserChildMessageManager> Create(
|
||||||
nsDocShell* aShell, nsIContent* aOwner, nsFrameMessageManager* aChrome);
|
nsDocShell* aShell, nsIContent* aOwner, nsFrameMessageManager* aChrome) {
|
||||||
|
RefPtr<InProcessBrowserChildMessageManager> mm =
|
||||||
|
new InProcessBrowserChildMessageManager(aShell, aOwner, aChrome);
|
||||||
|
|
||||||
|
NS_ENSURE_TRUE(mm->Init(), nullptr);
|
||||||
|
|
||||||
|
return mm.forget();
|
||||||
|
}
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
||||||
|
|
|
@ -44,9 +44,7 @@ nsWindowRoot::~nsWindowRoot() {
|
||||||
mListenerManager->Disconnect();
|
mListenerManager->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XRE_IsContentProcess()) {
|
JSWindowActorService::UnregisterWindowRoot(this);
|
||||||
JSWindowActorService::UnregisterChromeEventTarget(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsWindowRoot, mWindow, mListenerManager,
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsWindowRoot, mWindow, mListenerManager,
|
||||||
|
@ -322,9 +320,9 @@ void nsWindowRoot::EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) {
|
||||||
already_AddRefed<EventTarget> NS_NewWindowRoot(nsPIDOMWindowOuter* aWindow) {
|
already_AddRefed<EventTarget> NS_NewWindowRoot(nsPIDOMWindowOuter* aWindow) {
|
||||||
nsCOMPtr<EventTarget> result = new nsWindowRoot(aWindow);
|
nsCOMPtr<EventTarget> result = new nsWindowRoot(aWindow);
|
||||||
|
|
||||||
if (XRE_IsContentProcess()) {
|
RefPtr<JSWindowActorService> wasvc = JSWindowActorService::GetSingleton();
|
||||||
RefPtr<JSWindowActorService> wasvc = JSWindowActorService::GetSingleton();
|
if (wasvc) {
|
||||||
wasvc->RegisterChromeEventTarget(result);
|
wasvc->RegisterWindowRoot(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.forget();
|
return result.forget();
|
||||||
|
|
|
@ -155,8 +155,6 @@ dictionary WindowActorChildOptions : WindowActorSidedOptions {
|
||||||
* Events which this actor wants to be listening to. When these events fire,
|
* Events which this actor wants to be listening to. When these events fire,
|
||||||
* it will trigger actor creation, and then forward the event to the actor.
|
* it will trigger actor creation, and then forward the event to the actor.
|
||||||
*
|
*
|
||||||
* NOTE: Listeners are not attached for windows loaded in chrome docshells.
|
|
||||||
*
|
|
||||||
* NOTE: `once` option is not support due to we register listeners in a shared
|
* NOTE: `once` option is not support due to we register listeners in a shared
|
||||||
* location.
|
* location.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -243,8 +243,8 @@ NS_IMETHODIMP JSWindowActorProtocol::Observe(nsISupports* aSubject,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aTarget) {
|
void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aRoot) {
|
||||||
EventListenerManager* elm = aTarget->GetOrCreateListenerManager();
|
EventListenerManager* elm = aRoot->GetOrCreateListenerManager();
|
||||||
|
|
||||||
for (auto& event : mChild.mEvents) {
|
for (auto& event : mChild.mEvents) {
|
||||||
elm->AddEventListenerByType(EventListenerHolder(this), event.mName,
|
elm->AddEventListenerByType(EventListenerHolder(this), event.mName,
|
||||||
|
@ -252,8 +252,8 @@ void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aTarget) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSWindowActorProtocol::UnregisterListenersFor(EventTarget* aTarget) {
|
void JSWindowActorProtocol::UnregisterListenersFor(EventTarget* aRoot) {
|
||||||
EventListenerManager* elm = aTarget->GetOrCreateListenerManager();
|
EventListenerManager* elm = aRoot->GetOrCreateListenerManager();
|
||||||
|
|
||||||
for (auto& event : mChild.mEvents) {
|
for (auto& event : mChild.mEvents) {
|
||||||
elm->RemoveEventListenerByType(EventListenerHolder(this), event.mName,
|
elm->RemoveEventListenerByType(EventListenerHolder(this), event.mName,
|
||||||
|
@ -388,9 +388,9 @@ void JSWindowActorService::RegisterWindowActor(
|
||||||
Unused << cp->SendInitJSWindowActorInfos(ipcInfos);
|
Unused << cp->SendInitJSWindowActorInfos(ipcInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register event listeners for any existing chrome targets.
|
// Register event listeners for any existing window roots.
|
||||||
for (EventTarget* target : mChromeEventTargets) {
|
for (EventTarget* root : mRoots) {
|
||||||
proto->RegisterListenersFor(target);
|
proto->RegisterListenersFor(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add observers to the protocol.
|
// Add observers to the protocol.
|
||||||
|
@ -410,9 +410,9 @@ void JSWindowActorService::UnregisterWindowActor(const nsAString& aName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove listeners for this actor from each of our chrome targets.
|
// Remove listeners for this actor from each of our window roots.
|
||||||
for (EventTarget* target : mChromeEventTargets) {
|
for (EventTarget* root : mRoots) {
|
||||||
proto->UnregisterListenersFor(target);
|
proto->UnregisterListenersFor(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove observers for this actor from observer serivce.
|
// Remove observers for this actor from observer serivce.
|
||||||
|
@ -431,9 +431,9 @@ void JSWindowActorService::LoadJSWindowActorInfos(
|
||||||
JSWindowActorProtocol::FromIPC(aInfos[i]);
|
JSWindowActorProtocol::FromIPC(aInfos[i]);
|
||||||
mDescriptors.Put(aInfos[i].name(), proto);
|
mDescriptors.Put(aInfos[i].name(), proto);
|
||||||
|
|
||||||
// Register listeners for each chrome target.
|
// Register listeners for each window root.
|
||||||
for (EventTarget* target : mChromeEventTargets) {
|
for (EventTarget* root : mRoots) {
|
||||||
proto->RegisterListenersFor(target);
|
proto->RegisterListenersFor(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add observers for each actor.
|
// Add observers for each actor.
|
||||||
|
@ -451,21 +451,21 @@ void JSWindowActorService::GetJSWindowActorInfos(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSWindowActorService::RegisterChromeEventTarget(EventTarget* aTarget) {
|
void JSWindowActorService::RegisterWindowRoot(EventTarget* aRoot) {
|
||||||
MOZ_ASSERT(!mChromeEventTargets.Contains(aTarget));
|
MOZ_ASSERT(!mRoots.Contains(aRoot));
|
||||||
mChromeEventTargets.AppendElement(aTarget);
|
mRoots.AppendElement(aRoot);
|
||||||
|
|
||||||
// Register event listeners on the newly added Window Root.
|
// Register event listeners on the newly added Window Root.
|
||||||
for (auto iter = mDescriptors.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDescriptors.Iter(); !iter.Done(); iter.Next()) {
|
||||||
iter.Data()->RegisterListenersFor(aTarget);
|
iter.Data()->RegisterListenersFor(aRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void JSWindowActorService::UnregisterChromeEventTarget(EventTarget* aTarget) {
|
void JSWindowActorService::UnregisterWindowRoot(EventTarget* aRoot) {
|
||||||
if (gJSWindowActorService) {
|
if (gJSWindowActorService) {
|
||||||
// NOTE: No need to unregister listeners here, as the target is going away.
|
// NOTE: No need to unregister listeners here, as the root is going away.
|
||||||
gJSWindowActorService->mChromeEventTargets.RemoveElement(aTarget);
|
gJSWindowActorService->mRoots.RemoveElement(aRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ class JSWindowActorProtocol final : public nsIObserver,
|
||||||
const ParentSide& Parent() const { return mParent; }
|
const ParentSide& Parent() const { return mParent; }
|
||||||
const ChildSide& Child() const { return mChild; }
|
const ChildSide& Child() const { return mChild; }
|
||||||
|
|
||||||
void RegisterListenersFor(EventTarget* aTarget);
|
void RegisterListenersFor(EventTarget* aRoot);
|
||||||
void UnregisterListenersFor(EventTarget* aTarget);
|
void UnregisterListenersFor(EventTarget* aRoot);
|
||||||
void AddObservers();
|
void AddObservers();
|
||||||
void RemoveObservers();
|
void RemoveObservers();
|
||||||
bool Matches(BrowsingContext* aBrowsingContext, nsIURI* aURI,
|
bool Matches(BrowsingContext* aBrowsingContext, nsIURI* aURI,
|
||||||
|
@ -114,11 +114,11 @@ class JSWindowActorService final {
|
||||||
// from mDescriptors to JSWindowActorInfos.
|
// from mDescriptors to JSWindowActorInfos.
|
||||||
void GetJSWindowActorInfos(nsTArray<JSWindowActorInfo>& aInfos);
|
void GetJSWindowActorInfos(nsTArray<JSWindowActorInfo>& aInfos);
|
||||||
|
|
||||||
// Register or unregister a chrome event target.
|
// Register or unregister a WindowRoot object from this JSWindowActorService.
|
||||||
void RegisterChromeEventTarget(EventTarget* aTarget);
|
void RegisterWindowRoot(EventTarget* aRoot);
|
||||||
|
|
||||||
// NOTE: This method is static, as it may be called during shutdown.
|
// NOTE: This method is static, as it may be called during shutdown.
|
||||||
static void UnregisterChromeEventTarget(EventTarget* aTarget);
|
static void UnregisterWindowRoot(EventTarget* aRoot);
|
||||||
|
|
||||||
already_AddRefed<JSWindowActorProtocol> GetProtocol(const nsAString& aName);
|
already_AddRefed<JSWindowActorProtocol> GetProtocol(const nsAString& aName);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class JSWindowActorService final {
|
||||||
JSWindowActorService();
|
JSWindowActorService();
|
||||||
~JSWindowActorService();
|
~JSWindowActorService();
|
||||||
|
|
||||||
nsTArray<EventTarget*> mChromeEventTargets;
|
nsTArray<EventTarget*> mRoots;
|
||||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorProtocol> mDescriptors;
|
nsRefPtrHashtable<nsStringHashKey, JSWindowActorProtocol> mDescriptors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче