| 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 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, | 378 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
| 379 bool is_guest_view_hack) | 379 bool is_guest_view_hack) |
| 380 : host_(RenderWidgetHostImpl::From(host)), | 380 : host_(RenderWidgetHostImpl::From(host)), |
| 381 window_(nullptr), | 381 window_(nullptr), |
| 382 in_shutdown_(false), | 382 in_shutdown_(false), |
| 383 in_bounds_changed_(false), | 383 in_bounds_changed_(false), |
| 384 popup_parent_host_view_(nullptr), | 384 popup_parent_host_view_(nullptr), |
| 385 popup_child_host_view_(nullptr), | 385 popup_child_host_view_(nullptr), |
| 386 is_loading_(false), | 386 is_loading_(false), |
| 387 has_composition_text_(false), | 387 has_composition_text_(false), |
| 388 background_color_(SK_ColorWHITE), |
| 388 begin_frame_source_(nullptr), | 389 begin_frame_source_(nullptr), |
| 389 needs_begin_frames_(false), | 390 needs_begin_frames_(false), |
| 390 needs_flush_input_(false), | 391 needs_flush_input_(false), |
| 391 added_frame_observer_(false), | 392 added_frame_observer_(false), |
| 392 cursor_visibility_state_in_renderer_(UNKNOWN), | 393 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 393 #if defined(OS_WIN) | 394 #if defined(OS_WIN) |
| 394 legacy_render_widget_host_HWND_(nullptr), | 395 legacy_render_widget_host_HWND_(nullptr), |
| 395 legacy_window_destroyed_(false), | 396 legacy_window_destroyed_(false), |
| 396 virtual_keyboard_requested_(false), | 397 virtual_keyboard_requested_(false), |
| 397 #endif | 398 #endif |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 744 |
| 744 bool RenderWidgetHostViewAura::IsShowing() { | 745 bool RenderWidgetHostViewAura::IsShowing() { |
| 745 return window_->IsVisible(); | 746 return window_->IsVisible(); |
| 746 } | 747 } |
| 747 | 748 |
| 748 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 749 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
| 749 return window_->GetBoundsInScreen(); | 750 return window_->GetBoundsInScreen(); |
| 750 } | 751 } |
| 751 | 752 |
| 752 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { | 753 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { |
| 754 // The renderer will feed its color back to us with the first CompositorFrame. |
| 755 // We short-cut here to show a sensible color before that happens. |
| 756 UpdateBackgroundColorFromRenderer(color); |
| 757 |
| 758 DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE || |
| 759 SkColorGetA(color) == SK_AlphaTRANSPARENT); |
| 760 host_->SetBackgroundOpaque(SkColorGetA(color) == SK_AlphaOPAQUE); |
| 761 } |
| 762 |
| 763 SkColor RenderWidgetHostViewAura::background_color() const { |
| 764 return background_color_; |
| 765 } |
| 766 |
| 767 void RenderWidgetHostViewAura::UpdateBackgroundColorFromRenderer( |
| 768 SkColor color) { |
| 753 if (color == background_color()) | 769 if (color == background_color()) |
| 754 return; | 770 return; |
| 755 RenderWidgetHostViewBase::SetBackgroundColor(color); | 771 background_color_ = color; |
| 756 bool opaque = GetBackgroundOpaque(); | 772 |
| 757 host_->SetBackgroundOpaque(opaque); | 773 bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; |
| 758 window_->layer()->SetFillsBoundsOpaquely(opaque); | 774 window_->layer()->SetFillsBoundsOpaquely(opaque); |
| 759 window_->layer()->SetColor(color); | 775 window_->layer()->SetColor(color); |
| 760 } | 776 } |
| 761 | 777 |
| 762 bool RenderWidgetHostViewAura::IsMouseLocked() { | 778 bool RenderWidgetHostViewAura::IsMouseLocked() { |
| 763 return event_handler_->mouse_locked(); | 779 return event_handler_->mouse_locked(); |
| 764 } | 780 } |
| 765 | 781 |
| 766 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 782 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
| 767 gfx::Rect requested_rect(GetRequestedRendererSize()); | 783 gfx::Rect requested_rect(GetRequestedRendererSize()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 924 |
| 909 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 925 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 910 uint32_t compositor_frame_sink_id, | 926 uint32_t compositor_frame_sink_id, |
| 911 cc::CompositorFrame frame) { | 927 cc::CompositorFrame frame) { |
| 912 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 928 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
| 913 | 929 |
| 914 // Override the background color to the current compositor background. | 930 // Override the background color to the current compositor background. |
| 915 // This allows us to, when navigating to a new page, transfer this color to | 931 // This allows us to, when navigating to a new page, transfer this color to |
| 916 // that page. This allows us to pass this background color to new views on | 932 // that page. This allows us to pass this background color to new views on |
| 917 // navigation. | 933 // navigation. |
| 918 SetBackgroundColor(frame.metadata.root_background_color); | 934 SkColor root_background_color = frame.metadata.root_background_color; |
| 935 UpdateBackgroundColorFromRenderer(root_background_color); |
| 919 | 936 |
| 920 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 937 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
| 921 if (frame.render_pass_list.empty()) | 938 if (frame.render_pass_list.empty()) |
| 922 return; | 939 return; |
| 923 | 940 |
| 924 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; | 941 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; |
| 925 if (IsUseZoomForDSFEnabled()) { | 942 if (IsUseZoomForDSFEnabled()) { |
| 926 float viewportToDIPScale = 1.0f / current_device_scale_factor_; | 943 float viewportToDIPScale = 1.0f / current_device_scale_factor_; |
| 927 gfx::PointF start_edge_top = selection.start.edge_top(); | 944 gfx::PointF start_edge_top = selection.start.edge_top(); |
| 928 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); | 945 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 | 2387 |
| 2371 void RenderWidgetHostViewAura::SetPopupChild( | 2388 void RenderWidgetHostViewAura::SetPopupChild( |
| 2372 RenderWidgetHostViewAura* popup_child_host_view) { | 2389 RenderWidgetHostViewAura* popup_child_host_view) { |
| 2373 popup_child_host_view_ = popup_child_host_view; | 2390 popup_child_host_view_ = popup_child_host_view; |
| 2374 event_handler_->SetPopupChild( | 2391 event_handler_->SetPopupChild( |
| 2375 popup_child_host_view, | 2392 popup_child_host_view, |
| 2376 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2393 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
| 2377 } | 2394 } |
| 2378 | 2395 |
| 2379 } // namespace content | 2396 } // namespace content |
| OLD | NEW |