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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, | 375 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
376 bool is_guest_view_hack) | 376 bool is_guest_view_hack) |
377 : host_(RenderWidgetHostImpl::From(host)), | 377 : host_(RenderWidgetHostImpl::From(host)), |
378 window_(nullptr), | 378 window_(nullptr), |
379 in_shutdown_(false), | 379 in_shutdown_(false), |
380 in_bounds_changed_(false), | 380 in_bounds_changed_(false), |
381 popup_parent_host_view_(nullptr), | 381 popup_parent_host_view_(nullptr), |
382 popup_child_host_view_(nullptr), | 382 popup_child_host_view_(nullptr), |
383 is_loading_(false), | 383 is_loading_(false), |
384 has_composition_text_(false), | 384 has_composition_text_(false), |
| 385 background_color_(SK_ColorWHITE), |
385 needs_begin_frames_(false), | 386 needs_begin_frames_(false), |
386 needs_flush_input_(false), | 387 needs_flush_input_(false), |
387 added_frame_observer_(false), | 388 added_frame_observer_(false), |
388 cursor_visibility_state_in_renderer_(UNKNOWN), | 389 cursor_visibility_state_in_renderer_(UNKNOWN), |
389 #if defined(OS_WIN) | 390 #if defined(OS_WIN) |
390 legacy_render_widget_host_HWND_(nullptr), | 391 legacy_render_widget_host_HWND_(nullptr), |
391 legacy_window_destroyed_(false), | 392 legacy_window_destroyed_(false), |
392 virtual_keyboard_requested_(false), | 393 virtual_keyboard_requested_(false), |
393 #endif | 394 #endif |
394 has_snapped_to_boundary_(false), | 395 has_snapped_to_boundary_(false), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 713 |
713 bool RenderWidgetHostViewAura::IsShowing() { | 714 bool RenderWidgetHostViewAura::IsShowing() { |
714 return window_->IsVisible(); | 715 return window_->IsVisible(); |
715 } | 716 } |
716 | 717 |
717 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 718 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
718 return window_->GetBoundsInScreen(); | 719 return window_->GetBoundsInScreen(); |
719 } | 720 } |
720 | 721 |
721 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { | 722 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { |
| 723 // The renderer will feed its color back to us with the first CompositorFrame. |
| 724 // We short-cut here to show a sensible color before that happens. |
| 725 UpdateBackgroundColorFromRenderer(color); |
| 726 |
| 727 DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE || |
| 728 SkColorGetA(color) == SK_AlphaTRANSPARENT); |
| 729 host_->SetBackgroundOpaque(SkColorGetA(color) == SK_AlphaOPAQUE); |
| 730 } |
| 731 |
| 732 SkColor RenderWidgetHostViewAura::background_color() const { |
| 733 return background_color_; |
| 734 } |
| 735 |
| 736 void RenderWidgetHostViewAura::UpdateBackgroundColorFromRenderer( |
| 737 SkColor color) { |
722 if (color == background_color()) | 738 if (color == background_color()) |
723 return; | 739 return; |
724 RenderWidgetHostViewBase::SetBackgroundColor(color); | 740 background_color_ = color; |
725 bool opaque = GetBackgroundOpaque(); | 741 |
726 host_->SetBackgroundOpaque(opaque); | 742 bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; |
727 window_->layer()->SetFillsBoundsOpaquely(opaque); | 743 window_->layer()->SetFillsBoundsOpaquely(opaque); |
728 window_->layer()->SetColor(color); | 744 window_->layer()->SetColor(color); |
729 } | 745 } |
730 | 746 |
731 bool RenderWidgetHostViewAura::IsMouseLocked() { | 747 bool RenderWidgetHostViewAura::IsMouseLocked() { |
732 return event_handler_->mouse_locked(); | 748 return event_handler_->mouse_locked(); |
733 } | 749 } |
734 | 750 |
735 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 751 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
736 gfx::Rect requested_rect(GetRequestedRendererSize()); | 752 gfx::Rect requested_rect(GetRequestedRendererSize()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 | 897 |
882 void RenderWidgetHostViewAura::SubmitCompositorFrame( | 898 void RenderWidgetHostViewAura::SubmitCompositorFrame( |
883 const cc::LocalSurfaceId& local_surface_id, | 899 const cc::LocalSurfaceId& local_surface_id, |
884 cc::CompositorFrame frame) { | 900 cc::CompositorFrame frame) { |
885 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 901 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
886 | 902 |
887 // Override the background color to the current compositor background. | 903 // Override the background color to the current compositor background. |
888 // This allows us to, when navigating to a new page, transfer this color to | 904 // This allows us to, when navigating to a new page, transfer this color to |
889 // that page. This allows us to pass this background color to new views on | 905 // that page. This allows us to pass this background color to new views on |
890 // navigation. | 906 // navigation. |
891 SetBackgroundColor(frame.metadata.root_background_color); | 907 UpdateBackgroundColorFromRenderer(frame.metadata.root_background_color); |
892 | 908 |
893 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 909 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
894 | 910 |
895 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; | 911 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; |
896 if (IsUseZoomForDSFEnabled()) { | 912 if (IsUseZoomForDSFEnabled()) { |
897 float viewportToDIPScale = 1.0f / current_device_scale_factor_; | 913 float viewportToDIPScale = 1.0f / current_device_scale_factor_; |
898 gfx::PointF start_edge_top = selection.start.edge_top(); | 914 gfx::PointF start_edge_top = selection.start.edge_top(); |
899 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); | 915 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); |
900 gfx::PointF end_edge_top = selection.end.edge_top(); | 916 gfx::PointF end_edge_top = selection.end.edge_top(); |
901 gfx::PointF end_edge_bottom = selection.end.edge_bottom(); | 917 gfx::PointF end_edge_bottom = selection.end.edge_bottom(); |
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 } | 2362 } |
2347 | 2363 |
2348 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { | 2364 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { |
2349 if (!delegated_frame_host_) | 2365 if (!delegated_frame_host_) |
2350 return; | 2366 return; |
2351 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || | 2367 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || |
2352 needs_flush_input_); | 2368 needs_flush_input_); |
2353 } | 2369 } |
2354 | 2370 |
2355 } // namespace content | 2371 } // namespace content |
OLD | NEW |