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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 // someone (other than superview) has retained |cocoa_view_|. | 370 // someone (other than superview) has retained |cocoa_view_|. |
371 RenderWidgetHostImpl* render_widget_host_; | 371 RenderWidgetHostImpl* render_widget_host_; |
372 | 372 |
373 // Current text input type. | 373 // Current text input type. |
374 ui::TextInputType text_input_type_; | 374 ui::TextInputType text_input_type_; |
375 bool can_compose_inline_; | 375 bool can_compose_inline_; |
376 | 376 |
377 // The background CoreAnimation layer which is hosted by |cocoa_view_|. | 377 // The background CoreAnimation layer which is hosted by |cocoa_view_|. |
378 base::scoped_nsobject<CALayer> background_layer_; | 378 base::scoped_nsobject<CALayer> background_layer_; |
379 | 379 |
380 // The state of |delegated_frame_host_| and |browser_compositor_view_| to | |
381 // manage being visible, hidden, or occluded. | |
382 enum BrowserCompositorViewState { | |
383 // Effects: | |
384 // - |browser_compositor_view_| exists and |delegated_frame_host_| is | |
385 // visible. | |
386 // Happens when: | |
387 // - |render_widet_host_| is in the visible state (this includes when | |
388 // the tab isn't visible, but tab capture is enabled). | |
389 BrowserCompositorActive, | |
390 // Effects: | |
391 // - |browser_compositor_view_| exists, but |delegated_frame_host_| has | |
392 // been hidden. | |
393 // Happens when: | |
394 // - The |render_widget_host_| is hidden, but |cocoa_view_| is still in the | |
395 // NSWindow hierarchy. | |
396 // - This happens when |cocoa_view_| is occluded by another window. The | |
Andre
2014/10/30 03:19:26
Occlusion also happens when the window is minimize
ccameron
2014/10/30 19:23:33
Done.
| |
397 // |browser_compositor_view_| and its CALayers are kept around so that we | |
398 // will have content to show when we are un-occluded. | |
399 BrowserCompositorSuspended, | |
400 // Effects: | |
401 // - |browser_compositor_view_| has been destroyed and | |
402 // |delegated_frame_host_| has been hidden. This is for situations where | |
miu
2014/10/30 18:33:44
s/This is for situations where//
ccameron
2014/10/30 19:23:33
Done.
| |
403 // Happens when: | |
404 // - The |render_widget_host_| is hidden or dead, and |cocoa_view_| is not | |
405 // attached to a NSWindow. | |
406 // - This happens for backgrounded tabs. | |
407 BrowserCompositorDestroyed, | |
408 }; | |
Avi (use Gerrit)
2014/10/30 19:32:52
I love these comments.
| |
409 BrowserCompositorViewState browser_compositor_state_; | |
410 | |
380 // Delegated frame management and compositior. | 411 // Delegated frame management and compositior. |
381 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 412 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
382 scoped_ptr<ui::Layer> root_layer_; | 413 scoped_ptr<ui::Layer> root_layer_; |
383 | 414 |
384 // Container for the NSView drawn by the browser compositor. | 415 // Container for the CALayer tree drawn by the browser compositor. |
385 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_; | 416 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_; |
386 | 417 |
387 // Placeholder that is allocated while browser_compositor_view_ is NULL, | 418 // Placeholder that is allocated while browser_compositor_view_ is NULL, |
388 // indicating that a BrowserCompositorViewMac may be allocated. This is to | 419 // indicating that a BrowserCompositorViewMac may be allocated. This is to |
389 // help in recycling the internals of BrowserCompositorViewMac. | 420 // help in recycling the internals of BrowserCompositorViewMac. |
390 scoped_ptr<BrowserCompositorViewPlaceholderMac> | 421 scoped_ptr<BrowserCompositorViewPlaceholderMac> |
391 browser_compositor_view_placeholder_; | 422 browser_compositor_view_placeholder_; |
392 | 423 |
393 NSWindow* pepper_fullscreen_window() const { | 424 NSWindow* pepper_fullscreen_window() const { |
394 return pepper_fullscreen_window_; | 425 return pepper_fullscreen_window_; |
(...skipping 27 matching lines...) Expand all Loading... | |
422 gfx::Size DesiredFrameSize() override; | 453 gfx::Size DesiredFrameSize() override; |
423 float CurrentDeviceScaleFactor() override; | 454 float CurrentDeviceScaleFactor() override; |
424 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; | 455 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; |
425 DelegatedFrameHost* GetDelegatedFrameHost() const override; | 456 DelegatedFrameHost* GetDelegatedFrameHost() const override; |
426 | 457 |
427 // BrowserCompositorViewMacClient implementation. | 458 // BrowserCompositorViewMacClient implementation. |
428 bool BrowserCompositorViewShouldAckImmediately() const override; | 459 bool BrowserCompositorViewShouldAckImmediately() const override; |
429 void BrowserCompositorViewFrameSwapped( | 460 void BrowserCompositorViewFrameSwapped( |
430 const std::vector<ui::LatencyInfo>& latency_info) override; | 461 const std::vector<ui::LatencyInfo>& latency_info) override; |
431 | 462 |
463 // Transition from being in the Suspended state to being in the Destroyed | |
464 // state, if appropriate (see BrowserCompositorViewState for details). | |
465 void DestroySuspendedBrowserCompositorViewIfNeeded(); | |
466 | |
432 private: | 467 private: |
433 friend class RenderWidgetHostViewMacTest; | 468 friend class RenderWidgetHostViewMacTest; |
434 | 469 |
435 // Returns whether this render view is a popup (autocomplete window). | 470 // Returns whether this render view is a popup (autocomplete window). |
436 bool IsPopup() const; | 471 bool IsPopup() const; |
437 | 472 |
438 // Shuts down the render_widget_host_. This is a separate function so we can | 473 // Shuts down the render_widget_host_. This is a separate function so we can |
439 // invoke it from the message loop. | 474 // invoke it from the message loop. |
440 void ShutdownHost(); | 475 void ShutdownHost(); |
441 | 476 |
442 // Tear down all components of the browser compositor in an order that will | 477 // Tear down all components of the browser compositor in an order that will |
443 // ensure no dangling references. | 478 // ensure no dangling references. |
444 void ShutdownBrowserCompositor(); | 479 void ShutdownBrowserCompositor(); |
445 | 480 |
481 // The state of the the browser compositor and delegated frame host. See | |
482 // BrowserCompositorViewState for details. | |
446 void EnsureBrowserCompositorView(); | 483 void EnsureBrowserCompositorView(); |
484 void SuspendBrowserCompositorView(); | |
447 void DestroyBrowserCompositorView(); | 485 void DestroyBrowserCompositorView(); |
448 | 486 |
449 // IPC message handlers. | 487 // IPC message handlers. |
450 void OnPluginFocusChanged(bool focused, int plugin_id); | 488 void OnPluginFocusChanged(bool focused, int plugin_id); |
451 void OnStartPluginIme(); | 489 void OnStartPluginIme(); |
452 void OnGetRenderedTextCompleted(const std::string& text); | 490 void OnGetRenderedTextCompleted(const std::string& text); |
453 | 491 |
454 // Send updated vsync parameters to the renderer. | 492 // Send updated vsync parameters to the renderer. |
455 void SendVSyncParametersToRenderer(); | 493 void SendVSyncParametersToRenderer(); |
456 | 494 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 | 545 |
508 // The current caret bounds. | 546 // The current caret bounds. |
509 gfx::Rect caret_rect_; | 547 gfx::Rect caret_rect_; |
510 | 548 |
511 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 549 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
512 }; | 550 }; |
513 | 551 |
514 } // namespace content | 552 } // namespace content |
515 | 553 |
516 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 554 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |