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/IOSurface.h> | 9 #include <IOSurface/IOSurface.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <list> | 13 #include <list> |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <set> | 16 #include <set> |
17 #include <string> | 17 #include <string> |
18 #include <utility> | 18 #include <utility> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "base/mac/scoped_nsobject.h" | 21 #include "base/mac/scoped_nsobject.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "cc/scheduler/begin_frame_source.h" |
25 #include "cc/surfaces/surface_id.h" | 26 #include "cc/surfaces/surface_id.h" |
26 #include "content/browser/renderer_host/browser_compositor_view_mac.h" | 27 #include "content/browser/renderer_host/browser_compositor_view_mac.h" |
27 #include "content/browser/renderer_host/delegated_frame_host.h" | 28 #include "content/browser/renderer_host/delegated_frame_host.h" |
28 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" | 29 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" |
29 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 30 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
30 #include "content/common/content_export.h" | 31 #include "content/common/content_export.h" |
31 #include "content/common/cursors/webcursor.h" | 32 #include "content/common/cursors/webcursor.h" |
32 #include "content/common/edit_command.h" | 33 #include "content/common/edit_command.h" |
33 #include "ipc/ipc_sender.h" | 34 #include "ipc/ipc_sender.h" |
34 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 35 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 223 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
223 // If the render process dies, the RenderWidgetHost* goes away and all | 224 // If the render process dies, the RenderWidgetHost* goes away and all |
224 // references to it must become NULL." | 225 // references to it must become NULL." |
225 // | 226 // |
226 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 227 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
227 class CONTENT_EXPORT RenderWidgetHostViewMac | 228 class CONTENT_EXPORT RenderWidgetHostViewMac |
228 : public RenderWidgetHostViewBase, | 229 : public RenderWidgetHostViewBase, |
229 public DelegatedFrameHostClient, | 230 public DelegatedFrameHostClient, |
230 public ui::AcceleratedWidgetMacNSView, | 231 public ui::AcceleratedWidgetMacNSView, |
231 public IPC::Sender, | 232 public IPC::Sender, |
232 public gfx::DisplayObserver { | 233 public gfx::DisplayObserver, |
| 234 public cc::BeginFrameObserverBase { |
233 public: | 235 public: |
234 // The view will associate itself with the given widget. The native view must | 236 // The view will associate itself with the given widget. The native view must |
235 // be hooked up immediately to the view hierarchy, or else when it is | 237 // be hooked up immediately to the view hierarchy, or else when it is |
236 // deleted it will delete this out from under the caller. | 238 // deleted it will delete this out from under the caller. |
237 // | 239 // |
238 // When |is_guest_view_hack| is true, this view isn't really the view for | 240 // When |is_guest_view_hack| is true, this view isn't really the view for |
239 // the |widget|, a RenderWidgetHostViewGuest is. | 241 // the |widget|, a RenderWidgetHostViewGuest is. |
240 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 242 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
241 // to use RWHVChildFrame (http://crbug.com/330264). | 243 // to use RWHVChildFrame (http://crbug.com/330264). |
242 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); | 244 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 360 |
359 // gfx::DisplayObserver implementation. | 361 // gfx::DisplayObserver implementation. |
360 void OnDisplayAdded(const gfx::Display& new_display) override; | 362 void OnDisplayAdded(const gfx::Display& new_display) override; |
361 void OnDisplayRemoved(const gfx::Display& old_display) override; | 363 void OnDisplayRemoved(const gfx::Display& old_display) override; |
362 void OnDisplayMetricsChanged(const gfx::Display& display, | 364 void OnDisplayMetricsChanged(const gfx::Display& display, |
363 uint32_t metrics) override; | 365 uint32_t metrics) override; |
364 | 366 |
365 // Forwards the mouse event to the renderer. | 367 // Forwards the mouse event to the renderer. |
366 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 368 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
367 | 369 |
| 370 // Called when RenderWidget wants to start BeginFrame scheduling or stop. |
| 371 void OnSetNeedsBeginFrames(bool needs_begin_frames); |
| 372 |
368 void KillSelf(); | 373 void KillSelf(); |
369 | 374 |
370 void SetTextInputActive(bool active); | 375 void SetTextInputActive(bool active); |
371 | 376 |
372 const std::string& selected_text() const { return selected_text_; } | 377 const std::string& selected_text() const { return selected_text_; } |
373 const gfx::Range& composition_range() const { return composition_range_; } | 378 const gfx::Range& composition_range() const { return composition_range_; } |
374 const base::string16& selection_text() const { return selection_text_; } | 379 const base::string16& selection_text() const { return selection_text_; } |
375 size_t selection_text_offset() const { return selection_text_offset_; } | 380 size_t selection_text_offset() const { return selection_text_offset_; } |
376 | 381 |
377 // Returns true and stores first rectangle for character range if the | 382 // Returns true and stores first rectangle for character range if the |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 void DelegatedFrameHostSendCompositorSwapAck( | 503 void DelegatedFrameHostSendCompositorSwapAck( |
499 int output_surface_id, | 504 int output_surface_id, |
500 const cc::CompositorFrameAck& ack) override; | 505 const cc::CompositorFrameAck& ack) override; |
501 void DelegatedFrameHostSendReclaimCompositorResources( | 506 void DelegatedFrameHostSendReclaimCompositorResources( |
502 int output_surface_id, | 507 int output_surface_id, |
503 const cc::CompositorFrameAck& ack) override; | 508 const cc::CompositorFrameAck& ack) override; |
504 void DelegatedFrameHostOnLostCompositorResources() override; | 509 void DelegatedFrameHostOnLostCompositorResources() override; |
505 void DelegatedFrameHostUpdateVSyncParameters( | 510 void DelegatedFrameHostUpdateVSyncParameters( |
506 const base::TimeTicks& timebase, | 511 const base::TimeTicks& timebase, |
507 const base::TimeDelta& interval) override; | 512 const base::TimeDelta& interval) override; |
| 513 void SetBeginFrameSource(cc::BeginFrameSource* source) override; |
| 514 |
| 515 // cc::BeginFrameObserverBase implementation. |
| 516 bool OnBeginFrameDerivedImpl(const cc::BeginFrameArgs& args) override; |
| 517 void OnBeginFrameSourcePausedChanged(bool paused) override; |
508 | 518 |
509 // AcceleratedWidgetMacNSView implementation. | 519 // AcceleratedWidgetMacNSView implementation. |
510 NSView* AcceleratedWidgetGetNSView() const override; | 520 NSView* AcceleratedWidgetGetNSView() const override; |
511 void AcceleratedWidgetGetVSyncParameters( | 521 void AcceleratedWidgetGetVSyncParameters( |
512 base::TimeTicks* timebase, base::TimeDelta* interval) const override; | 522 base::TimeTicks* timebase, base::TimeDelta* interval) const override; |
513 void AcceleratedWidgetSwapCompleted() override; | 523 void AcceleratedWidgetSwapCompleted() override; |
514 | 524 |
515 // Transition from being in the Suspended state to being in the Destroyed | 525 // Transition from being in the Suspended state to being in the Destroyed |
516 // state, if appropriate (see BrowserCompositorViewState for details). | 526 // state, if appropriate (see BrowserCompositorViewState for details). |
517 void DestroySuspendedBrowserCompositorViewIfNeeded(); | 527 void DestroySuspendedBrowserCompositorViewIfNeeded(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 RenderWidgetHostViewMac* fullscreen_parent_host_view_; | 595 RenderWidgetHostViewMac* fullscreen_parent_host_view_; |
586 | 596 |
587 // Display link for getting vsync info. | 597 // Display link for getting vsync info. |
588 scoped_refptr<ui::DisplayLinkMac> display_link_; | 598 scoped_refptr<ui::DisplayLinkMac> display_link_; |
589 | 599 |
590 // The current VSync timebase and interval. This is zero until the first call | 600 // The current VSync timebase and interval. This is zero until the first call |
591 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. | 601 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. |
592 base::TimeTicks vsync_timebase_; | 602 base::TimeTicks vsync_timebase_; |
593 base::TimeDelta vsync_interval_; | 603 base::TimeDelta vsync_interval_; |
594 | 604 |
| 605 // The begin frame source being observed. Null if none. |
| 606 cc::BeginFrameSource* begin_frame_source_; |
| 607 bool needs_begin_frames_; |
| 608 |
595 // The current composition character range and its bounds. | 609 // The current composition character range and its bounds. |
596 gfx::Range composition_range_; | 610 gfx::Range composition_range_; |
597 std::vector<gfx::Rect> composition_bounds_; | 611 std::vector<gfx::Rect> composition_bounds_; |
598 | 612 |
599 // The current caret bounds. | 613 // The current caret bounds. |
600 gfx::Rect caret_rect_; | 614 gfx::Rect caret_rect_; |
601 | 615 |
602 // The current first selection bounds. | 616 // The current first selection bounds. |
603 gfx::Rect first_selection_rect_; | 617 gfx::Rect first_selection_rect_; |
604 | 618 |
605 // Factory used to safely scope delayed calls to ShutdownHost(). | 619 // Factory used to safely scope delayed calls to ShutdownHost(). |
606 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 620 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
607 | 621 |
608 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 622 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
609 }; | 623 }; |
610 | 624 |
611 } // namespace content | 625 } // namespace content |
612 | 626 |
613 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 627 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |