Chromium Code Reviews| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 legacy_render_widget_host_HWND_(nullptr), | 394 legacy_render_widget_host_HWND_(nullptr), |
| 395 legacy_window_destroyed_(false), | 395 legacy_window_destroyed_(false), |
| 396 virtual_keyboard_requested_(false), | 396 virtual_keyboard_requested_(false), |
| 397 #endif | 397 #endif |
| 398 has_snapped_to_boundary_(false), | 398 has_snapped_to_boundary_(false), |
| 399 is_guest_view_hack_(is_guest_view_hack), | 399 is_guest_view_hack_(is_guest_view_hack), |
| 400 device_scale_factor_(0.0f), | 400 device_scale_factor_(0.0f), |
| 401 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), | 401 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), |
| 402 last_active_widget_routing_id_(MSG_ROUTING_NONE), | 402 last_active_widget_routing_id_(MSG_ROUTING_NONE), |
| 403 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), | 403 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), |
| 404 cached_background_color_(background_color_), | |
| 404 weak_ptr_factory_(this) { | 405 weak_ptr_factory_(this) { |
| 405 if (!is_guest_view_hack_) | 406 if (!is_guest_view_hack_) |
| 406 host_->SetView(this); | 407 host_->SetView(this); |
| 407 | 408 |
| 408 // We should start observing the TextInputManager for IME-related events as | 409 // We should start observing the TextInputManager for IME-related events as |
| 409 // well as monitoring its lifetime. | 410 // well as monitoring its lifetime. |
| 410 if (GetTextInputManager()) | 411 if (GetTextInputManager()) |
| 411 GetTextInputManager()->AddObserver(this); | 412 GetTextInputManager()->AddObserver(this); |
| 412 | 413 |
| 413 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 414 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { |
| 753 if (color == background_color()) | 754 if (color == background_color()) |
| 754 return; | 755 return; |
| 755 RenderWidgetHostViewBase::SetBackgroundColor(color); | 756 RenderWidgetHostViewBase::SetBackgroundColor(color); |
| 756 bool opaque = GetBackgroundOpaque(); | 757 host_->SetBackgroundOpaque(GetBackgroundOpaque()); |
|
danakj
2017/02/24 16:01:23
I notice that other RenderWidgetHostViews do simil
Eric Seckler
2017/02/27 13:46:26
Done.
| |
| 757 host_->SetBackgroundOpaque(opaque); | 758 |
| 759 // The renderer will feed its color back to us with the first CompositorFrame. | |
| 760 // We short-cut here to show a sensible color before that happens. | |
| 761 UpdateBackgroundColorFromRenderer(color); | |
| 762 } | |
| 763 | |
| 764 void RenderWidgetHostViewAura::UpdateBackgroundColorFromRenderer( | |
| 765 SkColor color) { | |
| 766 if (color == cached_background_color_) | |
|
danakj
2017/02/24 16:01:23
I think this cached_background_color_ will cause a
danakj
2017/02/24 16:04:08
Oh, and at that point, the comment in the base cla
Eric Seckler
2017/02/27 13:46:26
Got rid of the base class implementations and upda
| |
| 767 return; | |
| 768 cached_background_color_ = color; | |
| 769 | |
| 770 bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; | |
| 758 window_->layer()->SetFillsBoundsOpaquely(opaque); | 771 window_->layer()->SetFillsBoundsOpaquely(opaque); |
| 759 window_->layer()->SetColor(color); | 772 window_->layer()->SetColor(color); |
| 760 } | 773 } |
| 761 | 774 |
| 762 bool RenderWidgetHostViewAura::IsMouseLocked() { | 775 bool RenderWidgetHostViewAura::IsMouseLocked() { |
| 763 return event_handler_->mouse_locked(); | 776 return event_handler_->mouse_locked(); |
| 764 } | 777 } |
| 765 | 778 |
| 766 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 779 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
| 767 gfx::Rect requested_rect(GetRequestedRendererSize()); | 780 gfx::Rect requested_rect(GetRequestedRendererSize()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 | 921 |
| 909 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 922 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 910 uint32_t compositor_frame_sink_id, | 923 uint32_t compositor_frame_sink_id, |
| 911 cc::CompositorFrame frame) { | 924 cc::CompositorFrame frame) { |
| 912 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 925 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
| 913 | 926 |
| 914 // Override the background color to the current compositor background. | 927 // Override the background color to the current compositor background. |
| 915 // This allows us to, when navigating to a new page, transfer this color to | 928 // 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 | 929 // that page. This allows us to pass this background color to new views on |
| 917 // navigation. | 930 // navigation. |
| 918 SetBackgroundColor(frame.metadata.root_background_color); | 931 SkColor root_background_color = frame.metadata.root_background_color; |
| 932 UpdateBackgroundColorFromRenderer(root_background_color); | |
| 919 | 933 |
| 920 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 934 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
| 921 if (frame.render_pass_list.empty()) | 935 if (frame.render_pass_list.empty()) |
| 922 return; | 936 return; |
| 923 | 937 |
| 924 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; | 938 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; |
| 925 if (IsUseZoomForDSFEnabled()) { | 939 if (IsUseZoomForDSFEnabled()) { |
| 926 float viewportToDIPScale = 1.0f / current_device_scale_factor_; | 940 float viewportToDIPScale = 1.0f / current_device_scale_factor_; |
| 927 gfx::PointF start_edge_top = selection.start.edge_top(); | 941 gfx::PointF start_edge_top = selection.start.edge_top(); |
| 928 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); | 942 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2370 | 2384 |
| 2371 void RenderWidgetHostViewAura::SetPopupChild( | 2385 void RenderWidgetHostViewAura::SetPopupChild( |
| 2372 RenderWidgetHostViewAura* popup_child_host_view) { | 2386 RenderWidgetHostViewAura* popup_child_host_view) { |
| 2373 popup_child_host_view_ = popup_child_host_view; | 2387 popup_child_host_view_ = popup_child_host_view; |
| 2374 event_handler_->SetPopupChild( | 2388 event_handler_->SetPopupChild( |
| 2375 popup_child_host_view, | 2389 popup_child_host_view, |
| 2376 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2390 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
| 2377 } | 2391 } |
| 2378 | 2392 |
| 2379 } // namespace content | 2393 } // namespace content |
| OLD | NEW |