Add a FrameHostMsg_BeginNavigation IPC
[chromium-blink-merge.git] / content / browser / renderer_host / render_widget_host_view_mac.h
blob9cc3e851c94a46c11040ff7f93fffc58108d1f3a
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_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
8 #import <Cocoa/Cocoa.h>
9 #include <IOSurface/IOSurfaceAPI.h>
10 #include <list>
11 #include <map>
12 #include <string>
13 #include <utility>
14 #include <vector>
16 #include "base/mac/scoped_nsobject.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h"
19 #include "base/time/time.h"
20 #include "content/browser/compositor/browser_compositor_view_mac.h"
21 #include "content/browser/compositor/delegated_frame_host.h"
22 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h"
23 #include "content/browser/renderer_host/display_link_mac.h"
24 #include "content/browser/renderer_host/render_widget_host_view_base.h"
25 #include "content/browser/renderer_host/software_frame_manager.h"
26 #include "content/common/content_export.h"
27 #include "content/common/cursors/webcursor.h"
28 #include "content/common/edit_command.h"
29 #import "content/public/browser/render_widget_host_view_mac_base.h"
30 #include "ipc/ipc_sender.h"
31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
32 #include "ui/base/cocoa/base_view.h"
33 #include "ui/base/cocoa/remote_layer_api.h"
35 struct ViewHostMsg_TextInputState_Params;
37 namespace content {
38 class BrowserCompositorviewMac;
39 class CompositingIOSurfaceMac;
40 class CompositingIOSurfaceContext;
41 class RenderWidgetHostViewMac;
42 class RenderWidgetHostViewMacEditCommandHelper;
43 class WebContents;
46 namespace ui {
47 class Compositor;
48 class Layer;
51 @class CompositingIOSurfaceLayer;
52 @class FullscreenWindowManager;
53 @protocol RenderWidgetHostViewMacDelegate;
54 @class SoftwareLayer;
55 @class ToolTip;
57 @protocol RenderWidgetHostViewMacOwner
58 - (content::RenderWidgetHostViewMac*)renderWidgetHostViewMac;
59 @end
61 // This is the view that lives in the Cocoa view hierarchy. In Windows-land,
62 // RenderWidgetHostViewWin is both the view and the delegate. We split the roles
63 // but that means that the view needs to own the delegate and will dispose of it
64 // when it's removed from the view system.
65 @interface RenderWidgetHostViewCocoa
66 : BaseView <RenderWidgetHostViewMacBase,
67 RenderWidgetHostViewMacOwner,
68 NSTextInputClient> {
69 @private
70 scoped_ptr<content::RenderWidgetHostViewMac> renderWidgetHostView_;
71 // This ivar is the cocoa delegate of the NSResponder.
72 base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate>>
73 responderDelegate_;
74 BOOL canBeKeyView_;
75 BOOL takesFocusOnlyOnMouseDown_;
76 BOOL closeOnDeactivate_;
77 scoped_ptr<content::RenderWidgetHostViewMacEditCommandHelper>
78 editCommand_helper_;
80 // These are part of the magic tooltip code from WebKit's WebHTMLView:
81 id trackingRectOwner_; // (not retained)
82 void* trackingRectUserData_;
83 NSTrackingRectTag lastToolTipTag_;
84 base::scoped_nsobject<NSString> toolTip_;
86 // Is YES if there was a mouse-down as yet unbalanced with a mouse-up.
87 BOOL hasOpenMouseDown_;
89 NSWindow* lastWindow_; // weak
91 // The cursor for the page. This is passed up from the renderer.
92 base::scoped_nsobject<NSCursor> currentCursor_;
94 // Variables used by our implementaion of the NSTextInput protocol.
95 // An input method of Mac calls the methods of this protocol not only to
96 // notify an application of its status, but also to retrieve the status of
97 // the application. That is, an application cannot control an input method
98 // directly.
99 // This object keeps the status of a composition of the renderer and returns
100 // it when an input method asks for it.
101 // We need to implement Objective-C methods for the NSTextInput protocol. On
102 // the other hand, we need to implement a C++ method for an IPC-message
103 // handler which receives input-method events from the renderer.
105 // Represents the input-method attributes supported by this object.
106 base::scoped_nsobject<NSArray> validAttributesForMarkedText_;
108 // Indicates if we are currently handling a key down event.
109 BOOL handlingKeyDown_;
111 // Indicates if there is any marked text.
112 BOOL hasMarkedText_;
114 // Indicates if unmarkText is called or not when handling a keyboard
115 // event.
116 BOOL unmarkTextCalled_;
118 // The range of current marked text inside the whole content of the DOM node
119 // being edited.
120 // TODO(suzhe): This is currently a fake value, as we do not support accessing
121 // the whole content yet.
122 NSRange markedRange_;
124 // The selected range, cached from a message sent by the renderer.
125 NSRange selectedRange_;
127 // Text to be inserted which was generated by handling a key down event.
128 base::string16 textToBeInserted_;
130 // Marked text which was generated by handling a key down event.
131 base::string16 markedText_;
133 // Underline information of the |markedText_|.
134 std::vector<blink::WebCompositionUnderline> underlines_;
136 // Indicates if doCommandBySelector method receives any edit command when
137 // handling a key down event.
138 BOOL hasEditCommands_;
140 // Contains edit commands received by the -doCommandBySelector: method when
141 // handling a key down event, not including inserting commands, eg. insertTab,
142 // etc.
143 content::EditCommands editCommands_;
145 // The plugin that currently has focus (-1 if no plugin has focus).
146 int focusedPluginIdentifier_;
148 // Whether or not plugin IME is currently enabled active.
149 BOOL pluginImeActive_;
151 // Whether the previous mouse event was ignored due to hitTest check.
152 BOOL mouseEventWasIgnored_;
154 // Event monitor for scroll wheel end event.
155 id endWheelMonitor_;
157 // OpenGL Support:
159 // recursive globalFrameDidChange protection:
160 BOOL handlingGlobalFrameDidChange_;
162 // The scale factor of the display this view is in.
163 float deviceScaleFactor_;
165 // If true then escape key down events are suppressed until the first escape
166 // key up event. (The up event is suppressed as well). This is used by the
167 // flash fullscreen code to avoid sending a key up event without a matching
168 // key down event.
169 BOOL suppressNextEscapeKeyUp_;
172 @property(nonatomic, readonly) NSRange selectedRange;
173 @property(nonatomic, readonly) BOOL suppressNextEscapeKeyUp;
175 - (void)setCanBeKeyView:(BOOL)can;
176 - (void)setTakesFocusOnlyOnMouseDown:(BOOL)b;
177 - (void)setCloseOnDeactivate:(BOOL)b;
178 - (void)setToolTipAtMousePoint:(NSString *)string;
179 // True for always-on-top special windows (e.g. Balloons and Panels).
180 - (BOOL)acceptsMouseEventsWhenInactive;
181 // Cancel ongoing composition (abandon the marked text).
182 - (void)cancelComposition;
183 // Confirm ongoing composition.
184 - (void)confirmComposition;
185 // Enables or disables plugin IME.
186 - (void)setPluginImeActive:(BOOL)active;
187 // Updates the current plugin focus state.
188 - (void)pluginFocusChanged:(BOOL)focused forPlugin:(int)pluginId;
189 // Evaluates the event in the context of plugin IME, if plugin IME is enabled.
190 // Returns YES if the event was handled.
191 - (BOOL)postProcessEventForPluginIme:(NSEvent*)event;
192 - (void)updateCursor:(NSCursor*)cursor;
193 - (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
194 actualRange:(NSRangePointer)actualRange;
195 @end
197 namespace content {
198 class RenderWidgetHostImpl;
200 ///////////////////////////////////////////////////////////////////////////////
201 // RenderWidgetHostViewMac
203 // An object representing the "View" of a rendered web page. This object is
204 // responsible for displaying the content of the web page, and integrating with
205 // the Cocoa view system. It is the implementation of the RenderWidgetHostView
206 // that the cross-platform RenderWidgetHost object uses
207 // to display the data.
209 // Comment excerpted from render_widget_host.h:
211 // "The lifetime of the RenderWidgetHost* is tied to the render process.
212 // If the render process dies, the RenderWidgetHost* goes away and all
213 // references to it must become NULL."
215 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
216 class CONTENT_EXPORT RenderWidgetHostViewMac
217 : public RenderWidgetHostViewBase,
218 public DelegatedFrameHostClient,
219 public BrowserCompositorViewMacClient,
220 public IPC::Sender,
221 public SoftwareFrameManagerClient,
222 public CompositingIOSurfaceLayerClient {
223 public:
224 // The view will associate itself with the given widget. The native view must
225 // be hooked up immediately to the view hierarchy, or else when it is
226 // deleted it will delete this out from under the caller.
227 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget);
228 virtual ~RenderWidgetHostViewMac();
230 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; }
232 // |delegate| is used to separate out the logic from the NSResponder delegate.
233 // |delegate| is retained by this class.
234 // |delegate| should be set at most once.
235 CONTENT_EXPORT void SetDelegate(
236 NSObject<RenderWidgetHostViewMacDelegate>* delegate);
237 void SetAllowOverlappingViews(bool overlapping);
239 // RenderWidgetHostView implementation.
240 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
241 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
242 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
243 virtual void SetSize(const gfx::Size& size) OVERRIDE;
244 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
245 virtual gfx::NativeView GetNativeView() const OVERRIDE;
246 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
247 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
248 virtual bool HasFocus() const OVERRIDE;
249 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
250 virtual void Show() OVERRIDE;
251 virtual void Hide() OVERRIDE;
252 virtual bool IsShowing() OVERRIDE;
253 virtual gfx::Rect GetViewBounds() const OVERRIDE;
254 virtual void SetShowingContextMenu(bool showing) OVERRIDE;
255 virtual void SetActive(bool active) OVERRIDE;
256 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE;
257 virtual void SetWindowVisibility(bool visible) OVERRIDE;
258 virtual void WindowFrameChanged() OVERRIDE;
259 virtual void ShowDefinitionForSelection() OVERRIDE;
260 virtual bool SupportsSpeech() const OVERRIDE;
261 virtual void SpeakSelection() OVERRIDE;
262 virtual bool IsSpeaking() const OVERRIDE;
263 virtual void StopSpeaking() OVERRIDE;
264 virtual void SetBackgroundOpaque(bool opaque) OVERRIDE;
266 // Implementation of RenderWidgetHostViewBase.
267 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
268 const gfx::Rect& pos) OVERRIDE;
269 virtual void InitAsFullscreen(
270 RenderWidgetHostView* reference_host_view) OVERRIDE;
271 virtual void WasShown() OVERRIDE;
272 virtual void WasHidden() OVERRIDE;
273 virtual void MovePluginWindows(
274 const std::vector<WebPluginGeometry>& moves) OVERRIDE;
275 virtual void Focus() OVERRIDE;
276 virtual void Blur() OVERRIDE;
277 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE;
278 virtual void SetIsLoading(bool is_loading) OVERRIDE;
279 virtual void TextInputStateChanged(
280 const ViewHostMsg_TextInputState_Params& params) OVERRIDE;
281 virtual void ImeCancelComposition() OVERRIDE;
282 virtual void ImeCompositionRangeChanged(
283 const gfx::Range& range,
284 const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
285 virtual void RenderProcessGone(base::TerminationStatus status,
286 int error_code) OVERRIDE;
287 virtual void Destroy() OVERRIDE;
288 virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE;
289 virtual void SelectionChanged(const base::string16& text,
290 size_t offset,
291 const gfx::Range& range) OVERRIDE;
292 virtual void SelectionBoundsChanged(
293 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE;
294 virtual void ScrollOffsetChanged() OVERRIDE;
295 virtual void CopyFromCompositingSurface(
296 const gfx::Rect& src_subrect,
297 const gfx::Size& dst_size,
298 const base::Callback<void(bool, const SkBitmap&)>& callback,
299 SkColorType color_type) OVERRIDE;
300 virtual void CopyFromCompositingSurfaceToVideoFrame(
301 const gfx::Rect& src_subrect,
302 const scoped_refptr<media::VideoFrame>& target,
303 const base::Callback<void(bool)>& callback) OVERRIDE;
304 virtual bool CanCopyToVideoFrame() const OVERRIDE;
305 virtual bool CanSubscribeFrame() const OVERRIDE;
306 virtual void BeginFrameSubscription(
307 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
308 virtual void EndFrameSubscription() OVERRIDE;
309 virtual void OnSwapCompositorFrame(
310 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) OVERRIDE;
311 virtual void AcceleratedSurfaceInitialized(int host_id,
312 int route_id) OVERRIDE;
313 virtual void CreateBrowserAccessibilityManagerIfNeeded() OVERRIDE;
314 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds)
315 OVERRIDE;
316 virtual void OnAccessibilitySetFocus(int acc_obj_id) OVERRIDE;
317 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE;
318 virtual bool PostProcessEventForPluginIme(
319 const NativeWebKeyboardEvent& event) OVERRIDE;
321 virtual void AcceleratedSurfaceBuffersSwapped(
322 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
323 int gpu_host_id) OVERRIDE;
324 virtual void AcceleratedSurfacePostSubBuffer(
325 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
326 int gpu_host_id) OVERRIDE;
327 virtual void AcceleratedSurfaceSuspend() OVERRIDE;
328 virtual void AcceleratedSurfaceRelease() OVERRIDE;
329 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
330 virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE;
331 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
332 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
334 virtual bool LockMouse() OVERRIDE;
335 virtual void UnlockMouse() OVERRIDE;
336 virtual void WheelEventAck(const blink::WebMouseWheelEvent& event,
337 InputEventAckState ack_result) OVERRIDE;
339 // IPC::Sender implementation.
340 virtual bool Send(IPC::Message* message) OVERRIDE;
342 // SoftwareFrameManagerClient implementation:
343 virtual void SoftwareFrameWasFreed(
344 uint32 output_surface_id, unsigned frame_id) OVERRIDE;
345 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE;
347 virtual SkColorType PreferredReadbackFormat() OVERRIDE;
349 // CompositingIOSurfaceLayerClient implementation.
350 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE;
352 // Forwards the mouse event to the renderer.
353 void ForwardMouseEvent(const blink::WebMouseEvent& event);
355 void KillSelf();
357 void SetTextInputActive(bool active);
359 // Sends completed plugin IME notification and text back to the renderer.
360 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id);
362 const std::string& selected_text() const { return selected_text_; }
364 // Update the IOSurface to be drawn and call setNeedsDisplay on
365 // |cocoa_view_|.
366 void CompositorSwapBuffers(IOSurfaceID surface_handle,
367 const gfx::Size& size,
368 float scale_factor,
369 const std::vector<ui::LatencyInfo>& latency_info);
371 // Called when a GPU error is detected. Posts a task to destroy all
372 // compositing state.
373 void GotAcceleratedCompositingError();
375 // Sets the overlay view, which should be drawn in the same IOSurface
376 // atop of this view, if both views are drawing accelerated content.
377 // Overlay is stored as a weak ptr.
378 void SetOverlayView(RenderWidgetHostViewMac* overlay,
379 const gfx::Point& offset);
381 // Removes the previously set overlay view.
382 void RemoveOverlayView();
384 // Returns true and stores first rectangle for character range if the
385 // requested |range| is already cached, otherwise returns false.
386 // Exposed for testing.
387 CONTENT_EXPORT bool GetCachedFirstRectForCharacterRange(
388 NSRange range, NSRect* rect, NSRange* actual_range);
390 // Returns true if there is line break in |range| and stores line breaking
391 // point to |line_breaking_point|. The |line_break_point| is valid only if
392 // this function returns true.
393 bool GetLineBreakIndex(const std::vector<gfx::Rect>& bounds,
394 const gfx::Range& range,
395 size_t* line_break_point);
397 // Returns composition character boundary rectangle. The |range| is
398 // composition based range. Also stores |actual_range| which is corresponding
399 // to actually used range for returned rectangle.
400 gfx::Rect GetFirstRectForCompositionRange(const gfx::Range& range,
401 gfx::Range* actual_range);
403 // Converts from given whole character range to composition oriented range. If
404 // the conversion failed, return gfx::Range::InvalidRange.
405 gfx::Range ConvertCharacterRangeToCompositionRange(
406 const gfx::Range& request_range);
408 WebContents* GetWebContents();
410 // These member variables should be private, but the associated ObjC class
411 // needs access to them and can't be made a friend.
413 // The associated Model. Can be NULL if Destroy() is called when
414 // someone (other than superview) has retained |cocoa_view_|.
415 RenderWidgetHostImpl* render_widget_host_;
417 // Current text input type.
418 ui::TextInputType text_input_type_;
419 bool can_compose_inline_;
421 // The background CoreAnimation layer which is hosted by |cocoa_view_|.
422 // The compositing or software layers will be added as sublayers to this.
423 base::scoped_nsobject<CALayer> background_layer_;
425 // The CoreAnimation layer hosted by the GPU process.
426 base::scoped_nsobject<CALayerHost> remote_layer_host_;
428 // The CoreAnimation layer for software compositing. This should be NULL
429 // when software compositing is not in use.
430 base::scoped_nsobject<SoftwareLayer> software_layer_;
432 // Accelerated compositing structures. These may be dynamically created and
433 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer.
434 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_;
435 scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_;
436 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_;
438 // Delegated frame management and compositior.
439 scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
440 scoped_ptr<ui::Layer> root_layer_;
442 // Container for the NSView drawn by the browser compositor.
443 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_;
445 // Placeholder that is allocated while browser_compositor_view_ is NULL,
446 // indicating that a BrowserCompositorViewMac may be allocated. This is to
447 // help in recycling the internals of BrowserCompositorViewMac.
448 scoped_ptr<BrowserCompositorViewPlaceholderMac>
449 browser_compositor_view_placeholder_;
451 // This holds the current software compositing framebuffer, if any.
452 scoped_ptr<SoftwareFrameManager> software_frame_manager_;
454 // Latency info to send back when the next frame appears on the
455 // screen.
456 std::vector<ui::LatencyInfo> pending_latency_info_;
458 NSWindow* pepper_fullscreen_window() const {
459 return pepper_fullscreen_window_;
462 CONTENT_EXPORT void release_pepper_fullscreen_window_for_testing();
464 RenderWidgetHostViewMac* fullscreen_parent_host_view() const {
465 return fullscreen_parent_host_view_;
468 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
469 return frame_subscriber_.get();
472 int window_number() const;
474 // The scale factor for the screen that the view is currently on.
475 float ViewScaleFactor() const;
477 // Update the scale factor for the backing store and for any CALayers.
478 void UpdateBackingStoreScaleFactor();
480 // Ensure that the display link is associated with the correct display.
481 void UpdateDisplayLink();
483 // The scale factor of the backing store. Note that this is updated based on
484 // ViewScaleFactor with some delay.
485 float backing_store_scale_factor_;
487 void AddPendingLatencyInfo(
488 const std::vector<ui::LatencyInfo>& latency_info);
489 void SendPendingLatencyInfoToHost();
491 void SendPendingSwapAck();
493 void PauseForPendingResizeOrRepaintsAndDraw();
495 // The geometric arrangement of the layers depends on cocoa_view's size, the
496 // compositing IOSurface's rounded size, and the software frame size. Update
497 // all of them using this function when any of those parameters changes. Also
498 // update the scale factor of the layers.
499 void LayoutLayers();
501 // DelegatedFrameHostClient implementation.
502 virtual ui::Compositor* GetCompositor() const OVERRIDE;
503 virtual ui::Layer* GetLayer() OVERRIDE;
504 virtual RenderWidgetHostImpl* GetHost() OVERRIDE;
505 virtual void SchedulePaintInRect(
506 const gfx::Rect& damage_rect_in_dip) OVERRIDE;
507 virtual bool IsVisible() OVERRIDE;
508 virtual scoped_ptr<ResizeLock> CreateResizeLock(
509 bool defer_compositor_lock) OVERRIDE;
510 virtual gfx::Size DesiredFrameSize() OVERRIDE;
511 virtual float CurrentDeviceScaleFactor() OVERRIDE;
512 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE;
513 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE;
515 // BrowserCompositorViewMacClient implementation.
516 virtual void BrowserCompositorViewFrameSwapped(
517 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
518 virtual NSView* BrowserCompositorSuperview() OVERRIDE;
519 virtual ui::Layer* BrowserCompositorRootLayer() OVERRIDE;
521 private:
522 friend class RenderWidgetHostViewMacTest;
524 struct PendingSwapAck {
525 PendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id)
526 : route_id(route_id),
527 gpu_host_id(gpu_host_id),
528 renderer_id(renderer_id) {}
529 int32 route_id;
530 int gpu_host_id;
531 int32 renderer_id;
533 scoped_ptr<PendingSwapAck> pending_swap_ack_;
534 void AddPendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id);
536 // Returns whether this render view is a popup (autocomplete window).
537 bool IsPopup() const;
539 // Shuts down the render_widget_host_. This is a separate function so we can
540 // invoke it from the message loop.
541 void ShutdownHost();
543 void EnsureBrowserCompositorView();
544 void DestroyBrowserCompositorView();
546 void EnsureSoftwareLayer();
547 void DestroySoftwareLayer();
549 bool EnsureCompositedIOSurface() WARN_UNUSED_RESULT;
550 void EnsureCompositedIOSurfaceLayer();
551 enum DestroyCompositedIOSurfaceLayerBehavior {
552 kLeaveLayerInHierarchy,
553 kRemoveLayerFromHierarchy,
555 void DestroyCompositedIOSurfaceLayer(
556 DestroyCompositedIOSurfaceLayerBehavior destroy_layer_behavior);
557 void DestroyCompositedIOSurfaceAndLayer();
559 void DestroyCompositingStateOnError();
561 // Called when a GPU SwapBuffers is received.
562 void GotAcceleratedFrame();
564 // Called when a software DIB is received.
565 void GotSoftwareFrame();
567 // IPC message handlers.
568 void OnPluginFocusChanged(bool focused, int plugin_id);
569 void OnStartPluginIme();
571 // Convert |rect| from the views coordinate (upper-left origin) into
572 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays.
573 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect);
575 // Send updated vsync parameters to the renderer.
576 void SendVSyncParametersToRenderer();
578 // The associated view. This is weak and is inserted into the view hierarchy
579 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the
580 // destructor.
581 RenderWidgetHostViewCocoa* cocoa_view_;
583 // Indicates if the page is loading.
584 bool is_loading_;
586 // The text to be shown in the tooltip, supplied by the renderer.
587 base::string16 tooltip_text_;
589 // Factory used to safely scope delayed calls to ShutdownHost().
590 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_;
592 // selected text on the renderer.
593 std::string selected_text_;
595 // The window used for popup widgets.
596 base::scoped_nsobject<NSWindow> popup_window_;
598 // The fullscreen window used for pepper flash.
599 base::scoped_nsobject<NSWindow> pepper_fullscreen_window_;
600 base::scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_;
601 // Our parent host view, if this is fullscreen. NULL otherwise.
602 RenderWidgetHostViewMac* fullscreen_parent_host_view_;
604 // The overlay view which is rendered above this one in the same
605 // accelerated IOSurface.
606 // Overlay view has |underlay_view_| set to this view.
607 base::WeakPtr<RenderWidgetHostViewMac> overlay_view_;
609 // The underlay view which this view is rendered above in the same
610 // accelerated IOSurface.
611 // Underlay view has |overlay_view_| set to this view.
612 base::WeakPtr<RenderWidgetHostViewMac> underlay_view_;
614 // Factory used to safely reference overlay view set in SetOverlayView.
615 base::WeakPtrFactory<RenderWidgetHostViewMac>
616 overlay_view_weak_factory_;
618 // Display link for getting vsync info.
619 scoped_refptr<DisplayLinkMac> display_link_;
621 // The current composition character range and its bounds.
622 gfx::Range composition_range_;
623 std::vector<gfx::Rect> composition_bounds_;
625 // The current caret bounds.
626 gfx::Rect caret_rect_;
628 // Subscriber that listens to frame presentation events.
629 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
631 base::WeakPtrFactory<RenderWidgetHostViewMac>
632 software_frame_weak_ptr_factory_;
633 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac);
636 } // namespace content
638 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_