зеркало из https://github.com/mozilla/gecko-dev.git
Bug 714874 - Fix Java warnings about redundant casts. r=pcwalton r=dougt a=dougt
This commit is contained in:
Родитель
043eb9f603
Коммит
a4d87cd62d
|
@ -439,7 +439,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
|||
if (mContextMenuSubject instanceof Cursor) {
|
||||
Cursor cursor = (Cursor)mContextMenuSubject;
|
||||
url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
|
||||
b = (byte[]) cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
|
||||
b = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
|
||||
title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
|
||||
} else if (mContextMenuSubject instanceof Map) {
|
||||
Map map = (Map)mContextMenuSubject;
|
||||
|
|
|
@ -479,8 +479,7 @@ public class AwesomeBarTabs extends TabHost {
|
|||
try {
|
||||
byte[] bytes = Base64.decode(base64, Base64.DEFAULT);
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
drawable = (Drawable) Drawable.createFromStream(stream, "src");
|
||||
|
||||
drawable = Drawable.createFromStream(stream, "src");
|
||||
stream.close();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.i(LOGTAG, "exception while decoding drawable: " + base64, e);
|
||||
|
|
|
@ -2374,10 +2374,10 @@ class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
|||
}
|
||||
|
||||
public static PluginLayoutParams create(int aX, int aY, int aWidth, int aHeight, float aResolution) {
|
||||
aX = (int)Math.round(aX * aResolution);
|
||||
aY = (int)Math.round(aY * aResolution);
|
||||
aWidth = (int)Math.round(aWidth * aResolution);
|
||||
aHeight = (int)Math.round(aHeight * aResolution);
|
||||
aX = Math.round(aX * aResolution);
|
||||
aY = Math.round(aY * aResolution);
|
||||
aWidth = Math.round(aWidth * aResolution);
|
||||
aHeight = Math.round(aHeight * aResolution);
|
||||
|
||||
return new PluginLayoutParams(aX, aY, aWidth, aHeight, aResolution);
|
||||
}
|
||||
|
@ -2395,10 +2395,10 @@ class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
|||
}
|
||||
|
||||
public void reset(int aX, int aY, int aWidth, int aHeight, float aResolution) {
|
||||
x = mOriginalX = (int)Math.round(aX * aResolution);
|
||||
y = mOriginalY = (int)Math.round(aY * aResolution);
|
||||
width = mOriginalWidth = (int)Math.round(aWidth * aResolution);
|
||||
height = mOriginalHeight = (int)Math.round(aHeight * aResolution);
|
||||
x = mOriginalX = Math.round(aX * aResolution);
|
||||
y = mOriginalY = Math.round(aY * aResolution);
|
||||
width = mOriginalWidth = Math.round(aWidth * aResolution);
|
||||
height = mOriginalHeight = Math.round(aHeight * aResolution);
|
||||
mLastResolution = mOriginalResolution = aResolution;
|
||||
|
||||
clampToMaxSize();
|
||||
|
@ -2413,8 +2413,8 @@ class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
|||
|
||||
if (!FloatUtils.fuzzyEquals(mLastResolution, aResolution)) {
|
||||
float scaleFactor = aResolution / mOriginalResolution;
|
||||
width = (int)Math.round(scaleFactor * mOriginalWidth);
|
||||
height = (int)Math.round(scaleFactor * mOriginalHeight);
|
||||
width = Math.round(scaleFactor * mOriginalWidth);
|
||||
height = Math.round(scaleFactor * mOriginalHeight);
|
||||
mLastResolution = aResolution;
|
||||
|
||||
clampToMaxSize();
|
||||
|
@ -2425,8 +2425,8 @@ class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
|||
PointF targetOrigin = targetViewport.getOrigin();
|
||||
PointF hostOrigin = hostViewport.getOrigin();
|
||||
|
||||
Point offset = new Point((int)Math.round(hostOrigin.x - targetOrigin.x),
|
||||
(int)Math.round(hostOrigin.y - targetOrigin.y));
|
||||
Point offset = new Point(Math.round(hostOrigin.x - targetOrigin.x),
|
||||
Math.round(hostOrigin.y - targetOrigin.y));
|
||||
|
||||
reposition(offset, hostViewport.getZoomFactor());
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ public class IntSize {
|
|||
public String toString() { return "(" + width + "," + height + ")"; }
|
||||
|
||||
public IntSize scale(float factor) {
|
||||
return new IntSize((int)Math.round(width * factor),
|
||||
(int)Math.round(height * factor));
|
||||
return new IntSize(Math.round(width * factor),
|
||||
Math.round(height * factor));
|
||||
}
|
||||
|
||||
/* Returns the power of two that is greater than or equal to value */
|
||||
|
|
|
@ -297,7 +297,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
|||
mDroppedFrames -= (mFrameTimings[mCurrentFrame] + 1) / MAX_FRAME_TIME;
|
||||
mDroppedFrames += (frameElapsedTime + 1) / MAX_FRAME_TIME;
|
||||
|
||||
mFrameTimings[mCurrentFrame] = (int)frameElapsedTime;
|
||||
mFrameTimings[mCurrentFrame] = frameElapsedTime;
|
||||
mCurrentFrame = (mCurrentFrame + 1) % mFrameTimings.length;
|
||||
|
||||
int averageTime = mFrameTimingsSum / mFrameTimings.length;
|
||||
|
|
|
@ -37,9 +37,13 @@
|
|||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.FloatUtils;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONException;
|
||||
import org.mozilla.gecko.FloatUtils;
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
public final class PointUtils {
|
||||
|
@ -72,5 +76,15 @@ public final class PointUtils {
|
|||
public static float distance(PointF point) {
|
||||
return (float)Math.sqrt(point.x * point.x + point.y * point.y);
|
||||
}
|
||||
|
||||
public static JSONObject toJSON(PointF point) throws JSONException {
|
||||
// Ensure we put ints, not longs, because Gecko message handlers call getInt().
|
||||
int x = Math.round(point.x);
|
||||
int y = Math.round(point.y);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("x", x);
|
||||
json.put("y", y);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,12 +57,12 @@ public final class RectUtils {
|
|||
}
|
||||
|
||||
public static Rect contract(Rect rect, int lessWidth, int lessHeight) {
|
||||
float halfLessWidth = (float)lessWidth / 2.0f;
|
||||
float halfLessHeight = (float)lessHeight / 2.0f;
|
||||
return new Rect((int)Math.round((float)rect.left + halfLessWidth),
|
||||
(int)Math.round((float)rect.top + halfLessHeight),
|
||||
(int)Math.round((float)rect.right - halfLessWidth),
|
||||
(int)Math.round((float)rect.bottom - halfLessHeight));
|
||||
float halfLessWidth = lessWidth / 2.0f;
|
||||
float halfLessHeight = lessHeight / 2.0f;
|
||||
return new Rect(Math.round(rect.left + halfLessWidth),
|
||||
Math.round(rect.top + halfLessHeight),
|
||||
Math.round(rect.right - halfLessWidth),
|
||||
Math.round(rect.bottom - halfLessHeight));
|
||||
}
|
||||
|
||||
public static RectF contract(RectF rect, float lessWidth, float lessHeight) {
|
||||
|
|
|
@ -152,7 +152,7 @@ public class ScrollbarLayer extends TileLayer {
|
|||
foregroundPaint.setAntiAlias(true);
|
||||
foregroundPaint.setStyle(Paint.Style.FILL);
|
||||
// use a (a,r,g,b) color of (127,0,0,0), and multiply the alpha by mOpacity for fading
|
||||
foregroundPaint.setColor(Color.argb((int)Math.round(mOpacity * 127), 0, 0, 0));
|
||||
foregroundPaint.setColor(Color.argb(Math.round(mOpacity * 127), 0, 0, 0));
|
||||
|
||||
mCanvas.drawColor(Color.argb(0, 0, 0, 0), PorterDuff.Mode.CLEAR);
|
||||
mCanvas.drawCircle(CAP_RADIUS, CAP_RADIUS, CAP_RADIUS, foregroundPaint);
|
||||
|
|
|
@ -80,8 +80,8 @@ public class SingleTileLayer extends TileLayer {
|
|||
|
||||
if (repeats()) {
|
||||
bounds = new RectF(0.0f, 0.0f, viewport.width(), viewport.height());
|
||||
int width = (int)Math.round(viewport.width());
|
||||
int height = (int)Math.round(-viewport.height());
|
||||
int width = Math.round(viewport.width());
|
||||
int height = Math.round(-viewport.height());
|
||||
cropRect = new int[] { 0, size.height, width, height };
|
||||
} else {
|
||||
bounds = getBounds(context, new FloatSize(size));
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.json.JSONException;
|
|||
import org.mozilla.gecko.gfx.FloatSize;
|
||||
import org.mozilla.gecko.gfx.LayerController;
|
||||
import org.mozilla.gecko.gfx.PointUtils;
|
||||
import org.mozilla.gecko.gfx.RectUtils;
|
||||
import org.mozilla.gecko.gfx.ViewportMetrics;
|
||||
import org.mozilla.gecko.FloatUtils;
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
|
@ -907,11 +906,11 @@ public class PanZoomController
|
|||
float minZoomFactor = 0.0f;
|
||||
if (viewport.width() > pageSize.width && pageSize.width > 0) {
|
||||
float scaleFactor = viewport.width() / pageSize.width;
|
||||
minZoomFactor = (float)Math.max(minZoomFactor, zoomFactor * scaleFactor);
|
||||
minZoomFactor = Math.max(minZoomFactor, zoomFactor * scaleFactor);
|
||||
}
|
||||
if (viewport.height() > pageSize.height && pageSize.height > 0) {
|
||||
float scaleFactor = viewport.height() / pageSize.height;
|
||||
minZoomFactor = (float)Math.max(minZoomFactor, zoomFactor * scaleFactor);
|
||||
minZoomFactor = Math.max(minZoomFactor, zoomFactor * scaleFactor);
|
||||
}
|
||||
|
||||
if (!FloatUtils.fuzzyEquals(minZoomFactor, 0.0f)) {
|
||||
|
@ -1037,20 +1036,20 @@ public class PanZoomController
|
|||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
String json;
|
||||
try {
|
||||
PointF point = new PointF(motionEvent.getX(), motionEvent.getY());
|
||||
point = mController.convertViewPointToLayerPoint(point);
|
||||
if (point == null) {
|
||||
return;
|
||||
}
|
||||
ret.put("x", (int)Math.round(point.x));
|
||||
ret.put("y", (int)Math.round(point.y));
|
||||
json = PointUtils.toJSON(point).toString();
|
||||
} catch(Exception ex) {
|
||||
Log.w(LOGTAG, "Error building return: " + ex);
|
||||
return; // json would be null
|
||||
}
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:LongPress", ret.toString());
|
||||
GeckoEvent e = new GeckoEvent("Gesture:LongPress", json);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
|
||||
|
@ -1060,36 +1059,34 @@ public class PanZoomController
|
|||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
String json;
|
||||
try {
|
||||
PointF point = new PointF(motionEvent.getX(), motionEvent.getY());
|
||||
point = mController.convertViewPointToLayerPoint(point);
|
||||
ret.put("x", (int)Math.round(point.x));
|
||||
ret.put("y", (int)Math.round(point.y));
|
||||
json = PointUtils.toJSON(point).toString();
|
||||
} catch(Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:ShowPress", ret.toString());
|
||||
GeckoEvent e = new GeckoEvent("Gesture:ShowPress", json);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
String json;
|
||||
try {
|
||||
PointF point = new PointF(motionEvent.getX(), motionEvent.getY());
|
||||
point = mController.convertViewPointToLayerPoint(point);
|
||||
ret.put("x", (int)Math.round(point.x));
|
||||
ret.put("y", (int)Math.round(point.y));
|
||||
json = PointUtils.toJSON(point).toString();
|
||||
} catch(Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
GeckoApp.mAppContext.mAutoCompletePopup.hide();
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:SingleTap", ret.toString());
|
||||
GeckoEvent e = new GeckoEvent("Gesture:SingleTap", json);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
return true;
|
||||
}
|
||||
|
@ -1101,17 +1098,16 @@ public class PanZoomController
|
|||
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
String json;
|
||||
try {
|
||||
PointF point = new PointF(motionEvent.getX(), motionEvent.getY());
|
||||
point = mController.convertViewPointToLayerPoint(point);
|
||||
ret.put("x", (int)Math.round(point.x));
|
||||
ret.put("y", (int)Math.round(point.y));
|
||||
json = PointUtils.toJSON(point).toString();
|
||||
} catch(Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:DoubleTap", ret.toString());
|
||||
GeckoEvent e = new GeckoEvent("Gesture:DoubleTap", json);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче