[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 6 commits - android/Bootstrap android/experimental
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue Jan 27 22:46:49 PST 2015
android/Bootstrap/src/org/libreoffice/kit/Document.java | 9
android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java | 7
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitInputConnectionHandler.java | 41 +
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java | 15
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 8
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 81 +-
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 11
android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java | 5
android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java | 8
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 114 ----
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java | 274 +++++-----
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java | 90 +++
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomController.java | 10
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomTarget.java | 2
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java | 55 --
15 files changed, 414 insertions(+), 316 deletions(-)
New commits:
commit 793354e317a225a14f4551ad9f192454f29a4d68
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed Jan 28 14:22:16 2015 +0900
android: get LayerView from LOKitShell
Change-Id: I4fa3f7b0906eabd41d9e44a8780c2cc62241b41d
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index dcb266c..401608e 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -9,6 +9,8 @@ import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import org.mozilla.gecko.gfx.LayerView;
+
public class LOKitShell {
private static final String LOGTAG = LOKitShell.class.getSimpleName();
@@ -94,4 +96,8 @@ public class LOKitShell {
public static boolean isEditingEnabled() {
return false;
}
+
+ public static LayerView getLayerView() {
+ return LibreOfficeMainActivity.mAppContext.getLayerClient().getView();
+ }
}
commit 4a9548b40ea1087eaad49ced1f9ca245f4c505f7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed Jan 28 14:15:16 2015 +0900
android: Use callback types, extract string to rect conversion
Change LOKitTileProvider to use callback types defined in Document.
Extract conversion from payload string to rect into its own method
and use it in INVALIDATE_TILES and INVALIDATE_VISIBLE_CURSOR.
Change-Id: Ic908fb187568d4b6fd73770448198e1e752cc2c6
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 357fa03..3e3412a7 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -339,31 +339,49 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
return mDocument.getPart();
}
+ private RectF convertCallbackMessageStringToRectF(String text) {
+ if (text.equals("EMPTY")) {
+ return null;
+ }
+
+ String[] coordinates = text.split(",");
+
+ if (coordinates.length != 4) {
+ return null;
+ }
+ int width = Integer.decode(coordinates[0].trim());
+ int height = Integer.decode(coordinates[1].trim());
+ int x = Integer.decode(coordinates[2].trim());
+ int y = Integer.decode(coordinates[3].trim());
+ RectF rect = new RectF(
+ twipToPixel(x, mDPI),
+ twipToPixel(y, mDPI),
+ twipToPixel(x + width, mDPI),
+ twipToPixel(y + height, mDPI)
+ );
+ return rect;
+ }
+
/**
* Process the retrieved messages from LOK
*/
@Override
public void messageRetrieved(int signalNumber, String payload) {
switch (signalNumber) {
- case 0:
- if (!payload.equals("EMPTY")) {
- String[] coordinates = payload.split(",");
-
- if (coordinates.length == 4) {
- int width = Integer.decode(coordinates[0].trim());
- int height = Integer.decode(coordinates[1].trim());
- int x = Integer.decode(coordinates[2].trim());
- int y = Integer.decode(coordinates[3].trim());
- RectF rect = new RectF(
- twipToPixel(x, mDPI),
- twipToPixel(y, mDPI),
- twipToPixel(x + width, mDPI),
- twipToPixel(y + height, mDPI)
- );
- tileInvalidationCallback.invalidate(rect);
- }
+ case Document.CALLBACK_INVALIDATE_TILES: {
+ RectF rect = convertCallbackMessageStringToRectF(payload);
+ if (rect != null) {
+ tileInvalidationCallback.invalidate(rect);
+ }
+ break;
+ }
+ case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR: {
+ RectF rect = convertCallbackMessageStringToRectF(payload);
+ if (rect != null) {
+ //tileInvalidationCallback.invalidate(rect);
}
break;
+ }
}
}
}
commit 9ce1b62655d2c2b0fe9f89cc8aceeca00b5b22e7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed Jan 28 14:03:52 2015 +0900
android: Add callback types to Document
Change-Id: I93d117d42b6ccf48b58f9c8d64be0266ff36c6f3
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 3cd9b0e..6966d29 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -26,10 +26,19 @@ public class Document {
public static final int DOCTYPE_DRAWING = 3;
public static final int DOCTYPE_OTHER = 4;
+ /**
+ * Mouse event types
+ */
public static final int MOUSE_BUTTON_DOWN = 0;
public static final int MOUSE_BUTTON_UP = 1;
public static final int MOUSE_MOVE = 2;
+ /**
+ * Callback message types
+ */
+ public static final int CALLBACK_INVALIDATE_TILES = 0;
+ public static final int CALLBACK_INVALIDATE_VISIBLE_CURSOR = 1;
+
private final ByteBuffer handle;
private MessageCallback messageCallback = null;
commit 9d402c904f55a8be20d3c899557047cd0833efc8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed Jan 28 13:50:40 2015 +0900
android: key press to key event, use InputConnectionHandler
Change key press event in LOEvent to a more general key event to
support key release.
Use InputConnectionHandler to react on key events, create
LOKitInputConnectionHandler as the implementation for LOKit.
Change-Id: I4282aa06cdd85ad4d80330f4d2a9c43eb67df30a
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
index 11bd72d..a9600ea 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
@@ -19,7 +19,7 @@ public class LOEvent implements Comparable<LOEvent> {
public static final int THUMBNAIL = 8;
public static final int TILE_RERENDER = 9;
public static final int TOUCH = 10;
- public static final int KEY_PRESS = 11;
+ public static final int KEY_EVENT = 11;
public final int mType;
public int mPriority = 0;
@@ -35,6 +35,7 @@ public class LOEvent implements Comparable<LOEvent> {
public String mTouchType;
public MotionEvent mMotionEvent;
public PointF mDocumentTouchCoordinate;
+ public String mKeyEventType;
public KeyEvent mKeyEvent;
public LOEvent(int type) {
@@ -91,8 +92,10 @@ public class LOEvent implements Comparable<LOEvent> {
mDocumentTouchCoordinate = documentTouchCoordinate;
}
- public LOEvent(int type, KeyEvent keyEvent) {
+ public LOEvent(int type, String keyEventType, KeyEvent keyEvent) {
mType = type;
+ mTypeString = "KeyEvent";
+ mKeyEventType = keyEventType;
mKeyEvent = keyEvent;
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitInputConnectionHandler.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitInputConnectionHandler.java
new file mode 100644
index 0000000..a63b28d
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitInputConnectionHandler.java
@@ -0,0 +1,41 @@
+package org.libreoffice;
+
+import android.view.KeyEvent;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+
+import org.mozilla.gecko.gfx.InputConnectionHandler;
+
+public class LOKitInputConnectionHandler implements InputConnectionHandler {
+ @Override
+ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
+ return null;
+ }
+
+ @Override
+ public boolean onKeyPreIme(int keyCode, KeyEvent event) {
+ return false;
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ LOKitShell.sendKeyPressEvent(event);
+ return true;
+ }
+
+ @Override
+ public boolean onKeyLongPress(int keyCode, KeyEvent event) {
+ return false;
+ }
+
+ @Override
+ public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
+ return false;
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ LOKitShell.sendKeyReleaseEvent(event);
+ return false;
+ }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 0f606ed..dcb266c 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -81,7 +81,14 @@ public class LOKitShell {
* Send key press event to LOKitThread.
*/
public static void sendKeyPressEvent(KeyEvent event) {
- LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_PRESS, event));
+ LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_EVENT, "KeyPress", event));
+ }
+
+ /**
+ * Send key release event to LOKitThread.
+ */
+ public static void sendKeyReleaseEvent(KeyEvent event) {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_EVENT, "KeyRelease", event));
}
public static boolean isEditingEnabled() {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a185d79..c8bcc23 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -153,11 +153,15 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
}
touch(event.mTouchType, event.mMotionEvent, event.mDocumentTouchCoordinate);
break;
- case LOEvent.KEY_PRESS:
+ case LOEvent.KEY_EVENT:
if (!LOKitShell.isEditingEnabled()) {
return;
}
- mTileProvider.keyPress(event.mKeyEvent);
+ if (event.mKeyEventType == "KeyPress") {
+ mTileProvider.keyPress(event.mKeyEvent);
+ } else if (event.mKeyEventType.equals("KeyRelease")) {
+ mTileProvider.keyRelease(event.mKeyEvent);
+ }
break;
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 1ace50f..357fa03 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -277,24 +277,29 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
this.tileInvalidationCallback = tileInvalidationCallback;
}
- @Override
- public void keyPress(KeyEvent keyEvent) {
- int code = 0;
+ private int getKeyCode(KeyEvent keyEvent) {
switch (keyEvent.getKeyCode())
{
- case KeyEvent.KEYCODE_DEL:
- code = com.sun.star.awt.Key.BACKSPACE;
- break;
- case KeyEvent.KEYCODE_ENTER:
- code = com.sun.star.awt.Key.RETURN;
- break;
- default:
- code = keyEvent.getUnicodeChar();
- break;
+ case KeyEvent.KEYCODE_DEL:
+ return com.sun.star.awt.Key.BACKSPACE;
+ case KeyEvent.KEYCODE_ENTER:
+ return com.sun.star.awt.Key.RETURN;
}
+ return keyEvent.getUnicodeChar();
+ }
+
+ @Override
+ public void keyPress(KeyEvent keyEvent) {
+ int code = getKeyCode(keyEvent);
mOffice.postKeyEvent(Office.KEY_PRESS, code);
}
+ @Override
+ public void keyRelease(KeyEvent keyEvent) {
+ int code = getKeyCode(keyEvent);
+ mOffice.postKeyEvent(Office.KEY_RELEASE, code);
+ }
+
private void mouseButton(int type, PointF inDocument) {
int x = (int) pixelToTwip(inDocument.x, mDPI);
int y = (int) pixelToTwip(inDocument.y, mDPI);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 1b20328..bca8230 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -128,6 +128,7 @@ public class LibreOfficeMainActivity extends LOAbout {
mLayerClient.setZoomConstraints(new ZoomConstraints(true));
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
mLayerClient.setView(layerView);
+ layerView.setInputConnectionHandler(new LOKitInputConnectionHandler());
mLayerClient.notifyReady();
}
@@ -238,16 +239,6 @@ public class LibreOfficeMainActivity extends LOAbout {
mDrawerLayout.closeDrawer(mDrawerList);
}
}
-
-
- /**
- * Listen to key presses and send event to LOK.
- */
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- LOKitShell.sendKeyPressEvent(event);
- return super.onKeyDown(keyCode, event);
- }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index f68678a..006ae90 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -93,6 +93,11 @@ public class MockTileProvider implements TileProvider {
}
@Override
+ public void keyRelease(KeyEvent keyEvent) {
+
+ }
+
+ @Override
public void mouseButtonDown(PointF inDocument) {
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index a411879..759ecad 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -63,11 +63,17 @@ public interface TileProvider {
/**
* Trigger a key press.
- * @param keyEvent - contains the
+ * @param keyEvent - contains information about key event
*/
void keyPress(KeyEvent keyEvent);
/**
+ * Trigger a key release.
+ * @param keyEvent - contains information about key event
+ */
+ void keyRelease(KeyEvent keyEvent);
+
+ /**
* Trigger a mouse button down event.
* @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
*/
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index 167da84..345fa4d 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -147,6 +147,10 @@ public class LayerView extends FrameLayout {
});
}
+ public void setInputConnectionHandler(InputConnectionHandler inputConnectionHandler) {
+ mInputConnectionHandler = inputConnectionHandler;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
commit 26e100aa3bd0f08ed9949ee5183c9709e819ef11
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 27 16:42:23 2015 +0900
android: move TouchEventHandler into JavaPanZoomController
Change-Id: I6de3c0cdf3a0ec646fd63c9cc2c5a9a153e3e574
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index e1a12bd..644ef46 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -61,7 +61,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
/* The new color for the checkerboard. */
private int mCheckerboardColor;
- private final PanZoomController mPanZoomController;
+ private PanZoomController mPanZoomController;
private LayerView mView;
public GeckoLayerClient(Context context) {
@@ -75,12 +75,11 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
mViewportMetrics = new ImmutableViewportMetrics(displayMetrics);
mZoomConstraints = new ZoomConstraints(false);
-
- mPanZoomController = PanZoomController.Factory.create(this);
}
public void setView(LayerView view) {
mView = view;
+ mPanZoomController = PanZoomController.Factory.create(this, view);
mView.connect(this);
}
@@ -347,6 +346,11 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
return layerPoint;
}
+ @Override
+ public boolean isFullScreen() {
+ return false;
+ }
+
public void destroy() {
mPanZoomController.destroy();
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
index 595657f..af3f11c 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -7,10 +7,13 @@ package org.mozilla.gecko.gfx;
import android.graphics.PointF;
import android.graphics.RectF;
+import android.os.Build;
import android.util.FloatMath;
import android.util.Log;
import android.view.GestureDetector;
+import android.view.InputDevice;
import android.view.MotionEvent;
+import android.view.View;
import org.libreoffice.LOKitShell;
import org.libreoffice.LibreOfficeMainActivity;
@@ -74,7 +77,7 @@ public class JavaPanZoomController
private final SubdocumentScrollHelper mSubscroller;
private final Axis mX;
private final Axis mY;
-
+ private final TouchEventHandler mTouchEventHandler;
private Thread mMainThread;
/* The timer that handles flings or bounces. */
@@ -90,11 +93,12 @@ public class JavaPanZoomController
/* Whether or not to wait for a double-tap before dispatching a single-tap */
private boolean mWaitForDoubleTap;
- public JavaPanZoomController(PanZoomTarget target) {
+ public JavaPanZoomController(PanZoomTarget target, View view) {
mTarget = target;
mSubscroller = new SubdocumentScrollHelper();
mX = new AxisX(mSubscroller);
mY = new AxisY(mSubscroller);
+ mTouchEventHandler = new TouchEventHandler(view.getContext(), view, this);
mMainThread = LibreOfficeMainActivity.mAppContext.getMainLooper().getThread();
checkMainThread();
@@ -104,6 +108,7 @@ public class JavaPanZoomController
public void destroy() {
mSubscroller.destroy();
+ mTouchEventHandler.destroy();
}
private final static float easeOut(float t) {
@@ -131,15 +136,40 @@ public class JavaPanZoomController
}
}
+ /** This function MUST be called on the UI thread */
+ public boolean onMotionEvent(MotionEvent event) {
+ if (Build.VERSION.SDK_INT <= 11) {
+ return false;
+ }
+
+ switch (event.getSource() & InputDevice.SOURCE_CLASS_MASK) {
+ case InputDevice.SOURCE_CLASS_POINTER:
+ switch (event.getAction() & MotionEvent.ACTION_MASK) {
+ case MotionEvent.ACTION_SCROLL: return handlePointerScroll(event);
+ }
+ break;
+ }
+ return false;
+ }
+
+ /** This function MUST be called on the UI thread */
public boolean onTouchEvent(MotionEvent event) {
+ return mTouchEventHandler.handleEvent(event);
+ }
+
+ boolean handleEvent(MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: return onTouchStart(event);
- case MotionEvent.ACTION_MOVE: return onTouchMove(event);
- case MotionEvent.ACTION_UP: return onTouchEnd(event);
- case MotionEvent.ACTION_CANCEL: return onTouchCancel(event);
- case MotionEvent.ACTION_SCROLL: return onScroll(event);
- default: return false;
+ case MotionEvent.ACTION_DOWN: return handleTouchStart(event);
+ case MotionEvent.ACTION_MOVE: return handleTouchMove(event);
+ case MotionEvent.ACTION_UP: return handleTouchEnd(event);
+ case MotionEvent.ACTION_CANCEL: return handleTouchCancel(event);
}
+ return false;
+ }
+
+ /** This function MUST be called on the UI thread */
+ public void notifyDefaultActionPrevented(boolean prevented) {
+ mTouchEventHandler.handleEventListenerAction(!prevented);
}
/** This function must be called from the UI thread. */
@@ -150,24 +180,24 @@ public class JavaPanZoomController
// snaps to edges. for other cases (where the user's finger(s) are down) don't do
// anything special.
switch (mState) {
- case FLING:
- mX.stopFling();
- mY.stopFling();
- // fall through
- case BOUNCE:
- case ANIMATED_ZOOM:
- // the zoom that's in progress likely makes no sense any more (such as if
- // the screen orientation changed) so abort it
- setState(PanZoomState.NOTHING);
- // fall through
- case NOTHING:
- // Don't do animations here; they're distracting and can cause flashes on page
- // transitions.
- synchronized (mTarget.getLock()) {
- mTarget.setViewportMetrics(getValidViewportMetrics());
- mTarget.forceRedraw();
- }
- break;
+ case FLING:
+ mX.stopFling();
+ mY.stopFling();
+ // fall through
+ case BOUNCE:
+ case ANIMATED_ZOOM:
+ // the zoom that's in progress likely makes no sense any more (such as if
+ // the screen orientation changed) so abort it
+ setState(PanZoomState.NOTHING);
+ // fall through
+ case NOTHING:
+ // Don't do animations here; they're distracting and can cause flashes on page
+ // transitions.
+ synchronized (mTarget.getLock()) {
+ mTarget.setViewportMetrics(getValidViewportMetrics());
+ mTarget.forceRedraw();
+ }
+ break;
}
}
@@ -212,122 +242,123 @@ public class JavaPanZoomController
* Panning/scrolling
*/
- private boolean onTouchStart(MotionEvent event) {
+ private boolean handleTouchStart(MotionEvent event) {
// user is taking control of movement, so stop
// any auto-movement we have going
stopAnimationTimer();
switch (mState) {
- case ANIMATED_ZOOM:
- // We just interrupted a double-tap animation, so force a redraw in
- // case this touchstart is just a tap that doesn't end up triggering
- // a redraw
- mTarget.forceRedraw();
- // fall through
- case FLING:
- case BOUNCE:
- case NOTHING:
- case WAITING_LISTENERS:
- startTouch(event.getX(0), event.getY(0), event.getEventTime());
- return false;
- case TOUCHING:
- case PANNING:
- case PANNING_LOCKED:
- case PANNING_HOLD:
- case PANNING_HOLD_LOCKED:
- case PINCHING:
- Log.e(LOGTAG, "Received impossible touch down while in " + mState);
- return false;
+ case ANIMATED_ZOOM:
+ // We just interrupted a double-tap animation, so force a redraw in
+ // case this touchstart is just a tap that doesn't end up triggering
+ // a redraw
+ mTarget.forceRedraw();
+ // fall through
+ case FLING:
+ case BOUNCE:
+ case NOTHING:
+ case WAITING_LISTENERS:
+ startTouch(event.getX(0), event.getY(0), event.getEventTime());
+ return false;
+ case TOUCHING:
+ case PANNING:
+ case PANNING_LOCKED:
+ case PANNING_HOLD:
+ case PANNING_HOLD_LOCKED:
+ case PINCHING:
+ Log.e(LOGTAG, "Received impossible touch down while in " + mState);
+ return false;
}
- Log.e(LOGTAG, "Unhandled case " + mState + " in onTouchStart");
+ Log.e(LOGTAG, "Unhandled case " + mState + " in handleTouchStart");
return false;
}
- private boolean onTouchMove(MotionEvent event) {
+ private boolean handleTouchMove(MotionEvent event) {
switch (mState) {
- case FLING:
- case BOUNCE:
- case WAITING_LISTENERS:
- // should never happen
- Log.e(LOGTAG, "Received impossible touch move while in " + mState);
- // fall through
- case ANIMATED_ZOOM:
- case NOTHING:
- // may happen if user double-taps and drags without lifting after the
- // second tap. ignore the move if this happens.
- return false;
+ case FLING:
+ case BOUNCE:
+ case WAITING_LISTENERS:
+ // should never happen
+ Log.e(LOGTAG, "Received impossible touch move while in " + mState);
+ // fall through
+ case ANIMATED_ZOOM:
+ case NOTHING:
+ // may happen if user double-taps and drags without lifting after the
+ // second tap. ignore the move if this happens.
+ return false;
- case TOUCHING:
- if (panDistance(event) < PAN_THRESHOLD) {
- return false;
- }
- cancelTouch();
- startPanning(event.getX(0), event.getY(0), event.getEventTime());
- track(event);
- return true;
+ case TOUCHING:
+ // Don't allow panning if there is an element in full-screen mode. See bug 775511.
+ if (mTarget.isFullScreen() || panDistance(event) < PAN_THRESHOLD) {
+ return false;
+ }
+ cancelTouch();
+ startPanning(event.getX(0), event.getY(0), event.getEventTime());
+ track(event);
+ return true;
- case PANNING_HOLD_LOCKED:
- setState(PanZoomState.PANNING_LOCKED);
- // fall through
- case PANNING_LOCKED:
- track(event);
- return true;
+ case PANNING_HOLD_LOCKED:
+ setState(PanZoomState.PANNING_LOCKED);
+ // fall through
+ case PANNING_LOCKED:
+ track(event);
+ return true;
- case PANNING_HOLD:
- setState(PanZoomState.PANNING);
- // fall through
- case PANNING:
- track(event);
- return true;
+ case PANNING_HOLD:
+ setState(PanZoomState.PANNING);
+ // fall through
+ case PANNING:
+ track(event);
+ return true;
- case PINCHING:
- // scale gesture listener will handle this
- return false;
+ case PINCHING:
+ // scale gesture listener will handle this
+ return false;
}
- Log.e(LOGTAG, "Unhandled case " + mState + " in onTouchMove");
+ Log.e(LOGTAG, "Unhandled case " + mState + " in handleTouchMove");
return false;
}
- private boolean onTouchEnd(MotionEvent event) {
+ private boolean handleTouchEnd(MotionEvent event) {
switch (mState) {
- case FLING:
- case BOUNCE:
- case WAITING_LISTENERS:
- // should never happen
- Log.e(LOGTAG, "Received impossible touch end while in " + mState);
- // fall through
- case ANIMATED_ZOOM:
- case NOTHING:
- // may happen if user double-taps and drags without lifting after the
- // second tap. ignore if this happens.
- return false;
+ case FLING:
+ case BOUNCE:
+ case WAITING_LISTENERS:
+ // should never happen
+ Log.e(LOGTAG, "Received impossible touch end while in " + mState);
+ // fall through
+ case ANIMATED_ZOOM:
+ case NOTHING:
+ // may happen if user double-taps and drags without lifting after the
+ // second tap. ignore if this happens.
+ return false;
- case TOUCHING:
- // the switch into TOUCHING might have happened while the page was
- // snapping back after overscroll. we need to finish the snap if that
- // was the case
- bounce();
- return false;
+ case TOUCHING:
+ // the switch into TOUCHING might have happened while the page was
+ // snapping back after overscroll. we need to finish the snap if that
+ // was the case
+ bounce();
+ return false;
- case PANNING:
- case PANNING_LOCKED:
- case PANNING_HOLD:
- case PANNING_HOLD_LOCKED:
- setState(PanZoomState.FLING);
- fling();
- return true;
+ case PANNING:
+ case PANNING_LOCKED:
+ case PANNING_HOLD:
+ case PANNING_HOLD_LOCKED:
+ setState(PanZoomState.FLING);
+ fling();
+ return true;
- case PINCHING:
- setState(PanZoomState.NOTHING);
- return true;
+ case PINCHING:
+ setState(PanZoomState.NOTHING);
+ return true;
}
- Log.e(LOGTAG, "Unhandled case " + mState + " in onTouchEnd");
+ Log.e(LOGTAG, "Unhandled case " + mState + " in handleTouchEnd");
return false;
}
- private boolean onTouchCancel(MotionEvent event) {
+ private boolean handleTouchCancel(MotionEvent event) {
cancelTouch();
if (mState == PanZoomState.WAITING_LISTENERS) {
@@ -345,7 +376,7 @@ public class JavaPanZoomController
return false;
}
- private boolean onScroll(MotionEvent event) {
+ private boolean handlePointerScroll(MotionEvent event) {
if (mState == PanZoomState.NOTHING || mState == PanZoomState.FLING) {
float scrollX = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
float scrollY = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
@@ -414,8 +445,8 @@ public class JavaPanZoomController
for (int i = 0; i < event.getHistorySize(); i++) {
track(event.getHistoricalX(0, i),
- event.getHistoricalY(0, i),
- event.getHistoricalEventTime(i));
+ event.getHistoricalY(0, i),
+ event.getHistoricalEventTime(i));
}
track(event.getX(0), event.getY(0), event.getEventTime());
@@ -791,6 +822,9 @@ public class JavaPanZoomController
@Override
public boolean onScale(SimpleScaleGestureDetector detector) {
+ if (mTarget.isFullScreen())
+ return false;
+
if (mState != PanZoomState.PINCHING)
return false;
@@ -834,7 +868,7 @@ public class JavaPanZoomController
}
scrollBy(mLastZoomFocus.x - detector.getFocusX(),
- mLastZoomFocus.y - detector.getFocusY());
+ mLastZoomFocus.y - detector.getFocusY());
PointF focus = new PointF(detector.getFocusX(), detector.getFocusY());
scaleWithFocus(newZoomFactor, focus);
}
@@ -867,7 +901,6 @@ public class JavaPanZoomController
mTarget.setViewportMetrics(viewportMetrics);
}
- @Override
public boolean getRedrawHint() {
switch (mState) {
case PINCHING:
@@ -989,19 +1022,16 @@ public class JavaPanZoomController
}
/** This function must be called from the UI thread. */
- @Override
public void abortPanning() {
checkMainThread();
bounce();
}
- @Override
public void setOverScrollMode(int overscrollMode) {
mX.setOverScrollMode(overscrollMode);
mY.setOverScrollMode(overscrollMode);
}
- @Override
public int getOverScrollMode() {
return mX.getOverScrollMode();
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index c6b4e2e..167da84 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -29,6 +29,7 @@ import android.widget.FrameLayout;
import org.libreoffice.LibreOfficeMainActivity;
import org.libreoffice.R;
+import org.mozilla.gecko.OnInterceptTouchListener;
import java.lang.reflect.Method;
import java.nio.IntBuffer;
@@ -45,7 +46,7 @@ public class LayerView extends FrameLayout {
private static String LOGTAG = LayerView.class.getName();
private GeckoLayerClient mLayerClient;
- private TouchEventHandler mTouchEventHandler;
+ private PanZoomController mPanZoomController;
private GLController mGLController;
private InputConnectionHandler mInputConnectionHandler;
private LayerRenderer mRenderer;
@@ -53,11 +54,13 @@ public class LayerView extends FrameLayout {
private boolean mRenderTimeReset;
/* Must be a PAINT_xxx constant */
private int mPaintState = PAINT_NONE;
+ private boolean mFullScreen = false;
private SurfaceView mSurfaceView;
private TextureView mTextureView;
private Listener mListener;
+ private OnInterceptTouchListener mTouchIntercepter;
/* Flags used to determine when to show the painted surface. The integer
* order must correspond to the order in which these states occur. */
@@ -105,7 +108,7 @@ public class LayerView extends FrameLayout {
void connect(GeckoLayerClient layerClient) {
mLayerClient = layerClient;
- mTouchEventHandler = new TouchEventHandler(getContext(), this, layerClient);
+ mPanZoomController = mLayerClient.getPanZoomController();
mRenderer = new LayerRenderer(this);
mInputConnectionHandler = null;
@@ -115,26 +118,81 @@ public class LayerView extends FrameLayout {
createGLThread();
}
+ public void show() {
+ // Fix this if TextureView support is turned back on above
+ mSurfaceView.setVisibility(View.VISIBLE);
+ }
+
+ public void hide() {
+ // Fix this if TextureView support is turned back on above
+ mSurfaceView.setVisibility(View.INVISIBLE);
+ }
+
+ public void destroy() {
+ if (mLayerClient != null) {
+ mLayerClient.destroy();
+ }
+ if (mRenderer != null) {
+ mRenderer.destroy();
+ }
+ }
+
+ public void setTouchIntercepter(final OnInterceptTouchListener touchIntercepter) {
+ // this gets run on the gecko thread, but for thread safety we want the assignment
+ // on the UI thread.
+ post(new Runnable() {
+ public void run() {
+ mTouchIntercepter = touchIntercepter;
+ }
+ });
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN)
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
requestFocus();
- return mTouchEventHandler.handleEvent(event);
+ }
+
+ if (mTouchIntercepter != null && mTouchIntercepter.onInterceptTouchEvent(this, event)) {
+ return true;
+ }
+ if (mPanZoomController != null && mPanZoomController.onTouchEvent(event)) {
+ return true;
+ }
+ if (mTouchIntercepter != null && mTouchIntercepter.onTouch(this, event)) {
+ return true;
+ }
+ return false;
}
@Override
public boolean onHoverEvent(MotionEvent event) {
- return mTouchEventHandler.handleEvent(event);
+ if (mTouchIntercepter != null && mTouchIntercepter.onTouch(this, event)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ if (mPanZoomController != null && mPanZoomController.onMotionEvent(event)) {
+ return true;
+ }
+ return false;
}
public GeckoLayerClient getLayerClient() { return mLayerClient; }
- public TouchEventHandler getTouchEventHandler() { return mTouchEventHandler; }
+ public PanZoomController getPanZoomController() { return mPanZoomController; }
/** The LayerRenderer calls this to indicate that the window has changed size. */
public void setViewportSize(IntSize size) {
mLayerClient.setViewportSize(new FloatSize(size));
}
+ public ImmutableViewportMetrics getViewportMetrics() {
+ return mLayerClient.getViewportMetrics();
+ }
+
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (mInputConnectionHandler != null)
@@ -177,6 +235,13 @@ public class LayerView extends FrameLayout {
return false;
}
+ public boolean isIMEEnabled() {
+ /*if (mInputConnectionHandler != null) {
+ return mInputConnectionHandler.isIMEEnabled();
+ }*/
+ return false;
+ }
+
public void requestRender() {
if (mRenderControllerThread != null) {
mRenderControllerThread.renderFrame();
@@ -242,7 +307,6 @@ public class LayerView extends FrameLayout {
return mPaintState;
}
-
public LayerRenderer getRenderer() {
return mRenderer;
}
@@ -422,4 +486,12 @@ public class LayerView extends FrameLayout {
super(e);
}
}
+
+ public void setFullScreen(boolean fullScreen) {
+ mFullScreen = fullScreen;
+ }
+
+ public boolean isFullScreen() {
+ return mFullScreen;
+ }
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomController.java
index 86036bb..829ffd5 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomController.java
@@ -6,6 +6,8 @@
package org.mozilla.gecko.gfx;
import android.graphics.PointF;
+import android.view.MotionEvent;
+import android.view.View;
import org.libreoffice.LOKitShell;
@@ -15,13 +17,17 @@ public interface PanZoomController {
public static final float PAN_THRESHOLD = 1/16f * LOKitShell.getDpi();
static class Factory {
- static PanZoomController create(PanZoomTarget target) {
- return new JavaPanZoomController(target);
+ static PanZoomController create(PanZoomTarget target, View view) {
+ return new JavaPanZoomController(target, view);
}
}
public void destroy();
+ public boolean onTouchEvent(MotionEvent event);
+ public boolean onMotionEvent(MotionEvent event);
+ public void notifyDefaultActionPrevented(boolean prevented);
+
public boolean getRedrawHint();
public PointF getVelocityVector();
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomTarget.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomTarget.java
index f79819c..88e1b21 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomTarget.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/PanZoomTarget.java
@@ -21,4 +21,6 @@ public interface PanZoomTarget {
public boolean post(Runnable action);
public Object getLock();
public PointF convertViewPointToLayerPoint(PointF viewPoint);
+
+ boolean isFullScreen();
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
index cba3802..4ac5146 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
@@ -11,6 +11,7 @@ import android.os.SystemClock;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
+import android.view.View;
import org.mozilla.gecko.OnInterceptTouchListener;
@@ -54,7 +55,7 @@ public final class TouchEventHandler {
// before we begin panning the page
private final int EVENT_LISTENER_TIMEOUT = 200;
- private final LayerView mView;
+ private final View mView;
private final GestureDetector mGestureDetector;
private final SimpleScaleGestureDetector mScaleGestureDetector;
private final JavaPanZoomController mPanZoomController;
@@ -64,9 +65,6 @@ public final class TouchEventHandler {
private final Queue<MotionEvent> mEventQueue;
private final ListenerTimeoutProcessor mListenerTimeoutProcessor;
- // the listener we use to notify gecko of touch events
- private OnInterceptTouchListener mOnTouchListener;
-
// whether or not we should wait for touch listeners to respond (this state is
// per-tab and is updated when we switch tabs).
private boolean mWaitForTouchListeners;
@@ -122,11 +120,11 @@ public final class TouchEventHandler {
// processed. (n is the absolute value of the balance.)
private int mProcessingBalance;
- TouchEventHandler(Context context, LayerView view, GeckoLayerClient layerClient) {
+ TouchEventHandler(Context context, View view, JavaPanZoomController panZoomController) {
mView = view;
mEventQueue = new LinkedList<MotionEvent>();
- mPanZoomController = (JavaPanZoomController)layerClient.getPanZoomController();
+ mPanZoomController = panZoomController;
mGestureDetector = new GestureDetector(context, mPanZoomController);
mScaleGestureDetector = new SimpleScaleGestureDetector(mPanZoomController);
mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
@@ -140,28 +138,6 @@ public final class TouchEventHandler {
/* This function MUST be called on the UI thread */
public boolean handleEvent(MotionEvent event) {
- // if we don't have gecko listeners, just dispatch the event
- // and be done with it, no extra work needed.
- if (mOnTouchListener == null) {
- dispatchEvent(event);
- return true;
- }
-
- if (mOnTouchListener.onInterceptTouchEvent(mView, event)) {
- return true;
- }
-
- // if this is a hover event just notify gecko, we don't have any interest in the java layer.
- if (isHoverEvent(event)) {
- mOnTouchListener.onTouch(mView, event);
- return true;
- }
-
- if (isScrollEvent(event)) {
- dispatchEvent(event);
- return true;
- }
-
if (isDownEvent(event)) {
// this is the start of a new block of events! whee!
mHoldInQueue = mWaitForTouchListeners;
@@ -204,9 +180,6 @@ public final class TouchEventHandler {
mPanZoomController.preventedTouchFinished();
}
- // notify gecko of the event
- mOnTouchListener.onTouch(mView, event);
-
return true;
}
@@ -235,16 +208,6 @@ public final class TouchEventHandler {
mWaitForTouchListeners = aValue;
}
- /* This function MUST be called on the UI thread. */
- public void setOnTouchListener(OnInterceptTouchListener onTouchListener) {
- mOnTouchListener = onTouchListener;
- }
-
- private boolean isHoverEvent(MotionEvent event) {
- int action = (event.getAction() & MotionEvent.ACTION_MASK);
- return (action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_MOVE || action == MotionEvent.ACTION_HOVER_EXIT);
- }
-
private boolean isDownEvent(MotionEvent event) {
int action = (event.getAction() & MotionEvent.ACTION_MASK);
return (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN);
@@ -255,14 +218,6 @@ public final class TouchEventHandler {
return (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL);
}
- private boolean isScrollEvent(MotionEvent event) {
- if (Build.VERSION.SDK_INT <= 11) {
- return false;
- }
- int action = (event.getAction() & MotionEvent.ACTION_MASK);
- return (action == MotionEvent.ACTION_SCROLL);
- }
-
/**
* Dispatch the event to the gesture detectors and the pan/zoom controller.
*/
@@ -274,7 +229,7 @@ public final class TouchEventHandler {
if (mScaleGestureDetector.isInProgress()) {
return;
}
- mPanZoomController.onTouchEvent(event);
+ mPanZoomController.handleEvent(event);
}
/**
commit 4da324ab072393263ff5e2004e1f3b39a59528fe
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 27 13:01:53 2015 +0900
android: remove unneded code from GeckoLayerClient
Change-Id: I5c7af6dfa7c921b186972b7b8d7bc079ddec0629
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index db21554..e1a12bd 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -26,36 +26,18 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
private Context mContext;
private IntSize mScreenSize;
- private IntSize mWindowSize;
private DisplayPortMetrics mDisplayPort;
private DisplayPortMetrics mReturnDisplayPort;
- private boolean mRecordDrawTimes;
- private final DrawTimingQueue mDrawTimingQueue;
-
private ComposedTileLayer mLowResLayer;
private ComposedTileLayer mRootLayer;
- /* 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 ImmutableViewportMetrics mGeckoViewport;
-
/*
* The viewport metrics being used to draw the current frame. This is only
* accessed by the compositor thread, and so needs no synchronisation.
*/
private ImmutableViewportMetrics mFrameMetrics;
- private ImmutableViewportMetrics mNewGeckoViewport;
-
- private boolean mPendingViewportAdjust;
-
private boolean mForceRedraw;
/* The current viewport metrics.
@@ -74,7 +56,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
private ZoomConstraints mZoomConstraints;
- private boolean mGeckoIsReady;
+ private boolean mIsReady ;
/* The new color for the checkerboard. */
private int mCheckerboardColor;
@@ -87,10 +69,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
// to before being read
mContext = context;
mScreenSize = new IntSize(0, 0);
- mWindowSize = new IntSize(0, 0);
mDisplayPort = new DisplayPortMetrics();
- mRecordDrawTimes = false;
- mDrawTimingQueue = new DrawTimingQueue();
mForceRedraw = true;
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
@@ -100,13 +79,13 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
mPanZoomController = PanZoomController.Factory.create(this);
}
- public void setView(LayerView v) {
- mView = v;
+ public void setView(LayerView view) {
+ mView = view;
mView.connect(this);
}
public void notifyReady() {
- mGeckoIsReady = true;
+ mIsReady = true;
mRootLayer = new DynamicTileLayer(mContext);
mLowResLayer = new FixedZoomTileLayer(mContext);
@@ -115,7 +94,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
mView.setListener(this);
mView.setLayerRenderer(mLayerRenderer);
- sendResizeEventIfNecessary(true);
+ sendResizeEventIfNecessary();
}
/**
@@ -136,11 +115,11 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
}
Layer getRoot() {
- return mGeckoIsReady ? mRootLayer : null;
+ return mIsReady ? mRootLayer : null;
}
Layer getLowResLayer() {
- return mGeckoIsReady ? mLowResLayer : null;
+ return mIsReady ? mLowResLayer : null;
}
public LayerView getView() {
@@ -157,7 +136,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
*/
void setViewportSize(FloatSize size) {
mViewportMetrics = mViewportMetrics.setViewportSize(size.width, size.height);
- sendResizeEventIfNecessary(true);
+ sendResizeEventIfNecessary();
}
public PanZoomController getPanZoomController() {
@@ -165,25 +144,17 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
}
/* Informs Gecko that the screen size has changed. */
- private void sendResizeEventIfNecessary(boolean force) {
+ private void sendResizeEventIfNecessary() {
DisplayMetrics metrics = LOKitShell.getDisplayMetrics();
-
IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
- // Return immediately if the screen size hasn't changed or the viewport
- // size is zero (which indicates that the rendering surface hasn't been
- // allocated yet).
- boolean screenSizeChanged = !mScreenSize.equals(newScreenSize);
-
- if (!force && !screenSizeChanged) {
+ if (mScreenSize.equals(newScreenSize)) {
return;
}
- Log.d(LOGTAG, "Screen-size changed to " + mScreenSize + " - > " + newScreenSize);
-
mScreenSize = newScreenSize;
- LOEvent event = LOEventFactory.sizeChanged(metrics.widthPixels, metrics.heightPixels);
+ LOEvent event = LOEventFactory.sizeChanged(mScreenSize.width, mScreenSize.height);
LOKitShell.sendEvent(event);
}
@@ -220,11 +191,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
}
mDisplayPort = displayPort;
- mGeckoViewport = clampedMetrics;
-
- if (mRecordDrawTimes) {
- mDrawTimingQueue.add(displayPort);
- }
reevaluateTiles();
}
@@ -274,42 +240,13 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
public void endDrawing(ImmutableViewportMetrics viewportMetrics) {
synchronized (this) {
- try {
- mNewGeckoViewport = viewportMetrics;
- updateViewport();
- //mLowResLayer.invalidate();
- //mRootLayer.invalidate();
- } finally {
- mLowResLayer.endTransaction();
- mRootLayer.endTransaction();
- }
- }
- }
-
- protected void updateViewport() {
- // save and restore the viewport size stored in java; never let the
- // JS-side viewport dimensions override the java-side ones because
- // java is the One True Source of this information, and allowing JS
- // to override can lead to race conditions where this data gets clobbered.
- FloatSize viewportSize = mViewportMetrics.getSize();
- mGeckoViewport = mNewGeckoViewport.setViewportSize(viewportSize.width, viewportSize.height);
-
- RectF position = mGeckoViewport.getViewport();
- mRootLayer.setPosition(RectUtils.round(position));
- mRootLayer.setResolution(mGeckoViewport.zoomFactor);
-
- mLowResLayer.setPosition(RectUtils.round(position));
- mLowResLayer.setResolution(mGeckoViewport.zoomFactor);
-
- // Don't adjust page size when zooming unless zoom levels are
- // approximately equal.
- if (FloatUtils.fuzzyEquals(getViewportMetrics().zoomFactor, mGeckoViewport.zoomFactor)) {
- setPageRect(mGeckoViewport.getPageRect(), mGeckoViewport.getCssPageRect());
+ mLowResLayer.endTransaction();
+ mRootLayer.endTransaction();
}
}
public void geometryChanged() {
- sendResizeEventIfNecessary(false);
+ sendResizeEventIfNecessary();
if (getRedrawHint()) {
adjustViewport(null);
}
@@ -359,7 +296,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
/** Implementation of PanZoomTarget */
public void setAnimationTarget(ImmutableViewportMetrics viewport) {
- if (mGeckoIsReady) {
+ if (mIsReady) {
// We know what the final viewport of the animation is going to be, so
// immediately request a draw of that area by setting the display port
// accordingly. This way we should have the content pre-rendered by the
@@ -375,7 +312,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
public void setViewportMetrics(ImmutableViewportMetrics viewport) {
mViewportMetrics = viewport;
mView.requestRender();
- if (mGeckoIsReady) {
+ if (mIsReady) {
geometryChanged();
}
}
@@ -383,7 +320,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
/** Implementation of PanZoomTarget */
public void forceRedraw() {
mForceRedraw = true;
- if (mGeckoIsReady) {
+ if (mIsReady) {
geometryChanged();
}
}
@@ -436,13 +373,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
});
}
- private class AdjustRunnable implements Runnable {
- public void run() {
- mPendingViewportAdjust = false;
- adjustViewport(null);
- }
- }
-
/* Root Layer Access */
public void reevaluateTiles() {
mLowResLayer.reevaluateTiles(mViewportMetrics, mDisplayPort);
More information about the Libreoffice-commits
mailing list