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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentView.java

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: EventForwarder... Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Configuration; 8 import android.content.res.Configuration;
9 import android.graphics.Rect; 9 import android.graphics.Rect;
10 import android.os.Build; 10 import android.os.Build;
11 import android.os.Bundle; 11 import android.os.Bundle;
12 import android.os.Handler; 12 import android.os.Handler;
13 import android.view.DragEvent; 13 import android.view.DragEvent;
14 import android.view.KeyEvent; 14 import android.view.KeyEvent;
15 import android.view.MotionEvent; 15 import android.view.MotionEvent;
16 import android.view.View; 16 import android.view.View;
17 import android.view.View.MeasureSpec; 17 import android.view.View.MeasureSpec;
18 import android.view.ViewStructure; 18 import android.view.ViewStructure;
19 import android.view.accessibility.AccessibilityNodeProvider; 19 import android.view.accessibility.AccessibilityNodeProvider;
20 import android.view.inputmethod.EditorInfo; 20 import android.view.inputmethod.EditorInfo;
21 import android.view.inputmethod.InputConnection; 21 import android.view.inputmethod.InputConnection;
22 import android.widget.FrameLayout; 22 import android.widget.FrameLayout;
23 23
24 import org.chromium.base.TraceEvent; 24 import org.chromium.base.TraceEvent;
25 import org.chromium.ui.base.EventForwarder;
25 26
26 /** 27 /**
27 * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and 28 * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and
28 * exposes the various {@link View} functionality to it. 29 * exposes the various {@link View} functionality to it.
29 */ 30 */
30 public class ContentView extends FrameLayout 31 public class ContentView extends FrameLayout
31 implements ContentViewCore.InternalAccessDelegate, SmartClipProvider { 32 implements ContentViewCore.InternalAccessDelegate, SmartClipProvider {
32 33
33 private static final String TAG = "cr.ContentView"; 34 private static final String TAG = "cr.ContentView";
34 35
35 // Default value to signal that the ContentView's size need not be overridde n. 36 // Default value to signal that the ContentView's size need not be overridde n.
36 public static final int DEFAULT_MEASURE_SPEC = 37 public static final int DEFAULT_MEASURE_SPEC =
37 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); 38 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
38 39
39 protected final ContentViewCore mContentViewCore; 40 protected final ContentViewCore mContentViewCore;
41 private EventForwarder mEventForwarder;
40 42
41 /** 43 /**
42 * The desired size of this view in {@link MeasureSpec}. Set by the host 44 * The desired size of this view in {@link MeasureSpec}. Set by the host
43 * when it should be different from that of the parent. 45 * when it should be different from that of the parent.
44 */ 46 */
45 private int mDesiredWidthMeasureSpec = DEFAULT_MEASURE_SPEC; 47 private int mDesiredWidthMeasureSpec = DEFAULT_MEASURE_SPEC;
46 private int mDesiredHeightMeasureSpec = DEFAULT_MEASURE_SPEC; 48 private int mDesiredHeightMeasureSpec = DEFAULT_MEASURE_SPEC;
47 49
48 /** 50 /**
49 * Constructs a new ContentView for the appropriate Android version. 51 * Constructs a new ContentView for the appropriate Android version.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 179 }
178 } 180 }
179 181
180 @Override 182 @Override
181 public boolean onDragEvent(DragEvent event) { 183 public boolean onDragEvent(DragEvent event) {
182 return mContentViewCore.onDragEvent(event); 184 return mContentViewCore.onDragEvent(event);
183 } 185 }
184 186
185 @Override 187 @Override
186 public boolean onTouchEvent(MotionEvent event) { 188 public boolean onTouchEvent(MotionEvent event) {
187 return mContentViewCore.onTouchEvent(event); 189 return getEventForwarder().onTouchEvent(event);
188 } 190 }
189 191
190 /** 192 /**
191 * Mouse move events are sent on hover enter, hover move and hover exit. 193 * Mouse move events are sent on hover enter, hover move and hover exit.
192 * They are sent on hover exit because sometimes it acts as both a hover 194 * They are sent on hover exit because sometimes it acts as both a hover
193 * move and hover exit. 195 * move and hover exit.
194 */ 196 */
195 @Override 197 @Override
196 public boolean onHoverEvent(MotionEvent event) { 198 public boolean onHoverEvent(MotionEvent event) {
197 boolean consumed = mContentViewCore.onHoverEvent(event); 199 boolean consumed = mContentViewCore.onHoverEvent(event);
198 if (!mContentViewCore.isTouchExplorationEnabled()) super.onHoverEvent(ev ent); 200 if (!mContentViewCore.isTouchExplorationEnabled()) super.onHoverEvent(ev ent);
199 return consumed; 201 return consumed;
200 } 202 }
201 203
202 @Override 204 @Override
203 public boolean onGenericMotionEvent(MotionEvent event) { 205 public boolean onGenericMotionEvent(MotionEvent event) {
204 return mContentViewCore.onGenericMotionEvent(event); 206 return mContentViewCore.onGenericMotionEvent(event);
205 } 207 }
206 208
209 private EventForwarder getEventForwarder() {
210 if (mEventForwarder == null) {
211 mEventForwarder = mContentViewCore.getWebContents().getEventForwarde r();
212 }
213 return mEventForwarder;
214 }
215
207 @Override 216 @Override
208 public boolean performLongClick() { 217 public boolean performLongClick() {
209 return false; 218 return false;
210 } 219 }
211 220
212 @Override 221 @Override
213 protected void onConfigurationChanged(Configuration newConfig) { 222 protected void onConfigurationChanged(Configuration newConfig) {
214 mContentViewCore.onConfigurationChanged(newConfig); 223 mContentViewCore.onConfigurationChanged(newConfig);
215 } 224 }
216 225
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 public ContentViewApi23(Context context, ContentViewCore cvc) { 347 public ContentViewApi23(Context context, ContentViewCore cvc) {
339 super(context, cvc); 348 super(context, cvc);
340 } 349 }
341 350
342 @Override 351 @Override
343 public void onProvideVirtualStructure(final ViewStructure structure) { 352 public void onProvideVirtualStructure(final ViewStructure structure) {
344 mContentViewCore.onProvideVirtualStructure(structure, false); 353 mContentViewCore.onProvideVirtualStructure(structure, false);
345 } 354 }
346 } 355 }
347 } 356 }
OLDNEW
« no previous file with comments | « content/public/android/BUILD.gn ('k') | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698