Backout 6b1414e0a6e8 and 8f3eacc9ceb6

This commit is contained in:
Wes Johnston 2011-11-15 14:04:07 -08:00
Родитель a35e0182fd
Коммит 2258d88fce
6 изменённых файлов: 2 добавлений и 175 удалений

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

@ -774,25 +774,6 @@ abstract public class GeckoApp
mBrowserToolbar.setVisibility(View.VISIBLE);
}
});
} else if (event.equals("Browser:ZoomToRect")) {
if (mLayerController != null) {
float x = (float)message.getDouble("x");
float y = (float)message.getDouble("y");
float width = (float)message.getDouble("w");
float height = (float)message.getDouble("h");
mLayerController.getPanZoomController().animatedZoomTo(x, y, width, height, 200);
}
} else if (event.equals("Browser:ZoomToPageWidth")) {
if (mLayerController != null) {
IntSize pageSize = mLayerController.getPageSize();
RectF viewableRect = mLayerController.getVisibleRect();
// attempt to keep the middle of the screen in the middle of the screen
float y = viewableRect.top;
float dh = (viewableRect.height() * pageSize.width/viewableRect.width()) - viewableRect.height(); // increase in the height
y -= dh/2;
mLayerController.getPanZoomController().animatedZoomTo(0, y, pageSize.width,
pageSize.width * viewableRect.height()/viewableRect.width(), 200);
}
}
} catch (Exception e) {
Log.i(LOG_NAME, "handleMessage throws " + e + " for message: " + event);
@ -1147,8 +1128,6 @@ abstract public class GeckoApp
GeckoAppShell.registerGeckoEventListener("PanZoom:Resize", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Browser:ZoomToRect", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Browser:ZoomToPageWidth", GeckoApp.mAppContext);
mConnectivityFilter = new IntentFilter();
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
@ -1349,10 +1328,9 @@ abstract public class GeckoApp
GeckoAppShell.unregisterGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Browser:ZoomToRect", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Browser:ZoomToPageWidth", GeckoApp.mAppContext);
mFavicons.close();
super.onDestroy();
}

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

@ -120,10 +120,8 @@ public class LayerController {
public Bitmap getCheckerboardPattern() { return getDrawable("checkerboard"); }
public Bitmap getShadowPattern() { return getDrawable("shadow"); }
public PanZoomController getPanZoomController() { return mPanZoomController; }
public GestureDetector.OnGestureListener getGestureListener() { return mPanZoomController; }
public ScaleGestureDetector.OnScaleGestureListener getScaleGestureListener() { return mPanZoomController; }
public GestureDetector.OnDoubleTapListener getDoubleTapListener() { return mPanZoomController; }
private Bitmap getDrawable(String name) {
Resources resources = mContext.getResources();
@ -164,10 +162,6 @@ public class LayerController {
setVisibleRect(x, y, mVisibleRect.width(), mVisibleRect.height());
}
public void setVisibleRect(RectF aRect) {
setVisibleRect(aRect.left, aRect.top, aRect.width(), aRect.height());
}
public void setVisibleRect(float x, float y, float width, float height) {
mVisibleRect = new RectF(x, y, x + width, y + height);
setNeedsDisplay();
@ -227,11 +221,6 @@ public class LayerController {
return new RectF(x, y, x + TILE_WIDTH, y + TILE_HEIGHT);
}
public RectF clampToScreenSize(RectF aRect) {
RectF pageRect = new RectF(0, 0, mPageSize.width, mPageSize.height);
return RectUtils.clamp(aRect, pageRect);
}
// Returns true if a checkerboard is about to be visible.
private boolean aboutToCheckerboard() {
Rect pageRect = new Rect(0, 0, mPageSize.width, mPageSize.height);

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

@ -70,7 +70,6 @@ public class LayerView extends GLSurfaceView {
mRenderer = new LayerRenderer(this);
setRenderer(mRenderer);
mGestureDetector = new GestureDetector(context, controller.getGestureListener());
mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
mScaleGestureDetector = new ScaleGestureDetector(context, controller.getScaleGestureListener());
mInputConnectionHandler = null;

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

@ -88,19 +88,4 @@ public final class RectUtils {
x + (rect.width() * scale),
y + (rect.height() * scale));
}
public static RectF clamp(RectF rect, RectF dest) {
float width = Math.min(rect.width(), dest.width());
float height = Math.min(rect.height(), dest.height());
float x = Math.max(dest.left, Math.min(dest.width()-rect.width(), rect.left));
float y = Math.max(dest.top, Math.min(dest.height()-rect.height(), rect.top));
return new RectF(x, y, width, height);
}
public static RectF blend(RectF aRect1, RectF aRect2, float aBlendAmount) {
return new RectF((aRect1.left-aRect2.left)*aBlendAmount + aRect2.left,
(aRect1.top-aRect2.top)*aBlendAmount + aRect2.top,
(aRect1.width()-aRect2.width())*aBlendAmount + aRect2.width(),
(aRect1.height()-aRect2.height())*aBlendAmount + aRect2.height());
}
}

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

@ -40,7 +40,6 @@ package org.mozilla.gecko.ui;
import org.json.JSONObject;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.RectUtils;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import android.graphics.PointF;
@ -51,7 +50,6 @@ import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Date;
/*
* Handles the kinetic scrolling and zooming physics for a layer controller.
@ -61,8 +59,7 @@ import java.util.Date;
*/
public class PanZoomController
extends GestureDetector.SimpleOnGestureListener
implements ScaleGestureDetector.OnScaleGestureListener,
GestureDetector.OnDoubleTapListener
implements ScaleGestureDetector.OnScaleGestureListener
{
private static final String LOG_NAME = "PanZoomController";
@ -584,14 +581,6 @@ public class PanZoomController
mLastTimestamp = System.currentTimeMillis();
mX.touchPos = detector.getFocusX();
mY.touchPos = detector.getFocusY();
RectF visible = mController.getVisibleRect();
IntSize pageSize = mController.getPageSize();
RectF pageRect = new RectF(0,0, pageSize.width, pageSize.height);
if (!pageRect.contains(visible)) {
RectF rect = mController.clampToScreenSize(visible);
animatedZoomTo(rect.left, rect.top, rect.width(), rect.height(), 200);
}
}
@Override
@ -609,58 +598,4 @@ public class PanZoomController
GeckoEvent e = new GeckoEvent("Gesture:LongPress", ret.toString());
GeckoAppShell.sendEventToGecko(e);
}
@Override
public boolean onDoubleTap(MotionEvent motionEvent) {
JSONObject ret = new JSONObject();
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));
} catch(Exception ex) {
throw new RuntimeException(ex);
}
GeckoEvent e = new GeckoEvent("Gesture:DoubleTap", ret.toString());
GeckoAppShell.sendEventToGecko(e);
return true;
}
private Timer mZoomTimer;
public boolean animatedZoomTo(float x, float y, float width, float height, final float duration) {
if (mZoomTimer != null) {
mZoomTimer.cancel();
}
IntSize screenSize = mController.getScreenSize();
float newHeight = width * screenSize.height / screenSize.width;
// if the requested rect would not fill the screen, shift it to be centered
if (height < newHeight) {
y -= (newHeight - height)/2;
}
final RectF finalRect = mController.clampToScreenSize(new RectF(x, y, width, newHeight));
mZoomTimer = new Timer();
final RectF startRect = mController.getVisibleRect();
final long startTime = new Date().getTime();
mZoomTimer.scheduleAtFixedRate(new TimerTask() {
public void run() {
long now = new Date().getTime();
float dt = (float)(now - startTime)/duration;
if (dt < 1) {
mController.setVisibleRect(RectUtils.blend(finalRect, startRect, dt));
mController.notifyLayerClientOfGeometryChange();
geometryChanged();
} else {
mController.setVisibleRect(finalRect);
mController.notifyLayerClientOfGeometryChange();
geometryChanged();
mZoomTimer.cancel();
mZoomTimer = null;
}
}
}, 0, 1000L/60L);
return true;
}
}

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

