diff --git a/widget/android/jni/Natives.h b/widget/android/jni/Natives.h index ac7a1e4d37af..722996b501ff 100644 --- a/widget/android/jni/Natives.h +++ b/widget/android/jni/Natives.h @@ -356,14 +356,14 @@ public: ProxyNativeCall(const ProxyNativeCall&) = default; // Get class ref for static calls or object ref for instance calls. - typename ThisArgClass::Param GetThisArg() { return mThisArg; } + typename ThisArgClass::Param GetThisArg() const { return mThisArg; } // Return if target is the given function pointer / pointer-to-member. // Because we can only compare pointers of the same type, we use a // templated overload that is chosen only if given a different type of // pointer than our target pointer type. - bool IsTarget(NativeCallType call) { return call == mNativeCall; } - template bool IsTarget(T&&) { return false; } + bool IsTarget(NativeCallType call) const { return call == mNativeCall; } + template bool IsTarget(T&&) const { return false; } void operator()() { diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index 0756e8d740c6..f7f76565efb2 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -383,7 +383,7 @@ public: void Run() override; void PostTo(mozilla::LinkedList& queue) override; - mozilla::HangMonitor::ActivityType ActivityType() const + Event::Type ActivityType() const override { return ae->IsInputEvent() ? mozilla::HangMonitor::kUIActivity : mozilla::HangMonitor::kGeneralActivity; diff --git a/widget/android/nsAppShell.h b/widget/android/nsAppShell.h index 1241f6f070e1..583d03262f6a 100644 --- a/widget/android/nsAppShell.h +++ b/widget/android/nsAppShell.h @@ -33,6 +33,8 @@ class nsAppShell : public: struct Event : mozilla::LinkedListElement { + typedef mozilla::HangMonitor::ActivityType Type; + bool HasSameTypeAs(const Event* other) const { // Compare vtable addresses to determine same type. @@ -48,9 +50,9 @@ public: queue.insertBack(this); } - virtual mozilla::HangMonitor::ActivityType ActivityType() const + virtual Type ActivityType() const { - return mozilla::HangMonitor::kGeneralActivity; + return Type::kGeneralActivity; } }; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 539e74a7c6e7..7c75d1129e15 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -200,6 +200,20 @@ class nsWindow::Natives final return Base::Run(); } } + + nsAppShell::Event::Type ActivityType() const override + { + // Events that result in user-visible changes count as UI events. + if (Base::lambda.IsTarget(&Natives::OnKeyEvent) || + Base::lambda.IsTarget(&Natives::OnImeReplaceText) || + Base::lambda.IsTarget(&Natives::OnImeSetSelection) || + Base::lambda.IsTarget(&Natives::OnImeRemoveComposition) || + Base::lambda.IsTarget(&Natives::OnImeUpdateComposition)) + { + return nsAppShell::Event::Type::kUIActivity; + } + return Base::ActivityType(); + } }; public: