Bug 1416310 - 4. Don't use GeckoLayerClient in native code; r=rbarker

Use LayerSession::Compositor or NativePanZoomController to call back
into Java from nsWindow.

MozReview-Commit-ID: 9JUKAE5XQK1

--HG--
extra : rebase_source : 9d6861b9d641e6abb6b6f94f5f9c4b3661ff071c
This commit is contained in:
Jim Chen 2017-11-20 17:17:02 -05:00
parent 85057e2e9a
commit a845c063bf
3 changed files with 30 additions and 30 deletions

View File

@ -873,8 +873,8 @@ __attribute__ ((visibility("default")))
jobject JNICALL
Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(JNIEnv *env, jclass, jlong size);
static jni::DependentRef<java::GeckoLayerClient>
GetJavaLayerClient(mozIDOMWindowProxy* aWindow)
static jni::DependentRef<java::LayerSession::Compositor>
GetJavaCompositor(mozIDOMWindowProxy* aWindow)
{
MOZ_ASSERT(aWindow);
@ -883,13 +883,13 @@ GetJavaLayerClient(mozIDOMWindowProxy* aWindow)
widget::WidgetUtils::DOMWindowToWidget(domWindow);
MOZ_ASSERT(widget);
return static_cast<nsWindow*>(widget.get())->GetLayerClient();
return static_cast<nsWindow*>(widget.get())->GetJavaCompositor();
}
void
AndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow)
{
auto layerClient = GetJavaLayerClient(aWindow);
auto layerClient = GetJavaCompositor(aWindow);
if (!layerClient) {
return;
}
@ -899,7 +899,7 @@ AndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow)
bool
AndroidBridge::IsContentDocumentDisplayed(mozIDOMWindowProxy* aWindow)
{
auto layerClient = GetJavaLayerClient(aWindow);
auto layerClient = GetJavaCompositor(aWindow);
if (!layerClient) {
return false;
}

View File

@ -436,6 +436,11 @@ public:
mozilla::Move(npzc)), nsIThread::DISPATCH_NORMAL);
}
const NativePanZoomController::Ref& GetJavaNPZC() const
{
return mNPZC;
}
public:
void SetIsLongpressEnabled(bool aIsLongpressEnabled)
{
@ -784,7 +789,6 @@ class nsWindow::LayerViewSupport final
WindowPtr<LayerViewSupport> mWindow;
LayerSession::Compositor::GlobalRef mCompositor;
GeckoLayerClient::GlobalRef mLayerClient;
Atomic<bool, ReleaseAcquire> mCompositorPaused;
jni::Object::GlobalRef mSurface;
@ -870,9 +874,9 @@ public:
}
}
const GeckoLayerClient::Ref& GetLayerClient() const
const LayerSession::Compositor::Ref& GetJavaCompositor() const
{
return mLayerClient;
return mCompositor;
}
bool CompositorPaused() const
@ -899,15 +903,13 @@ private:
* Compositor methods
*/
public:
void AttachToJava(jni::Object::Param aClient, jni::Object::Param aNPZC)
void AttachToJava(jni::Object::Param aNPZC)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mWindow) {
return; // Already shut down.
}
mLayerClient = GeckoLayerClient::Ref::From(aClient);
MOZ_ASSERT(aNPZC);
auto npzc = NativePanZoomController::LocalRef(
jni::GetGeckoThreadEnv(),
@ -2215,11 +2217,10 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
return NS_ERROR_UNEXPECTED;
}
MOZ_ASSERT(mLayerViewSupport);
GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient();
client->SynthesizeNativeTouchPoint(aPointerId, eventType,
aPoint.x, aPoint.y, aPointerPressure, aPointerOrientation);
MOZ_ASSERT(mNPZCSupport);
const auto& npzc = mNPZCSupport->GetJavaNPZC();
npzc->SynthesizeNativeTouchPoint(aPointerId, eventType, aPoint.x, aPoint.y,
aPointerPressure, aPointerOrientation);
return NS_OK;
}
@ -2231,10 +2232,9 @@ nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
{
mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent");
MOZ_ASSERT(mLayerViewSupport);
GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient();
client->SynthesizeNativeMouseEvent(aNativeMessage, aPoint.x, aPoint.y);
MOZ_ASSERT(mNPZCSupport);
const auto& npzc = mNPZCSupport->GetJavaNPZC();
npzc->SynthesizeNativeMouseEvent(aNativeMessage, aPoint.x, aPoint.y);
return NS_OK;
}
@ -2244,10 +2244,10 @@ nsWindow::SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
{
mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent");
MOZ_ASSERT(mLayerViewSupport);
GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient();
client->SynthesizeNativeMouseEvent(sdk::MotionEvent::ACTION_HOVER_MOVE, aPoint.x, aPoint.y);
MOZ_ASSERT(mNPZCSupport);
const auto& npzc = mNPZCSupport->GetJavaNPZC();
npzc->SynthesizeNativeMouseEvent(sdk::MotionEvent::ACTION_HOVER_MOVE,
aPoint.x, aPoint.y);
return NS_OK;
}
@ -2323,11 +2323,11 @@ nsWindow::GetWidgetScreen()
return screenMgrAndroid->ScreenForId(mScreenId);
}
jni::DependentRef<java::GeckoLayerClient>
nsWindow::GetLayerClient()
jni::DependentRef<java::LayerSession::Compositor>
nsWindow::GetJavaCompositor()
{
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
return lvs->GetLayerClient().Get();
return lvs->GetJavaCompositor().Get();
}
return nullptr;
}
@ -2345,8 +2345,8 @@ nsWindow::UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset, const CSSToSc
{
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
GeckoLayerClient::LocalRef client = lvs->GetLayerClient();
client->UpdateRootFrameMetrics(aScrollOffset.x, aScrollOffset.y, aZoom.scale);
const auto& compositor = lvs->GetJavaCompositor();
compositor->UpdateRootFrameMetrics(aScrollOffset.x, aScrollOffset.y, aZoom.scale);
}
}

View File

@ -300,7 +300,7 @@ public:
mozilla::layers::CompositorBridgeChild* GetCompositorBridgeChild() const;
mozilla::jni::DependentRef<mozilla::java::GeckoLayerClient> GetLayerClient();
mozilla::jni::DependentRef<mozilla::java::LayerSession::Compositor> GetJavaCompositor();
// Call this function when the users activity is the direct cause of an
// event (like a keypress or mouse click).