1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_
#include <map>
#include "base/compiler_specific.h"
#include "base/i18n/rtl.h"
#include "base/memory/scoped_ptr.h"
#include "base/process.h"
#include "content/browser/renderer_host/ime_adapter_android.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "ui/gfx/size.h"
struct ViewHostMsg_TextInputState_Params;
struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
namespace cc {
class Layer;
class TextureLayer;
}
namespace WebKit {
class WebExternalTextureLayer;
class WebTouchEvent;
class WebMouseEvent;
}
namespace content {
class ContentViewCoreImpl;
class RenderWidgetHost;
class RenderWidgetHostImpl;
class SurfaceTextureTransportClient;
struct NativeWebKeyboardEvent;
// -----------------------------------------------------------------------------
// See comments in render_widget_host_view.h about this class and its members.
// -----------------------------------------------------------------------------
class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
public:
RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget,
ContentViewCoreImpl* content_view_core);
virtual ~RenderWidgetHostViewAndroid();
// RenderWidgetHostView implementation.
virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) OVERRIDE;
virtual void InitAsFullscreen(
RenderWidgetHostView* reference_host_view) OVERRIDE;
virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
virtual void WasShown() OVERRIDE;
virtual void WasHidden() OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
virtual void MovePluginWindows(
const gfx::Vector2d& scroll_offset,
const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE;
virtual void Focus() OVERRIDE;
virtual void Blur() OVERRIDE;
virtual bool HasFocus() const OVERRIDE;
virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual bool IsShowing() OVERRIDE;
virtual gfx::Rect GetViewBounds() const OVERRIDE;
virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE;
virtual void SetIsLoading(bool is_loading) OVERRIDE;
virtual void TextInputStateChanged(
const ViewHostMsg_TextInputState_Params& params) OVERRIDE;
virtual void ImeCancelComposition() OVERRIDE;
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
const std::vector<gfx::Rect>& copy_rects) OVERRIDE;
virtual void RenderViewGone(base::TerminationStatus status,
int error_code) OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE;
virtual void SelectionChanged(const string16& text,
size_t offset,
const ui::Range& range) OVERRIDE;
virtual void SelectionBoundsChanged(
const gfx::Rect& start_rect,
WebKit::WebTextDirection start_direction,
const gfx::Rect& end_rect,
WebKit::WebTextDirection end_direction) OVERRIDE;
virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfacePostSubBuffer(
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfaceSuspend() OVERRIDE;
virtual void AcceleratedSurfaceRelease() OVERRIDE;
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
virtual void SetBackground(const SkBitmap& background) OVERRIDE;
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
const base::Callback<void(bool)>& callback,
skia::PlatformBitmap* output) OVERRIDE;
virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE;
virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE;
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
virtual void UnhandledWheelEvent(
const WebKit::WebMouseWheelEvent& event) OVERRIDE;
virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch,
InputEventAckState ack_result) OVERRIDE;
virtual void SetHasHorizontalScrollbar(
bool has_horizontal_scrollbar) OVERRIDE;
virtual void SetScrollOffsetPinning(
bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
virtual bool LockMouse() OVERRIDE;
virtual void UnlockMouse() OVERRIDE;
virtual void StartContentIntent(const GURL& content_url) OVERRIDE;
virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE;
virtual void SetCachedBackgroundColor(SkColor color) OVERRIDE;
virtual void SetCachedPageScaleFactorLimits(float minimum_scale,
float maximum_scale) OVERRIDE;
virtual void UpdateFrameInfo(const gfx::Vector2d& scroll_offset,
float page_scale_factor,
float min_page_scale_factor,
float max_page_scale_factor,
const gfx::Size& content_size) OVERRIDE;
virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect,
const SkBitmap& zoomed_bitmap) OVERRIDE;
// Non-virtual methods
void SetContentViewCore(ContentViewCoreImpl* content_view_core);
SkColor GetCachedBackgroundColor() const;
void SendKeyEvent(const NativeWebKeyboardEvent& event);
void SendTouchEvent(const WebKit::WebTouchEvent& event);
void SendMouseEvent(const WebKit::WebMouseEvent& event);
void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event);
void SendGestureEvent(const WebKit::WebGestureEvent& event);
int GetNativeImeAdapter();
WebKit::WebGLId GetScaledContentTexture(float scale, gfx::Size* out_size);
bool PopulateBitmapWithContents(jobject jbitmap);
bool HasValidFrame() const;
// Select all text between the given coordinates.
void SelectRange(const gfx::Point& start, const gfx::Point& end);
void MoveCaret(const gfx::Point& point);
private:
// The model object.
RenderWidgetHostImpl* host_;
// Whether or not this widget is potentially attached to the view hierarchy.
// This view may not actually be attached if this is true, but it should be
// treated as such, because as soon as a ContentViewCore is set the layer
// will be attached automatically.
bool is_layer_attached_;
// ContentViewCoreImpl is our interface to the view system.
ContentViewCoreImpl* content_view_core_;
ImeAdapterAndroid ime_adapter_android_;
// Body background color of the underlying document.
SkColor cached_background_color_;
// The texture layer for this view when using browser-side compositing.
scoped_refptr<cc::TextureLayer> texture_layer_;
// The layer used for rendering the contents of this view.
// It is either owned by texture_layer_ or surface_texture_transport_
// depending on the mode.
scoped_refptr<cc::Layer> layer_;
// The most recent texture id that was pushed to the texture layer.
unsigned int texture_id_in_layer_;
// The most recent texture size that was pushed to the texture layer.
gfx::Size texture_size_in_layer_;
// Used for image transport when needing to share resources across threads.
scoped_ptr<SurfaceTextureTransportClient> surface_texture_transport_;
// The mailbox name of the previously received frame.
std::string current_mailbox_name_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_
|