Backed out changeset ac6d8297cdc4 (bug 1581925) for test_bug89419.xul & test_MozDomFullscreen_event.xul failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2019-09-24 21:56:18 +03:00
Родитель 04851f6503
Коммит 9adecce6d4
6 изменённых файлов: 38 добавлений и 58 удалений

Просмотреть файл

@ -23,30 +23,11 @@
#include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/WindowProxyHolder.h"
#include "mozilla/dom/JSWindowActorService.h"
using namespace mozilla;
using namespace mozilla::dom;
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(
JSContext* aCx, const nsAString& aMessage, StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows, nsIPrincipal* aPrincipal,
@ -120,10 +101,6 @@ InProcessBrowserChildMessageManager::InProcessBrowserChildMessageManager(
}
InProcessBrowserChildMessageManager::~InProcessBrowserChildMessageManager() {
if (XRE_IsParentProcess()) {
JSWindowActorService::UnregisterChromeEventTarget(this);
}
mAnonymousGlobalScopes.Clear();
mozilla::DropJSObjects(this);
}

Просмотреть файл

@ -47,7 +47,14 @@ class InProcessBrowserChildMessageManager final
public:
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_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(

Просмотреть файл

@ -44,9 +44,7 @@ nsWindowRoot::~nsWindowRoot() {
mListenerManager->Disconnect();
}
if (XRE_IsContentProcess()) {
JSWindowActorService::UnregisterChromeEventTarget(this);
}
JSWindowActorService::UnregisterWindowRoot(this);
}
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) {
nsCOMPtr<EventTarget> result = new nsWindowRoot(aWindow);
if (XRE_IsContentProcess()) {
RefPtr<JSWindowActorService> wasvc = JSWindowActorService::GetSingleton();
wasvc->RegisterChromeEventTarget(result);
RefPtr<JSWindowActorService> wasvc = JSWindowActorService::GetSingleton();
if (wasvc) {
wasvc->RegisterWindowRoot(result);
}
return result.forget();

Просмотреть файл

@ -155,8 +155,6 @@ dictionary WindowActorChildOptions : WindowActorSidedOptions {
* 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.
*
* 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
* location.
*/

Просмотреть файл

@ -243,8 +243,8 @@ NS_IMETHODIMP JSWindowActorProtocol::Observe(nsISupports* aSubject,
return NS_OK;
}
void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aTarget) {
EventListenerManager* elm = aTarget->GetOrCreateListenerManager();
void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aRoot) {
EventListenerManager* elm = aRoot->GetOrCreateListenerManager();
for (auto& event : mChild.mEvents) {
elm->AddEventListenerByType(EventListenerHolder(this), event.mName,
@ -252,8 +252,8 @@ void JSWindowActorProtocol::RegisterListenersFor(EventTarget* aTarget) {
}
}
void JSWindowActorProtocol::UnregisterListenersFor(EventTarget* aTarget) {
EventListenerManager* elm = aTarget->GetOrCreateListenerManager();
void JSWindowActorProtocol::UnregisterListenersFor(EventTarget* aRoot) {
EventListenerManager* elm = aRoot->GetOrCreateListenerManager();
for (auto& event : mChild.mEvents) {
elm->RemoveEventListenerByType(EventListenerHolder(this), event.mName,
@ -388,9 +388,9 @@ void JSWindowActorService::RegisterWindowActor(
Unused << cp->SendInitJSWindowActorInfos(ipcInfos);
}
// Register event listeners for any existing chrome targets.
for (EventTarget* target : mChromeEventTargets) {
proto->RegisterListenersFor(target);
// Register event listeners for any existing window roots.
for (EventTarget* root : mRoots) {
proto->RegisterListenersFor(root);
}
// 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.
for (EventTarget* target : mChromeEventTargets) {
proto->UnregisterListenersFor(target);
// Remove listeners for this actor from each of our window roots.
for (EventTarget* root : mRoots) {
proto->UnregisterListenersFor(root);
}
// Remove observers for this actor from observer serivce.
@ -431,9 +431,9 @@ void JSWindowActorService::LoadJSWindowActorInfos(
JSWindowActorProtocol::FromIPC(aInfos[i]);
mDescriptors.Put(aInfos[i].name(), proto);
// Register listeners for each chrome target.
for (EventTarget* target : mChromeEventTargets) {
proto->RegisterListenersFor(target);
// Register listeners for each window root.
for (EventTarget* root : mRoots) {
proto->RegisterListenersFor(root);
}
// Add observers for each actor.
@ -451,21 +451,21 @@ void JSWindowActorService::GetJSWindowActorInfos(
}
}
void JSWindowActorService::RegisterChromeEventTarget(EventTarget* aTarget) {
MOZ_ASSERT(!mChromeEventTargets.Contains(aTarget));
mChromeEventTargets.AppendElement(aTarget);
void JSWindowActorService::RegisterWindowRoot(EventTarget* aRoot) {
MOZ_ASSERT(!mRoots.Contains(aRoot));
mRoots.AppendElement(aRoot);
// Register event listeners on the newly added Window Root.
for (auto iter = mDescriptors.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->RegisterListenersFor(aTarget);
iter.Data()->RegisterListenersFor(aRoot);
}
}
/* static */
void JSWindowActorService::UnregisterChromeEventTarget(EventTarget* aTarget) {
void JSWindowActorService::UnregisterWindowRoot(EventTarget* aRoot) {
if (gJSWindowActorService) {
// NOTE: No need to unregister listeners here, as the target is going away.
gJSWindowActorService->mChromeEventTargets.RemoveElement(aTarget);
// NOTE: No need to unregister listeners here, as the root is going away.
gJSWindowActorService->mRoots.RemoveElement(aRoot);
}
}

Просмотреть файл

@ -70,8 +70,8 @@ class JSWindowActorProtocol final : public nsIObserver,
const ParentSide& Parent() const { return mParent; }
const ChildSide& Child() const { return mChild; }
void RegisterListenersFor(EventTarget* aTarget);
void UnregisterListenersFor(EventTarget* aTarget);
void RegisterListenersFor(EventTarget* aRoot);
void UnregisterListenersFor(EventTarget* aRoot);
void AddObservers();
void RemoveObservers();
bool Matches(BrowsingContext* aBrowsingContext, nsIURI* aURI,
@ -114,11 +114,11 @@ class JSWindowActorService final {
// from mDescriptors to JSWindowActorInfos.
void GetJSWindowActorInfos(nsTArray<JSWindowActorInfo>& aInfos);
// Register or unregister a chrome event target.
void RegisterChromeEventTarget(EventTarget* aTarget);
// Register or unregister a WindowRoot object from this JSWindowActorService.
void RegisterWindowRoot(EventTarget* aRoot);
// 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);
@ -126,7 +126,7 @@ class JSWindowActorService final {
JSWindowActorService();
~JSWindowActorService();
nsTArray<EventTarget*> mChromeEventTargets;
nsTArray<EventTarget*> mRoots;
nsRefPtrHashtable<nsStringHashKey, JSWindowActorProtocol> mDescriptors;
};