OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <IOSurface/IOSurfaceAPI.h> | 9 #include <IOSurface/IOSurfaceAPI.h> |
10 #include <list> | 10 #include <list> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 24 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/browser/renderer_host/software_frame_manager.h" | 25 #include "content/browser/renderer_host/software_frame_manager.h" |
26 #include "content/common/content_export.h" | 26 #include "content/common/content_export.h" |
27 #include "content/common/cursors/webcursor.h" | 27 #include "content/common/cursors/webcursor.h" |
28 #include "content/common/edit_command.h" | 28 #include "content/common/edit_command.h" |
29 #import "content/public/browser/render_widget_host_view_mac_base.h" | 29 #import "content/public/browser/render_widget_host_view_mac_base.h" |
30 #include "ipc/ipc_sender.h" | 30 #include "ipc/ipc_sender.h" |
31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
32 #include "ui/base/cocoa/base_view.h" | 32 #include "ui/base/cocoa/base_view.h" |
33 #include "ui/base/cocoa/remote_layer_api.h" | 33 #include "ui/base/cocoa/remote_layer_api.h" |
| 34 #include "ui/base/compositor/compositor_begin_frame_observer.h" |
34 #include "ui/gfx/display_observer.h" | 35 #include "ui/gfx/display_observer.h" |
35 | 36 |
36 struct ViewHostMsg_TextInputState_Params; | 37 struct ViewHostMsg_TextInputState_Params; |
37 | 38 |
38 namespace content { | 39 namespace content { |
39 class BrowserCompositorviewMac; | 40 class BrowserCompositorviewMac; |
40 class RenderWidgetHostViewMac; | 41 class RenderWidgetHostViewMac; |
41 class RenderWidgetHostViewMacEditCommandHelper; | 42 class RenderWidgetHostViewMacEditCommandHelper; |
42 class WebContents; | 43 class WebContents; |
43 } | 44 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 201 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
201 // If the render process dies, the RenderWidgetHost* goes away and all | 202 // If the render process dies, the RenderWidgetHost* goes away and all |
202 // references to it must become NULL." | 203 // references to it must become NULL." |
203 // | 204 // |
204 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 205 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
205 class CONTENT_EXPORT RenderWidgetHostViewMac | 206 class CONTENT_EXPORT RenderWidgetHostViewMac |
206 : public RenderWidgetHostViewBase, | 207 : public RenderWidgetHostViewBase, |
207 public DelegatedFrameHostClient, | 208 public DelegatedFrameHostClient, |
208 public BrowserCompositorViewMacClient, | 209 public BrowserCompositorViewMacClient, |
209 public IPC::Sender, | 210 public IPC::Sender, |
210 public gfx::DisplayObserver { | 211 public SoftwareFrameManagerClient, |
| 212 public CompositingIOSurfaceLayerClient, |
| 213 public gfx::DisplayObserver, |
| 214 public DisplayLinkMac::Observer, |
| 215 public ui::CompositorBeginFrameObserver { |
211 public: | 216 public: |
212 // The view will associate itself with the given widget. The native view must | 217 // The view will associate itself with the given widget. The native view must |
213 // be hooked up immediately to the view hierarchy, or else when it is | 218 // be hooked up immediately to the view hierarchy, or else when it is |
214 // deleted it will delete this out from under the caller. | 219 // deleted it will delete this out from under the caller. |
215 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); | 220 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); |
216 virtual ~RenderWidgetHostViewMac(); | 221 virtual ~RenderWidgetHostViewMac(); |
217 | 222 |
218 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } | 223 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } |
219 | 224 |
220 // |delegate| is used to separate out the logic from the NSResponder delegate. | 225 // |delegate| is used to separate out the logic from the NSResponder delegate. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 virtual bool Send(IPC::Message* message) OVERRIDE; | 334 virtual bool Send(IPC::Message* message) OVERRIDE; |
330 | 335 |
331 virtual SkColorType PreferredReadbackFormat() OVERRIDE; | 336 virtual SkColorType PreferredReadbackFormat() OVERRIDE; |
332 | 337 |
333 // gfx::DisplayObserver implementation. | 338 // gfx::DisplayObserver implementation. |
334 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; | 339 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; |
335 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; | 340 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; |
336 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 341 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
337 uint32_t metrics) OVERRIDE; | 342 uint32_t metrics) OVERRIDE; |
338 | 343 |
| 344 // DisplayLinkMac::Observer implementation. |
| 345 virtual void OnVSync(base::TimeTicks timebase, |
| 346 base::TimeDelta interval) OVERRIDE; |
| 347 |
| 348 // ui::CompositorBeginFrameObserver implementation. |
| 349 virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) OVERRIDE; |
| 350 |
339 // Forwards the mouse event to the renderer. | 351 // Forwards the mouse event to the renderer. |
340 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 352 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
341 | 353 |
342 void KillSelf(); | 354 void KillSelf(); |
343 | 355 |
344 void SetTextInputActive(bool active); | 356 void SetTextInputActive(bool active); |
345 | 357 |
346 // Sends completed plugin IME notification and text back to the renderer. | 358 // Sends completed plugin IME notification and text back to the renderer. |
347 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); | 359 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); |
348 | 360 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 void ShutdownBrowserCompositor(); | 470 void ShutdownBrowserCompositor(); |
459 | 471 |
460 void EnsureBrowserCompositorView(); | 472 void EnsureBrowserCompositorView(); |
461 void DestroyBrowserCompositorView(); | 473 void DestroyBrowserCompositorView(); |
462 | 474 |
463 // IPC message handlers. | 475 // IPC message handlers. |
464 void OnPluginFocusChanged(bool focused, int plugin_id); | 476 void OnPluginFocusChanged(bool focused, int plugin_id); |
465 void OnStartPluginIme(); | 477 void OnStartPluginIme(); |
466 void OnGetRenderedTextCompleted(const std::string& text); | 478 void OnGetRenderedTextCompleted(const std::string& text); |
467 | 479 |
468 // Send updated vsync parameters to the renderer. | 480 // Called when RenderWidget want to get BeginFrame message. |
469 void SendVSyncParametersToRenderer(); | 481 void OnSetNeedsBeginFrame(bool enabled); |
470 | 482 |
471 // Dispatches a TTS session. | 483 // Dispatches a TTS session. |
472 void SpeakText(const std::string& text); | 484 void SpeakText(const std::string& text); |
473 | 485 |
474 // The associated view. This is weak and is inserted into the view hierarchy | 486 // The associated view. This is weak and is inserted into the view hierarchy |
475 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the | 487 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the |
476 // destructor. | 488 // destructor. |
477 RenderWidgetHostViewCocoa* cocoa_view_; | 489 RenderWidgetHostViewCocoa* cocoa_view_; |
478 | 490 |
479 // Indicates if the page is loading. | 491 // Indicates if the page is loading. |
(...skipping 19 matching lines...) Expand all Loading... |
499 | 511 |
500 // The fullscreen window used for pepper flash. | 512 // The fullscreen window used for pepper flash. |
501 base::scoped_nsobject<NSWindow> pepper_fullscreen_window_; | 513 base::scoped_nsobject<NSWindow> pepper_fullscreen_window_; |
502 base::scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; | 514 base::scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; |
503 // Our parent host view, if this is fullscreen. NULL otherwise. | 515 // Our parent host view, if this is fullscreen. NULL otherwise. |
504 RenderWidgetHostViewMac* fullscreen_parent_host_view_; | 516 RenderWidgetHostViewMac* fullscreen_parent_host_view_; |
505 | 517 |
506 // Display link for getting vsync info. | 518 // Display link for getting vsync info. |
507 scoped_refptr<DisplayLinkMac> display_link_; | 519 scoped_refptr<DisplayLinkMac> display_link_; |
508 | 520 |
509 // The current VSync timebase and interval. This is zero until the first call | |
510 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. | |
511 base::TimeTicks vsync_timebase_; | |
512 base::TimeDelta vsync_interval_; | |
513 | |
514 // The current composition character range and its bounds. | 521 // The current composition character range and its bounds. |
515 gfx::Range composition_range_; | 522 gfx::Range composition_range_; |
516 std::vector<gfx::Rect> composition_bounds_; | 523 std::vector<gfx::Rect> composition_bounds_; |
517 | 524 |
518 // The current caret bounds. | 525 // The current caret bounds. |
519 gfx::Rect caret_rect_; | 526 gfx::Rect caret_rect_; |
520 | 527 |
| 528 // Subscriber that listens to frame presentation events. |
| 529 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; |
| 530 |
| 531 // True when corresponding RenderWidget needs BeginFrame. |
| 532 bool needs_begin_frame_; |
| 533 |
| 534 // Pass |last_begin_frame_args_| to BeginFrameManager when |this| is added |
| 535 // as its observer. With this, BeginFrameManager can determine whether latest |
| 536 // BeginFrameArgs is used immediately or not. |
| 537 cc::BeginFrameArgs last_begin_frame_args_; |
| 538 |
| 539 base::WeakPtrFactory<RenderWidgetHostViewMac> |
| 540 software_frame_weak_ptr_factory_; |
521 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 541 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
522 }; | 542 }; |
523 | 543 |
524 } // namespace content | 544 } // namespace content |
525 | 545 |
526 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 546 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |