diff options
Diffstat (limited to 'dom/base')
-rw-r--r-- | dom/base/Element.cpp | 1 | ||||
-rw-r--r-- | dom/base/Navigator.cpp | 78 | ||||
-rw-r--r-- | dom/base/Navigator.h | 7 | ||||
-rw-r--r-- | dom/base/nsCCUncollectableMarker.cpp | 40 | ||||
-rw-r--r-- | dom/base/nsGlobalWindow.cpp | 79 | ||||
-rw-r--r-- | dom/base/nsGlobalWindow.h | 24 | ||||
-rw-r--r-- | dom/base/nsScriptLoader.cpp | 12 |
7 files changed, 43 insertions, 198 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 79b36a314..3760dc43f 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -145,7 +145,6 @@ #include "mozilla/dom/KeyframeEffectBinding.h" #include "mozilla/dom/WindowBinding.h" #include "mozilla/dom/ElementBinding.h" -#include "mozilla/dom/VRDisplay.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/Preferences.h" #include "nsComputedDOMStyle.h" diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 1bc4f82f4..286cd0e79 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -44,7 +44,6 @@ #include "mozilla/dom/ServiceWorkerContainer.h" #include "mozilla/dom/StorageManager.h" #include "mozilla/dom/TCPSocket.h" -#include "mozilla/dom/VRDisplay.h" #include "mozilla/dom/workers/RuntimeService.h" #include "mozilla/Hal.h" #include "nsISiteSpecificUserAgent.h" @@ -1471,83 +1470,6 @@ Navigator::RequestGamepadServiceTest() } #endif -already_AddRefed<Promise> -Navigator::GetVRDisplays(ErrorResult& aRv) -{ - if (!mWindow || !mWindow->GetDocShell()) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return nullptr; - } - - nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow); - win->NotifyVREventListenerAdded(); - - nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow); - RefPtr<Promise> p = Promise::Create(go, aRv); - if (aRv.Failed()) { - return nullptr; - } - - // We pass mWindow's id to RefreshVRDisplays, so NotifyVRDisplaysUpdated will - // be called asynchronously, resolving the promises in mVRGetDisplaysPromises. - if (!VRDisplay::RefreshVRDisplays(win->WindowID())) { - p->MaybeReject(NS_ERROR_FAILURE); - return p.forget(); - } - - mVRGetDisplaysPromises.AppendElement(p); - return p.forget(); -} - -void -Navigator::GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const -{ - /** - * Get only the active VR displays. - * Callers do not wish to VRDisplay::RefreshVRDisplays, as the enumeration may - * activate hardware that is not yet intended to be used. - */ - if (!mWindow || !mWindow->GetDocShell()) { - return; - } - nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow); - win->NotifyVREventListenerAdded(); - nsTArray<RefPtr<VRDisplay>> displays; - if (win->UpdateVRDisplays(displays)) { - for (auto display : displays) { - if (display->IsPresenting()) { - aDisplays.AppendElement(display); - } - } - } -} - -void -Navigator::NotifyVRDisplaysUpdated() -{ - // Synchronize the VR devices and resolve the promises in - // mVRGetDisplaysPromises - nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow); - - nsTArray<RefPtr<VRDisplay>> vrDisplays; - if (win->UpdateVRDisplays(vrDisplays)) { - for (auto p : mVRGetDisplaysPromises) { - p->MaybeResolve(vrDisplays); - } - } else { - for (auto p : mVRGetDisplaysPromises) { - p->MaybeReject(NS_ERROR_FAILURE); - } - } - mVRGetDisplaysPromises.Clear(); -} - -void -Navigator::NotifyActiveVRDisplaysChanged() -{ - NavigatorBinding::ClearCachedActiveVRDisplaysValue(this); -} - //***************************************************************************** // Navigator::nsIMozNavigatorNetwork //***************************************************************************** diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index d47a80bc1..91b7fc15c 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -76,7 +76,6 @@ class Connection; class PowerManager; class Presentation; class LegacyMozTCPSocket; -class VRDisplay; class StorageManager; namespace time { @@ -204,8 +203,6 @@ public: void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv); GamepadServiceTest* RequestGamepadServiceTest(); #endif // MOZ_GAMEPAD - already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv); - void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const; #ifdef MOZ_TIME_MANAGER time::TimeManager* GetMozTime(ErrorResult& aRv); #endif // MOZ_TIME_MANAGER @@ -269,10 +266,6 @@ private: RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager; #endif -public: - void NotifyVRDisplaysUpdated(); - void NotifyActiveVRDisplaysChanged(); - private: virtual ~Navigator(); diff --git a/dom/base/nsCCUncollectableMarker.cpp b/dom/base/nsCCUncollectableMarker.cpp index 861cda521..db4d0d351 100644 --- a/dom/base/nsCCUncollectableMarker.cpp +++ b/dom/base/nsCCUncollectableMarker.cpp @@ -188,23 +188,20 @@ MarkMessageManagers() } void -MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS, - bool aPrepareForCC) +MarkDocument(nsIDocument* aDoc, bool aCleanupJS, bool aPrepareForCC) { - if (!aViewer) { + if (!aDoc) { return; } - nsIDocument *doc = aViewer->GetDocument(); - if (doc && - doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) { - doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); + if (aDoc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) { + aDoc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); if (aCleanupJS) { - EventListenerManager* elm = doc->GetExistingListenerManager(); + EventListenerManager* elm = aDoc->GetExistingListenerManager(); if (elm) { elm->MarkForCC(); } - nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow()); + nsCOMPtr<EventTarget> win = do_QueryInterface(aDoc->GetInnerWindow()); if (win) { elm = win->GetExistingListenerManager(); if (elm) { @@ -215,18 +212,27 @@ MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS, } else if (aPrepareForCC) { // Unfortunately we need to still mark user data just before running CC so // that it has the right generation. - doc->PropertyTable(DOM_USER_DATA)-> + aDoc->PropertyTable(DOM_USER_DATA)-> EnumerateAll(MarkUserData, &nsCCUncollectableMarker::sGeneration); } } - if (doc) { - if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) { - inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); - } - if (nsPIDOMWindowOuter* outer = doc->GetWindow()) { - outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); - } + if (nsPIDOMWindowInner* inner = aDoc->GetInnerWindow()) { + inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); + } + if (nsPIDOMWindowOuter* outer = aDoc->GetWindow()) { + outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); + } +} + +void +MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS, + bool aPrepareForCC) +{ + if (!aViewer) { + return; } + + MarkDocument(aViewer->GetDocument(), aCleanupJS, aPrepareForCC); } void MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS, diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 88cebe42b..677e1a0ea 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -202,9 +202,6 @@ #include "mozilla/dom/GamepadManager.h" #endif -#include "mozilla/dom/VRDisplay.h" -#include "mozilla/dom/VREventObserver.h" - #include "nsRefreshDriver.h" #include "Layers.h" @@ -1532,7 +1529,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) mShowFocusRingForContent(false), mFocusByKeyOccurred(false), mHasGamepad(false), - mHasVREvents(false), #ifdef MOZ_GAMEPAD mHasSeenGamepadInput(false), #endif @@ -1967,12 +1963,9 @@ nsGlobalWindow::CleanUp() if (IsInnerWindow()) { DisableGamepadUpdates(); mHasGamepad = false; - DisableVRUpdates(); - mHasVREvents = false; DisableIdleCallbackRequests(); } else { MOZ_ASSERT(!mHasGamepad); - MOZ_ASSERT(!mHasVREvents); } if (mCleanMessageManager) { @@ -2023,7 +2016,7 @@ nsGlobalWindow::ClearControllers() } void -nsGlobalWindow::FreeInnerObjects() +nsGlobalWindow::FreeInnerObjects(bool aForDocumentOpen) { NS_ASSERTION(IsInnerWindow(), "Don't free inner objects on an outer window"); @@ -2082,8 +2075,10 @@ nsGlobalWindow::FreeInnerObjects() mDocumentURI = mDoc->GetDocumentURI(); mDocBaseURI = mDoc->GetDocBaseURI(); - while (mDoc->EventHandlingSuppressed()) { - mDoc->UnsuppressEventHandlingAndFireEvents(nsIDocument::eEvents, false); + if (!aForDocumentOpen) { + while (mDoc->EventHandlingSuppressed()) { + mDoc->UnsuppressEventHandlingAndFireEvents(nsIDocument::eEvents, false); + } } // Note: we don't have to worry about eAnimationsOnly suppressions because @@ -2116,9 +2111,6 @@ nsGlobalWindow::FreeInnerObjects() mHasGamepad = false; mGamepads.Clear(); #endif - DisableVRUpdates(); - mHasVREvents = false; - mVRDisplays.Clear(); } //***************************************************************************** @@ -2273,7 +2265,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow) #endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays) // Traverse stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler) @@ -2350,7 +2341,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) #endif NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays) // Unlink stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler) @@ -3000,6 +2990,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, nsCOMPtr<WindowStateHolder> wsh = do_QueryInterface(aState); NS_ASSERTION(!aState || wsh, "What kind of weird state are you giving me here?"); + bool handleDocumentOpen = false; + JS::Rooted<JSObject*> newInnerGlobal(cx); if (reUseInnerWindow) { // We're reusing the current inner window. @@ -3091,6 +3083,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, if (currentInner && currentInner->GetWrapperPreserveColor()) { if (oldDoc == aDocument) { + handleDocumentOpen = true; // Move the navigator from the old inner window to the new one since // this is a document.write. This is safe from a same-origin point of // view because document.write can only be used by the same origin. @@ -3115,7 +3108,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, // Don't free objects on our current inner window if it's going to be // held in the bfcache. if (!currentInner->IsFrozen()) { - currentInner->FreeInnerObjects(); + currentInner->FreeInnerObjects(handleDocumentOpen); } } @@ -10503,24 +10496,6 @@ nsGlobalWindow::DisableGamepadUpdates() } void -nsGlobalWindow::EnableVRUpdates() -{ - MOZ_ASSERT(IsInnerWindow()); - - if (mHasVREvents && !mVREventObserver) { - mVREventObserver = new VREventObserver(this); - } -} - -void -nsGlobalWindow::DisableVRUpdates() -{ - MOZ_ASSERT(IsInnerWindow()); - - mVREventObserver = nullptr; -} - -void nsGlobalWindow::SetChromeEventHandler(EventTarget* aChromeEventHandler) { MOZ_ASSERT(IsOuterWindow()); @@ -12205,7 +12180,6 @@ nsGlobalWindow::Suspend() ac->RemoveWindowListener(mEnabledSensors[i], this); } DisableGamepadUpdates(); - DisableVRUpdates(); mozilla::dom::workers::SuspendWorkersForWindow(AsInner()); @@ -12269,7 +12243,6 @@ nsGlobalWindow::Resume() ac->AddWindowListener(mEnabledSensors[i], this); } EnableGamepadUpdates(); - EnableVRUpdates(); // Resume all of the AudioContexts for this window for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) { @@ -14025,19 +13998,6 @@ nsGlobalWindow::SetHasGamepadEventListener(bool aHasGamepad/* = true*/) void nsGlobalWindow::EventListenerAdded(nsIAtom* aType) { - if (aType == nsGkAtoms::onvrdisplayconnect || - aType == nsGkAtoms::onvrdisplaydisconnect || - aType == nsGkAtoms::onvrdisplaypresentchange) { - NotifyVREventListenerAdded(); - } -} - -void -nsGlobalWindow::NotifyVREventListenerAdded() -{ - MOZ_ASSERT(IsInnerWindow()); - mHasVREvents = true; - EnableVRUpdates(); } void @@ -14182,27 +14142,6 @@ nsGlobalWindow::SyncGamepadState() } #endif // MOZ_GAMEPAD -bool -nsGlobalWindow::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices) -{ - FORWARD_TO_INNER(UpdateVRDisplays, (aDevices), false); - - VRDisplay::UpdateVRDisplays(mVRDisplays, AsInner()); - aDevices = mVRDisplays; - return true; -} - -void -nsGlobalWindow::NotifyActiveVRDisplaysChanged() -{ - MOZ_ASSERT(IsInnerWindow()); - - if (mNavigator) { - mNavigator->NotifyActiveVRDisplaysChanged(); - } -} - - // nsGlobalChromeWindow implementation NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow) diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 467bc6796..1cb825a77 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -135,8 +135,6 @@ class SpeechSynthesis; class TabGroup; class Timeout; class U2F; -class VRDisplay; -class VREventObserver; class WakeLock; #if defined(MOZ_WIDGET_ANDROID) class WindowOrientationObserver; @@ -745,18 +743,6 @@ public: void EnableGamepadUpdates(); void DisableGamepadUpdates(); - // Inner windows only. - // Enable/disable updates for VR - void EnableVRUpdates(); - void DisableVRUpdates(); - - // Update the VR displays for this window - bool UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDisplays); - - // Inner windows only. - // Called to inform that the set of active VR displays has changed. - void NotifyActiveVRDisplaysChanged(); - #define EVENT(name_, id_, type_, struct_) \ mozilla::dom::EventHandlerNonNull* GetOn##name_() \ { \ @@ -1380,7 +1366,7 @@ protected: } } - void FreeInnerObjects(); + void FreeInnerObjects(bool aForDocumentOpen = false); nsGlobalWindow *CallerInnerWindow(); // Only to be called on an inner window. @@ -1832,9 +1818,6 @@ protected: // Indicates whether this window wants gamepad input events bool mHasGamepad : 1; - // Inner windows only. - // Indicates whether this window wants VR events - bool mHasVREvents : 1; #ifdef MOZ_GAMEPAD nsCheapSet<nsUint32HashKey> mGamepadIndexSet; nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads; @@ -1989,11 +1972,6 @@ protected: // This is the CC generation the last time we called CanSkip. uint32_t mCanSkipCCGeneration; - // The VR Displays for this window - nsTArray<RefPtr<mozilla::dom::VRDisplay>> mVRDisplays; - - nsAutoPtr<mozilla::dom::VREventObserver> mVREventObserver; - friend class nsDOMScriptableHelper; friend class nsDOMWindowUtils; friend class mozilla::dom::PostMessageEvent; diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index a6d20e363..0eb5bbf31 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -81,11 +81,19 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoadRequest) NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTION_0(nsScriptLoadRequest) - NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoadRequest) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoadRequest) +NS_IMPL_CYCLE_COLLECTION_CLASS(nsScriptLoadRequest) + +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsScriptLoadRequest) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsScriptLoadRequest) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END + nsScriptLoadRequest::~nsScriptLoadRequest() { js_free(mScriptTextBuf); |