Bug 1632301 - part2 : use ContentControlKeyEventReceiver's browsing context to notify any changes. r=bryce

This patch will do :
- use current broswing context as a parameter when propagate state change to the chrome process.

The advantage of doing so :
- the chrome process can know which browsing context the state change actually comes from.

---

More details about this change :

Currently, when we propagate any controlled media related states, we would find the top level browsing context first, then pass it through IPC in order to get the correct media controller in the chrome process. However, we have implemented [1] which can find the correct media controller even if we are not passing the top level browsing context.

In addition, in bug1627999, we would like to know which browsing context those states come from. Therefore, we should replace the top browsing context with the current browsing context where controlled media exists.

[1] https://searchfox.org/mozilla-central/rev/41c3ea3ee8eab9ce7b82932257cb80b703cbba67/docshell/base/CanonicalBrowsingContext.cpp#511-515

Differential Revision: https://phabricator.services.mozilla.com/D72056
This commit is contained in:
alwu
2020-04-28 05:10:21 +00:00
parent 33c6833a20
commit 1ae1716e41
3 changed files with 13 additions and 20 deletions

View File

@@ -505,17 +505,17 @@ class HTMLMediaElement::MediaControlEventListener final
}
}
BrowsingContext* GetBrowsingContext() const override {
nsPIDOMWindowInner* window = Owner()->OwnerDoc()->GetInnerWindow();
return window ? window->GetBrowsingContext() : nullptr;
}
private:
~MediaControlEventListener() = default;
bool InitMediaAgent() {
MOZ_ASSERT(NS_IsMainThread());
nsPIDOMWindowInner* window = Owner()->OwnerDoc()->GetInnerWindow();
if (!window) {
return false;
}
mControlAgent = ContentMediaAgent::Get(window->GetBrowsingContext());
mControlAgent = ContentMediaAgent::Get(GetBrowsingContext());
if (!mControlAgent) {
return false;
}