Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/layouts/GestureHandlerLayoutDelegate.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/layouts/GestureHandlerLayoutDelegate.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/layouts/GestureHandlerLayoutDelegate.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/layouts/GestureHandlerLayoutDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..21b136a5494f8014072d820cbe1a8326d69c1fac
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/layouts/GestureHandlerLayoutDelegate.java
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.compositor.layouts;
+
+import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureHandler;
+
+/**
+ * A {@link GestureHandler} that takes a {@link LayoutProvider} and delegates all gesture events
+ * to {@link LayoutProvider#getActiveLayout()}.
+ */
+class GestureHandlerLayoutDelegate implements GestureHandler {
+ private final LayoutProvider mLayoutProvider;
+
+ /**
+ * Creates an instance of the {@link GestureHandlerLayoutDelegate}.
+ * @param provider A {@link LayoutProvider} instance.
+ */
+ public GestureHandlerLayoutDelegate(LayoutProvider provider) {
+ mLayoutProvider = provider;
+ }
+
+ @Override
+ public void onDown(float x, float y) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().onDown(LayoutManager.time(), x, y);
+ }
+
+ @Override
+ public void onUpOrCancel() {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().onUpOrCancel(LayoutManager.time());
+ }
+
+ @Override
+ public void drag(float x, float y, float dx, float dy, float tx, float ty) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().drag(LayoutManager.time(), x, y, dx, dy);
+ }
+
+ @Override
+ public void click(float x, float y) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().click(LayoutManager.time(), x, y);
+ }
+
+ @Override
+ public void fling(float x, float y, float velocityX, float velocityY) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().fling(LayoutManager.time(), x, y, velocityX, velocityY);
+ }
+
+ @Override
+ public void onLongPress(float x, float y) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().onLongPress(LayoutManager.time(), x, y);
+ }
+
+ @Override
+ public void onPinch(float x0, float y0, float x1, float y1, boolean firstEvent) {
+ if (mLayoutProvider.getActiveLayout() == null) return;
+ mLayoutProvider.getActiveLayout().onPinch(LayoutManager.time(), x0, y0, x1, y1, firstEvent);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698