diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-11-28 23:10:30 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-11-28 23:10:30 +0100 |
commit | 088c3cf890cc2d96f2093e2116612cbf65bfaeea (patch) | |
tree | b4d3c68155f2de43432dd00c167d3029732be146 /dom | |
parent | ec3829bf7266ebec111f41268c6c491356576df1 (diff) | |
parent | fe11e14d3cfc2900facf152257acda87280b6cdc (diff) | |
download | UXP-088c3cf890cc2d96f2093e2116612cbf65bfaeea.tar UXP-088c3cf890cc2d96f2093e2116612cbf65bfaeea.tar.gz UXP-088c3cf890cc2d96f2093e2116612cbf65bfaeea.tar.lz UXP-088c3cf890cc2d96f2093e2116612cbf65bfaeea.tar.xz UXP-088c3cf890cc2d96f2093e2116612cbf65bfaeea.zip |
Merge branch 'master' into Sync-weave
Diffstat (limited to 'dom')
42 files changed, 149 insertions, 2048 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); diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 14bc7e3e3..e2e05e5fd 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -47,7 +47,6 @@ #include "nsSVGEffects.h" #include "prenv.h" #include "ScopedGLHelpers.h" -#include "VRManagerChild.h" #include "mozilla/layers/TextureClientSharedSurface.h" // Local @@ -2239,84 +2238,6 @@ WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, uint32_t height, return totalBytes; } -already_AddRefed<layers::SharedSurfaceTextureClient> -WebGLContext::GetVRFrame() -{ - if (!mLayerIsMirror) { - /** - * Do not allow VR frame submission until a mirroring canvas layer has - * been returned by GetCanvasLayer - */ - return nullptr; - } - - VRManagerChild* vrmc = VRManagerChild::Get(); - if (!vrmc) { - return nullptr; - } - - /** - * Swap buffers as though composition has occurred. - * We will then share the resulting front buffer to be submitted to the VR - * compositor. - */ - BeginComposition(); - EndComposition(); - - gl::GLScreenBuffer* screen = gl->Screen(); - if (!screen) { - return nullptr; - } - - RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front(); - if (!sharedSurface) { - return nullptr; - } - - if (sharedSurface && sharedSurface->GetAllocator() != vrmc) { - RefPtr<SharedSurfaceTextureClient> dest = - screen->Factory()->NewTexClient(sharedSurface->GetSize()); - if (!dest) { - return nullptr; - } - gl::SharedSurface* destSurf = dest->Surf(); - destSurf->ProducerAcquire(); - SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(), - screen->Factory()); - destSurf->ProducerRelease(); - - return dest.forget(); - } - - return sharedSurface.forget(); -} - -bool -WebGLContext::StartVRPresentation() -{ - VRManagerChild* vrmc = VRManagerChild::Get(); - if (!vrmc) { - return false; - } - gl::GLScreenBuffer* screen = gl->Screen(); - if (!screen) { - return false; - } - gl::SurfaceCaps caps = screen->mCaps; - - UniquePtr<gl::SurfaceFactory> factory = - gl::GLScreenBuffer::CreateFactory(gl, - caps, - vrmc, - vrmc->GetBackendType(), - TextureFlags::ORIGIN_BOTTOM_LEFT); - - if (factory) { - screen->Morph(Move(factory)); - } - return true; -} - //////////////////////////////////////////////////////////////////////////////// static inline size_t diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index b4d416a33..3ec307b00 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -656,9 +656,6 @@ public: void PixelStorei(GLenum pname, GLint param); void PolygonOffset(GLfloat factor, GLfloat units); - already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame(); - bool StartVRPresentation(); - //// webgl::PackingInfo diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp index dde71dd0a..e17829652 100644 --- a/dom/gamepad/GamepadManager.cpp +++ b/dom/gamepad/GamepadManager.cpp @@ -28,7 +28,6 @@ #include "nsIObserverService.h" #include "nsIServiceManager.h" #include "nsThreadUtils.h" -#include "VRManagerChild.h" #include "mozilla/Services.h" #include "mozilla/Unused.h" @@ -110,11 +109,6 @@ GamepadManager::StopMonitoring() } mChannelChildren.Clear(); mGamepads.Clear(); - -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX) - mVRChannelChild = gfx::VRManagerChild::Get(); - mVRChannelChild->SendControllerListenerRemoved(); -#endif } void @@ -211,11 +205,6 @@ uint32_t GamepadManager::GetGamepadIndexWithServiceType(uint32_t aIndex, newIndex = aIndex; break; } - case GamepadServiceType::VR: - { - newIndex = aIndex + VR_GAMEPAD_IDX_OFFSET; - break; - } default: MOZ_ASSERT(false); break; @@ -679,13 +668,6 @@ GamepadManager::ActorCreated(PBackgroundChild *aActor) MOZ_ASSERT(initedChild == child); child->SendGamepadListenerAdded(); mChannelChildren.AppendElement(child); - -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX) - // Construct VRManagerChannel and ask adding the connected - // VR controllers to GamepadManager - mVRChannelChild = gfx::VRManagerChild::Get(); - mVRChannelChild->SendControllerListenerAdded(); -#endif } //Override nsIIPCBackgroundChildCreateCallback diff --git a/dom/gamepad/GamepadManager.h b/dom/gamepad/GamepadManager.h index 1bb437d8f..a772221ca 100644 --- a/dom/gamepad/GamepadManager.h +++ b/dom/gamepad/GamepadManager.h @@ -16,9 +16,6 @@ class nsGlobalWindow; namespace mozilla { -namespace gfx { -class VRManagerChild; -} // namespace gfx namespace dom { class EventTarget; @@ -123,7 +120,6 @@ class GamepadManager final : public nsIObserver, // will be destroyed during the IPDL shutdown chain, so we // don't need to refcount it here. nsTArray<GamepadEventChannelChild *> mChannelChildren; - gfx::VRManagerChild* mVRChannelChild; private: @@ -138,8 +134,6 @@ class GamepadManager final : public nsIObserver, // Indicate that a window has received data from a gamepad. void SetWindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex, bool aHasSeen = true); - // Our gamepad index has VR_GAMEPAD_IDX_OFFSET while GamepadChannelType - // is from VRManager. uint32_t GetGamepadIndexWithServiceType(uint32_t aIndex, GamepadServiceType aServiceType); // Gamepads connected to the system. Copies of these are handed out diff --git a/dom/gamepad/ipc/GamepadServiceType.h b/dom/gamepad/ipc/GamepadServiceType.h index acc0967d1..6200cdfa9 100644 --- a/dom/gamepad/ipc/GamepadServiceType.h +++ b/dom/gamepad/ipc/GamepadServiceType.h @@ -6,11 +6,9 @@ namespace mozilla{ namespace dom{ // Standard channel is used for managing gamepads that -// are from GamepadPlatformService. VR channel -// is for gamepads that are from VRManagerChild. +// are from GamepadPlatformService. enum class GamepadServiceType : uint16_t { Standard, - VR, NumGamepadServiceType }; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 88b41bce0..527135a80 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -42,7 +42,6 @@ #include "nsRefreshDriver.h" #include "nsStreamUtils.h" #include "ActiveLayerTracker.h" -#include "VRManagerChild.h" #include "WebGL1Context.h" #include "WebGL2Context.h" @@ -358,7 +357,6 @@ NS_IMPL_ISUPPORTS(HTMLCanvasElementObserver, nsIObserver) HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mResetLayer(true) , - mVRPresentationActive(false), mWriteOnly(false) {} @@ -1111,7 +1109,7 @@ HTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder, static uint8_t sOffscreenCanvasLayerUserDataDummy = 0; if (mCurrentContext) { - return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager, mVRPresentationActive); + return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager); } if (mOffscreenCanvas) { @@ -1441,42 +1439,5 @@ HTMLCanvasElement::InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRende element->InvalidateCanvasContent(nullptr); } -void -HTMLCanvasElement::StartVRPresentation() -{ - WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0)); - if (!webgl) { - return; - } - - if (!webgl->StartVRPresentation()) { - return; - } - - mVRPresentationActive = true; -} - -void -HTMLCanvasElement::StopVRPresentation() -{ - mVRPresentationActive = false; -} - -already_AddRefed<layers::SharedSurfaceTextureClient> -HTMLCanvasElement::GetVRFrame() -{ - if (GetCurrentContextType() != CanvasContextType::WebGL1 && - GetCurrentContextType() != CanvasContextType::WebGL2) { - return nullptr; - } - - WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0)); - if (!webgl) { - return nullptr; - } - - return webgl->GetVRFrame(); -} - } // namespace dom } // namespace mozilla diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h index 81c141d3c..746fab198 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -350,10 +350,6 @@ public: static void SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer); static void InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer); - void StartVRPresentation(); - void StopVRPresentation(); - already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame(); - protected: virtual ~HTMLCanvasElement(); diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index a3dc710ed..58c113058 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -23,6 +23,7 @@ #include "mozilla/AppProcessChecker.h" #include "mozilla/AutoRestore.h" #include "mozilla/Casting.h" +#include "mozilla/CheckedInt.h" #include "mozilla/EndianUtils.h" #include "mozilla/ErrorNames.h" #include "mozilla/LazyIdleThread.h" @@ -782,29 +783,25 @@ MakeCompressedIndexDataValues( MOZ_ASSERT(!keyBuffer.IsEmpty()); - // Don't let |infoLength| overflow. - if (NS_WARN_IF(UINT32_MAX - keyBuffer.Length() < - CompressedByteCountForIndexId(info.mIndexId) + - CompressedByteCountForNumber(keyBufferLength) + - CompressedByteCountForNumber(sortKeyBufferLength))) { - IDB_REPORT_INTERNAL_ERR(); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - const uint32_t infoLength = - CompressedByteCountForIndexId(info.mIndexId) + + const CheckedUint32 infoLength = + CheckedUint32(CompressedByteCountForIndexId(info.mIndexId)) + CompressedByteCountForNumber(keyBufferLength) + CompressedByteCountForNumber(sortKeyBufferLength) + keyBufferLength + sortKeyBufferLength; + // Don't let |infoLength| overflow. + if (NS_WARN_IF(!infoLength.isValid())) { + IDB_REPORT_INTERNAL_ERR(); + return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + } // Don't let |blobDataLength| overflow. - if (NS_WARN_IF(UINT32_MAX - infoLength < blobDataLength)) { + if (NS_WARN_IF(UINT32_MAX - infoLength.value() < blobDataLength)) { IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } - blobDataLength += infoLength; + blobDataLength += infoLength.value(); } UniqueFreePtr<uint8_t> blobData( diff --git a/dom/indexedDB/KeyPath.cpp b/dom/indexedDB/KeyPath.cpp index dc8d10668..30edd8cd7 100644 --- a/dom/indexedDB/KeyPath.cpp +++ b/dom/indexedDB/KeyPath.cpp @@ -14,6 +14,7 @@ #include "xpcpublic.h" #include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/dom/BlobBinding.h" #include "mozilla/dom/IDBObjectStoreBinding.h" namespace mozilla { @@ -100,7 +101,6 @@ GetJSValFromKeyPathString(JSContext* aCx, const char16_t* keyPathChars = token.BeginReading(); const size_t keyPathLen = token.Length(); - bool hasProp; if (!targetObject) { // We're still walking the chain of existing objects // http://w3c.github.io/IndexedDB/#dfn-evaluate-a-key-path-on-a-value @@ -116,16 +116,77 @@ GetJSValFromKeyPathString(JSContext* aCx, } obj = ¤tVal.toObject(); - bool ok = JS_HasUCProperty(aCx, obj, keyPathChars, keyPathLen, - &hasProp); + // We call JS_GetOwnUCPropertyDescriptor on purpose (as opposed to + // JS_GetUCPropertyDescriptor) to avoid searching the prototype chain. + JS::Rooted<JS::PropertyDescriptor> desc(aCx); + bool ok = JS_GetOwnUCPropertyDescriptor(aCx, obj, keyPathChars, + keyPathLen, &desc); IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - if (hasProp) { - // Get if the property exists... - JS::Rooted<JS::Value> intermediate(aCx); - bool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen, &intermediate); - IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + JS::Rooted<JS::Value> intermediate(aCx); + bool hasProp = false; + + if (desc.object()) { + intermediate = desc.value(); + hasProp = true; + } else { + // If we get here it means the object doesn't have the property or the + // property is available throuch a getter. We don't want to call any + // getters to avoid potential re-entrancy. + // The blob object is special since its properties are available + // only through getters but we still want to support them for key + // extraction. So they need to be handled manually. + Blob* blob; + if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, &obj, blob))) { + if (token.EqualsLiteral("size")) { + ErrorResult rv; + uint64_t size = blob->GetSize(rv); + MOZ_ALWAYS_TRUE(!rv.Failed()); + + intermediate = JS_NumberValue(size); + hasProp = true; + } else if (token.EqualsLiteral("type")) { + nsString type; + blob->GetType(type); + + JSString* string = + JS_NewUCStringCopyN(aCx, type.get(), type.Length()); + + intermediate = JS::StringValue(string); + hasProp = true; + } else { + RefPtr<File> file = blob->ToFile(); + if (file) { + if (token.EqualsLiteral("name")) { + nsString name; + file->GetName(name); + + JSString* string = + JS_NewUCStringCopyN(aCx, name.get(), name.Length()); + + intermediate = JS::StringValue(string); + hasProp = true; + } else if (token.EqualsLiteral("lastModified")) { + ErrorResult rv; + int64_t lastModifiedDate = file->GetLastModified(rv); + MOZ_ALWAYS_TRUE(!rv.Failed()); + + intermediate = JS_NumberValue(lastModifiedDate); + hasProp = true; + } else if (token.EqualsLiteral("lastModifiedDate")) { + ErrorResult rv; + Date lastModifiedDate = file->GetLastModifiedDate(rv); + MOZ_ALWAYS_TRUE(!rv.Failed()); + + lastModifiedDate.ToDateObject(aCx, &intermediate); + hasProp = true; + } + } + } + } + } + if (hasProp) { // Treat explicitly undefined as an error. if (intermediate.isUndefined()) { return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index fc288e2c5..fdf0fcf3e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -171,7 +171,6 @@ #include "GMPServiceChild.h" #include "gfxPlatform.h" #include "nscore.h" // for NS_FREE_PERMANENT_DATA -#include "VRManagerChild.h" using namespace mozilla; using namespace mozilla::docshell; @@ -1148,7 +1147,6 @@ ContentChild::RecvGMPsChanged(nsTArray<GMPCapabilityData>&& capabilities) bool ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor, Endpoint<PImageBridgeChild>&& aImageBridge, - Endpoint<PVRManagerChild>&& aVRBridge, Endpoint<PVideoDecoderManagerChild>&& aVideoManager) { if (!CompositorBridgeChild::InitForContent(Move(aCompositor))) { @@ -1157,9 +1155,6 @@ ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor, if (!ImageBridgeChild::InitForContent(Move(aImageBridge))) { return false; } - if (!gfx::VRManagerChild::InitForContent(Move(aVRBridge))) { - return false; - } VideoDecoderManagerChild::InitForContent(Move(aVideoManager)); return true; } @@ -1167,7 +1162,6 @@ ContentChild::RecvInitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor, bool ContentChild::RecvReinitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor, Endpoint<PImageBridgeChild>&& aImageBridge, - Endpoint<PVRManagerChild>&& aVRBridge, Endpoint<PVideoDecoderManagerChild>&& aVideoManager) { nsTArray<RefPtr<TabChild>> tabs = TabChild::GetAll(); @@ -1186,9 +1180,6 @@ ContentChild::RecvReinitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor if (!ImageBridgeChild::ReinitForContent(Move(aImageBridge))) { return false; } - if (!gfx::VRManagerChild::ReinitForContent(Move(aVRBridge))) { - return false; - } // Establish new PLayerTransactions. for (const auto& tabChild : tabs) { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index ba590b58e..f29d17e7f 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -152,15 +152,13 @@ public: RecvInitRendering( Endpoint<PCompositorBridgeChild>&& aCompositor, Endpoint<PImageBridgeChild>&& aImageBridge, - Endpoint<PVRManagerChild>&& aVRBridge, - Endpoint<PVideoDecoderManagerChild>&& aVideoManager) override; + Endpoint<PVideoDecoderManagerChild>&& aVideoManager); bool RecvReinitRendering( Endpoint<PCompositorBridgeChild>&& aCompositor, Endpoint<PImageBridgeChild>&& aImageBridge, - Endpoint<PVRManagerChild>&& aVRBridge, - Endpoint<PVideoDecoderManagerChild>&& aVideoManager) override; + Endpoint<PVideoDecoderManagerChild>&& aVideoManager); PProcessHangMonitorChild* AllocPProcessHangMonitorChild(Transport* aTransport, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 5c6aadb77..417420ecb 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2073,21 +2073,18 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, Endpoint<PCompositorBridgeChild> compositor; Endpoint<PImageBridgeChild> imageBridge; - Endpoint<PVRManagerChild> vrBridge; Endpoint<PVideoDecoderManagerChild> videoManager; DebugOnly<bool> opened = gpm->CreateContentBridges( OtherPid(), &compositor, &imageBridge, - &vrBridge, &videoManager); MOZ_ASSERT(opened); Unused << SendInitRendering( Move(compositor), Move(imageBridge), - Move(vrBridge), Move(videoManager)); gpm->AddListener(this); @@ -2201,21 +2198,18 @@ ContentParent::OnCompositorUnexpectedShutdown() Endpoint<PCompositorBridgeChild> compositor; Endpoint<PImageBridgeChild> imageBridge; - Endpoint<PVRManagerChild> vrBridge; Endpoint<PVideoDecoderManagerChild> videoManager; DebugOnly<bool> opened = gpm->CreateContentBridges( OtherPid(), &compositor, &imageBridge, - &vrBridge, &videoManager); MOZ_ASSERT(opened); Unused << SendReinitRendering( Move(compositor), Move(imageBridge), - Move(vrBridge), Move(videoManager)); } diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index c01ad59c1..9298f9d02 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -44,7 +44,6 @@ include protocol PRemoteSpellcheckEngine; include protocol PWebBrowserPersistDocument; include protocol PWebrtcGlobal; include protocol PPresentation; -include protocol PVRManager; include protocol PVideoDecoderManager; include protocol PFlyWebPublishedServer; include DOMTypes; @@ -311,7 +310,6 @@ child: async InitRendering( Endpoint<PCompositorBridgeChild> compositor, Endpoint<PImageBridgeChild> imageBridge, - Endpoint<PVRManagerChild> vr, Endpoint<PVideoDecoderManagerChild> video); // Re-create the rendering stack using the given endpoints. This is sent @@ -320,7 +318,6 @@ child: async ReinitRendering( Endpoint<PCompositorBridgeChild> compositor, Endpoint<PImageBridgeChild> bridge, - Endpoint<PVRManagerChild> vr, Endpoint<PVideoDecoderManagerChild> video); /** diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 244fa9969..3fe94001e 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -107,7 +107,6 @@ #include "nsDeviceContext.h" #include "nsSandboxFlags.h" #include "FrameLayerBuilder.h" -#include "VRManagerChild.h" #include "nsICommandParams.h" #include "nsISHistory.h" #include "nsQueryObject.h" @@ -2565,7 +2564,6 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden lf->SetShadowManager(shadowManager); lf->IdentifyTextureHost(mTextureFactoryIdentifier); ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier); - gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier); } mRemoteFrame = remoteFrame; diff --git a/dom/media/MediaPrefs.h b/dom/media/MediaPrefs.h index e67796edd..c67a89989 100644 --- a/dom/media/MediaPrefs.h +++ b/dom/media/MediaPrefs.h @@ -105,9 +105,6 @@ private: DECL_MEDIA_PREF("media.eme.enabled", EMEEnabled, bool, false); DECL_MEDIA_PREF("media.use-blank-decoder", PDMUseBlankDecoder, bool, false); DECL_MEDIA_PREF("media.gpu-process-decoder", PDMUseGPUDecoder, bool, false); -#ifdef MOZ_GONK_MEDIACODEC - DECL_MEDIA_PREF("media.gonk.enabled", PDMGonkDecoderEnabled, bool, true); -#endif #ifdef MOZ_WIDGET_ANDROID DECL_MEDIA_PREF("media.android-media-codec.enabled", PDMAndroidMediaCodecEnabled, bool, false); DECL_MEDIA_PREF("media.android-media-codec.preferred", PDMAndroidMediaCodecPreferred, bool, false); diff --git a/dom/media/directshow/DirectShowReader.h b/dom/media/directshow/DirectShowReader.h index e1326d416..881b27c28 100644 --- a/dom/media/directshow/DirectShowReader.h +++ b/dom/media/directshow/DirectShowReader.h @@ -14,7 +14,7 @@ #include "MP3FrameParser.h" // Add the graph to the Running Object Table so that we can connect -// to this graph with GraphEdit/GraphStudio. Note: on Vista and up you must +// to this graph with GraphEdit/GraphStudio. Note: you must // also regsvr32 proppage.dll from the Windows SDK. // See: http://msdn.microsoft.com/en-us/library/ms787252(VS.85).aspx // #define DIRECTSHOW_REGISTER_GRAPH diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index fdd6f2c7e..6954e9757 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -83,10 +83,6 @@ MP4Decoder::CanHandleMediaType(const MediaContentType& aType, const bool isMP4Audio = aType.GetMIMEType().EqualsASCII("audio/mp4") || aType.GetMIMEType().EqualsASCII("audio/x-m4a"); const bool isMP4Video = - // On B2G, treat 3GPP as MP4 when Gonk PDM is available. -#ifdef MOZ_GONK_MEDIACODEC - aType.GetMIMEType().EqualsASCII(VIDEO_3GPP) || -#endif aType.GetMIMEType().EqualsASCII("video/mp4") || aType.GetMIMEType().EqualsASCII("video/quicktime") || aType.GetMIMEType().EqualsASCII("video/x-m4v"); @@ -139,6 +135,14 @@ MP4Decoder::CanHandleMediaType(const MediaContentType& aType, NS_LITERAL_CSTRING("audio/flac"), aType)); continue; } +#ifdef MOZ_AV1 + if (IsAV1CodecString(codec)) { + trackInfos.AppendElement( + CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters( + NS_LITERAL_CSTRING("video/av1"), aType)); + continue; + } +#endif // Note: Only accept H.264 in a video content type, not in an audio // content type. if (IsWhitelistedH264Codec(codec) && isMP4Video) { diff --git a/dom/media/fmp4/moz.build b/dom/media/fmp4/moz.build index 6a249ae3e..a79fb0229 100644 --- a/dom/media/fmp4/moz.build +++ b/dom/media/fmp4/moz.build @@ -20,6 +20,3 @@ SOURCES += [ ] FINAL_LIBRARY = 'xul' - -if CONFIG['MOZ_GONK_MEDIACODEC']: - DEFINES['MOZ_GONK_MEDIACODEC'] = True diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index 40c3e5141..418f14736 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -516,8 +516,7 @@ GMPCapability::Supports(const nsTArray<GMPCapability>& aCapabilities, #ifdef XP_WIN // Clearkey on Windows advertises that it can decode in its GMP info // file, but uses Windows Media Foundation to decode. That's not present - // on Windows XP, and on some Vista, Windows N, and KN variants without - // certain services packs. + // on Windows N and KN variants without certain services packs. if (tag.Equals(kEMEKeySystemClearkey)) { if (capabilities.mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) { if (!WMFDecoderModule::HasH264()) { diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index af541bbbb..152c0085a 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -62,8 +62,6 @@ namespace mozilla { // Returns true if we should enable MSE webm regardless of preferences. // 1. If MP4/H264 isn't supported: -// * Windows XP -// * Windows Vista and Server 2008 without the optional "Platform Update Supplement" // * N/KN editions (Europe and Korea) of Windows 7/8/8.1/10 without the // optional "Windows Media Feature Pack" // 2. If H264 hardware acceleration is not available. diff --git a/dom/media/mediasource/moz.build b/dom/media/mediasource/moz.build index 6ded1875d..a1689c216 100644 --- a/dom/media/mediasource/moz.build +++ b/dom/media/mediasource/moz.build @@ -38,9 +38,6 @@ TEST_DIRS += [ 'gtest', ] -if CONFIG['MOZ_GONK_MEDIACODEC']: - DEFINES['MOZ_GONK_MEDIACODEC'] = True - include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index c1e58fdc2..5bfdcffb7 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -19,9 +19,6 @@ #ifdef MOZ_APPLEMEDIA #include "AppleDecoderModule.h" #endif -#ifdef MOZ_GONK_MEDIACODEC -#include "GonkDecoderModule.h" -#endif #ifdef MOZ_WIDGET_ANDROID #include "AndroidDecoderModule.h" #endif @@ -390,12 +387,6 @@ PDMFactory::CreatePDMs() m = new AppleDecoderModule(); StartupPDM(m); #endif -#ifdef MOZ_GONK_MEDIACODEC - if (MediaPrefs::PDMGonkDecoderEnabled()) { - m = new GonkDecoderModule(); - StartupPDM(m); - } -#endif #ifdef MOZ_WIDGET_ANDROID if(MediaPrefs::PDMAndroidMediaCodecEnabled()){ m = new AndroidDecoderModule(); diff --git a/dom/media/platforms/omx/OmxPlatformLayer.cpp b/dom/media/platforms/omx/OmxPlatformLayer.cpp index 039b4a22f..15b3062a4 100644 --- a/dom/media/platforms/omx/OmxPlatformLayer.cpp +++ b/dom/media/platforms/omx/OmxPlatformLayer.cpp @@ -282,26 +282,7 @@ OmxPlatformLayer::CompressionFormat() } } -// Implementations for different platforms will be defined in their own files. -#ifdef OMX_PLATFORM_GONK - -bool -OmxPlatformLayer::SupportsMimeType(const nsACString& aMimeType) -{ - return GonkOmxPlatformLayer::FindComponents(aMimeType); -} - -OmxPlatformLayer* -OmxPlatformLayer::Create(OmxDataDecoder* aDataDecoder, - OmxPromiseLayer* aPromiseLayer, - TaskQueue* aTaskQueue, - layers::ImageContainer* aImageContainer) -{ - return new GonkOmxPlatformLayer(aDataDecoder, aPromiseLayer, aTaskQueue, aImageContainer); -} - -#else // For platforms without OMX IL support. - +// For platforms without OMX IL support. bool OmxPlatformLayer::SupportsMimeType(const nsACString& aMimeType) { @@ -317,6 +298,4 @@ OmxPlatformLayer::Create(OmxDataDecoder* aDataDecoder, return nullptr; } -#endif - } diff --git a/dom/media/platforms/wmf/WMFDecoderModule.h b/dom/media/platforms/wmf/WMFDecoderModule.h index cd7b8c660..6582f8056 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.h +++ b/dom/media/platforms/wmf/WMFDecoderModule.h @@ -40,10 +40,8 @@ public: static int GetNumDecoderThreads(); // Accessors that report whether we have the required MFTs available - // on the system to play various codecs. Windows Vista doesn't have the - // H.264/AAC decoders if the "Platform Update Supplement for Windows Vista" - // is not installed, and Window N and KN variants also require a "Media - // Feature Pack" to be installed. Windows XP doesn't have WMF. + // on the system to play various codecs. Windows N and KN variants + // require a "Media Feature Pack" to be installed. static bool HasAAC(); static bool HasH264(); diff --git a/dom/moz.build b/dom/moz.build index 358fc6411..54dc0510e 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -94,7 +94,6 @@ DIRS += [ 'xslt', 'xul', 'manifest', - 'vr', 'u2f', 'console', 'performance', diff --git a/dom/vr/VRDisplay.cpp b/dom/vr/VRDisplay.cpp deleted file mode 100644 index 80922422f..000000000 --- a/dom/vr/VRDisplay.cpp +++ /dev/null @@ -1,802 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#include "nsWrapperCache.h" - -#include "mozilla/dom/Element.h" -#include "mozilla/dom/ElementBinding.h" -#include "mozilla/dom/Promise.h" -#include "mozilla/dom/VRDisplay.h" -#include "mozilla/HoldDropJSObjects.h" -#include "mozilla/dom/VRDisplayBinding.h" -#include "Navigator.h" -#include "gfxVR.h" -#include "VRDisplayClient.h" -#include "VRManagerChild.h" -#include "VRDisplayPresentation.h" -#include "nsIObserverService.h" -#include "nsIFrame.h" -#include "nsISupportsPrimitives.h" - -using namespace mozilla::gfx; - -namespace mozilla { -namespace dom { - -VRFieldOfView::VRFieldOfView(nsISupports* aParent, - double aUpDegrees, double aRightDegrees, - double aDownDegrees, double aLeftDegrees) - : mParent(aParent) - , mUpDegrees(aUpDegrees) - , mRightDegrees(aRightDegrees) - , mDownDegrees(aDownDegrees) - , mLeftDegrees(aLeftDegrees) -{ -} - -VRFieldOfView::VRFieldOfView(nsISupports* aParent, const gfx::VRFieldOfView& aSrc) - : mParent(aParent) - , mUpDegrees(aSrc.upDegrees) - , mRightDegrees(aSrc.rightDegrees) - , mDownDegrees(aSrc.downDegrees) - , mLeftDegrees(aSrc.leftDegrees) -{ -} - -bool -VRDisplayCapabilities::HasPosition() const -{ - return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Position); -} - -bool -VRDisplayCapabilities::HasOrientation() const -{ - return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Orientation); -} - -bool -VRDisplayCapabilities::HasExternalDisplay() const -{ - return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_External); -} - -bool -VRDisplayCapabilities::CanPresent() const -{ - return bool(mFlags & gfx::VRDisplayCapabilityFlags::Cap_Present); -} - -uint32_t -VRDisplayCapabilities::MaxLayers() const -{ - return CanPresent() ? 1 : 0; -} - -/*static*/ bool -VRDisplay::RefreshVRDisplays(uint64_t aWindowId) -{ - gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); - return vm && vm->RefreshVRDisplaysWithCallback(aWindowId); -} - -/*static*/ void -VRDisplay::UpdateVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays, nsPIDOMWindowInner* aWindow) -{ - nsTArray<RefPtr<VRDisplay>> displays; - - gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); - nsTArray<RefPtr<gfx::VRDisplayClient>> updatedDisplays; - if (vm && vm->GetVRDisplays(updatedDisplays)) { - for (size_t i = 0; i < updatedDisplays.Length(); i++) { - RefPtr<gfx::VRDisplayClient> display = updatedDisplays[i]; - bool isNewDisplay = true; - for (size_t j = 0; j < aDisplays.Length(); j++) { - if (aDisplays[j]->GetClient()->GetDisplayInfo() == display->GetDisplayInfo()) { - displays.AppendElement(aDisplays[j]); - isNewDisplay = false; - } - } - - if (isNewDisplay) { - displays.AppendElement(new VRDisplay(aWindow, display)); - } - } - } - - aDisplays = displays; -} - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRFieldOfView, mParent) -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRFieldOfView, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRFieldOfView, Release) - - -JSObject* -VRFieldOfView::WrapObject(JSContext* aCx, - JS::Handle<JSObject*> aGivenProto) -{ - return VRFieldOfViewBinding::Wrap(aCx, this, aGivenProto); -} - -NS_IMPL_CYCLE_COLLECTION_CLASS(VREyeParameters) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VREyeParameters) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent, mFOV) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER - tmp->mOffset = nullptr; -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VREyeParameters) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent, mFOV) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VREyeParameters) - NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOffset) -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VREyeParameters, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VREyeParameters, Release) - -VREyeParameters::VREyeParameters(nsISupports* aParent, - const gfx::Point3D& aEyeTranslation, - const gfx::VRFieldOfView& aFOV, - const gfx::IntSize& aRenderSize) - : mParent(aParent) - , mEyeTranslation(aEyeTranslation) - , mRenderSize(aRenderSize) -{ - mFOV = new VRFieldOfView(aParent, aFOV); - mozilla::HoldJSObjects(this); -} - -VREyeParameters::~VREyeParameters() -{ - mozilla::DropJSObjects(this); -} - -VRFieldOfView* -VREyeParameters::FieldOfView() -{ - return mFOV; -} - -void -VREyeParameters::GetOffset(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv) -{ - if (!mOffset) { - // Lazily create the Float32Array - mOffset = dom::Float32Array::Create(aCx, this, 3, mEyeTranslation.components); - if (!mOffset) { - aRv.NoteJSContextException(aCx); - return; - } - } - aRetval.set(mOffset); -} - -JSObject* -VREyeParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return VREyeParametersBinding::Wrap(aCx, this, aGivenProto); -} - -VRStageParameters::VRStageParameters(nsISupports* aParent, - const gfx::Matrix4x4& aSittingToStandingTransform, - const gfx::Size& aSize) - : mParent(aParent) - , mSittingToStandingTransform(aSittingToStandingTransform) - , mSittingToStandingTransformArray(nullptr) - , mSize(aSize) -{ - mozilla::HoldJSObjects(this); -} - -VRStageParameters::~VRStageParameters() -{ - mozilla::DropJSObjects(this); -} - -JSObject* -VRStageParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return VRStageParametersBinding::Wrap(aCx, this, aGivenProto); -} - -NS_IMPL_CYCLE_COLLECTION_CLASS(VRStageParameters) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VRStageParameters) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER - tmp->mSittingToStandingTransformArray = nullptr; -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VRStageParameters) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VRStageParameters) - NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mSittingToStandingTransformArray) -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRStageParameters, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRStageParameters, Release) - -void -VRStageParameters::GetSittingToStandingTransform(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - if (!mSittingToStandingTransformArray) { - // Lazily create the Float32Array - mSittingToStandingTransformArray = dom::Float32Array::Create(aCx, this, 16, - mSittingToStandingTransform.components); - if (!mSittingToStandingTransformArray) { - aRv.NoteJSContextException(aCx); - return; - } - } - aRetval.set(mSittingToStandingTransformArray); -} - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRDisplayCapabilities, mParent) -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRDisplayCapabilities, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRDisplayCapabilities, Release) - -JSObject* -VRDisplayCapabilities::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return VRDisplayCapabilitiesBinding::Wrap(aCx, this, aGivenProto); -} - -VRPose::VRPose(nsISupports* aParent, const gfx::VRHMDSensorState& aState) - : Pose(aParent) - , mVRState(aState) -{ - mFrameId = aState.inputFrameID; - mozilla::HoldJSObjects(this); -} - -VRPose::VRPose(nsISupports* aParent) - : Pose(aParent) -{ - mFrameId = 0; - mVRState.Clear(); - mozilla::HoldJSObjects(this); -} - -VRPose::~VRPose() -{ - mozilla::DropJSObjects(this); -} - -void -VRPose::GetPosition(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mPosition, mVRState.position, 3, - !mPosition && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position), - aRv); -} - -void -VRPose::GetLinearVelocity(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mLinearVelocity, mVRState.linearVelocity, 3, - !mLinearVelocity && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position), - aRv); -} - -void -VRPose::GetLinearAcceleration(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mLinearAcceleration, mVRState.linearAcceleration, 3, - !mLinearAcceleration && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_LinearAcceleration), - aRv); - -} - -void -VRPose::GetOrientation(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mOrientation, mVRState.orientation, 4, - !mOrientation && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation), - aRv); -} - -void -VRPose::GetAngularVelocity(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mAngularVelocity, mVRState.angularVelocity, 3, - !mAngularVelocity && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation), - aRv); -} - -void -VRPose::GetAngularAcceleration(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - SetFloat32Array(aCx, aRetval, mAngularAcceleration, mVRState.angularAcceleration, 3, - !mAngularAcceleration && bool(mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_AngularAcceleration), - aRv); -} - -JSObject* -VRPose::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return VRPoseBinding::Wrap(aCx, this, aGivenProto); -} - -/* virtual */ JSObject* -VRDisplay::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return VRDisplayBinding::Wrap(aCx, this, aGivenProto); -} - -VRDisplay::VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient) - : DOMEventTargetHelper(aWindow) - , mClient(aClient) - , mDepthNear(0.01f) // Default value from WebVR Spec - , mDepthFar(10000.0f) // Default value from WebVR Spec -{ - const gfx::VRDisplayInfo& info = aClient->GetDisplayInfo(); - mDisplayId = info.GetDisplayID(); - mDisplayName = NS_ConvertASCIItoUTF16(info.GetDisplayName()); - mCapabilities = new VRDisplayCapabilities(aWindow, info.GetCapabilities()); - if (info.GetCapabilities() & gfx::VRDisplayCapabilityFlags::Cap_StageParameters) { - mStageParameters = new VRStageParameters(aWindow, - info.GetSittingToStandingTransform(), - info.GetStageSize()); - } - mozilla::HoldJSObjects(this); -} - -VRDisplay::~VRDisplay() -{ - ExitPresentInternal(); - mozilla::DropJSObjects(this); -} - -void -VRDisplay::LastRelease() -{ - // We don't want to wait for the CC to free up the presentation - // for use in other documents, so we do this in LastRelease(). - ExitPresentInternal(); -} - -already_AddRefed<VREyeParameters> -VRDisplay::GetEyeParameters(VREye aEye) -{ - gfx::VRDisplayInfo::Eye eye = aEye == VREye::Left ? gfx::VRDisplayInfo::Eye_Left : gfx::VRDisplayInfo::Eye_Right; - RefPtr<VREyeParameters> params = - new VREyeParameters(GetParentObject(), - mClient->GetDisplayInfo().GetEyeTranslation(eye), - mClient->GetDisplayInfo().GetEyeFOV(eye), - mClient->GetDisplayInfo().SuggestedEyeResolution()); - return params.forget(); -} - -VRDisplayCapabilities* -VRDisplay::Capabilities() -{ - return mCapabilities; -} - -VRStageParameters* -VRDisplay::GetStageParameters() -{ - return mStageParameters; -} - -void -VRDisplay::UpdateFrameInfo() -{ - /** - * The WebVR 1.1 spec Requires that VRDisplay.getPose and VRDisplay.getFrameData - * must return the same values until the next VRDisplay.submitFrame. - * - * mFrameInfo is marked dirty at the end of the frame or start of a new - * composition and lazily created here in order to receive mid-frame - * pose-prediction updates while still ensuring conformance to the WebVR spec - * requirements. - * - * If we are not presenting WebVR content, the frame will never end and we should - * return the latest frame data always. - */ - if (mFrameInfo.IsDirty() || !mPresentation) { - gfx::VRHMDSensorState state = mClient->GetSensorState(); - const gfx::VRDisplayInfo& info = mClient->GetDisplayInfo(); - mFrameInfo.Update(info, state, mDepthNear, mDepthFar); - } -} - -bool -VRDisplay::GetFrameData(VRFrameData& aFrameData) -{ - UpdateFrameInfo(); - aFrameData.Update(mFrameInfo); - return true; -} - -already_AddRefed<VRPose> -VRDisplay::GetPose() -{ - UpdateFrameInfo(); - RefPtr<VRPose> obj = new VRPose(GetParentObject(), mFrameInfo.mVRState); - - return obj.forget(); -} - -void -VRDisplay::ResetPose() -{ - mClient->ZeroSensor(); -} - -already_AddRefed<Promise> -VRDisplay::RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv) -{ - nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject()); - if (!global) { - aRv.Throw(NS_ERROR_FAILURE); - return nullptr; - } - - RefPtr<Promise> promise = Promise::Create(global, aRv); - NS_ENSURE_TRUE(!aRv.Failed(), nullptr); - - nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); - NS_ENSURE_TRUE(obs, nullptr); - - if (mClient->GetIsPresenting()) { - // Only one presentation allowed per VRDisplay - // on a first-come-first-serve basis. - promise->MaybeRejectWithUndefined(); - } else { - mPresentation = mClient->BeginPresentation(aLayers); - mFrameInfo.Clear(); - - nsresult rv = obs->AddObserver(this, "inner-window-destroyed", false); - if (NS_WARN_IF(NS_FAILED(rv))) { - mPresentation = nullptr; - promise->MaybeRejectWithUndefined(); - } else { - promise->MaybeResolve(JS::UndefinedHandleValue); - } - } - return promise.forget(); -} - -NS_IMETHODIMP -VRDisplay::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (strcmp(aTopic, "inner-window-destroyed") == 0) { - nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(aSubject); - NS_ENSURE_TRUE(wrapper, NS_ERROR_FAILURE); - - uint64_t innerID; - nsresult rv = wrapper->GetData(&innerID); - NS_ENSURE_SUCCESS(rv, rv); - - if (!GetOwner() || GetOwner()->WindowID() == innerID) { - ExitPresentInternal(); - } - - return NS_OK; - } - - // This should not happen. - return NS_ERROR_FAILURE; -} - -already_AddRefed<Promise> -VRDisplay::ExitPresent(ErrorResult& aRv) -{ - nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject()); - if (!global) { - aRv.Throw(NS_ERROR_FAILURE); - return nullptr; - } - - - RefPtr<Promise> promise = Promise::Create(global, aRv); - NS_ENSURE_TRUE(!aRv.Failed(), nullptr); - - if (!IsPresenting()) { - // We can not exit a presentation outside of the context that - // started the presentation. - promise->MaybeRejectWithUndefined(); - } else { - promise->MaybeResolve(JS::UndefinedHandleValue); - ExitPresentInternal(); - } - - return promise.forget(); -} - -void -VRDisplay::ExitPresentInternal() -{ - mPresentation = nullptr; -} - -void -VRDisplay::GetLayers(nsTArray<VRLayer>& result) -{ - if (mPresentation) { - mPresentation->GetDOMLayers(result); - } else { - result = nsTArray<VRLayer>(); - } -} - -void -VRDisplay::SubmitFrame() -{ - if (mPresentation) { - mPresentation->SubmitFrame(); - } - mFrameInfo.Clear(); -} - -int32_t -VRDisplay::RequestAnimationFrame(FrameRequestCallback& aCallback, -ErrorResult& aError) -{ - gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); - - int32_t handle; - aError = vm->ScheduleFrameRequestCallback(aCallback, &handle); - return handle; -} - -void -VRDisplay::CancelAnimationFrame(int32_t aHandle, ErrorResult& aError) -{ - gfx::VRManagerChild* vm = gfx::VRManagerChild::Get(); - vm->CancelFrameRequestCallback(aHandle); -} - - -bool -VRDisplay::IsPresenting() const -{ - // IsPresenting returns true only if this Javascript context is presenting - // and will return false if another context is presenting. - return mPresentation != nullptr; -} - -bool -VRDisplay::IsConnected() const -{ - return mClient->GetIsConnected(); -} - -NS_IMPL_CYCLE_COLLECTION_INHERITED(VRDisplay, DOMEventTargetHelper, mCapabilities, mStageParameters) - -NS_IMPL_ADDREF_INHERITED(VRDisplay, DOMEventTargetHelper) -NS_IMPL_RELEASE_INHERITED(VRDisplay, DOMEventTargetHelper) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VRDisplay) -NS_INTERFACE_MAP_ENTRY(nsIObserver) -NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, DOMEventTargetHelper) -NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) - -NS_IMPL_CYCLE_COLLECTION_CLASS(VRFrameData) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(VRFrameData) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent, mPose) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER - tmp->mLeftProjectionMatrix = nullptr; - tmp->mLeftViewMatrix = nullptr; - tmp->mRightProjectionMatrix = nullptr; - tmp->mRightViewMatrix = nullptr; -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(VRFrameData) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent, mPose) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(VRFrameData) - NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLeftProjectionMatrix) - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLeftViewMatrix) - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mRightProjectionMatrix) - NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mRightViewMatrix) -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRFrameData, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRFrameData, Release) - -VRFrameData::VRFrameData(nsISupports* aParent) - : mParent(aParent) - , mLeftProjectionMatrix(nullptr) - , mLeftViewMatrix(nullptr) - , mRightProjectionMatrix(nullptr) - , mRightViewMatrix(nullptr) -{ - mozilla::HoldJSObjects(this); - mPose = new VRPose(aParent); -} - -VRFrameData::~VRFrameData() -{ - mozilla::DropJSObjects(this); -} - -/* static */ already_AddRefed<VRFrameData> -VRFrameData::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) -{ - RefPtr<VRFrameData> obj = new VRFrameData(aGlobal.GetAsSupports()); - return obj.forget(); -} - -JSObject* -VRFrameData::WrapObject(JSContext* aCx, - JS::Handle<JSObject*> aGivenProto) -{ - return VRFrameDataBinding::Wrap(aCx, this, aGivenProto); -} - -VRPose* -VRFrameData::Pose() -{ - return mPose; -} - -void -VRFrameData::LazyCreateMatrix(JS::Heap<JSObject*>& aArray, gfx::Matrix4x4& aMat, JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv) -{ - if (!aArray) { - // Lazily create the Float32Array - aArray = dom::Float32Array::Create(aCx, this, 16, aMat.components); - if (!aArray) { - aRv.NoteJSContextException(aCx); - return; - } - } - if (aArray) { - JS::ExposeObjectToActiveJS(aArray); - } - aRetval.set(aArray); -} - -double -VRFrameData::Timestamp() const -{ - // Converting from seconds to milliseconds - return mFrameInfo.mVRState.timestamp * 1000.0f; -} - -void -VRFrameData::GetLeftProjectionMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - LazyCreateMatrix(mLeftProjectionMatrix, mFrameInfo.mLeftProjection, aCx, - aRetval, aRv); -} - -void -VRFrameData::GetLeftViewMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - LazyCreateMatrix(mLeftViewMatrix, mFrameInfo.mLeftView, aCx, aRetval, aRv); -} - -void -VRFrameData::GetRightProjectionMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - LazyCreateMatrix(mRightProjectionMatrix, mFrameInfo.mRightProjection, aCx, - aRetval, aRv); -} - -void -VRFrameData::GetRightViewMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) -{ - LazyCreateMatrix(mRightViewMatrix, mFrameInfo.mRightView, aCx, aRetval, aRv); -} - -void -VRFrameData::Update(const VRFrameInfo& aFrameInfo) -{ - mFrameInfo = aFrameInfo; - - mLeftProjectionMatrix = nullptr; - mLeftViewMatrix = nullptr; - mRightProjectionMatrix = nullptr; - mRightViewMatrix = nullptr; - - mPose = new VRPose(GetParentObject(), mFrameInfo.mVRState); -} - -void -VRFrameInfo::Update(const gfx::VRDisplayInfo& aInfo, - const gfx::VRHMDSensorState& aState, - float aDepthNear, - float aDepthFar) -{ - mVRState = aState; - - gfx::Quaternion qt; - if (mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Orientation) { - qt.x = mVRState.orientation[0]; - qt.y = mVRState.orientation[1]; - qt.z = mVRState.orientation[2]; - qt.w = mVRState.orientation[3]; - } - gfx::Point3D pos; - if (mVRState.flags & gfx::VRDisplayCapabilityFlags::Cap_Position) { - pos.x = -mVRState.position[0]; - pos.y = -mVRState.position[1]; - pos.z = -mVRState.position[2]; - } - gfx::Matrix4x4 matHead; - matHead.SetRotationFromQuaternion(qt); - matHead.PreTranslate(pos); - - mLeftView = matHead; - mLeftView.PostTranslate(-aInfo.mEyeTranslation[gfx::VRDisplayInfo::Eye_Left]); - - mRightView = matHead; - mRightView.PostTranslate(-aInfo.mEyeTranslation[gfx::VRDisplayInfo::Eye_Right]); - - // Avoid division by zero within ConstructProjectionMatrix - const float kEpsilon = 0.00001f; - if (fabs(aDepthFar - aDepthNear) < kEpsilon) { - aDepthFar = aDepthNear + kEpsilon; - } - - const gfx::VRFieldOfView leftFOV = aInfo.mEyeFOV[gfx::VRDisplayInfo::Eye_Left]; - mLeftProjection = leftFOV.ConstructProjectionMatrix(aDepthNear, aDepthFar, true); - const gfx::VRFieldOfView rightFOV = aInfo.mEyeFOV[gfx::VRDisplayInfo::Eye_Right]; - mRightProjection = rightFOV.ConstructProjectionMatrix(aDepthNear, aDepthFar, true); -} - -VRFrameInfo::VRFrameInfo() -{ - mVRState.Clear(); -} - -bool -VRFrameInfo::IsDirty() -{ - return mVRState.timestamp == 0; -} - -void -VRFrameInfo::Clear() -{ - mVRState.Clear(); -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/vr/VRDisplay.h b/dom/vr/VRDisplay.h deleted file mode 100644 index d40d3d8ac..000000000 --- a/dom/vr/VRDisplay.h +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#ifndef mozilla_dom_VRDisplay_h_ -#define mozilla_dom_VRDisplay_h_ - -#include <stdint.h> - -#include "mozilla/ErrorResult.h" -#include "mozilla/dom/TypedArray.h" -#include "mozilla/dom/VRDisplayBinding.h" -#include "mozilla/DOMEventTargetHelper.h" -#include "mozilla/dom/DOMPoint.h" -#include "mozilla/dom/DOMRect.h" -#include "mozilla/dom/Pose.h" - -#include "nsCOMPtr.h" -#include "nsString.h" -#include "nsTArray.h" - -#include "gfxVR.h" - -namespace mozilla { -namespace gfx { -class VRDisplayClient; -class VRDisplayPresentation; -struct VRFieldOfView; -enum class VRDisplayCapabilityFlags : uint16_t; -struct VRHMDSensorState; -} -namespace dom { -class Navigator; - -class VRFieldOfView final : public nsWrapperCache -{ -public: - VRFieldOfView(nsISupports* aParent, - double aUpDegrees, double aRightDegrees, - double aDownDegrees, double aLeftDegrees); - VRFieldOfView(nsISupports* aParent, const gfx::VRFieldOfView& aSrc); - - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFieldOfView) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFieldOfView) - - double UpDegrees() const { return mUpDegrees; } - double RightDegrees() const { return mRightDegrees; } - double DownDegrees() const { return mDownDegrees; } - double LeftDegrees() const { return mLeftDegrees; } - - nsISupports* GetParentObject() const { return mParent; } - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - -protected: - virtual ~VRFieldOfView() {} - - nsCOMPtr<nsISupports> mParent; - - double mUpDegrees; - double mRightDegrees; - double mDownDegrees; - double mLeftDegrees; -}; - -class VRDisplayCapabilities final : public nsWrapperCache -{ -public: - VRDisplayCapabilities(nsISupports* aParent, const gfx::VRDisplayCapabilityFlags& aFlags) - : mParent(aParent) - , mFlags(aFlags) - { - } - - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRDisplayCapabilities) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRDisplayCapabilities) - - nsISupports* GetParentObject() const - { - return mParent; - } - - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - - bool HasPosition() const; - bool HasOrientation() const; - bool HasExternalDisplay() const; - bool CanPresent() const; - uint32_t MaxLayers() const; - -protected: - ~VRDisplayCapabilities() {} - nsCOMPtr<nsISupports> mParent; - gfx::VRDisplayCapabilityFlags mFlags; -}; - -class VRPose final : public Pose -{ - -public: - VRPose(nsISupports* aParent, const gfx::VRHMDSensorState& aState); - explicit VRPose(nsISupports* aParent); - - uint32_t FrameID() const { return mFrameId; } - - virtual void GetPosition(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - virtual void GetLinearVelocity(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - virtual void GetLinearAcceleration(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - virtual void GetOrientation(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - virtual void GetAngularVelocity(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - virtual void GetAngularAcceleration(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv) override; - - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - -protected: - ~VRPose(); - - uint32_t mFrameId; - gfx::VRHMDSensorState mVRState; -}; - -struct VRFrameInfo -{ - VRFrameInfo(); - - void Update(const gfx::VRDisplayInfo& aInfo, - const gfx::VRHMDSensorState& aState, - float aDepthNear, - float aDepthFar); - - void Clear(); - bool IsDirty(); - - gfx::VRHMDSensorState mVRState; - gfx::Matrix4x4 mLeftProjection; - gfx::Matrix4x4 mLeftView; - gfx::Matrix4x4 mRightProjection; - gfx::Matrix4x4 mRightView; - -}; - -class VRFrameData final : public nsWrapperCache -{ -public: - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFrameData) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFrameData) - - explicit VRFrameData(nsISupports* aParent); - static already_AddRefed<VRFrameData> Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv); - - void Update(const VRFrameInfo& aFrameInfo); - - // WebIDL Members - double Timestamp() const; - void GetLeftProjectionMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); - void GetLeftViewMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); - void GetRightProjectionMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); - void GetRightViewMatrix(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); - - VRPose* Pose(); - - // WebIDL Boilerplate - nsISupports* GetParentObject() const { return mParent; } - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - -protected: - ~VRFrameData(); - nsCOMPtr<nsISupports> mParent; - - VRFrameInfo mFrameInfo; - RefPtr<VRPose> mPose; - JS::Heap<JSObject*> mLeftProjectionMatrix; - JS::Heap<JSObject*> mLeftViewMatrix; - JS::Heap<JSObject*> mRightProjectionMatrix; - JS::Heap<JSObject*> mRightViewMatrix; - - void LazyCreateMatrix(JS::Heap<JSObject*>& aArray, gfx::Matrix4x4& aMat, - JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); -}; - -class VRStageParameters final : public nsWrapperCache -{ -public: - VRStageParameters(nsISupports* aParent, - const gfx::Matrix4x4& aSittingToStandingTransform, - const gfx::Size& aSize); - - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRStageParameters) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRStageParameters) - - void GetSittingToStandingTransform(JSContext* aCx, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& aRv); - float SizeX() const { return mSize.width; } - float SizeZ() const { return mSize.height; } - - nsISupports* GetParentObject() const { return mParent; } - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - -protected: - ~VRStageParameters(); - - nsCOMPtr<nsISupports> mParent; - - gfx::Matrix4x4 mSittingToStandingTransform; - JS::Heap<JSObject*> mSittingToStandingTransformArray; - gfx::Size mSize; -}; - -class VREyeParameters final : public nsWrapperCache -{ -public: - VREyeParameters(nsISupports* aParent, - const gfx::Point3D& aEyeTranslation, - const gfx::VRFieldOfView& aFOV, - const gfx::IntSize& aRenderSize); - - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VREyeParameters) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VREyeParameters) - - void GetOffset(JSContext* aCx, JS::MutableHandle<JSObject*> aRetVal, - ErrorResult& aRv); - - VRFieldOfView* FieldOfView(); - - uint32_t RenderWidth() const { return mRenderSize.width; } - uint32_t RenderHeight() const { return mRenderSize.height; } - - nsISupports* GetParentObject() const { return mParent; } - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; -protected: - ~VREyeParameters(); - - nsCOMPtr<nsISupports> mParent; - - - gfx::Point3D mEyeTranslation; - gfx::IntSize mRenderSize; - JS::Heap<JSObject*> mOffset; - RefPtr<VRFieldOfView> mFOV; -}; - -class VRDisplay final : public DOMEventTargetHelper - , public nsIObserver -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIOBSERVER - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRDisplay, DOMEventTargetHelper) - - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - - bool IsPresenting() const; - bool IsConnected() const; - - VRDisplayCapabilities* Capabilities(); - VRStageParameters* GetStageParameters(); - - uint32_t DisplayId() const { return mDisplayId; } - void GetDisplayName(nsAString& aDisplayName) const { aDisplayName = mDisplayName; } - - static bool RefreshVRDisplays(uint64_t aWindowId); - static void UpdateVRDisplays(nsTArray<RefPtr<VRDisplay> >& aDisplays, - nsPIDOMWindowInner* aWindow); - - gfx::VRDisplayClient *GetClient() { - return mClient; - } - - virtual already_AddRefed<VREyeParameters> GetEyeParameters(VREye aEye); - - bool GetFrameData(VRFrameData& aFrameData); - already_AddRefed<VRPose> GetPose(); - void ResetPose(); - - double DepthNear() { - return mDepthNear; - } - - double DepthFar() { - return mDepthFar; - } - - void SetDepthNear(double aDepthNear) { - // XXX When we start sending depth buffers to VRLayer's we will want - // to communicate this with the VRDisplayHost - mDepthNear = aDepthNear; - } - - void SetDepthFar(double aDepthFar) { - // XXX When we start sending depth buffers to VRLayer's we will want - // to communicate this with the VRDisplayHost - mDepthFar = aDepthFar; - } - - already_AddRefed<Promise> RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv); - already_AddRefed<Promise> ExitPresent(ErrorResult& aRv); - void GetLayers(nsTArray<VRLayer>& result); - void SubmitFrame(); - - int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback, - mozilla::ErrorResult& aError); - void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError); - -protected: - VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient); - virtual ~VRDisplay(); - virtual void LastRelease() override; - - void ExitPresentInternal(); - void UpdateFrameInfo(); - - RefPtr<gfx::VRDisplayClient> mClient; - - uint32_t mDisplayId; - nsString mDisplayName; - - RefPtr<VRDisplayCapabilities> mCapabilities; - RefPtr<VRStageParameters> mStageParameters; - - double mDepthNear; - double mDepthFar; - - RefPtr<gfx::VRDisplayPresentation> mPresentation; - - /** - * The WebVR 1.1 spec Requires that VRDisplay.getPose and VRDisplay.getFrameData - * must return the same values until the next VRDisplay.submitFrame. - * mFrameInfo is updated only on the first call to either function within one - * frame. Subsequent calls before the next SubmitFrame or ExitPresent call - * will use these cached values. - */ - VRFrameInfo mFrameInfo; -}; - -} // namespace dom -} // namespace mozilla - -#endif diff --git a/dom/vr/VREventObserver.cpp b/dom/vr/VREventObserver.cpp deleted file mode 100644 index 1b6d1b978..000000000 --- a/dom/vr/VREventObserver.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#include "VREventObserver.h" - -#include "nsContentUtils.h" -#include "nsGlobalWindow.h" -#include "VRManagerChild.h" - -namespace mozilla { -namespace dom { - -using namespace gfx; - -/** - * This class is used by nsGlobalWindow to implement window.onvrdisplayconnected, - * window.onvrdisplaydisconnected, and window.onvrdisplaypresentchange. - */ -VREventObserver::VREventObserver(nsGlobalWindow* aGlobalWindow) - : mWindow(aGlobalWindow) -{ - MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow()); - - VRManagerChild* vmc = VRManagerChild::Get(); - if (vmc) { - vmc->AddListener(this); - } -} - -VREventObserver::~VREventObserver() -{ - VRManagerChild* vmc = VRManagerChild::Get(); - if (vmc) { - vmc->RemoveListener(this); - } -} - -void -VREventObserver::NotifyVRDisplayConnect() -{ - /** - * We do not call nsGlobalWindow::NotifyActiveVRDisplaysChanged here, as we - * can assume that a newly enumerated display is not presenting WebVR - * content. - */ - if (mWindow->AsInner()->IsCurrentInnerWindow()) { - MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - mWindow->GetOuterWindow()->DispatchCustomEvent( - NS_LITERAL_STRING("vrdisplayconnected")); - } -} - -void -VREventObserver::NotifyVRDisplayDisconnect() -{ - if (mWindow->AsInner()->IsCurrentInnerWindow()) { - mWindow->NotifyActiveVRDisplaysChanged(); - MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - mWindow->GetOuterWindow()->DispatchCustomEvent( - NS_LITERAL_STRING("vrdisplaydisconnected")); - } -} - -void -VREventObserver::NotifyVRDisplayPresentChange() -{ - if (mWindow->AsInner()->IsCurrentInnerWindow()) { - mWindow->NotifyActiveVRDisplaysChanged(); - MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - mWindow->GetOuterWindow()->DispatchCustomEvent( - NS_LITERAL_STRING("vrdisplaypresentchange")); - } -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/vr/VREventObserver.h b/dom/vr/VREventObserver.h deleted file mode 100644 index a30bb5960..000000000 --- a/dom/vr/VREventObserver.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#ifndef mozilla_dom_VREventObserver_h -#define mozilla_dom_VREventObserver_h - -class nsGlobalWindow; - -namespace mozilla { -namespace dom { - -class VREventObserver final -{ -public: - ~VREventObserver(); - explicit VREventObserver(nsGlobalWindow* aGlobalWindow); - - void NotifyVRDisplayConnect(); - void NotifyVRDisplayDisconnect(); - void NotifyVRDisplayPresentChange(); - -private: - // Weak pointer, instance is owned by mWindow. - nsGlobalWindow* MOZ_NON_OWNING_REF mWindow; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_VREventObserver_h diff --git a/dom/vr/moz.build b/dom/vr/moz.build deleted file mode 100644 index a4aa8d69b..000000000 --- a/dom/vr/moz.build +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -EXPORTS.mozilla.dom += [ - 'VRDisplay.h', - 'VREventObserver.h', - ] - -UNIFIED_SOURCES = [ - 'VRDisplay.cpp', - 'VREventObserver.cpp', - ] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' -LOCAL_INCLUDES += [ - '/dom/base' -] diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 5452f3247..c353e8be7 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -268,14 +268,6 @@ partial interface Navigator { }; #endif // MOZ_GAMEPAD -partial interface Navigator { - [Throws, Pref="dom.vr.enabled"] - Promise<sequence<VRDisplay>> getVRDisplays(); - // TODO: Use FrozenArray once available. (Bug 1236777) - [Frozen, Cached, Pure, Pref="dom.vr.enabled"] - readonly attribute sequence<VRDisplay> activeVRDisplays; -}; - #ifdef MOZ_TIME_MANAGER // nsIDOMMozNavigatorTime partial interface Navigator { diff --git a/dom/webidl/VRDisplay.webidl b/dom/webidl/VRDisplay.webidl deleted file mode 100644 index 63ebd1205..000000000 --- a/dom/webidl/VRDisplay.webidl +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -enum VREye { - "left", - "right" -}; - -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRFieldOfView { - readonly attribute double upDegrees; - readonly attribute double rightDegrees; - readonly attribute double downDegrees; - readonly attribute double leftDegrees; -}; - -typedef (HTMLCanvasElement or OffscreenCanvas) VRSource; - -dictionary VRLayer { - /** - * XXX - When WebVR in WebWorkers is implemented, HTMLCanvasElement below - * should be replaced with VRSource. - */ - HTMLCanvasElement? source = null; - - /** - * The left and right viewports contain 4 values defining the viewport - * rectangles within the canvas to present to the eye in UV space. - * [0] left offset of the viewport (0.0 - 1.0) - * [1] top offset of the viewport (0.0 - 1.0) - * [2] width of the viewport (0.0 - 1.0) - * [3] height of the viewport (0.0 - 1.0) - * - * When no values are passed, they will be processed as though the left - * and right sides of the viewport were passed: - * - * leftBounds: [0.0, 0.0, 0.5, 1.0] - * rightBounds: [0.5, 0.0, 0.5, 1.0] - */ - sequence<float> leftBounds = []; - sequence<float> rightBounds = []; -}; - -/** - * Values describing the capabilities of a VRDisplay. - * These are expected to be static per-device/per-user. - */ -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRDisplayCapabilities { - /** - * hasPosition is true if the VRDisplay is capable of tracking its position. - */ - readonly attribute boolean hasPosition; - - /** - * hasOrientation is true if the VRDisplay is capable of tracking its orientation. - */ - readonly attribute boolean hasOrientation; - - /** - * Whether the VRDisplay is separate from the device’s - * primary display. If presenting VR content will obscure - * other content on the device, this should be false. When - * false, the application should not attempt to mirror VR content - * or update non-VR UI because that content will not be visible. - */ - readonly attribute boolean hasExternalDisplay; - - /** - * Whether the VRDisplay is capable of presenting content to an HMD or similar device. - * Can be used to indicate “magic window” devices that are capable of 6DoF tracking but for - * which requestPresent is not meaningful. If false then calls to requestPresent should - * always fail, and getEyeParameters should return null. - */ - readonly attribute boolean canPresent; - - /** - * Indicates the maximum length of the array that requestPresent() will accept. MUST be 1 if - canPresent is true, 0 otherwise. - */ - readonly attribute unsigned long maxLayers; -}; - -/** - * Values describing the the stage / play area for devices - * that support room-scale experiences. - */ -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRStageParameters { - /** - * A 16-element array containing the components of a column-major 4x4 - * affine transform matrix. This matrix transforms the sitting-space position - * returned by get{Immediate}Pose() to a standing-space position. - */ - [Throws] readonly attribute Float32Array sittingToStandingTransform; - - /** - * Dimensions of the play-area bounds. The bounds are defined - * as an axis-aligned rectangle on the floor. - * The center of the rectangle is at (0,0,0) in standing-space - * coordinates. - * These bounds are defined for safety purposes. - * Content should not require the user to move beyond these - * bounds; however, it is possible for the user to ignore - * the bounds resulting in position values outside of - * this rectangle. - */ - readonly attribute float sizeX; - readonly attribute float sizeZ; -}; - -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRPose -{ - /** - * position, linearVelocity, and linearAcceleration are 3-component vectors. - * position is relative to a sitting space. Transforming this point with - * VRStageParameters.sittingToStandingTransform converts this to standing space. - */ - [Constant, Throws] readonly attribute Float32Array? position; - [Constant, Throws] readonly attribute Float32Array? linearVelocity; - [Constant, Throws] readonly attribute Float32Array? linearAcceleration; - - /* orientation is a 4-entry array representing the components of a quaternion. */ - [Constant, Throws] readonly attribute Float32Array? orientation; - /* angularVelocity and angularAcceleration are the components of 3-dimensional vectors. */ - [Constant, Throws] readonly attribute Float32Array? angularVelocity; - [Constant, Throws] readonly attribute Float32Array? angularAcceleration; -}; - -[Constructor, - Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRFrameData { - readonly attribute DOMHighResTimeStamp timestamp; - - [Throws, Pure] readonly attribute Float32Array leftProjectionMatrix; - [Throws, Pure] readonly attribute Float32Array leftViewMatrix; - - [Throws, Pure] readonly attribute Float32Array rightProjectionMatrix; - [Throws, Pure] readonly attribute Float32Array rightViewMatrix; - - [Pure] readonly attribute VRPose pose; -}; - -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VREyeParameters { - /** - * offset is a 3-component vector representing an offset to - * translate the eye. This value may vary from frame - * to frame if the user adjusts their headset ipd. - */ - [Constant, Throws] readonly attribute Float32Array offset; - - /* These values may vary as the user adjusts their headset ipd. */ - [Constant] readonly attribute VRFieldOfView fieldOfView; - - /** - * renderWidth and renderHeight specify the recommended render target - * size of each eye viewport, in pixels. If multiple eyes are rendered - * in a single render target, then the render target should be made large - * enough to fit both viewports. - */ - [Constant] readonly attribute unsigned long renderWidth; - [Constant] readonly attribute unsigned long renderHeight; -}; - -[Pref="dom.vr.enabled", - HeaderFile="mozilla/dom/VRDisplay.h"] -interface VRDisplay : EventTarget { - readonly attribute boolean isConnected; - readonly attribute boolean isPresenting; - - /** - * Dictionary of capabilities describing the VRDisplay. - */ - [Constant] readonly attribute VRDisplayCapabilities capabilities; - - /** - * If this VRDisplay supports room-scale experiences, the optional - * stage attribute contains details on the room-scale parameters. - */ - readonly attribute VRStageParameters? stageParameters; - - /* Return the current VREyeParameters for the given eye. */ - VREyeParameters getEyeParameters(VREye whichEye); - - /** - * An identifier for this distinct VRDisplay. Used as an - * association point in the Gamepad API. - */ - [Constant] readonly attribute unsigned long displayId; - - /** - * A display name, a user-readable name identifying it. - */ - [Constant] readonly attribute DOMString displayName; - - /** - * Populates the passed VRFrameData with the information required to render - * the current frame. - */ - boolean getFrameData(VRFrameData frameData); - - /** - * Return a VRPose containing the future predicted pose of the VRDisplay - * when the current frame will be presented. Subsequent calls to getPose() - * MUST return a VRPose with the same values until the next call to - * submitFrame(). - * - * The VRPose will contain the position, orientation, velocity, - * and acceleration of each of these properties. - */ - [NewObject] VRPose getPose(); - - /** - * Reset the pose for this display, treating its current position and - * orientation as the "origin/zero" values. VRPose.position, - * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be - * updated when calling resetPose(). This should be called in only - * sitting-space experiences. - */ - void resetPose(); - - /** - * z-depth defining the near plane of the eye view frustum - * enables mapping of values in the render target depth - * attachment to scene coordinates. Initially set to 0.01. - */ - attribute double depthNear; - - /** - * z-depth defining the far plane of the eye view frustum - * enables mapping of values in the render target depth - * attachment to scene coordinates. Initially set to 10000.0. - */ - attribute double depthFar; - - /** - * The callback passed to `requestAnimationFrame` will be called - * any time a new frame should be rendered. When the VRDisplay is - * presenting the callback will be called at the native refresh - * rate of the HMD. When not presenting this function acts - * identically to how window.requestAnimationFrame acts. Content should - * make no assumptions of frame rate or vsync behavior as the HMD runs - * asynchronously from other displays and at differing refresh rates. - */ - [Throws] long requestAnimationFrame(FrameRequestCallback callback); - - /** - * Passing the value returned by `requestAnimationFrame` to - * `cancelAnimationFrame` will unregister the callback. - */ - [Throws] void cancelAnimationFrame(long handle); - - /** - * Begin presenting to the VRDisplay. Must be called in response to a user gesture. - * Repeat calls while already presenting will update the VRLayers being displayed. - */ - [Throws] Promise<void> requestPresent(sequence<VRLayer> layers); - - /** - * Stops presenting to the VRDisplay. - */ - [Throws] Promise<void> exitPresent(); - - /** - * Get the layers currently being presented. - */ - sequence<VRLayer> getLayers(); - - /** - * The VRLayer provided to the VRDisplay will be captured and presented - * in the HMD. Calling this function has the same effect on the source - * canvas as any other operation that uses its source image, and canvases - * created without preserveDrawingBuffer set to true will be cleared. - */ - void submitFrame(); -}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 4c2567a1c..06fea2f20 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -555,7 +555,6 @@ WEBIDL_FILES = [ 'VideoStreamTrack.webidl', 'VideoTrack.webidl', 'VideoTrackList.webidl', - 'VRDisplay.webidl', 'VTTCue.webidl', 'VTTRegion.webidl', 'WaveShaperNode.webidl', diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp index d9a2aacc5..b8174f6c2 100644 --- a/dom/xbl/nsXBLBinding.cpp +++ b/dom/xbl/nsXBLBinding.cpp @@ -1049,7 +1049,8 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, // to create and define it. JS::Rooted<JSObject*> proto(cx); JS::Rooted<JS::PropertyDescriptor> desc(cx); - if (!JS_GetOwnUCPropertyDescriptor(cx, holder, aClassName.get(), &desc)) { + if (!JS_GetOwnUCPropertyDescriptor(cx, holder, aClassName.get(), + aClassName.Length(), &desc)) { return NS_ERROR_OUT_OF_MEMORY; } *aNew = !desc.object(); diff --git a/dom/xbl/nsXBLProtoImpl.cpp b/dom/xbl/nsXBLProtoImpl.cpp index 4db9cabf0..5efcb71e0 100644 --- a/dom/xbl/nsXBLProtoImpl.cpp +++ b/dom/xbl/nsXBLProtoImpl.cpp @@ -100,11 +100,15 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, // end up with a different content prototype, but we'll already have a property // holder called |foo| in the XBL scope. Check for that to avoid wasteful and // weird property holder duplication. - const char16_t* className = aPrototypeBinding->ClassName().get(); + const nsString& className = aPrototypeBinding->ClassName(); + const char16_t* classNameChars = className.get(); + const size_t classNameLen = className.Length(); + JS::Rooted<JSObject*> propertyHolder(cx); JS::Rooted<JS::PropertyDescriptor> existingHolder(cx); if (scopeObject != globalObject && - !JS_GetOwnUCPropertyDescriptor(cx, scopeObject, className, &existingHolder)) { + !JS_GetOwnUCPropertyDescriptor(cx, scopeObject, classNameChars, + classNameLen, &existingHolder)) { return NS_ERROR_FAILURE; } bool propertyHolderIsNew = !existingHolder.object() || !existingHolder.value().isObject(); @@ -119,8 +123,8 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, // Define it as a property on the scopeObject, using the same name used on // the content side. - bool ok = JS_DefineUCProperty(cx, scopeObject, className, -1, propertyHolder, - JSPROP_PERMANENT | JSPROP_READONLY, + bool ok = JS_DefineUCProperty(cx, scopeObject, classNameChars, classNameLen, + propertyHolder, JSPROP_PERMANENT | JSPROP_READONLY, JS_STUBGETTER, JS_STUBSETTER); NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED); } else { |