Bug 1419581 - Part 3: Guard PresentationMediaPlayer windows with MOZ_NATIVE_DEVICES. r=jchen draft
authorNick Alexander <nalexander@mozilla.com>
Fri, 05 Jan 2018 11:35:00 -0800
changeset 747338 277c272236fed0a4d316401d7369bf025221fe75
parent 747337 8cc4621269ac24abe889494ccfa80e6f90c7f428
child 747339 c02766104281a895ab57e58079a1f651e1b9f832
push id96881
push usernalexander@mozilla.com
push dateThu, 25 Jan 2018 22:25:52 +0000
reviewersjchen
bugs1419581
milestone60.0a1
Bug 1419581 - Part 3: Guard PresentationMediaPlayer windows with MOZ_NATIVE_DEVICES. r=jchen MozReview-Commit-ID: 3ZlVUMufn2g
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1134,16 +1134,17 @@ public:
            }
         }
     }
 };
 
 template<> const char
 nsWindow::NativePtr<nsWindow::LayerViewSupport>::sName[] = "LayerViewSupport";
 
+#ifdef MOZ_NATIVE_DEVICES
 /* PresentationMediaPlayerManager native calls access inner nsWindow functionality so PMPMSupport is a child class of nsWindow */
 class nsWindow::PMPMSupport final
     : public PresentationMediaPlayerManager::Natives<PMPMSupport>
 {
     PMPMSupport() = delete;
 
     static LayerViewSupport* GetLayerViewSupport(jni::Object::Param aSession)
     {
@@ -1218,16 +1219,17 @@ public:
             ANativeWindow_release(sWindow);
             sWindow = nullptr;
         }
     }
 };
 
 ANativeWindow* nsWindow::PMPMSupport::sWindow;
 EGLSurface nsWindow::PMPMSupport::sSurface;
+#endif
 
 
 nsWindow::GeckoViewSupport::~GeckoViewSupport()
 {
     // Disassociate our GeckoEditable instance with our native object.
     if (window.mEditableSupport) {
         window.mEditableSupport.Detach();
         window.mEditableParent = nullptr;
@@ -1385,19 +1387,21 @@ nsWindow::GeckoViewSupport::AttachEditab
 }
 
 void
 nsWindow::InitNatives()
 {
     nsWindow::GeckoViewSupport::Base::Init();
     nsWindow::LayerViewSupport::Init();
     nsWindow::NPZCSupport::Init();
+#ifdef MOZ_NATIVE_DEVICES
     if (jni::IsFennec()) {
         nsWindow::PMPMSupport::Init();
     }
+#endif
 
     GeckoEditableSupport::Init();
 }
 
 nsWindow*
 nsWindow::TopWindow()
 {
     if (!gTopLevelWindows.IsEmpty())
@@ -2069,33 +2073,37 @@ nsWindow::GetNativeData(uint32_t aDataTy
         }
 
         case NS_JAVA_SURFACE:
             if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
                 return lvs->GetSurface().Get();
             }
             return nullptr;
 
+#ifdef MOZ_NATIVE_DEVICES
         case NS_PRESENTATION_WINDOW:
             return PMPMSupport::sWindow;
 
         case NS_PRESENTATION_SURFACE:
             return PMPMSupport::sSurface;
+#endif
     }
 
     return nullptr;
 }
 
 void
 nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
 {
     switch (aDataType) {
+#ifdef MOZ_NATIVE_DEVICES
         case NS_PRESENTATION_SURFACE:
             PMPMSupport::sSurface = reinterpret_cast<EGLSurface>(aVal);
             break;
+#endif
     }
 }
 
 void
 nsWindow::DispatchHitTest(const WidgetTouchEvent& aEvent)
 {
     if (aEvent.mMessage == eTouchStart && aEvent.mTouches.Length() == 1) {
         // Since touch events don't get retargeted by PositionedEventTargeting.cpp
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -188,18 +188,20 @@ private:
 
     class GeckoViewSupport;
     // Object that implements native GeckoView calls and associated states.
     // nullptr for nsWindows that were not opened from GeckoView.
     // Because other objects get destroyed in the mGeckOViewSupport destructor,
     // keep it last in the list, so its destructor is called first.
     mozilla::UniquePtr<GeckoViewSupport> mGeckoViewSupport;
 
+#ifdef MOZ_NATIVE_DEVICES
     // Class that implements native PresentationMediaPlayerManager calls.
     class PMPMSupport;
+#endif
 
     mozilla::Atomic<bool, mozilla::ReleaseAcquire> mContentDocumentDisplayed;
 
 public:
     static nsWindow* TopWindow();
 
     static mozilla::Modifiers GetModifiers(int32_t aMetaState);
     static mozilla::TimeStamp GetEventTimeStamp(int64_t aEventTime);