From b71e9c9fdcd9f507503061279a501828294b5872 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 18 Jul 2014 16:47:10 -0700 Subject: [PATCH] Bug 1017242 - Part C: remove API 8 code from GeckoEvent. r=mfinkle --- mobile/android/base/GeckoEvent.java | 50 ++++++++++++----------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/mobile/android/base/GeckoEvent.java b/mobile/android/base/GeckoEvent.java index e0ffb981a98..a42f4bab4cd 100644 --- a/mobile/android/base/GeckoEvent.java +++ b/mobile/android/base/GeckoEvent.java @@ -470,38 +470,30 @@ public class GeckoEvent { mPoints[index] = new Point(Math.round(geckoPoint.x), Math.round(geckoPoint.y)); mPointIndicies[index] = event.getPointerId(eventIndex); - // getToolMajor, getToolMinor and getOrientation are API Level 9 features - if (Build.VERSION.SDK_INT >= 9) { - double radians = event.getOrientation(eventIndex); - mOrientations[index] = (float) Math.toDegrees(radians); - // w3c touchevents spec does not allow orientations == 90 - // this shifts it to -90, which will be shifted to zero below - if (mOrientations[index] == 90) - mOrientations[index] = -90; - // w3c touchevent radius are given by an orientation between 0 and 90 - // the radius is found by removing the orientation and measuring the x and y - // radius of the resulting ellipse - // for android orientations >= 0 and < 90, the major axis should correspond to - // just reporting the y radius as the major one, and x as minor - // however, for a radius < 0, we have to shift the orientation by adding 90, and - // reverse which radius is major and minor - if (mOrientations[index] < 0) { - mOrientations[index] += 90; - mPointRadii[index] = new Point((int)event.getToolMajor(eventIndex)/2, - (int)event.getToolMinor(eventIndex)/2); - } else { - mPointRadii[index] = new Point((int)event.getToolMinor(eventIndex)/2, - (int)event.getToolMajor(eventIndex)/2); - } + double radians = event.getOrientation(eventIndex); + mOrientations[index] = (float) Math.toDegrees(radians); + // w3c touchevents spec does not allow orientations == 90 + // this shifts it to -90, which will be shifted to zero below + if (mOrientations[index] == 90) + mOrientations[index] = -90; + + // w3c touchevent radius are given by an orientation between 0 and 90 + // the radius is found by removing the orientation and measuring the x and y + // radius of the resulting ellipse + // for android orientations >= 0 and < 90, the major axis should correspond to + // just reporting the y radius as the major one, and x as minor + // however, for a radius < 0, we have to shift the orientation by adding 90, and + // reverse which radius is major and minor + if (mOrientations[index] < 0) { + mOrientations[index] += 90; + mPointRadii[index] = new Point((int)event.getToolMajor(eventIndex)/2, + (int)event.getToolMinor(eventIndex)/2); } else { - float size = event.getSize(eventIndex); - Resources resources = GeckoAppShell.getContext().getResources(); - DisplayMetrics displaymetrics = resources.getDisplayMetrics(); - size = size*Math.min(displaymetrics.heightPixels, displaymetrics.widthPixels); - mPointRadii[index] = new Point((int)size,(int)size); - mOrientations[index] = 0; + mPointRadii[index] = new Point((int)event.getToolMinor(eventIndex)/2, + (int)event.getToolMajor(eventIndex)/2); } + if (!keepInViewCoordinates) { // If we are converting to gecko CSS pixels, then we should adjust the // radii as well