Bug 1416319 - 1. Move content-document-is-displayed flag to native code; r=rbarker

One fix I forgot to make in bug 1416310 is to change the code to reset
the flag in LayerView. I think it's better if we just moved the whole
thing to native code, since we don't really use the flag in Java.

MozReview-Commit-ID: 9cbcYb89LhC

--HG--
extra : rebase_source : a209669d6657a60c198f59f4a0e4d959478485c3
This commit is contained in:
Jim Chen 2017-11-22 14:12:22 -05:00
Родитель bda10d4bd8
Коммит b21cdffaf4
7 изменённых файлов: 25 добавлений и 89 удалений

Просмотреть файл

@ -31,8 +31,6 @@ public class LayerSession {
protected class Compositor extends JNIObject {
public LayerView layerView;
private volatile boolean mContentDocumentIsDisplayed;
public boolean isReady() {
return LayerSession.this.isCompositorReady();
}
@ -129,23 +127,12 @@ public class LayerSession {
public native void sendToolbarPixelsToCompositor(final int width, final int height,
final int[] pixels);
@WrapForJNI(calledFrom = "gecko")
private void contentDocumentChanged() {
mContentDocumentIsDisplayed = false;
}
@WrapForJNI(calledFrom = "gecko")
private boolean isContentDocumentDisplayed() {
return mContentDocumentIsDisplayed;
}
// The compositor invokes this function just before compositing a frame where the
// document is different from the document composited on the last frame. In these
// cases, the viewport information we have in Java is no longer valid and needs to
// be replaced with the new viewport information provided.
@WrapForJNI(calledFrom = "ui")
public void updateRootFrameMetrics(float scrollX, float scrollY, float zoom) {
mContentDocumentIsDisplayed = true;
if (layerView != null) {
layerView.onMetricsChanged(scrollX, scrollY, zoom);
}

Просмотреть файл

@ -319,10 +319,6 @@ public class LayerView extends FrameLayout {
mCompositor = session.mCompositor;
mCompositor.layerView = this;
// Reset the content-document-is-displayed flag.
mCompositor.updateRootFrameMetrics(/* scroolX */ 0, /* scrollY */ 0,
/* zoom */ 1.0f);
mToolbarAnimator.notifyCompositorCreated(mCompositor);
final NativePanZoomController npzc = (NativePanZoomController) mPanZoomController;

Просмотреть файл

@ -873,8 +873,8 @@ __attribute__ ((visibility("default")))
jobject JNICALL
Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(JNIEnv *env, jclass, jlong size);
static jni::DependentRef<java::LayerSession::Compositor>
GetJavaCompositor(mozIDOMWindowProxy* aWindow)
static RefPtr<nsWindow>
GetWidget(mozIDOMWindowProxy* aWindow)
{
MOZ_ASSERT(aWindow);
@ -883,27 +883,26 @@ GetJavaCompositor(mozIDOMWindowProxy* aWindow)
widget::WidgetUtils::DOMWindowToWidget(domWindow);
MOZ_ASSERT(widget);
return static_cast<nsWindow*>(widget.get())->GetJavaCompositor();
return RefPtr<nsWindow>(static_cast<nsWindow*>(widget.get()));
}
void
AndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow)
{
auto layerClient = GetJavaCompositor(aWindow);
if (!layerClient) {
return;
auto widget = GetWidget(aWindow);
if (widget) {
widget->SetContentDocumentDisplayed(false);
}
layerClient->ContentDocumentChanged();
}
bool
AndroidBridge::IsContentDocumentDisplayed(mozIDOMWindowProxy* aWindow)
{
auto layerClient = GetJavaCompositor(aWindow);
if (!layerClient) {
return false;
auto widget = GetWidget(aWindow);
if (widget) {
return widget->IsContentDocumentDisplayed();
}
return layerClient->IsContentDocumentDisplayed();
return false;
}
jni::Object::LocalRef AndroidBridge::ChannelCreate(jni::Object::Param stream) {

Просмотреть файл

@ -1254,14 +1254,6 @@ const char LayerSession::Compositor::name[] =
constexpr char LayerSession::Compositor::AttachToJava_t::name[];
constexpr char LayerSession::Compositor::AttachToJava_t::signature[];
constexpr char LayerSession::Compositor::ContentDocumentChanged_t::name[];
constexpr char LayerSession::Compositor::ContentDocumentChanged_t::signature[];
auto LayerSession::Compositor::ContentDocumentChanged() const -> void
{
return mozilla::jni::Method<ContentDocumentChanged_t>::Call(Compositor::mCtx, nullptr);
}
constexpr char LayerSession::Compositor::CreateCompositor_t::name[];
constexpr char LayerSession::Compositor::CreateCompositor_t::signature[];
@ -1271,14 +1263,6 @@ constexpr char LayerSession::Compositor::DisposeNative_t::signature[];
constexpr char LayerSession::Compositor::EnableLayerUpdateNotifications_t::name[];
constexpr char LayerSession::Compositor::EnableLayerUpdateNotifications_t::signature[];
constexpr char LayerSession::Compositor::IsContentDocumentDisplayed_t::name[];
constexpr char LayerSession::Compositor::IsContentDocumentDisplayed_t::signature[];
auto LayerSession::Compositor::IsContentDocumentDisplayed() const -> bool
{
return mozilla::jni::Method<IsContentDocumentDisplayed_t>::Call(Compositor::mCtx, nullptr);
}
constexpr char LayerSession::Compositor::OnBoundsChanged_t::name[];
constexpr char LayerSession::Compositor::OnBoundsChanged_t::signature[];

Просмотреть файл

@ -3812,25 +3812,6 @@ public:
mozilla::jni::DispatchTarget::GECKO;
};
struct ContentDocumentChanged_t {
typedef Compositor Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "contentDocumentChanged";
static constexpr char signature[] =
"()V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::GECKO;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto ContentDocumentChanged() const -> void;
struct CreateCompositor_t {
typedef Compositor Owner;
typedef void ReturnType;
@ -3886,25 +3867,6 @@ public:
mozilla::jni::DispatchTarget::CURRENT;
};
struct IsContentDocumentDisplayed_t {
typedef Compositor Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "isContentDocumentDisplayed";
static constexpr char signature[] =
"()Z";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::GECKO;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto IsContentDocumentDisplayed() const -> bool;
struct OnBoundsChanged_t {
typedef Compositor Owner;
typedef void ReturnType;

Просмотреть файл

@ -2323,14 +2323,18 @@ nsWindow::GetWidgetScreen()
return screenMgrAndroid->ScreenForId(mScreenId);
}
jni::DependentRef<java::LayerSession::Compositor>
nsWindow::GetJavaCompositor()
void
nsWindow::SetContentDocumentDisplayed(bool aDisplayed)
{
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
return lvs->GetJavaCompositor().Get();
}
return nullptr;
mContentDocumentDisplayed = aDisplayed;
}
bool
nsWindow::IsContentDocumentDisplayed()
{
return mContentDocumentDisplayed;
}
void
nsWindow::RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage)
{
@ -2346,6 +2350,7 @@ nsWindow::UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset, const CSSToSc
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
const auto& compositor = lvs->GetJavaCompositor();
mContentDocumentDisplayed = true;
compositor->UpdateRootFrameMetrics(aScrollOffset.x, aScrollOffset.y, aZoom.scale);
}
}

Просмотреть файл

@ -196,6 +196,8 @@ private:
// Class that implements native PresentationMediaPlayerManager calls.
class PMPMSupport;
mozilla::Atomic<bool, mozilla::ReleaseAcquire> mContentDocumentDisplayed;
public:
static nsWindow* TopWindow();
@ -300,7 +302,8 @@ public:
mozilla::layers::CompositorBridgeChild* GetCompositorBridgeChild() const;
mozilla::jni::DependentRef<mozilla::java::LayerSession::Compositor> GetJavaCompositor();
void SetContentDocumentDisplayed(bool aDisplayed);
bool IsContentDocumentDisplayed();
// Call this function when the users activity is the direct cause of an
// event (like a keypress or mouse click).