Bug 1224325 - Ensure the coordinates passed to Gesture:SingleTap have the resolution unapplied so that they are in the RCD's CSS space. r=rbarker
This commit is contained in:
@@ -4,10 +4,13 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AndroidContentController.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
using mozilla::layers::APZCTreeManager;
|
||||
|
||||
@@ -54,11 +57,26 @@ AndroidContentController::HandleSingleTap(const CSSPoint& aPoint,
|
||||
// This function will get invoked first on the Java UI thread, and then
|
||||
// again on the main thread (because of the code in ChromeProcessController::
|
||||
// HandleSingleTap). We want to post the SingleTap message once; it can be
|
||||
// done from either thread but for backwards compatibility with the JPZC
|
||||
// architecture it's better to do it as soon as possible.
|
||||
if (AndroidBridge::IsJavaUiThread()) {
|
||||
CSSIntPoint point = RoundedToInt(aPoint);
|
||||
nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", point.x, point.y);
|
||||
// done from either thread but we need access to the callback transform
|
||||
// so we do it from the main thread.
|
||||
if (NS_IsMainThread()) {
|
||||
CSSPoint point = mozilla::layers::APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid);
|
||||
|
||||
nsIContent* content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
||||
nsIPresShell* shell = content
|
||||
? mozilla::layers::APZCCallbackHelper::GetRootContentDocumentPresShellForContent(content)
|
||||
: nullptr;
|
||||
|
||||
if (shell && shell->ScaleToResolution()) {
|
||||
// We need to convert from the root document to the root content document,
|
||||
// by unapplying the resolution that's on the content document.
|
||||
const float resolution = shell->GetResolution();
|
||||
point.x /= resolution;
|
||||
point.y /= resolution;
|
||||
}
|
||||
|
||||
CSSIntPoint rounded = RoundedToInt(point);
|
||||
nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", rounded.x, rounded.y);
|
||||
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeBroadcastEvent(
|
||||
NS_LITERAL_CSTRING("Gesture:SingleTap"), data));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user