blob: fc4afa7ed2da631a819977451ab59b1dc6b1b416 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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>::IsLoadingOrRunningTimeout() const
{
if (IsOuterWindow()) {
return AsOuter()->GetCurrentInnerWindow()->IsLoadingOrRunningTimeout();
}
return !mIsDocumentLoaded || mRunningTimeout;
}
template <class T>
bool
nsPIDOMWindow<T>::IsLoading() const
{
if (IsOuterWindow()) {
auto* win = AsOuter()->GetCurrentInnerWindow();
if (!win) {
NS_ERROR("No current inner window available!");
return false;
}
return win->IsLoading();
}
if (!mOuterWindow) {
NS_ERROR("IsLoading() called on orphan inner window!");
return false;
}
return !mIsDocumentLoaded;
}
template <class T>
bool
nsPIDOMWindow<T>::IsHandlingResizeEvent() const
{
if (IsOuterWindow()) {
auto* win = AsOuter()->GetCurrentInnerWindow();
if (!win) {
NS_ERROR("No current inner window available!");
return false;
}
return win->IsHandlingResizeEvent();
}
if (!mOuterWindow) {
NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
return false;
}
return mIsHandlingResizeEvent;
}
bool
nsPIDOMWindowInner::IsCurrentInnerWindow() const
{
return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == AsInner();
}
bool
nsPIDOMWindowInner::HasActiveDocument()
{
return IsCurrentInnerWindow() ||
(mOuterWindow &&
mOuterWindow->GetCurrentInnerWindow() &&
mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc);
}
template <class T>
nsIDocShell*
nsPIDOMWindow<T>::GetDocShell() const
{
if (mOuterWindow) {
return mOuterWindow->GetDocShell();
}
return mDocShell;
}
template <class T>
nsIContent*
nsPIDOMWindow<T>::GetFocusedNode() const
{
if (IsOuterWindow()) {
return mInnerWindow ? mInnerWindow->GetFocusedNode() : nullptr;
}
return mFocusedNode;
}
|