зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1419144 - Part 18: Move AsInner() and AsOuter() off of nsPIDOMWindow<T>, r=smaug
MozReview-Commit-ID: IA29zmacrJ4
This commit is contained in:
Родитель
cc1a61fcdc
Коммит
b1a42230f1
|
@ -319,10 +319,6 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
|
|||
mNumOfIndexedDBDatabases(0),
|
||||
mNumOfOpenWebSockets(0)
|
||||
{
|
||||
if (aOuterWindow) {
|
||||
mTimeoutManager =
|
||||
MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindowInner::Cast(AsInner()));
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -650,6 +650,9 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow)
|
|||
// window list of inners.
|
||||
PR_INSERT_AFTER(this, aOuterWindow);
|
||||
|
||||
mTimeoutManager =
|
||||
MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindowInner::Cast(AsInner()));
|
||||
|
||||
mObserver = new nsGlobalWindowObserver(this);
|
||||
if (mObserver) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
|
|
@ -291,7 +291,7 @@ public:
|
|||
// nsWrapperCache
|
||||
virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return IsInnerWindow() || AsOuter()->EnsureInnerWindow() ? GetWrapper() : nullptr;
|
||||
return GetWrapper();
|
||||
}
|
||||
|
||||
// nsIGlobalJSObjectHolder
|
||||
|
|
|
@ -127,11 +127,6 @@ template<class T>
|
|||
class nsPIDOMWindow : public T
|
||||
{
|
||||
public:
|
||||
nsPIDOMWindowInner* AsInner();
|
||||
const nsPIDOMWindowInner* AsInner() const;
|
||||
nsPIDOMWindowOuter* AsOuter();
|
||||
const nsPIDOMWindowOuter* AsOuter() const;
|
||||
|
||||
virtual nsPIDOMWindowOuter* GetPrivateRoot() = 0;
|
||||
virtual mozilla::dom::CustomElementRegistry* CustomElements() = 0;
|
||||
// Outer windows only.
|
||||
|
@ -223,10 +218,6 @@ protected:
|
|||
void MaybeCreateDoc();
|
||||
|
||||
public:
|
||||
// Check whether a document is currently loading
|
||||
inline bool IsLoading() const;
|
||||
inline bool IsHandlingResizeEvent() const;
|
||||
|
||||
// Set the window up with an about:blank document with the current subject
|
||||
// principal.
|
||||
// Outer windows only.
|
||||
|
@ -255,13 +246,6 @@ public:
|
|||
// the window was frozen.
|
||||
virtual nsresult FireDelayedDOMEvents() = 0;
|
||||
|
||||
nsPIDOMWindowOuter* GetOuterWindow() const
|
||||
{
|
||||
return mIsInnerWindow
|
||||
? mOuterWindow.get()
|
||||
: const_cast<nsPIDOMWindowOuter*>(AsOuter());
|
||||
}
|
||||
|
||||
bool IsInnerWindow() const
|
||||
{
|
||||
return mIsInnerWindow;
|
||||
|
@ -763,6 +747,17 @@ class nsPIDOMWindowInner : public nsPIDOMWindow<mozIDOMWindow>
|
|||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWINNER_IID)
|
||||
|
||||
nsPIDOMWindowInner* AsInner() {
|
||||
return this;
|
||||
}
|
||||
const nsPIDOMWindowInner* AsInner() const {
|
||||
return this;
|
||||
}
|
||||
|
||||
nsPIDOMWindowOuter* GetOuterWindow() const {
|
||||
return mOuterWindow;
|
||||
}
|
||||
|
||||
static nsPIDOMWindowInner* From(mozIDOMWindow* aFrom) {
|
||||
return static_cast<nsPIDOMWindowInner*>(aFrom);
|
||||
}
|
||||
|
@ -779,6 +774,10 @@ public:
|
|||
// Returns true if this window is the same as mTopInnerWindow
|
||||
inline bool IsTopInnerWindow() const;
|
||||
|
||||
// Check whether a document is currently loading
|
||||
inline bool IsLoading() const;
|
||||
inline bool IsHandlingResizeEvent() const;
|
||||
|
||||
bool AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
|
||||
void RemoveAudioContext(mozilla::dom::AudioContext* aAudioContext);
|
||||
void MuteAudioContexts();
|
||||
|
@ -958,6 +957,17 @@ protected:
|
|||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWOUTER_IID)
|
||||
|
||||
nsPIDOMWindowOuter* AsOuter() {
|
||||
return this;
|
||||
}
|
||||
const nsPIDOMWindowOuter* AsOuter() const {
|
||||
return this;
|
||||
}
|
||||
|
||||
nsPIDOMWindowOuter* GetOuterWindow() const {
|
||||
return const_cast<nsPIDOMWindowOuter*>(this);
|
||||
}
|
||||
|
||||
static nsPIDOMWindowOuter* From(mozIDOMWindowProxy* aFrom) {
|
||||
return static_cast<nsPIDOMWindowOuter*>(aFrom);
|
||||
}
|
||||
|
@ -966,6 +976,10 @@ public:
|
|||
// Otherwise (argument null or not an inner or not current) return null.
|
||||
static nsPIDOMWindowOuter* GetFromCurrentInner(nsPIDOMWindowInner* aInner);
|
||||
|
||||
// Check whether a document is currently loading
|
||||
inline bool IsLoading() const;
|
||||
inline bool IsHandlingResizeEvent() const;
|
||||
|
||||
nsPIDOMWindowInner* GetCurrentInnerWindow() const
|
||||
{
|
||||
return mInnerWindow;
|
||||
|
|
|
@ -4,44 +4,10 @@
|
|||
* 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/. */
|
||||
|
||||
template<class T>
|
||||
nsPIDOMWindowInner*
|
||||
nsPIDOMWindow<T>::AsInner()
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
return reinterpret_cast<nsPIDOMWindowInner*>(this);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const nsPIDOMWindowInner*
|
||||
nsPIDOMWindow<T>::AsInner() const
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
return reinterpret_cast<const nsPIDOMWindowInner*>(this);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
nsPIDOMWindowOuter*
|
||||
nsPIDOMWindow<T>::AsOuter()
|
||||
{
|
||||
MOZ_ASSERT(IsOuterWindow());
|
||||
return reinterpret_cast<nsPIDOMWindowOuter*>(this);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const nsPIDOMWindowOuter*
|
||||
nsPIDOMWindow<T>::AsOuter() const
|
||||
{
|
||||
MOZ_ASSERT(IsOuterWindow());
|
||||
return reinterpret_cast<const nsPIDOMWindowOuter*>(this);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
nsPIDOMWindow<T>::IsLoading() const
|
||||
nsPIDOMWindowOuter::IsLoading() const
|
||||
{
|
||||
if (IsOuterWindow()) {
|
||||
auto* win = AsOuter()->GetCurrentInnerWindow();
|
||||
auto* win = GetCurrentInnerWindow();
|
||||
|
||||
if (!win) {
|
||||
NS_ERROR("No current inner window available!");
|
||||
|
@ -52,6 +18,9 @@ nsPIDOMWindow<T>::IsLoading() const
|
|||
return win->IsLoading();
|
||||
}
|
||||
|
||||
bool
|
||||
nsPIDOMWindowInner::IsLoading() const
|
||||
{
|
||||
if (!mOuterWindow) {
|
||||
NS_ERROR("IsLoading() called on orphan inner window!");
|
||||
|
||||
|
@ -61,12 +30,10 @@ nsPIDOMWindow<T>::IsLoading() const
|
|||
return !mIsDocumentLoaded;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
nsPIDOMWindow<T>::IsHandlingResizeEvent() const
|
||||
nsPIDOMWindowOuter::IsHandlingResizeEvent() const
|
||||
{
|
||||
if (IsOuterWindow()) {
|
||||
auto* win = AsOuter()->GetCurrentInnerWindow();
|
||||
auto* win = GetCurrentInnerWindow();
|
||||
|
||||
if (!win) {
|
||||
NS_ERROR("No current inner window available!");
|
||||
|
@ -77,6 +44,9 @@ nsPIDOMWindow<T>::IsHandlingResizeEvent() const
|
|||
return win->IsHandlingResizeEvent();
|
||||
}
|
||||
|
||||
bool
|
||||
nsPIDOMWindowInner::IsHandlingResizeEvent() const
|
||||
{
|
||||
if (!mOuterWindow) {
|
||||
NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче