Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / android_webview / java / src / org / chromium / android_webview / NullAwViewMethods.java
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.android_webview;
6
7 import android.content.res.Configuration;
8 import android.graphics.Canvas;
9 import android.graphics.Paint;
10 import android.graphics.Rect;
11 import android.view.KeyEvent;
12 import android.view.MotionEvent;
13 import android.view.View;
14 import android.view.inputmethod.EditorInfo;
15 import android.view.inputmethod.InputConnection;
16
17 import org.chromium.android_webview.AwContents.InternalAccessDelegate;
18
19 /**
20  * No-op implementation of {@link AwViewMethods} that follows the null object pattern.
21  * This {@link NullAwViewMethods} is hooked up to the WebView in fullscreen mode, and
22  * to the {@link FullScreenView} in embedded mode, but not to both at the same time.
23  */
24 class NullAwViewMethods implements AwViewMethods {
25     private AwContents mAwContents;
26     private InternalAccessDelegate mInternalAccessAdapter;
27     private View mContainerView;
28
29     public NullAwViewMethods(
30             AwContents awContents, InternalAccessDelegate internalAccessAdapter,
31             View containerView) {
32         mAwContents = awContents;
33         mInternalAccessAdapter = internalAccessAdapter;
34         mContainerView = containerView;
35     }
36
37     @Override
38     public void onDraw(Canvas canvas) {
39         canvas.drawColor(mAwContents.getEffectiveBackgroundColor());
40     }
41
42     @Override
43     public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
44         // When the containerView is using the NullAwViewMethods then it is not
45         // attached to the AwContents. As such, we don't have any contents to measure
46         // and using the last measured dimension is the best we can do.
47         mInternalAccessAdapter.setMeasuredDimension(
48                 mContainerView.getMeasuredWidth(), mContainerView.getMeasuredHeight());
49     }
50
51     @Override
52     public void requestFocus() {
53         // Intentional no-op.
54     }
55
56     @Override
57     public void setLayerType(int layerType, Paint paint) {
58         // Intentional no-op.
59     }
60
61     @Override
62     public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
63         return null; // Intentional no-op.
64     }
65
66     @Override
67     public boolean onKeyUp(int keyCode, KeyEvent event) {
68         return false; // Intentional no-op.
69     }
70
71     @Override
72     public boolean dispatchKeyEvent(KeyEvent event) {
73         return false; // Intentional no-op.
74     }
75
76     @Override
77     public boolean onTouchEvent(MotionEvent event) {
78         return false; // Intentional no-op.
79     }
80
81     @Override
82     public boolean onHoverEvent(MotionEvent event) {
83         return false; // Intentional no-op.
84     }
85
86     @Override
87     public boolean onGenericMotionEvent(MotionEvent event) {
88         return false; // Intentional no-op.
89     }
90
91     @Override
92     public void onConfigurationChanged(Configuration newConfig) {
93         // Intentional no-op.
94     }
95
96     @Override
97     public void onAttachedToWindow() {
98         // Intentional no-op.
99     }
100
101     @Override
102     public void onDetachedFromWindow() {
103         // Intentional no-op.
104     }
105
106     @Override
107     public void onWindowFocusChanged(boolean hasWindowFocus) {
108         // Intentional no-op.
109     }
110
111     @Override
112     public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
113         // Intentional no-op.
114     }
115
116     @Override
117     public void onSizeChanged(int w, int h, int ow, int oh) {
118         // Intentional no-op.
119     }
120
121     @Override
122     public void onVisibilityChanged(View changedView, int visibility) {
123         // Intentional no-op.
124     }
125
126     @Override
127     public void onWindowVisibilityChanged(int visibility) {
128         // Intentional no-op.
129     }
130
131     @Override
132     public void onContainerViewScrollChanged(int l, int t, int oldl, int oldt) {
133         // Intentional no-op.
134     }
135
136     @Override
137     public void onContainerViewOverScrolled(int scrollX, int scrollY, boolean clampedX,
138             boolean clampedY) {
139         // Intentional no-op.
140     }
141
142     @Override
143     public int computeHorizontalScrollRange() {
144         return 0;
145     }
146
147     @Override
148     public int computeHorizontalScrollOffset() {
149         return 0;
150     }
151
152     @Override
153     public int computeVerticalScrollRange() {
154         return 0;
155     }
156
157     @Override
158     public int computeVerticalScrollOffset() {
159         return 0;
160     }
161
162     @Override
163     public int computeVerticalScrollExtent() {
164         return 0;
165     }
166
167     @Override
168     public void computeScroll() {
169         // Intentional no-op.
170     }
171 }