OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
11 import android.graphics.Canvas; | 11 import android.graphics.Canvas; |
12 import android.graphics.Rect; | 12 import android.graphics.Rect; |
13 import android.os.Build; | 13 import android.os.Build; |
14 import android.util.AttributeSet; | 14 import android.util.AttributeSet; |
15 import android.view.KeyEvent; | 15 import android.view.KeyEvent; |
16 import android.view.MotionEvent; | 16 import android.view.MotionEvent; |
17 import android.view.View; | 17 import android.view.View; |
18 import android.view.accessibility.AccessibilityEvent; | 18 import android.view.accessibility.AccessibilityEvent; |
19 import android.view.accessibility.AccessibilityNodeInfo; | 19 import android.view.accessibility.AccessibilityNodeInfo; |
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 com.google.common.annotations.VisibleForTesting; | 24 import com.google.common.annotations.VisibleForTesting; |
25 | 25 |
26 import org.chromium.content.common.TraceEvent; | 26 import org.chromium.content.common.TraceEvent; |
27 import org.chromium.ui.gfx.NativeWindow; | 27 import org.chromium.ui.WindowAndroid; |
28 | 28 |
29 /** | 29 /** |
30 * The containing view for {@link ContentViewCore} that exists in the Android UI
hierarchy and | 30 * The containing view for {@link ContentViewCore} that exists in the Android UI
hierarchy and |
31 * exposes the various {@link View} functionality to it. | 31 * exposes the various {@link View} functionality to it. |
32 * | 32 * |
33 * TODO(joth): Remove any methods overrides from this class that were added for
WebView | 33 * TODO(joth): Remove any methods overrides from this class that were added for
WebView |
34 * compatibility. | 34 * compatibility. |
35 */ | 35 */ |
36 public class ContentView extends FrameLayout implements ContentViewCore.Internal
AccessDelegate { | 36 public class ContentView extends FrameLayout implements ContentViewCore.Internal
AccessDelegate { |
37 // Used when ContentView implements a standalone View. | 37 // Used when ContentView implements a standalone View. |
38 public static final int PERSONALITY_VIEW = ContentViewCore.PERSONALITY_VIEW; | 38 public static final int PERSONALITY_VIEW = ContentViewCore.PERSONALITY_VIEW; |
39 // Used for Chrome. | 39 // Used for Chrome. |
40 public static final int PERSONALITY_CHROME = ContentViewCore.PERSONALITY_CHR
OME; | 40 public static final int PERSONALITY_CHROME = ContentViewCore.PERSONALITY_CHR
OME; |
41 | 41 |
42 private ContentViewCore mContentViewCore; | 42 private ContentViewCore mContentViewCore; |
43 | 43 |
44 private float mCurrentTouchOffsetX; | 44 private float mCurrentTouchOffsetX; |
45 private float mCurrentTouchOffsetY; | 45 private float mCurrentTouchOffsetY; |
46 | 46 |
47 /** | 47 /** |
48 * Creates an instance of a ContentView. | 48 * Creates an instance of a ContentView. |
49 * @param context The Context the view is running in, through which it can | 49 * @param context The Context the view is running in, through which it can |
50 * access the current theme, resources, etc. | 50 * access the current theme, resources, etc. |
51 * @param nativeWebContents A pointer to the native web contents. | 51 * @param nativeWebContents A pointer to the native web contents. |
52 * @param nativeWindow An instance of the NativeWindow. | 52 * @param windowAndroid An instance of the WindowAndroid. |
53 * @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONAL
ITY_VIEW}. | 53 * @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONAL
ITY_VIEW}. |
54 * @return A ContentView instance. | 54 * @return A ContentView instance. |
55 */ | 55 */ |
56 public static ContentView newInstance(Context context, int nativeWebContents
, | 56 public static ContentView newInstance(Context context, int nativeWebContents
, |
57 NativeWindow nativeWindow, int personality) { | 57 WindowAndroid windowAndroid, int personality) { |
58 return newInstance(context, nativeWebContents, nativeWindow, null, | 58 return newInstance(context, nativeWebContents, windowAndroid, null, |
59 android.R.attr.webViewStyle, personality); | 59 android.R.attr.webViewStyle, personality); |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Creates an instance of a ContentView. | 63 * Creates an instance of a ContentView. |
64 * @param context The Context the view is running in, through which it can | 64 * @param context The Context the view is running in, through which it can |
65 * access the current theme, resources, etc. | 65 * access the current theme, resources, etc. |
66 * @param nativeWebContents A pointer to the native web contents. | 66 * @param nativeWebContents A pointer to the native web contents. |
67 * @param nativeWindow An instance of the NativeWindow. | 67 * @param windowAndroid An instance of the WindowAndroid. |
68 * @param attrs The attributes of the XML tag that is inflating the view. | 68 * @param attrs The attributes of the XML tag that is inflating the view. |
69 * @return A ContentView instance. | 69 * @return A ContentView instance. |
70 */ | 70 */ |
71 public static ContentView newInstance(Context context, int nativeWebContents
, | 71 public static ContentView newInstance(Context context, int nativeWebContents
, |
72 NativeWindow nativeWindow, AttributeSet attrs) { | 72 WindowAndroid windowAndroid, AttributeSet attrs) { |
73 // TODO(klobag): use the WebViewStyle as the default style for now. It e
nables scrollbar. | 73 // TODO(klobag): use the WebViewStyle as the default style for now. It e
nables scrollbar. |
74 // When ContentView is moved to framework, we can define its own style i
n the res. | 74 // When ContentView is moved to framework, we can define its own style i
n the res. |
75 return newInstance(context, nativeWebContents, nativeWindow, attrs, | 75 return newInstance(context, nativeWebContents, windowAndroid, attrs, |
76 android.R.attr.webViewStyle); | 76 android.R.attr.webViewStyle); |
77 } | 77 } |
78 | 78 |
79 /** | 79 /** |
80 * Creates an instance of a ContentView. | 80 * Creates an instance of a ContentView. |
81 * @param context The Context the view is running in, through which it can | 81 * @param context The Context the view is running in, through which it can |
82 * access the current theme, resources, etc. | 82 * access the current theme, resources, etc. |
83 * @param nativeWebContents A pointer to the native web contents. | 83 * @param nativeWebContents A pointer to the native web contents. |
84 * @param nativeWindow An instance of the NativeWindow. | 84 * @param windowAndroid An instance of the WindowAndroid. |
85 * @param attrs The attributes of the XML tag that is inflating the view. | 85 * @param attrs The attributes of the XML tag that is inflating the view. |
86 * @param defStyle The default style to apply to this view. | 86 * @param defStyle The default style to apply to this view. |
87 * @return A ContentView instance. | 87 * @return A ContentView instance. |
88 */ | 88 */ |
89 public static ContentView newInstance(Context context, int nativeWebContents
, | 89 public static ContentView newInstance(Context context, int nativeWebContents
, |
90 NativeWindow nativeWindow, AttributeSet attrs, int defStyle) { | 90 WindowAndroid windowAndroid, AttributeSet attrs, int defStyle) { |
91 return newInstance(context, nativeWebContents, nativeWindow, attrs, defS
tyle, | 91 return newInstance(context, nativeWebContents, windowAndroid, attrs, def
Style, |
92 PERSONALITY_VIEW); | 92 PERSONALITY_VIEW); |
93 } | 93 } |
94 | 94 |
95 private static ContentView newInstance(Context context, int nativeWebContent
s, | 95 private static ContentView newInstance(Context context, int nativeWebContent
s, |
96 NativeWindow nativeWindow, AttributeSet attrs, int defStyle, int per
sonality) { | 96 WindowAndroid windowAndroid, AttributeSet attrs, int defStyle, int p
ersonality) { |
97 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { | 97 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { |
98 return new ContentView(context, nativeWebContents, nativeWindow, att
rs, defStyle, | 98 return new ContentView(context, nativeWebContents, windowAndroid, at
trs, defStyle, |
99 personality); | 99 personality); |
100 } else { | 100 } else { |
101 return new JellyBeanContentView(context, nativeWebContents, nativeWi
ndow, attrs, | 101 return new JellyBeanContentView(context, nativeWebContents, windowAn
droid, attrs, |
102 defStyle, personality); | 102 defStyle, personality); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 protected ContentView(Context context, int nativeWebContents, NativeWindow n
ativeWindow, | 106 protected ContentView(Context context, int nativeWebContents, WindowAndroid
windowAndroid, |
107 AttributeSet attrs, int defStyle, int personality) { | 107 AttributeSet attrs, int defStyle, int personality) { |
108 super(context, attrs, defStyle); | 108 super(context, attrs, defStyle); |
109 | 109 |
110 mContentViewCore = new ContentViewCore(context, personality); | 110 mContentViewCore = new ContentViewCore(context, personality); |
111 mContentViewCore.initialize(this, this, nativeWebContents, nativeWindow,
false); | 111 mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid
, false); |
112 } | 112 } |
113 | 113 |
114 /** | 114 /** |
115 * @return The core component of the ContentView that handles JNI communicat
ion. Should only be | 115 * @return The core component of the ContentView that handles JNI communicat
ion. Should only be |
116 * used for passing to native. | 116 * used for passing to native. |
117 */ | 117 */ |
118 public ContentViewCore getContentViewCore() { | 118 public ContentViewCore getContentViewCore() { |
119 return mContentViewCore; | 119 return mContentViewCore; |
120 } | 120 } |
121 | 121 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 822 |
823 @Override | 823 @Override |
824 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { | 824 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { |
825 return super.awakenScrollBars(startDelay, invalidate); | 825 return super.awakenScrollBars(startDelay, invalidate); |
826 } | 826 } |
827 | 827 |
828 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 828 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
829 // End Implementation of ContentViewCore.InternalAccessDelega
te // | 829 // End Implementation of ContentViewCore.InternalAccessDelega
te // |
830 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 830 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
831 } | 831 } |
OLD | NEW |