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.
5 package org.chromium.android_webview;
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;
17 import org.chromium.android_webview.AwContents.InternalAccessDelegate;
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.
24 class NullAwViewMethods implements AwViewMethods {
25 private AwContents mAwContents;
26 private InternalAccessDelegate mInternalAccessAdapter;
27 private View mContainerView;
29 public NullAwViewMethods(
30 AwContents awContents, InternalAccessDelegate internalAccessAdapter,
32 mAwContents = awContents;
33 mInternalAccessAdapter = internalAccessAdapter;
34 mContainerView = containerView;
38 public void onDraw(Canvas canvas) {
39 canvas.drawColor(mAwContents.getEffectiveBackgroundColor());
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());
52 public void requestFocus() {
57 public void setLayerType(int layerType, Paint paint) {
62 public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
63 return null; // Intentional no-op.
67 public boolean onKeyUp(int keyCode, KeyEvent event) {
68 return false; // Intentional no-op.
72 public boolean dispatchKeyEvent(KeyEvent event) {
73 return false; // Intentional no-op.
77 public boolean onTouchEvent(MotionEvent event) {
78 return false; // Intentional no-op.
82 public boolean onHoverEvent(MotionEvent event) {
83 return false; // Intentional no-op.
87 public boolean onGenericMotionEvent(MotionEvent event) {
88 return false; // Intentional no-op.
92 public void onConfigurationChanged(Configuration newConfig) {
97 public void onAttachedToWindow() {
102 public void onDetachedFromWindow() {
103 // Intentional no-op.
107 public void onWindowFocusChanged(boolean hasWindowFocus) {
108 // Intentional no-op.
112 public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
113 // Intentional no-op.
117 public void onSizeChanged(int w, int h, int ow, int oh) {
118 // Intentional no-op.
122 public void onVisibilityChanged(View changedView, int visibility) {
123 // Intentional no-op.
127 public void onWindowVisibilityChanged(int visibility) {
128 // Intentional no-op.
132 public void onContainerViewScrollChanged(int l, int t, int oldl, int oldt) {
133 // Intentional no-op.
137 public void onContainerViewOverScrolled(int scrollX, int scrollY, boolean clampedX,
139 // Intentional no-op.
143 public int computeHorizontalScrollRange() {
148 public int computeHorizontalScrollOffset() {
153 public int computeVerticalScrollRange() {
158 public int computeVerticalScrollOffset() {
163 public int computeVerticalScrollExtent() {
168 public void computeScroll() {
169 // Intentional no-op.