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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 cc::CompositorFrame frame) { | 911 cc::CompositorFrame frame) { |
912 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 912 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
913 | 913 |
914 // Override the background color to the current compositor background. | 914 // Override the background color to the current compositor background. |
915 // This allows us to, when navigating to a new page, transfer this color to | 915 // 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 | 916 // that page. This allows us to pass this background color to new views on |
917 // navigation. | 917 // navigation. |
918 UpdateBackgroundColorFromRenderer(frame.metadata.root_background_color); | 918 UpdateBackgroundColorFromRenderer(frame.metadata.root_background_color); |
919 | 919 |
920 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 920 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
921 | |
922 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; | 921 cc::Selection<gfx::SelectionBound> selection = frame.metadata.selection; |
923 if (IsUseZoomForDSFEnabled()) { | 922 if (IsUseZoomForDSFEnabled()) { |
924 float viewportToDIPScale = 1.0f / current_device_scale_factor_; | 923 float viewportToDIPScale = 1.0f / current_device_scale_factor_; |
925 gfx::PointF start_edge_top = selection.start.edge_top(); | 924 gfx::PointF start_edge_top = selection.start.edge_top(); |
926 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); | 925 gfx::PointF start_edge_bottom = selection.start.edge_bottom(); |
927 gfx::PointF end_edge_top = selection.end.edge_top(); | 926 gfx::PointF end_edge_top = selection.end.edge_top(); |
928 gfx::PointF end_edge_bottom = selection.end.edge_bottom(); | 927 gfx::PointF end_edge_bottom = selection.end.edge_bottom(); |
929 | 928 |
930 start_edge_top.Scale(viewportToDIPScale); | 929 start_edge_top.Scale(viewportToDIPScale); |
931 start_edge_bottom.Scale(viewportToDIPScale); | 930 start_edge_bottom.Scale(viewportToDIPScale); |
932 end_edge_top.Scale(viewportToDIPScale); | 931 end_edge_top.Scale(viewportToDIPScale); |
933 end_edge_bottom.Scale(viewportToDIPScale); | 932 end_edge_bottom.Scale(viewportToDIPScale); |
934 | 933 |
935 selection.start.SetEdge(start_edge_top, start_edge_bottom); | 934 selection.start.SetEdge(start_edge_top, start_edge_bottom); |
936 selection.end.SetEdge(end_edge_top, end_edge_bottom); | 935 selection.end.SetEdge(end_edge_top, end_edge_bottom); |
937 } | 936 } |
938 | 937 |
939 if (delegated_frame_host_) { | 938 if (delegated_frame_host_) { |
940 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, | 939 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, |
941 std::move(frame)); | 940 std::move(frame)); |
942 } | 941 } |
943 selection_controller_->OnSelectionBoundsChanged(selection.start, | 942 if (selection.start != selection_start_ || selection.end != selection_end_) { |
944 selection.end); | 943 selection_start_ = selection.start; |
| 944 selection_end_ = selection.end; |
| 945 selection_controller_client_->UpdateClientSelectionBounds(selection_start_, |
| 946 selection_end_); |
| 947 } |
945 } | 948 } |
946 | 949 |
947 void RenderWidgetHostViewAura::OnDidNotProduceFrame( | 950 void RenderWidgetHostViewAura::OnDidNotProduceFrame( |
948 const cc::BeginFrameAck& ack) { | 951 const cc::BeginFrameAck& ack) { |
949 if (delegated_frame_host_) | 952 if (delegated_frame_host_) |
950 delegated_frame_host_->DidNotProduceFrame(ack); | 953 delegated_frame_host_->DidNotProduceFrame(ack); |
951 } | 954 } |
952 | 955 |
953 void RenderWidgetHostViewAura::ClearCompositorFrame() { | 956 void RenderWidgetHostViewAura::ClearCompositorFrame() { |
954 if (delegated_frame_host_) | 957 if (delegated_frame_host_) |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 BrowserAccessibilityManager* manager = | 1785 BrowserAccessibilityManager* manager = |
1783 host_->GetRootBrowserAccessibilityManager(); | 1786 host_->GetRootBrowserAccessibilityManager(); |
1784 if (manager) | 1787 if (manager) |
1785 manager->OnWindowFocused(); | 1788 manager->OnWindowFocused(); |
1786 } else if (window_ == lost_focus) { | 1789 } else if (window_ == lost_focus) { |
1787 host_->SetActive(false); | 1790 host_->SetActive(false); |
1788 host_->Blur(); | 1791 host_->Blur(); |
1789 | 1792 |
1790 DetachFromInputMethod(); | 1793 DetachFromInputMethod(); |
1791 | 1794 |
| 1795 // TODO(wjmaclean): Do we need to let TouchSelectionControllerClientAura |
| 1796 // handle this, just in case it stomps on a new highlight in another view |
| 1797 // that has just become focused? So far it doesn't appear to be a problem, |
| 1798 // but we should keep an eye on it. |
1792 selection_controller_->HideAndDisallowShowingAutomatically(); | 1799 selection_controller_->HideAndDisallowShowingAutomatically(); |
1793 | 1800 |
1794 if (overscroll_controller_) | 1801 if (overscroll_controller_) |
1795 overscroll_controller_->Cancel(); | 1802 overscroll_controller_->Cancel(); |
1796 | 1803 |
1797 BrowserAccessibilityManager* manager = | 1804 BrowserAccessibilityManager* manager = |
1798 host_->GetRootBrowserAccessibilityManager(); | 1805 host_->GetRootBrowserAccessibilityManager(); |
1799 if (manager) | 1806 if (manager) |
1800 manager->OnWindowBlurred(); | 1807 manager->OnWindowBlurred(); |
1801 | 1808 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 return root_window->GetHost()->GetInputMethod(); | 2038 return root_window->GetHost()->GetInputMethod(); |
2032 } | 2039 } |
2033 | 2040 |
2034 void RenderWidgetHostViewAura::Shutdown() { | 2041 void RenderWidgetHostViewAura::Shutdown() { |
2035 if (!in_shutdown_) { | 2042 if (!in_shutdown_) { |
2036 in_shutdown_ = true; | 2043 in_shutdown_ = true; |
2037 host_->ShutdownAndDestroyWidget(true); | 2044 host_->ShutdownAndDestroyWidget(true); |
2038 } | 2045 } |
2039 } | 2046 } |
2040 | 2047 |
| 2048 TouchSelectionControllerClientManager* |
| 2049 RenderWidgetHostViewAura::touch_selection_controller_client_manager() { |
| 2050 return selection_controller_client_.get(); |
| 2051 } |
| 2052 |
2041 bool RenderWidgetHostViewAura::NeedsInputGrab() { | 2053 bool RenderWidgetHostViewAura::NeedsInputGrab() { |
2042 return popup_type_ == blink::kWebPopupTypePage; | 2054 return popup_type_ == blink::kWebPopupTypePage; |
2043 } | 2055 } |
2044 | 2056 |
2045 bool RenderWidgetHostViewAura::NeedsMouseCapture() { | 2057 bool RenderWidgetHostViewAura::NeedsMouseCapture() { |
2046 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 2058 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
2047 return NeedsInputGrab(); | 2059 return NeedsInputGrab(); |
2048 #endif | 2060 #endif |
2049 return false; | 2061 return false; |
2050 } | 2062 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 } | 2419 } |
2408 | 2420 |
2409 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { | 2421 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { |
2410 if (!delegated_frame_host_) | 2422 if (!delegated_frame_host_) |
2411 return; | 2423 return; |
2412 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || | 2424 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || |
2413 needs_flush_input_); | 2425 needs_flush_input_); |
2414 } | 2426 } |
2415 | 2427 |
2416 } // namespace content | 2428 } // namespace content |
OLD | NEW |