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> |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/mac/scoped_nsobject.h" | 16 #include "base/mac/scoped_nsobject.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h" |
20 #include "content/browser/compositor/browser_compositor_view_mac.h" | 21 #include "content/browser/compositor/browser_compositor_view_mac.h" |
21 #include "content/browser/compositor/delegated_frame_host.h" | 22 #include "content/browser/compositor/delegated_frame_host.h" |
22 #include "content/browser/compositor/io_surface_layer_mac.h" | 23 #include "content/browser/compositor/io_surface_layer_mac.h" |
23 #include "content/browser/renderer_host/display_link_mac.h" | 24 #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/render_widget_host_view_base.h" |
25 #include "content/browser/renderer_host/software_frame_manager.h" | 26 #include "content/browser/renderer_host/software_frame_manager.h" |
26 #include "content/common/content_export.h" | 27 #include "content/common/content_export.h" |
27 #include "content/common/cursors/webcursor.h" | 28 #include "content/common/cursors/webcursor.h" |
28 #include "content/common/edit_command.h" | 29 #include "content/common/edit_command.h" |
29 #import "content/public/browser/render_widget_host_view_mac_base.h" | 30 #import "content/public/browser/render_widget_host_view_mac_base.h" |
30 #include "ipc/ipc_sender.h" | 31 #include "ipc/ipc_sender.h" |
31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
32 #include "ui/base/cocoa/base_view.h" | 33 #include "ui/base/cocoa/base_view.h" |
33 #include "ui/base/cocoa/remote_layer_api.h" | 34 #include "ui/base/cocoa/remote_layer_api.h" |
34 #include "ui/gfx/display_observer.h" | 35 #include "ui/gfx/display_observer.h" |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 class BrowserCompositorviewMac; | |
38 class RenderWidgetHostViewMac; | 38 class RenderWidgetHostViewMac; |
39 class RenderWidgetHostViewMacEditCommandHelper; | 39 class RenderWidgetHostViewMacEditCommandHelper; |
40 class WebContents; | 40 class WebContents; |
41 } | 41 } |
42 | 42 |
43 namespace ui { | 43 namespace ui { |
44 class Compositor; | 44 class Compositor; |
45 class Layer; | 45 class Layer; |
46 } | 46 } |
47 | 47 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Comment excerpted from render_widget_host.h: | 198 // Comment excerpted from render_widget_host.h: |
199 // | 199 // |
200 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 200 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
201 // If the render process dies, the RenderWidgetHost* goes away and all | 201 // If the render process dies, the RenderWidgetHost* goes away and all |
202 // references to it must become NULL." | 202 // references to it must become NULL." |
203 // | 203 // |
204 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 204 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
205 class CONTENT_EXPORT RenderWidgetHostViewMac | 205 class CONTENT_EXPORT RenderWidgetHostViewMac |
206 : public RenderWidgetHostViewBase, | 206 : public RenderWidgetHostViewBase, |
207 public DelegatedFrameHostClient, | 207 public DelegatedFrameHostClient, |
208 public BrowserCompositorViewMacClient, | 208 public AcceleratedWidgetMacNSView, |
209 public IPC::Sender, | 209 public IPC::Sender, |
210 public gfx::DisplayObserver { | 210 public gfx::DisplayObserver { |
211 public: | 211 public: |
212 // The view will associate itself with the given widget. The native view must | 212 // 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 | 213 // be hooked up immediately to the view hierarchy, or else when it is |
214 // deleted it will delete this out from under the caller. | 214 // deleted it will delete this out from under the caller. |
215 // | 215 // |
216 // When |is_guest_view_hack| is true, this view isn't really the view for | 216 // When |is_guest_view_hack| is true, this view isn't really the view for |
217 // the |widget|, a RenderWidgetHostViewGuest is. | 217 // the |widget|, a RenderWidgetHostViewGuest is. |
218 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 218 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // someone (other than superview) has retained |cocoa_view_|. | 373 // someone (other than superview) has retained |cocoa_view_|. |
374 RenderWidgetHostImpl* render_widget_host_; | 374 RenderWidgetHostImpl* render_widget_host_; |
375 | 375 |
376 // Current text input type. | 376 // Current text input type. |
377 ui::TextInputType text_input_type_; | 377 ui::TextInputType text_input_type_; |
378 bool can_compose_inline_; | 378 bool can_compose_inline_; |
379 | 379 |
380 // The background CoreAnimation layer which is hosted by |cocoa_view_|. | 380 // The background CoreAnimation layer which is hosted by |cocoa_view_|. |
381 base::scoped_nsobject<CALayer> background_layer_; | 381 base::scoped_nsobject<CALayer> background_layer_; |
382 | 382 |
383 // The state of |delegated_frame_host_| and |browser_compositor_view_| to | 383 // The state of |delegated_frame_host_| and |browser_compositor_| to |
384 // manage being visible, hidden, or occluded. | 384 // manage being visible, hidden, or occluded. |
385 enum BrowserCompositorViewState { | 385 enum BrowserCompositorViewState { |
386 // Effects: | 386 // Effects: |
387 // - |browser_compositor_view_| exists and |delegated_frame_host_| is | 387 // - |browser_compositor_| exists and |delegated_frame_host_| is |
388 // visible. | 388 // visible. |
389 // Happens when: | 389 // Happens when: |
390 // - |render_widet_host_| is in the visible state (this includes when | 390 // - |render_widet_host_| is in the visible state (this includes when |
391 // the tab isn't visible, but tab capture is enabled). | 391 // the tab isn't visible, but tab capture is enabled). |
392 BrowserCompositorActive, | 392 BrowserCompositorActive, |
393 // Effects: | 393 // Effects: |
394 // - |browser_compositor_view_| exists, but |delegated_frame_host_| has | 394 // - |browser_compositor_| exists, but |delegated_frame_host_| has |
395 // been hidden. | 395 // been hidden. |
396 // Happens when: | 396 // Happens when: |
397 // - The |render_widget_host_| is hidden, but |cocoa_view_| is still in the | 397 // - The |render_widget_host_| is hidden, but |cocoa_view_| is still in the |
398 // NSWindow hierarchy. | 398 // NSWindow hierarchy. |
399 // - This happens when |cocoa_view_| is hidden (minimized, on another | 399 // - This happens when |cocoa_view_| is hidden (minimized, on another |
400 // occluded by other windows, etc). The |browser_compositor_view_| and | 400 // occluded by other windows, etc). The |browser_compositor_| and |
401 // its CALayers are kept around so that we will have content to show when | 401 // its CALayers are kept around so that we will have content to show when |
402 // we are un-occluded. | 402 // we are un-occluded. |
403 BrowserCompositorSuspended, | 403 BrowserCompositorSuspended, |
404 // Effects: | 404 // Effects: |
405 // - |browser_compositor_view_| has been destroyed and | 405 // - |browser_compositor_| has been destroyed and |
406 // |delegated_frame_host_| has been hidden. | 406 // |delegated_frame_host_| has been hidden. |
407 // Happens when: | 407 // Happens when: |
408 // - The |render_widget_host_| is hidden or dead, and |cocoa_view_| is not | 408 // - The |render_widget_host_| is hidden or dead, and |cocoa_view_| is not |
409 // attached to a NSWindow. | 409 // attached to a NSWindow. |
410 // - This happens for backgrounded tabs. | 410 // - This happens for backgrounded tabs. |
411 BrowserCompositorDestroyed, | 411 BrowserCompositorDestroyed, |
412 }; | 412 }; |
413 BrowserCompositorViewState browser_compositor_state_; | 413 BrowserCompositorViewState browser_compositor_state_; |
414 | 414 |
415 // Delegated frame management and compositior. | 415 // Delegated frame management and compositior. |
416 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 416 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
417 scoped_ptr<ui::Layer> root_layer_; | 417 scoped_ptr<ui::Layer> root_layer_; |
418 | 418 |
419 // Container for the CALayer tree drawn by the browser compositor. | 419 // Container for ui::Compositor the CALayer tree drawn by it. |
420 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_; | 420 scoped_ptr<BrowserCompositorMac> browser_compositor_; |
421 | 421 |
422 // Placeholder that is allocated while browser_compositor_view_ is NULL, | 422 // Placeholder that is allocated while browser_compositor_ is NULL, |
423 // indicating that a BrowserCompositorViewMac may be allocated. This is to | 423 // indicating that a BrowserCompositorViewMac may be allocated. This is to |
424 // help in recycling the internals of BrowserCompositorViewMac. | 424 // help in recycling the internals of BrowserCompositorViewMac. |
425 scoped_ptr<BrowserCompositorViewPlaceholderMac> | 425 scoped_ptr<BrowserCompositorMacPlaceholder> |
426 browser_compositor_view_placeholder_; | 426 browser_compositor_placeholder_; |
427 | 427 |
428 NSWindow* pepper_fullscreen_window() const { | 428 NSWindow* pepper_fullscreen_window() const { |
429 return pepper_fullscreen_window_; | 429 return pepper_fullscreen_window_; |
430 } | 430 } |
431 | 431 |
432 CONTENT_EXPORT void release_pepper_fullscreen_window_for_testing(); | 432 CONTENT_EXPORT void release_pepper_fullscreen_window_for_testing(); |
433 | 433 |
434 RenderWidgetHostViewMac* fullscreen_parent_host_view() const { | 434 RenderWidgetHostViewMac* fullscreen_parent_host_view() const { |
435 return fullscreen_parent_host_view_; | 435 return fullscreen_parent_host_view_; |
436 } | 436 } |
(...skipping 15 matching lines...) Expand all Loading... |
452 ui::Compositor* GetCompositor() const override; | 452 ui::Compositor* GetCompositor() const override; |
453 ui::Layer* GetLayer() override; | 453 ui::Layer* GetLayer() override; |
454 RenderWidgetHostImpl* GetHost() override; | 454 RenderWidgetHostImpl* GetHost() override; |
455 bool IsVisible() override; | 455 bool IsVisible() override; |
456 scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock) override; | 456 scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock) override; |
457 gfx::Size DesiredFrameSize() override; | 457 gfx::Size DesiredFrameSize() override; |
458 float CurrentDeviceScaleFactor() override; | 458 float CurrentDeviceScaleFactor() override; |
459 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; | 459 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; |
460 DelegatedFrameHost* GetDelegatedFrameHost() const override; | 460 DelegatedFrameHost* GetDelegatedFrameHost() const override; |
461 | 461 |
462 // BrowserCompositorViewMacClient implementation. | 462 // AcceleratedWidgetMacNSView implementation. |
463 bool BrowserCompositorViewShouldAckImmediately() const override; | 463 NSView* AcceleratedWidgetGetNSView() const override; |
464 void BrowserCompositorViewFrameSwapped( | 464 bool AcceleratedWidgetShouldIgnoreBackpressure() const override; |
| 465 void AcceleratedWidgetSwapCompleted( |
465 const std::vector<ui::LatencyInfo>& latency_info) override; | 466 const std::vector<ui::LatencyInfo>& latency_info) override; |
| 467 void AcceleratedWidgetHitError() override; |
466 | 468 |
467 // Transition from being in the Suspended state to being in the Destroyed | 469 // Transition from being in the Suspended state to being in the Destroyed |
468 // state, if appropriate (see BrowserCompositorViewState for details). | 470 // state, if appropriate (see BrowserCompositorViewState for details). |
469 void DestroySuspendedBrowserCompositorViewIfNeeded(); | 471 void DestroySuspendedBrowserCompositorViewIfNeeded(); |
470 | 472 |
471 private: | 473 private: |
472 friend class RenderWidgetHostViewMacTest; | 474 friend class RenderWidgetHostViewMacTest; |
473 | 475 |
474 // Returns whether this render view is a popup (autocomplete window). | 476 // Returns whether this render view is a popup (autocomplete window). |
475 bool IsPopup() const; | 477 bool IsPopup() const; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 551 |
550 // The current caret bounds. | 552 // The current caret bounds. |
551 gfx::Rect caret_rect_; | 553 gfx::Rect caret_rect_; |
552 | 554 |
553 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 555 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
554 }; | 556 }; |
555 | 557 |
556 } // namespace content | 558 } // namespace content |
557 | 559 |
558 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 560 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |