summaryrefslogtreecommitdiffstats
path: root/dom/base/nsPIDOMWindowInlines.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/nsPIDOMWindowInlines.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/nsPIDOMWindowInlines.h')
-rw-r--r--dom/base/nsPIDOMWindowInlines.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/dom/base/nsPIDOMWindowInlines.h b/dom/base/nsPIDOMWindowInlines.h
new file mode 100644
index 000000000..fc4afa7ed
--- /dev/null
+++ b/dom/base/nsPIDOMWindowInlines.h
@@ -0,0 +1,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;
+}