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

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

Issue 275733002: Remove all external references to ContentView from Tab/Shell/etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
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.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Rect; 10 import android.graphics.Rect;
11 import android.os.Build; 11 import android.os.Build;
12 import android.view.KeyEvent; 12 import android.view.KeyEvent;
13 import android.view.MotionEvent; 13 import android.view.MotionEvent;
14 import android.view.View; 14 import android.view.View;
15 import android.view.accessibility.AccessibilityEvent; 15 import android.view.accessibility.AccessibilityEvent;
16 import android.view.accessibility.AccessibilityNodeInfo; 16 import android.view.accessibility.AccessibilityNodeInfo;
17 import android.view.inputmethod.EditorInfo; 17 import android.view.inputmethod.EditorInfo;
18 import android.view.inputmethod.InputConnection; 18 import android.view.inputmethod.InputConnection;
19 import android.widget.FrameLayout; 19 import android.widget.FrameLayout;
20 20
21 import org.chromium.base.TraceEvent; 21 import org.chromium.base.TraceEvent;
22 import org.chromium.ui.base.WindowAndroid;
23 22
24 /** 23 /**
25 * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and 24 * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and
26 * exposes the various {@link View} functionality to it. 25 * exposes the various {@link View} functionality to it.
27 *
28 * TODO(joth): Remove any methods overrides from this class that were added for WebView
29 * compatibility.
30 */ 26 */
31 public class ContentView extends FrameLayout 27 public class ContentView extends FrameLayout
32 implements ContentViewCore.InternalAccessDelegate { 28 implements ContentViewCore.InternalAccessDelegate {
33 29
34 private final ContentViewCore mContentViewCore; 30 protected final ContentViewCore mContentViewCore;
35 31
36 private final int[] mLocationInWindow = new int[2]; 32 private final int[] mLocationInWindow = new int[2];
37 33
38 /** 34 /**
39 * Creates an instance of a ContentView. 35 * Creates an instance of a ContentView.
40 * @param context The Context the view is running in, through which it can 36 * @param context The Context the view is running in, through which it can
41 * access the current theme, resources, etc. 37 * access the current theme, resources, etc.
42 * @param nativeWebContents A pointer to the native web contents. 38 * @param cvc A pointer to the content view core managing this content view.
43 * @param windowAndroid An instance of the WindowAndroid.
44 * @return A ContentView instance. 39 * @return A ContentView instance.
45 */ 40 */
46 public static ContentView newInstance( 41 public static ContentView newInstance(Context context, ContentViewCore cvc) {
47 Context context, long nativeWebContents, WindowAndroid windowAndroid ) {
48 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { 42 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
49 return new ContentView(context, nativeWebContents, windowAndroid); 43 return new ContentView(context, cvc);
50 } else { 44 } else {
51 return new JellyBeanContentView(context, nativeWebContents, windowAn droid); 45 return new JellyBeanContentView(context, cvc);
52 } 46 }
53 } 47 }
54 48
55 protected ContentView(Context context, long nativeWebContents, WindowAndroid windowAndroid) { 49 protected ContentView(Context context, ContentViewCore cvc) {
56 super(context, null, android.R.attr.webViewStyle); 50 super(context, null, android.R.attr.webViewStyle);
57 51
58 if (getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY) { 52 if (getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY) {
59 setHorizontalScrollBarEnabled(false); 53 setHorizontalScrollBarEnabled(false);
60 setVerticalScrollBarEnabled(false); 54 setVerticalScrollBarEnabled(false);
61 } 55 }
62 56
63 setFocusable(true); 57 setFocusable(true);
64 setFocusableInTouchMode(true); 58 setFocusableInTouchMode(true);
65 59
66 mContentViewCore = new ContentViewCore(context); 60 mContentViewCore = cvc;
67 mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid );
68 } 61 }
69 62
70 /**
71 * @return The core component of the ContentView that handles JNI communicat ion. Should only be
72 * used for passing to native.
73 */
74 public ContentViewCore getContentViewCore() {
75 return mContentViewCore;
76 }
77
78 // FrameLayout overrides.
79
80 // Needed by ContentViewCore.InternalAccessDelegate 63 // Needed by ContentViewCore.InternalAccessDelegate
81 @Override 64 @Override
82 public boolean drawChild(Canvas canvas, View child, long drawingTime) { 65 public boolean drawChild(Canvas canvas, View child, long drawingTime) {
83 return super.drawChild(canvas, child, drawingTime); 66 return super.drawChild(canvas, child, drawingTime);
84 } 67 }
85 68
86 // Needed by ContentViewCore.InternalAccessDelegate 69 // Needed by ContentViewCore.InternalAccessDelegate
87 @Override 70 @Override
88 public void onScrollChanged(int l, int t, int oldl, int oldt) { 71 public void onScrollChanged(int l, int t, int oldl, int oldt) {
89 super.onScrollChanged(l, t, oldl, oldt); 72 super.onScrollChanged(l, t, oldl, oldt);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 super.onDetachedFromWindow(); 251 super.onDetachedFromWindow();
269 mContentViewCore.onDetachedFromWindow(); 252 mContentViewCore.onDetachedFromWindow();
270 } 253 }
271 254
272 @Override 255 @Override
273 protected void onVisibilityChanged(View changedView, int visibility) { 256 protected void onVisibilityChanged(View changedView, int visibility) {
274 super.onVisibilityChanged(changedView, visibility); 257 super.onVisibilityChanged(changedView, visibility);
275 mContentViewCore.onVisibilityChanged(changedView, visibility); 258 mContentViewCore.onVisibilityChanged(changedView, visibility);
276 } 259 }
277 260
278 /**
279 * Return content scroll y.
280 *
281 * @return The vertical scroll position in pixels.
282 */
283 public int getContentScrollY() {
284 return mContentViewCore.computeVerticalScrollOffset();
285 }
286
287 /**
288 * Return content height.
289 *
290 * @return The height of the content in pixels.
291 */
292 public int getContentHeight() {
293 return mContentViewCore.computeVerticalScrollRange();
294 }
295
296 //////////////////////////////////////////////////////////////////////////// /////////////////// 261 //////////////////////////////////////////////////////////////////////////// ///////////////////
297 // Start Implementation of ContentViewCore.InternalAccessDelega te // 262 // Start Implementation of ContentViewCore.InternalAccessDelega te //
298 //////////////////////////////////////////////////////////////////////////// /////////////////// 263 //////////////////////////////////////////////////////////////////////////// ///////////////////
299 264
300 @Override 265 @Override
301 public boolean super_onKeyUp(int keyCode, KeyEvent event) { 266 public boolean super_onKeyUp(int keyCode, KeyEvent event) {
302 return super.onKeyUp(keyCode, event); 267 return super.onKeyUp(keyCode, event);
303 } 268 }
304 269
305 @Override 270 @Override
(...skipping 18 matching lines...) Expand all
324 289
325 @Override 290 @Override
326 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { 291 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) {
327 return super.awakenScrollBars(startDelay, invalidate); 292 return super.awakenScrollBars(startDelay, invalidate);
328 } 293 }
329 294
330 //////////////////////////////////////////////////////////////////////////// /////////////////// 295 //////////////////////////////////////////////////////////////////////////// ///////////////////
331 // End Implementation of ContentViewCore.InternalAccessDelega te // 296 // End Implementation of ContentViewCore.InternalAccessDelega te //
332 //////////////////////////////////////////////////////////////////////////// /////////////////// 297 //////////////////////////////////////////////////////////////////////////// ///////////////////
333 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698