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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 | 885 |
886 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { | 886 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { |
887 RECT window_rect = | 887 RECT window_rect = |
888 display::Screen::GetScreen() | 888 display::Screen::GetScreen() |
889 ->DIPToScreenRectInWindow(window_, window_->GetBoundsInScreen()) | 889 ->DIPToScreenRectInWindow(window_, window_->GetBoundsInScreen()) |
890 .ToRECT(); | 890 .ToRECT(); |
891 ::ClipCursor(&window_rect); | 891 ::ClipCursor(&window_rect); |
892 } | 892 } |
893 | 893 |
894 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { | 894 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { |
895 legacy_render_widget_host_HWND_ = NULL; | 895 legacy_render_widget_host_HWND_ = nullptr; |
896 legacy_window_destroyed_ = true; | 896 legacy_window_destroyed_ = true; |
897 } | 897 } |
898 #endif | 898 #endif |
899 | 899 |
900 void RenderWidgetHostViewAura::DidCreateNewRendererCompositorFrameSink( | 900 void RenderWidgetHostViewAura::DidCreateNewRendererCompositorFrameSink( |
901 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) { | 901 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) { |
902 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; | 902 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; |
903 if (delegated_frame_host_) { | 903 if (delegated_frame_host_) { |
904 delegated_frame_host_->DidCreateNewRendererCompositorFrameSink( | 904 delegated_frame_host_->DidCreateNewRendererCompositorFrameSink( |
905 renderer_compositor_frame_sink_); | 905 renderer_compositor_frame_sink_); |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2344 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( | 2344 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( |
2345 TextInputManager* text_input_manager, | 2345 TextInputManager* text_input_manager, |
2346 RenderWidgetHostViewBase* updated_view) { | 2346 RenderWidgetHostViewBase* updated_view) { |
2347 if (GetInputMethod()) | 2347 if (GetInputMethod()) |
2348 GetInputMethod()->OnCaretBoundsChanged(this); | 2348 GetInputMethod()->OnCaretBoundsChanged(this); |
2349 } | 2349 } |
2350 | 2350 |
2351 void RenderWidgetHostViewAura::OnTextSelectionChanged( | 2351 void RenderWidgetHostViewAura::OnTextSelectionChanged( |
2352 TextInputManager* text_input_manager, | 2352 TextInputManager* text_input_manager, |
2353 RenderWidgetHostViewBase* updated_view) { | 2353 RenderWidgetHostViewBase* updated_view) { |
2354 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
2355 if (!GetTextInputManager()) | 2354 if (!GetTextInputManager()) |
2356 return; | 2355 return; |
2357 | 2356 |
2358 // We obtain the TextSelection from focused RWH which is obtained from the | 2357 // We obtain the TextSelection from focused RWH which is obtained from the |
2359 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree | 2358 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree |
2360 // and the focused RWH will be that of the embedder which is incorrect. In | 2359 // and the focused RWH will be that of the embedder which is incorrect. In |
2361 // this case we should use TextSelection for |this| since RWHV for guest | 2360 // this case we should use TextSelection for |this| since RWHV for guest |
2362 // forwards text selection information to its platform view. | 2361 // forwards text selection information to its platform view. |
2363 RenderWidgetHostViewBase* focused_view = | 2362 RenderWidgetHostViewBase* focused_view = |
2364 is_guest_view_hack_ ? this : GetFocusedWidget() | 2363 is_guest_view_hack_ ? this : GetFocusedWidget() |
2365 ? GetFocusedWidget()->GetView() | 2364 ? GetFocusedWidget()->GetView() |
2366 : nullptr; | 2365 : nullptr; |
2367 | 2366 |
2368 if (!focused_view) | 2367 if (!focused_view) |
2369 return; | 2368 return; |
2370 | 2369 |
2370 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
sadrul
2017/05/11 17:46:34
You wouldn't normally need OS_CHROMEOS check here
| |
2371 const TextInputManager::TextSelection* selection = | 2371 const TextInputManager::TextSelection* selection = |
2372 GetTextInputManager()->GetTextSelection(focused_view); | 2372 GetTextInputManager()->GetTextSelection(focused_view); |
2373 if (selection->selected_text().length()) { | 2373 if (selection->selected_text().length()) { |
2374 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 2374 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
2375 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 2375 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
2376 clipboard_writer.WriteText(selection->selected_text()); | 2376 clipboard_writer.WriteText(selection->selected_text()); |
2377 } | 2377 } |
2378 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 2378 |
2379 #elif defined(OS_WIN) | |
2380 // Some assistive software need to track the location of the caret. | |
2381 if (!GetRenderWidgetHost() || !legacy_render_widget_host_HWND_) | |
2382 return; | |
2383 | |
2384 // Not using |GetCaretBounds| because it includes the whole of the selection, | |
2385 // not just the focus. | |
2386 const TextInputManager::SelectionRegion* region = | |
2387 GetTextInputManager()->GetSelectionRegion(focused_view); | |
2388 if (!region) | |
2389 return; | |
2390 const gfx::Rect caret_rect = ConvertRectToScreen(gfx::Rect( | |
2391 region->focus.edge_top_rounded().x(), | |
2392 region->focus.edge_top_rounded().y(), 1, region->focus.GetHeight())); | |
2393 legacy_render_widget_host_HWND_->MoveCaretTo(caret_rect); | |
2394 #endif // defined(OS_WIN) | |
2379 } | 2395 } |
2380 | 2396 |
2381 void RenderWidgetHostViewAura::SetPopupChild( | 2397 void RenderWidgetHostViewAura::SetPopupChild( |
2382 RenderWidgetHostViewAura* popup_child_host_view) { | 2398 RenderWidgetHostViewAura* popup_child_host_view) { |
2383 popup_child_host_view_ = popup_child_host_view; | 2399 popup_child_host_view_ = popup_child_host_view; |
2384 event_handler_->SetPopupChild( | 2400 event_handler_->SetPopupChild( |
2385 popup_child_host_view, | 2401 popup_child_host_view, |
2386 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2402 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
2387 } | 2403 } |
2388 | 2404 |
2389 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { | 2405 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { |
2390 if (!delegated_frame_host_) | 2406 if (!delegated_frame_host_) |
2391 return; | 2407 return; |
2392 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || | 2408 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || |
2393 needs_flush_input_); | 2409 needs_flush_input_); |
2394 } | 2410 } |
2395 | 2411 |
2396 } // namespace content | 2412 } // namespace content |
OLD | NEW |