mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-07 15:13:18 +00:00
Bug 777351 - Scope down and inline some functions in the new GeckoLayerClient. r=sriram
This commit is contained in:
parent
82eff50b5a
commit
f320e3d05f
@ -50,7 +50,14 @@ public class GeckoLayerClient
|
|||||||
|
|
||||||
private VirtualLayer mRootLayer;
|
private VirtualLayer mRootLayer;
|
||||||
|
|
||||||
/* The Gecko viewport as per the UI thread. Must be touched only on the UI thread. */
|
/* The Gecko viewport as per the UI thread. Must be touched only on the UI thread.
|
||||||
|
* If any events being sent to Gecko that are relative to the Gecko viewport position,
|
||||||
|
* they must (a) be relative to this viewport, and (b) be sent on the UI thread to
|
||||||
|
* avoid races. As long as these two conditions are satisfied, and the events being
|
||||||
|
* sent to Gecko are processed in FIFO order, the events will properly be relative
|
||||||
|
* to the Gecko viewport position. Note that if Gecko updates its viewport independently,
|
||||||
|
* we get notified synchronously and also update this on the UI thread.
|
||||||
|
*/
|
||||||
private ViewportMetrics mGeckoViewport;
|
private ViewportMetrics mGeckoViewport;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -160,7 +167,7 @@ public class GeckoLayerClient
|
|||||||
* Returns true if this client is fine with performing a redraw operation or false if it
|
* Returns true if this client is fine with performing a redraw operation or false if it
|
||||||
* would prefer that the action didn't take place.
|
* would prefer that the action didn't take place.
|
||||||
*/
|
*/
|
||||||
public boolean getRedrawHint() {
|
private boolean getRedrawHint() {
|
||||||
if (mForceRedraw) {
|
if (mForceRedraw) {
|
||||||
mForceRedraw = false;
|
mForceRedraw = false;
|
||||||
return true;
|
return true;
|
||||||
@ -174,7 +181,7 @@ public class GeckoLayerClient
|
|||||||
mPanZoomController.getVelocityVector(), mDisplayPort);
|
mPanZoomController.getVelocityVector(), mDisplayPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Layer getRoot() {
|
Layer getRoot() {
|
||||||
return mGeckoIsReady ? mRootLayer : null;
|
return mGeckoIsReady ? mRootLayer : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,13 +201,20 @@ public class GeckoLayerClient
|
|||||||
* to the layer client. That way, the layer client won't be tempted to call this, which might
|
* to the layer client. That way, the layer client won't be tempted to call this, which might
|
||||||
* result in an infinite loop.
|
* result in an infinite loop.
|
||||||
*/
|
*/
|
||||||
public void setViewportSize(FloatSize size) {
|
void setViewportSize(FloatSize size) {
|
||||||
ViewportMetrics viewportMetrics = new ViewportMetrics(mViewportMetrics);
|
ViewportMetrics viewportMetrics = new ViewportMetrics(mViewportMetrics);
|
||||||
viewportMetrics.setSize(size);
|
viewportMetrics.setSize(size);
|
||||||
mViewportMetrics = new ImmutableViewportMetrics(viewportMetrics);
|
mViewportMetrics = new ImmutableViewportMetrics(viewportMetrics);
|
||||||
|
|
||||||
if (mGeckoIsReady) {
|
if (mGeckoIsReady) {
|
||||||
viewportSizeChanged();
|
// here we send gecko a resize message. The code in browser.js is responsible for
|
||||||
|
// picking up on that resize event, modifying the viewport as necessary, and informing
|
||||||
|
// us of the new viewport.
|
||||||
|
sendResizeEventIfNecessary(true);
|
||||||
|
// the following call also sends gecko a message, which will be processed after the resize
|
||||||
|
// message above has updated the viewport. this message ensures that if we have just put
|
||||||
|
// focus in a text field, we scroll the content so that the text field is in view.
|
||||||
|
GeckoAppShell.viewSizeChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,18 +222,6 @@ public class GeckoLayerClient
|
|||||||
return mPanZoomController;
|
return mPanZoomController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GestureDetector.OnGestureListener getGestureListener() {
|
|
||||||
return mPanZoomController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleScaleGestureDetector.SimpleScaleGestureListener getScaleGestureListener() {
|
|
||||||
return mPanZoomController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GestureDetector.OnDoubleTapListener getDoubleTapListener() {
|
|
||||||
return mPanZoomController;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Informs Gecko that the screen size has changed. */
|
/* Informs Gecko that the screen size has changed. */
|
||||||
private void sendResizeEventIfNecessary(boolean force) {
|
private void sendResizeEventIfNecessary(boolean force) {
|
||||||
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
|
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
|
||||||
@ -251,17 +253,6 @@ public class GeckoLayerClient
|
|||||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Window:Resize", ""));
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Window:Resize", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewportSizeChanged() {
|
|
||||||
// here we send gecko a resize message. The code in browser.js is responsible for
|
|
||||||
// picking up on that resize event, modifying the viewport as necessary, and informing
|
|
||||||
// us of the new viewport.
|
|
||||||
sendResizeEventIfNecessary(true);
|
|
||||||
// the following call also sends gecko a message, which will be processed after the resize
|
|
||||||
// message above has updated the viewport. this message ensures that if we have just put
|
|
||||||
// focus in a text field, we scroll the content so that the text field is in view.
|
|
||||||
GeckoAppShell.viewSizeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the current page rect. You must hold the monitor while calling this. */
|
/** Sets the current page rect. You must hold the monitor while calling this. */
|
||||||
private void setPageRect(RectF rect, RectF cssRect) {
|
private void setPageRect(RectF rect, RectF cssRect) {
|
||||||
// Since the "rect" is always just a multiple of "cssRect" we don't need to
|
// Since the "rect" is always just a multiple of "cssRect" we don't need to
|
||||||
@ -285,7 +276,7 @@ public class GeckoLayerClient
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustViewport(DisplayPortMetrics displayPort) {
|
private void adjustViewport(DisplayPortMetrics displayPort) {
|
||||||
ImmutableViewportMetrics metrics = getViewportMetrics();
|
ImmutableViewportMetrics metrics = getViewportMetrics();
|
||||||
|
|
||||||
ViewportMetrics clampedMetrics = new ViewportMetrics(metrics);
|
ViewportMetrics clampedMetrics = new ViewportMetrics(metrics);
|
||||||
@ -373,9 +364,9 @@ public class GeckoLayerClient
|
|||||||
ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(new ViewportMetrics(message));
|
ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(new ViewportMetrics(message));
|
||||||
mReturnDisplayPort = DisplayPortCalculator.calculate(newMetrics, null);
|
mReturnDisplayPort = DisplayPortCalculator.calculate(newMetrics, null);
|
||||||
} else if ("Checkerboard:Toggle".equals(event)) {
|
} else if ("Checkerboard:Toggle".equals(event)) {
|
||||||
boolean showChecks = message.getBoolean("value");
|
mCheckerboardShouldShowChecks = message.getBoolean("value");
|
||||||
setCheckerboardShowChecks(showChecks);
|
mView.requestRender();
|
||||||
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
Log.i(LOGTAG, "Showing checks: " + mCheckerboardShouldShowChecks);
|
||||||
} else if ("Preferences:Data".equals(event)) {
|
} else if ("Preferences:Data".equals(event)) {
|
||||||
JSONArray jsonPrefs = message.getJSONArray("preferences");
|
JSONArray jsonPrefs = message.getJSONArray("preferences");
|
||||||
Map<String, Integer> prefValues = new HashMap<String, Integer>();
|
Map<String, Integer> prefValues = new HashMap<String, Integer>();
|
||||||
@ -418,31 +409,14 @@ public class GeckoLayerClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
boolean checkerboardShouldShowChecks() {
|
||||||
* This function returns the last viewport that we sent to Gecko. If any additional events are
|
|
||||||
* being sent to Gecko that are relative on the Gecko viewport position, they must (a) be relative
|
|
||||||
* to this viewport, and (b) be sent on the UI thread to avoid races. As long as these two
|
|
||||||
* conditions are satisfied, and the events being sent to Gecko are processed in FIFO order, the
|
|
||||||
* events will properly be relative to the Gecko viewport position. Note that if Gecko updates
|
|
||||||
* its viewport independently, we get notified synchronously and also update this on the UI thread.
|
|
||||||
*/
|
|
||||||
public ViewportMetrics getGeckoViewportMetrics() {
|
|
||||||
return mGeckoViewport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkerboardShouldShowChecks() {
|
|
||||||
return mCheckerboardShouldShowChecks;
|
return mCheckerboardShouldShowChecks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCheckerboardColor() {
|
int getCheckerboardColor() {
|
||||||
return mCheckerboardColor;
|
return mCheckerboardColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckerboardShowChecks(boolean showChecks) {
|
|
||||||
mCheckerboardShouldShowChecks = showChecks;
|
|
||||||
mView.requestRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCheckerboardColor(int newColor) {
|
public void setCheckerboardColor(int newColor) {
|
||||||
mCheckerboardColor = newColor;
|
mCheckerboardColor = newColor;
|
||||||
mView.requestRender();
|
mView.requestRender();
|
||||||
@ -584,7 +558,7 @@ public class GeckoLayerClient
|
|||||||
mLayerRenderer.deactivateDefaultProgram();
|
mLayerRenderer.deactivateDefaultProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
void geometryChanged() {
|
private void geometryChanged() {
|
||||||
/* Let Gecko know if the screensize has changed */
|
/* Let Gecko know if the screensize has changed */
|
||||||
sendResizeEventIfNecessary(false);
|
sendResizeEventIfNecessary(false);
|
||||||
if (getRedrawHint()) {
|
if (getRedrawHint()) {
|
||||||
@ -707,7 +681,7 @@ public class GeckoLayerClient
|
|||||||
ImmutableViewportMetrics viewportMetrics = mViewportMetrics;
|
ImmutableViewportMetrics viewportMetrics = mViewportMetrics;
|
||||||
PointF origin = viewportMetrics.getOrigin();
|
PointF origin = viewportMetrics.getOrigin();
|
||||||
float zoom = viewportMetrics.zoomFactor;
|
float zoom = viewportMetrics.zoomFactor;
|
||||||
ViewportMetrics geckoViewport = getGeckoViewportMetrics();
|
ViewportMetrics geckoViewport = mGeckoViewport;
|
||||||
PointF geckoOrigin = geckoViewport.getOrigin();
|
PointF geckoOrigin = geckoViewport.getOrigin();
|
||||||
float geckoZoom = geckoViewport.getZoomFactor();
|
float geckoZoom = geckoViewport.getZoomFactor();
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
|
|||||||
mView = view;
|
mView = view;
|
||||||
|
|
||||||
mEventQueue = new LinkedList<MotionEvent>();
|
mEventQueue = new LinkedList<MotionEvent>();
|
||||||
mGestureDetector = new GestureDetector(context, layerClient.getGestureListener());
|
|
||||||
mScaleGestureDetector = new SimpleScaleGestureDetector(layerClient.getScaleGestureListener());
|
|
||||||
mPanZoomController = layerClient.getPanZoomController();
|
mPanZoomController = layerClient.getPanZoomController();
|
||||||
|
mGestureDetector = new GestureDetector(context, mPanZoomController);
|
||||||
|
mScaleGestureDetector = new SimpleScaleGestureDetector(mPanZoomController);
|
||||||
mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
|
mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
|
||||||
mDispatchEvents = true;
|
mDispatchEvents = true;
|
||||||
|
|
||||||
mGestureDetector.setOnDoubleTapListener(layerClient.getDoubleTapListener());
|
mGestureDetector.setOnDoubleTapListener(mPanZoomController);
|
||||||
|
|
||||||
Tabs.registerOnTabsChangedListener(this);
|
Tabs.registerOnTabsChangedListener(this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user