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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
// Copyright (c) 2011 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_VIEWS_H_
#define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_VIEWS_H_
#pragma once
#include <map>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/time.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/gfx/native_widget_types.h"
#include "views/controls/native/native_view_host.h"
#include "views/events/event.h"
#include "views/ime/text_input_client.h"
#include "views/touchui/touch_selection_controller.h"
#include "views/view.h"
#include "webkit/glue/webcursor.h"
#if defined(TOUCH_UI)
namespace ui {
enum TouchStatus;
}
class AcceleratedSurfaceContainerTouch;
#endif
class RenderWidgetHost;
struct NativeWebKeyboardEvent;
// -----------------------------------------------------------------------------
// See comments in render_widget_host_view.h about this class and its members.
// -----------------------------------------------------------------------------
class RenderWidgetHostViewViews : public RenderWidgetHostView,
public views::TouchSelectionClientView,
public views::TextInputClient {
public:
// Internal class name.
static const char kViewClassName[];
explicit RenderWidgetHostViewViews(RenderWidgetHost* widget);
virtual ~RenderWidgetHostViewViews();
// Initialize this object for use as a drawing area.
void InitAsChild();
// RenderWidgetHostView implementation.
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 DidBecomeSelected() 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() OVERRIDE;
virtual void MovePluginWindows(
const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE;
virtual bool HasFocus() 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 ImeUpdateTextInputState(ui::TextInputType type,
bool can_compose_inline,
const gfx::Rect& caret_rect) OVERRIDE;
virtual void ImeCancelComposition() OVERRIDE;
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy,
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 std::wstring& tooltip_text) OVERRIDE;
virtual void SelectionChanged(const std::string& text,
const ui::Range& range,
const gfx::Point& start,
const gfx::Point& end) OVERRIDE;
virtual void ShowingContextMenu(bool showing) OVERRIDE;
virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE;
virtual void SetBackground(const SkBitmap& background) OVERRIDE;
#if defined(TOOLKIT_USES_GTK)
virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
#endif
virtual void SetVisuallyDeemphasized(const SkColor* color,
bool animate) OVERRIDE;
virtual void UnhandledWheelEvent(
const WebKit::WebMouseWheelEvent& event) OVERRIDE;
virtual void SetHasHorizontalScrollbar(
bool has_horizontal_scrollbar) OVERRIDE;
virtual void SetScrollOffsetPinning(
bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
#if defined(TOOLKIT_USES_GTK)
virtual void AcceleratedCompositingActivated(bool activated) OVERRIDE;
#endif
#if defined(OS_WIN)
virtual void WillWmDestroy() OVERRIDE;
virtual void ShowCompositorHostWindow(bool show) OVERRIDE;
#endif
virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE;
// Overridden from views::TouchSelectionClientView.
virtual void SelectRect(const gfx::Point& start,
const gfx::Point& end) OVERRIDE;
// Overridden from ui::SimpleMenuModel::Delegate.
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
virtual bool GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) OVERRIDE;
virtual void ExecuteCommand(int command_id) OVERRIDE;
// Overridden from views::View.
virtual std::string GetClassName() const OVERRIDE;
virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
#if defined(TOUCH_UI)
virtual ui::TouchStatus OnTouchEvent(const views::TouchEvent& event) OVERRIDE;
#endif
virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const views::MouseWheelEvent& event) OVERRIDE;
virtual views::TextInputClient* GetTextInputClient() OVERRIDE;
virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip)
OVERRIDE;
// Overridden from TextInputClient:
virtual void SetCompositionText(
const ui::CompositionText& composition) OVERRIDE;
virtual void ConfirmCompositionText() OVERRIDE;
virtual void ClearCompositionText() OVERRIDE;
virtual void InsertText(const string16& text) OVERRIDE;
virtual void InsertChar(char16 ch, int flags) OVERRIDE;
virtual ui::TextInputType GetTextInputType() OVERRIDE;
virtual gfx::Rect GetCaretBounds() OVERRIDE;
virtual bool HasCompositionText() OVERRIDE;
virtual bool GetTextRange(ui::Range* range) OVERRIDE;
virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE;
virtual bool GetSelectionRange(ui::Range* range) OVERRIDE;
virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE;
virtual bool DeleteRange(const ui::Range& range) OVERRIDE;
virtual bool GetTextFromRange(
const ui::Range& range,
const base::Callback<void(const string16&)>& callback) OVERRIDE;
virtual void OnInputMethodChanged() OVERRIDE;
virtual bool ChangeTextDirectionAndLayoutAlignment(
base::i18n::TextDirection direction) OVERRIDE;
virtual views::View* GetOwnerViewOfTextInputClient() OVERRIDE;
#if defined(TOUCH_UI)
virtual void AcceleratedSurfaceSetIOSurface(
int32 width, int32 height, uint64 surface_id) OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped(uint64 surface_id) OVERRIDE;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;
#endif
protected:
// Overridden from RenderWidgetHostView / views::View.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void Focus() OVERRIDE;
virtual void Blur() OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
private:
friend class RenderWidgetHostViewViewsWidget;
// Returns whether the widget needs an input grab to work
// properly.
bool NeedsInputGrab();
// Returns whether this render view is a popup (<select> dropdown or
// autocomplete window).
bool IsPopup();
// Update the display cursor for the render view.
void ShowCurrentCursor();
// Translate a views::MouseEvent into a WebKit::WebMouseEvent.
WebKit::WebMouseEvent WebMouseEventFromViewsEvent(
const views::MouseEvent& event);
// Confirm existing composition text in the webpage and ask the input method
// to cancel its ongoing composition sesstion.
void FinishImeCompositionSession();
#if defined(TOOLKIT_USES_GTK)
// On some systems, there can be two native views, where an outer native view
// contains the inner native view (e.g. when using GTK+). This returns the
// inner view. This can return NULL when it's not attached to a view.
gfx::NativeView GetInnerNativeView() const;
#endif
// The model object.
RenderWidgetHost* host_;
// This is true when we are currently painting and thus should handle extra
// paint requests by expanding the invalid rect rather than actually
// painting.
bool about_to_validate_and_paint_;
// This is the rectangle which we'll paint.
gfx::Rect invalid_rect_;
// Whether or not this widget is hidden.
bool is_hidden_;
// Whether we are currently loading.
bool is_loading_;
// The cursor for the page. This is passed up from the renderer.
WebCursor current_cursor_;
// The native cursor.
gfx::NativeCursor native_cursor_;
// Whether we are showing a context menu.
bool is_showing_context_menu_;
// The time at which this view started displaying white pixels as a result of
// not having anything to paint (empty backing store from renderer). This
// value returns true for is_null() if we are not recording whiteout times.
base::TimeTicks whiteout_start_time_;
// The time it took after this view was selected for it to be fully painted.
base::TimeTicks tab_switch_paint_time_;
// If true, fade the render widget when painting it.
bool visually_deemphasized_;
// The size that we want the renderer to be.
gfx::Size requested_size_;
// The touch-event. Its touch-points are updated as necessary. A new
// touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is
// removed from the list on an ET_TOUCH_RELEASED event.
WebKit::WebTouchEvent touch_event_;
// The current text input type.
ui::TextInputType text_input_type_;
// The current caret bounds.
gfx::Rect caret_bounds_;
// Indicates if there is onging composition text.
bool has_composition_text_;
string16 tooltip_text_;
scoped_ptr<views::TouchSelectionController> touch_selection_controller_;
#if defined(TOUCH_UI)
std::map<uint64, scoped_refptr<AcceleratedSurfaceContainerTouch> >
accelerated_surface_containers_;
#endif
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewViews);
};
#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_VIEWS_H_
|