@ -162,7 +162,6 @@ var BrowserApp = {
Services.obs.addObserver(this, "Sanitize:ClearAll", false);
Services.obs.addObserver(this, "PanZoom:PanZoom", false);
Services.obs.addObserver(this, "FullScreen:Exit", false);
Services.obs.addObserver(this, "Gesture:DoubleTap", false);
Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
@ -615,38 +614,6 @@ var BrowserApp = {
this.panZoom(aData);
} else if (aTopic == "FullScreen:Exit") {
browser.contentDocument.mozCancelFullScreen();
} else if (aTopic == "Gesture:DoubleTap") {
this.onDoubleTap(aData);
}
},
onDoubleTap: function(aData) {
let data = JSON.parse(aData);
let rect = {};
let win = BrowserApp.selectedBrowser.contentWindow;
let element = ElementTouchHelper.anyElementFromPoint(win, data.x, data.y);
win = element.ownerDocument.defaultView;
while (element && win.getComputedStyle(element,null).display == "inline")
element = element.parentNode;
if (!element || element == this._zoomedToElement) {
this._zoomedToElement = null;
// zoom out, try to keep the center in the center of the page
setTimeout(function() {
rect.type = "Browser:ZoomToPageWidth";
sendMessageToJava({ gecko: rect });
}, 0);
} else if (element) {
const margin = 15;
this._zoomedToElement = element;
rect = ElementTouchHelper.getBoundingContentRect(element);
setTimeout(function() {
rect.type = "Browser:ZoomToRect";
rect.x -= 2*margin;
rect.w += 2*margin;
sendMessageToJava({ gecko: rect });
}, 0);
}
}
}
@ -1874,32 +1841,6 @@ const ElementTouchHelper = {
});
}
return result;
},
getBoundingContentRect: function(aElement) {
if (!aElement)
return {x: 0, y: 0, w: 0, h: 0};
let document = aElement.ownerDocument;
while (document.defaultView.frameElement)
document = document.defaultView.frameElement.ownerDocument;
let cwu = document.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let scrollX = {}, scrollY = {};
cwu.getScrollXY(false, scrollX, scrollY);
let r = aElement.getBoundingClientRect();
// step out of iframes and frames, offsetting scroll values
for (let frame = aElement.ownerDocument.defaultView; frame != content; frame = frame.parent) {
// adjust client coordinates' origin to be top left of iframe viewport
let rect = frame.frameElement.getBoundingClientRect();
let left = frame.getComputedStyle(frame.frameElement, "").borderLeftWidth;
let top = frame.getComputedStyle(frame.frameElement, "").borderTopWidth;
scrollX.value += rect.left + parseInt(left);
scrollY.value += rect.top + parseInt(top);
}
return {x: r.left + scrollX.value, y: r.top + scrollY.value, w: r.width, h: r.height};
}
};