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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
13 #include "base/callback.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h"
19 #include "content/browser/accessibility/browser_accessibility_manager.h"
20 #include "content/browser/compositor/delegated_frame_host.h"
21 #include "content/browser/compositor/image_transport_factory.h"
22 #include "content/browser/compositor/owned_mailbox.h"
23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
24 #include "content/common/content_export.h"
25 #include "content/common/cursors/webcursor.h"
26 #include "third_party/skia/include/core/SkRegion.h"
27 #include "ui/aura/client/cursor_client_observer.h"
28 #include "ui/aura/client/focus_change_observer.h"
29 #include "ui/aura/window_delegate.h"
30 #include "ui/aura/window_tree_host_observer.h"
31 #include "ui/base/ime/text_input_client.h"
32 #include "ui/gfx/display_observer.h"
33 #include "ui/gfx/insets.h"
34 #include "ui/gfx/rect.h"
35 #include "ui/wm/public/activation_change_observer.h"
36 #include "ui/wm/public/activation_delegate.h"
38 struct ViewHostMsg_TextInputState_Params;
43 class ScopedTooltipDisabler;
48 class CopyOutputRequest;
49 class CopyOutputResult;
50 class DelegatedFrameData;
71 class LegacyRenderWidgetHostHWND;
74 class OverscrollController;
75 class RenderFrameHostImpl;
76 class RenderWidgetHostImpl;
77 class RenderWidgetHostView;
79 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
80 class CONTENT_EXPORT RenderWidgetHostViewAura
81 : public RenderWidgetHostViewBase,
82 public DelegatedFrameHostClient,
83 public ui::TextInputClient,
84 public gfx::DisplayObserver,
85 public aura::WindowTreeHostObserver,
86 public aura::WindowDelegate,
87 public aura::client::ActivationDelegate,
88 public aura::client::ActivationChangeObserver,
89 public aura::client::FocusChangeObserver,
90 public aura::client::CursorClientObserver,
91 public base::SupportsWeakPtr<RenderWidgetHostViewAura> {
93 // Displays and controls touch editing elements such as selection handles.
94 class TouchEditingClient {
96 TouchEditingClient() {}
98 // Tells the client to start showing touch editing handles.
99 virtual void StartTouchEditing() = 0;
101 // Notifies the client that touch editing is no longer needed. |quick|
102 // determines whether the handles should fade out quickly or slowly.
103 virtual void EndTouchEditing(bool quick) = 0;
105 // Notifies the client that the selection bounds need to be updated.
106 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor,
107 const gfx::Rect& focus) = 0;
109 // Notifies the client that the current text input type as changed.
110 virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0;
112 // Notifies the client that an input event is about to be sent to the
113 // renderer. Returns true if the client wants to stop event propagation.
114 virtual bool HandleInputEvent(const ui::Event* event) = 0;
116 // Notifies the client that a gesture event ack was received.
117 virtual void GestureEventAck(int gesture_event_type) = 0;
119 // Notifies the client that the fling has ended, so it can activate touch
120 // editing if needed.
121 virtual void DidStopFlinging() = 0;
123 // This is called when the view is destroyed, so that the client can
124 // perform any necessary clean-up.
125 virtual void OnViewDestroyed() = 0;
128 virtual ~TouchEditingClient() {}
131 void set_touch_editing_client(TouchEditingClient* client) {
132 touch_editing_client_ = client;
135 explicit RenderWidgetHostViewAura(RenderWidgetHost* host);
137 // RenderWidgetHostView implementation.
138 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
139 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
140 virtual void SetSize(const gfx::Size& size) OVERRIDE;
141 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
142 virtual gfx::Vector2dF GetLastScrollOffset() const OVERRIDE;
143 virtual gfx::NativeView GetNativeView() const OVERRIDE;
144 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
145 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
146 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
147 virtual bool HasFocus() const OVERRIDE;
148 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
149 virtual void Show() OVERRIDE;
150 virtual void Hide() OVERRIDE;
151 virtual bool IsShowing() OVERRIDE;
152 virtual gfx::Rect GetViewBounds() const OVERRIDE;
153 virtual void SetBackgroundOpaque(bool opaque) OVERRIDE;
154 virtual gfx::Size GetVisibleViewportSize() const OVERRIDE;
155 virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
157 // Overridden from RenderWidgetHostViewBase:
158 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
159 const gfx::Rect& pos) OVERRIDE;
160 virtual void InitAsFullscreen(
161 RenderWidgetHostView* reference_host_view) OVERRIDE;
162 virtual void WasShown() OVERRIDE;
163 virtual void WasHidden() OVERRIDE;
164 virtual void MovePluginWindows(
165 const std::vector<WebPluginGeometry>& moves) OVERRIDE;
166 virtual void Focus() OVERRIDE;
167 virtual void Blur() OVERRIDE;
168 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE;
169 virtual void SetIsLoading(bool is_loading) OVERRIDE;
170 virtual void TextInputStateChanged(
171 const ViewHostMsg_TextInputState_Params& params) OVERRIDE;
172 virtual void ImeCancelComposition() OVERRIDE;
173 virtual void ImeCompositionRangeChanged(
174 const gfx::Range& range,
175 const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
176 virtual void RenderProcessGone(base::TerminationStatus status,
177 int error_code) OVERRIDE;
178 virtual void Destroy() OVERRIDE;
179 virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE;
180 virtual void SelectionChanged(const base::string16& text,
182 const gfx::Range& range) OVERRIDE;
183 virtual gfx::Size GetRequestedRendererSize() const OVERRIDE;
184 virtual void SelectionBoundsChanged(
185 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE;
186 virtual void CopyFromCompositingSurface(
187 const gfx::Rect& src_subrect,
188 const gfx::Size& dst_size,
189 CopyFromCompositingSurfaceCallback& callback,
190 const SkColorType color_type) OVERRIDE;
191 virtual void CopyFromCompositingSurfaceToVideoFrame(
192 const gfx::Rect& src_subrect,
193 const scoped_refptr<media::VideoFrame>& target,
194 const base::Callback<void(bool)>& callback) OVERRIDE;
195 virtual bool CanCopyToVideoFrame() const OVERRIDE;
196 virtual bool CanSubscribeFrame() const OVERRIDE;
197 virtual void BeginFrameSubscription(
198 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
199 virtual void EndFrameSubscription() OVERRIDE;
200 virtual void AcceleratedSurfaceInitialized(int host_id,
201 int route_id) OVERRIDE;
202 virtual void AcceleratedSurfaceBuffersSwapped(
203 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
204 int gpu_host_id) OVERRIDE;
205 virtual void AcceleratedSurfacePostSubBuffer(
206 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
207 int gpu_host_id) OVERRIDE;
208 virtual void AcceleratedSurfaceSuspend() OVERRIDE;
209 virtual void AcceleratedSurfaceRelease() OVERRIDE;
210 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
211 virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE;
212 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
213 virtual void WheelEventAck(const blink::WebMouseWheelEvent& event,
214 InputEventAckState ack_result) OVERRIDE;
215 virtual void GestureEventAck(const blink::WebGestureEvent& event,
216 InputEventAckState ack_result) OVERRIDE;
217 virtual void ProcessAckedTouchEvent(
218 const TouchEventWithLatencyInfo& touch,
219 InputEventAckState ack_result) OVERRIDE;
220 virtual scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget()
222 virtual InputEventAckState FilterInputEvent(
223 const blink::WebInputEvent& input_event) OVERRIDE;
224 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
225 virtual BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
226 BrowserAccessibilityDelegate* delegate) OVERRIDE;
227 virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() OVERRIDE;
228 virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible()
230 virtual void ShowDisambiguationPopup(const gfx::Rect& rect_pixels,
231 const SkBitmap& zoomed_bitmap) OVERRIDE;
232 virtual bool LockMouse() OVERRIDE;
233 virtual void UnlockMouse() OVERRIDE;
234 virtual void OnSwapCompositorFrame(
235 uint32 output_surface_id,
236 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE;
237 virtual void DidStopFlinging() OVERRIDE;
240 virtual void SetParentNativeViewAccessible(
241 gfx::NativeViewAccessible accessible_parent) OVERRIDE;
242 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE;
245 // Overridden from ui::TextInputClient:
246 virtual void SetCompositionText(
247 const ui::CompositionText& composition) OVERRIDE;
248 virtual void ConfirmCompositionText() OVERRIDE;
249 virtual void ClearCompositionText() OVERRIDE;
250 virtual void InsertText(const base::string16& text) OVERRIDE;
251 virtual void InsertChar(base::char16 ch, int flags) OVERRIDE;
252 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE;
253 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
254 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE;
255 virtual bool CanComposeInline() const OVERRIDE;
256 virtual gfx::Rect GetCaretBounds() const OVERRIDE;
257 virtual bool GetCompositionCharacterBounds(uint32 index,
258 gfx::Rect* rect) const OVERRIDE;
259 virtual bool HasCompositionText() const OVERRIDE;
260 virtual bool GetTextRange(gfx::Range* range) const OVERRIDE;
261 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE;
262 virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE;
263 virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE;
264 virtual bool DeleteRange(const gfx::Range& range) OVERRIDE;
265 virtual bool GetTextFromRange(const gfx::Range& range,
266 base::string16* text) const OVERRIDE;
267 virtual void OnInputMethodChanged() OVERRIDE;
268 virtual bool ChangeTextDirectionAndLayoutAlignment(
269 base::i18n::TextDirection direction) OVERRIDE;
270 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE;
271 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE;
272 virtual void OnCandidateWindowShown() OVERRIDE;
273 virtual void OnCandidateWindowUpdated() OVERRIDE;
274 virtual void OnCandidateWindowHidden() OVERRIDE;
275 virtual bool IsEditingCommandEnabled(int command_id) OVERRIDE;
276 virtual void ExecuteEditingCommand(int command_id) OVERRIDE;
278 // Overridden from gfx::DisplayObserver:
279 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
280 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
281 virtual void OnDisplayMetricsChanged(const gfx::Display& display,
282 uint32_t metrics) OVERRIDE;
284 // Overridden from aura::WindowDelegate:
285 virtual gfx::Size GetMinimumSize() const OVERRIDE;
286 virtual gfx::Size GetMaximumSize() const OVERRIDE;
287 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
288 const gfx::Rect& new_bounds) OVERRIDE;
289 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
290 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
291 virtual bool ShouldDescendIntoChildForEventHandling(
293 const gfx::Point& location) OVERRIDE;
294 virtual bool CanFocus() OVERRIDE;
295 virtual void OnCaptureLost() OVERRIDE;
296 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
297 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
298 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
299 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
300 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
301 virtual bool HasHitTestMask() const OVERRIDE;
302 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
304 // Overridden from ui::EventHandler:
305 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
306 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
307 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
308 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
309 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
311 // Overridden from aura::client::ActivationDelegate:
312 virtual bool ShouldActivate() const OVERRIDE;
314 // Overridden from aura::client::ActivationChangeObserver:
315 virtual void OnWindowActivated(aura::Window* gained_activation,
316 aura::Window* lost_activation) OVERRIDE;
318 // Overridden from aura::client::CursorClientObserver:
319 virtual void OnCursorVisibilityChanged(bool is_visible) OVERRIDE;
321 // Overridden from aura::client::FocusChangeObserver:
322 virtual void OnWindowFocused(aura::Window* gained_focus,
323 aura::Window* lost_focus) OVERRIDE;
325 // Overridden from aura::WindowTreeHostObserver:
326 virtual void OnHostMoved(const aura::WindowTreeHost* host,
327 const gfx::Point& new_origin) OVERRIDE;
330 // Sets the cutout rects from constrained windows. These are rectangles that
331 // windowed NPAPI plugins shouldn't paint in. Overwrites any previous cutout
333 void UpdateConstrainedWindowRects(const std::vector<gfx::Rect>& rects);
335 // Updates the cursor clip region. Used for mouse locking.
336 void UpdateMouseLockRegion();
338 // Notification that the LegacyRenderWidgetHostHWND was destroyed.
339 void OnLegacyWindowDestroyed();
342 void DisambiguationPopupRendered(bool success, const SkBitmap& result);
344 void HideDisambiguationPopup();
346 void ProcessDisambiguationGesture(ui::GestureEvent* event);
348 void ProcessDisambiguationMouse(ui::MouseEvent* event);
350 // Method to indicate if this instance is shutting down or closing.
351 // TODO(shrikant): Discuss around to see if it makes sense to add this method
352 // as part of RenderWidgetHostView.
353 bool IsClosing() const { return in_shutdown_; }
355 // Sets whether the overscroll controller should be enabled for this page.
356 void SetOverscrollControllerEnabled(bool enabled);
358 void SnapToPhysicalPixelBoundary();
360 OverscrollController* overscroll_controller() const {
361 return overscroll_controller_.get();
365 virtual ~RenderWidgetHostViewAura();
367 // Exposed for tests.
368 aura::Window* window() { return window_; }
369 virtual SkColorType PreferredReadbackFormat() OVERRIDE;
370 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE;
373 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SetCompositionText);
374 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventState);
375 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
376 TouchEventPositionsArentRounded);
377 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventSyncAsync);
378 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SwapNotifiesWindow);
379 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
380 SkippedDelegatedFrames);
381 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange);
382 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
383 DiscardDelegatedFrames);
384 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
385 DiscardDelegatedFramesWithLocking);
386 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SoftwareDPIChange);
387 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
388 UpdateCursorIfOverSelf);
389 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest,
390 DestroyedAfterCopyRequest);
391 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
392 VisibleViewportTest);
393 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
394 OverscrollResetsOnBlur);
395 FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest,
396 WebContentsViewReparent);
398 class WindowObserver;
399 friend class WindowObserver;
401 void UpdateCursorIfOverSelf();
403 // Tracks whether SnapToPhysicalPixelBoundary() has been called.
404 bool has_snapped_to_boundary() { return has_snapped_to_boundary_; }
405 void ResetHasSnappedToBoundary() { has_snapped_to_boundary_ = false; }
407 // Set the bounds of the window and handle size changes. Assumes the caller
408 // has already adjusted the origin of |rect| to conform to whatever coordinate
409 // space is required by the aura::Window.
410 void InternalSetBounds(const gfx::Rect& rect);
413 bool UsesNativeWindowFrame() const;
416 ui::InputMethod* GetInputMethod() const;
418 // Returns whether the widget needs an input grab to work properly.
419 bool NeedsInputGrab();
421 // Confirm existing composition text in the webpage and ask the input method
422 // to cancel its ongoing composition session.
423 void FinishImeCompositionSession();
425 // This method computes movementX/Y and keeps track of mouse location for
426 // mouse lock on all mouse move events.
427 void ModifyEventMovementAndCoords(blink::WebMouseEvent* event);
429 // Sends an IPC to the renderer process to communicate whether or not
430 // the mouse cursor is visible anywhere on the screen.
431 void NotifyRendererOfCursorVisibilityState(bool is_visible);
433 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty
434 // SchedulePaint() is invoked for |rect|.
435 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip);
437 // Helper method to determine if, in mouse locked mode, the cursor should be
439 bool ShouldMoveToCenter();
441 // Called after |window_| is parented to a WindowEventDispatcher.
442 void AddedToRootWindow();
444 // Called prior to removing |window_| from a WindowEventDispatcher.
445 void RemovingFromRootWindow();
447 // DelegatedFrameHostClient implementation.
448 virtual ui::Compositor* GetCompositor() const OVERRIDE;
449 virtual ui::Layer* GetLayer() OVERRIDE;
450 virtual RenderWidgetHostImpl* GetHost() OVERRIDE;
451 virtual bool IsVisible() OVERRIDE;
452 virtual scoped_ptr<ResizeLock> CreateResizeLock(
453 bool defer_compositor_lock) OVERRIDE;
454 virtual gfx::Size DesiredFrameSize() OVERRIDE;
455 virtual float CurrentDeviceScaleFactor() OVERRIDE;
456 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE;
458 // Detaches |this| from the input method object.
459 void DetachFromInputMethod();
461 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method
462 // calls our keybindings handler against the event and send matched
463 // edit commands to renderer instead.
464 void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event);
466 // Dismisses a Web Popup on a mouse or touch press outside the popup and its
468 void ApplyEventFilterForPopupExit(ui::LocatedEvent* event);
470 // Converts |rect| from window coordinate to screen coordinate.
471 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const;
473 // Converts |rect| from screen coordinate to window coordinate.
474 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const;
476 // Helper function to set keyboard focus to the main window.
477 void SetKeyboardFocus();
479 RenderFrameHostImpl* GetFocusedFrame();
482 RenderWidgetHostImpl* host_;
484 aura::Window* window_;
486 scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
488 scoped_ptr<WindowObserver> window_observer_;
490 // Are we in the process of closing? Tracked so fullscreen views can avoid
491 // sending a second shutdown request to the host when they lose the focus
492 // after requesting shutdown for another reason (e.g. Escape key).
495 // True if in the process of handling a window bounds changed notification.
496 bool in_bounds_changed_;
498 // Is this a fullscreen view?
501 // Our parent host view, if this is a popup. NULL otherwise.
502 RenderWidgetHostViewAura* popup_parent_host_view_;
504 // Our child popup host. NULL if we do not have a child popup.
505 RenderWidgetHostViewAura* popup_child_host_view_;
507 class EventFilterForPopupExit;
508 friend class EventFilterForPopupExit;
509 scoped_ptr<ui::EventHandler> event_filter_for_popup_exit_;
511 // True when content is being loaded. Used to show an hourglass cursor.
514 // The cursor for the page. This is passed up from the renderer.
515 WebCursor current_cursor_;
517 // The touch-event. Its touch-points are updated as necessary. A new
518 // touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is
519 // removed from the list on an ET_TOUCH_RELEASED event.
520 blink::WebTouchEvent touch_event_;
522 // The current text input type.
523 ui::TextInputType text_input_type_;
524 // The current text input mode corresponding to HTML5 inputmode attribute.
525 ui::TextInputMode text_input_mode_;
526 bool can_compose_inline_;
528 // Rectangles for the selection anchor and focus.
529 gfx::Rect selection_anchor_rect_;
530 gfx::Rect selection_focus_rect_;
532 // The current composition character bounds.
533 std::vector<gfx::Rect> composition_character_bounds_;
535 // Indicates if there is onging composition text.
536 bool has_composition_text_;
538 // Whether return characters should be passed on to the RenderWidgetHostImpl.
539 bool accept_return_character_;
541 // Current tooltip text.
542 base::string16 tooltip_;
544 // The size and scale of the last software compositing frame that was swapped.
545 gfx::Size last_swapped_software_frame_size_;
546 float last_swapped_software_frame_scale_factor_;
548 // If non-NULL we're in OnPaint() and this is the supplied canvas.
549 gfx::Canvas* paint_canvas_;
551 // Used to record the last position of the mouse.
552 // While the mouse is locked, they store the last known position just as mouse
554 // Relative to the upper-left corner of the view.
555 gfx::Point unlocked_mouse_position_;
556 // Relative to the upper-left corner of the screen.
557 gfx::Point unlocked_global_mouse_position_;
558 // Last cursor position relative to screen. Used to compute movementX/Y.
559 gfx::Point global_mouse_position_;
560 // In mouse locked mode, we synthetically move the mouse cursor to the center
561 // of the window when it reaches the window borders to avoid it going outside.
562 // This flag is used to differentiate between these synthetic mouse move
563 // events vs. normal mouse move events.
564 bool synthetic_move_sent_;
566 // Used to track the state of the window we're created from. Only used when
567 // created fullscreen.
568 scoped_ptr<aura::WindowTracker> host_tracker_;
570 // Used to track the last cursor visibility update that was sent to the
571 // renderer via NotifyRendererOfCursorVisibilityState().
572 enum CursorVisibilityState {
577 CursorVisibilityState cursor_visibility_state_in_renderer_;
580 // The list of rectangles from constrained windows over this view. Windowed
581 // NPAPI plugins shouldn't draw over them.
582 std::vector<gfx::Rect> constrained_rects_;
584 typedef std::map<HWND, WebPluginGeometry> PluginWindowMoves;
585 // Contains information about each windowed plugin's clip and cutout rects (
586 // from the renderer). This is needed because when the transient windows
587 // over this view changes, we need this information in order to create a new
588 // region for the HWND.
589 PluginWindowMoves plugin_window_moves_;
591 // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used
592 // for accessibility, as the container for windowless plugins like
593 // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads,
595 // The LegacyRenderWidgetHostHWND instance is created during the first call
596 // to RenderWidgetHostViewAura::InternalSetBounds. The instance is destroyed
597 // when the LegacyRenderWidgetHostHWND hwnd is destroyed.
598 content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_;
600 // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed
601 // by Windows. This could happen if the browser window was destroyed by
602 // DestroyWindow for e.g. This flag helps ensure that we don't try to create
603 // the LegacyRenderWidgetHostHWND instance again as that would be a futile
605 bool legacy_window_destroyed_;
608 bool has_snapped_to_boundary_;
610 TouchEditingClient* touch_editing_client_;
612 scoped_ptr<OverscrollController> overscroll_controller_;
614 // The last scroll offset of the view.
615 gfx::Vector2dF last_scroll_offset_;
619 std::vector<ui::LatencyInfo> software_latency_info_;
621 scoped_ptr<aura::client::ScopedTooltipDisabler> tooltip_disabler_;
623 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_;
625 gfx::Rect disambiguation_target_rect_;
627 // The last scroll offset when we start to render the link disambiguation
628 // view, so we can ensure the window hasn't moved between copying from the
629 // compositing surface and showing the disambiguation popup.
630 gfx::Vector2dF disambiguation_scroll_offset_;
632 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura);
635 } // namespace content
637 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_