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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 #include "ui/touch_selection/touch_selection_controller.h" | 96 #include "ui/touch_selection/touch_selection_controller.h" |
97 #include "ui/wm/public/activation_client.h" | 97 #include "ui/wm/public/activation_client.h" |
98 #include "ui/wm/public/scoped_tooltip_disabler.h" | 98 #include "ui/wm/public/scoped_tooltip_disabler.h" |
99 #include "ui/wm/public/tooltip_client.h" | 99 #include "ui/wm/public/tooltip_client.h" |
100 | 100 |
101 #if defined(OS_WIN) | 101 #if defined(OS_WIN) |
102 #include "base/time/time.h" | 102 #include "base/time/time.h" |
103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
104 #include "content/browser/accessibility/browser_accessibility_win.h" | 104 #include "content/browser/accessibility/browser_accessibility_win.h" |
105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" | 105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
106 #include "ui/accessibility/platform/ax_fake_caret_win.h" | |
106 #include "ui/base/win/hidden_window.h" | 107 #include "ui/base/win/hidden_window.h" |
107 #include "ui/base/win/osk_display_manager.h" | 108 #include "ui/base/win/osk_display_manager.h" |
108 #include "ui/base/win/osk_display_observer.h" | 109 #include "ui/base/win/osk_display_observer.h" |
109 #include "ui/display/win/screen_win.h" | 110 #include "ui/display/win/screen_win.h" |
110 #include "ui/gfx/gdi_util.h" | 111 #include "ui/gfx/gdi_util.h" |
111 #endif | 112 #endif |
112 | 113 |
113 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) | 114 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) |
114 #include "content/browser/accessibility/browser_accessibility_auralinux.h" | 115 #include "content/browser/accessibility/browser_accessibility_auralinux.h" |
115 #endif | 116 #endif |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 | 879 |
879 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { | 880 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { |
880 RECT window_rect = | 881 RECT window_rect = |
881 display::Screen::GetScreen() | 882 display::Screen::GetScreen() |
882 ->DIPToScreenRectInWindow(window_, window_->GetBoundsInScreen()) | 883 ->DIPToScreenRectInWindow(window_, window_->GetBoundsInScreen()) |
883 .ToRECT(); | 884 .ToRECT(); |
884 ::ClipCursor(&window_rect); | 885 ::ClipCursor(&window_rect); |
885 } | 886 } |
886 | 887 |
887 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { | 888 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { |
888 legacy_render_widget_host_HWND_ = NULL; | 889 ui::AXFakeCaretWin::Get()->SetTargetForNativeAccessibilityEvent( |
dmazzoni
2017/04/21 21:06:30
Hmmm, I wonder if it'd make more sense for each
HW
| |
890 gfx::kNullAcceleratedWidget); | |
891 legacy_render_widget_host_HWND_ = nullptr; | |
889 legacy_window_destroyed_ = true; | 892 legacy_window_destroyed_ = true; |
890 } | 893 } |
891 #endif | 894 #endif |
892 | 895 |
893 void RenderWidgetHostViewAura::DidCreateNewRendererCompositorFrameSink() { | 896 void RenderWidgetHostViewAura::DidCreateNewRendererCompositorFrameSink() { |
894 if (delegated_frame_host_) | 897 if (delegated_frame_host_) |
895 delegated_frame_host_->DidCreateNewRendererCompositorFrameSink(); | 898 delegated_frame_host_->DidCreateNewRendererCompositorFrameSink(); |
896 } | 899 } |
897 | 900 |
898 void RenderWidgetHostViewAura::SubmitCompositorFrame( | 901 void RenderWidgetHostViewAura::SubmitCompositorFrame( |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 // in the dtor. However there may be cases where the window is destroyed | 1552 // in the dtor. However there may be cases where the window is destroyed |
1550 // by Windows, i.e. the parent window is destroyed before the | 1553 // by Windows, i.e. the parent window is destroyed before the |
1551 // RenderWidgetHostViewAura instance goes away etc. To avoid that we | 1554 // RenderWidgetHostViewAura instance goes away etc. To avoid that we |
1552 // destroy the LegacyRenderWidgetHostHWND instance here. | 1555 // destroy the LegacyRenderWidgetHostHWND instance here. |
1553 if (legacy_render_widget_host_HWND_) { | 1556 if (legacy_render_widget_host_HWND_) { |
1554 legacy_render_widget_host_HWND_->set_host(NULL); | 1557 legacy_render_widget_host_HWND_->set_host(NULL); |
1555 legacy_render_widget_host_HWND_->Destroy(); | 1558 legacy_render_widget_host_HWND_->Destroy(); |
1556 // The Destroy call above will delete the LegacyRenderWidgetHostHWND | 1559 // The Destroy call above will delete the LegacyRenderWidgetHostHWND |
1557 // instance. | 1560 // instance. |
1558 legacy_render_widget_host_HWND_ = NULL; | 1561 legacy_render_widget_host_HWND_ = NULL; |
1562 ui::AXFakeCaretWin::Get()->SetTargetForNativeAccessibilityEvent( | |
1563 gfx::kNullAcceleratedWidget); | |
1559 } | 1564 } |
1560 #endif | 1565 #endif |
1561 | 1566 |
1562 // Make sure that the input method no longer references to this object before | 1567 // Make sure that the input method no longer references to this object before |
1563 // this object is removed from the root window (i.e. this object loses access | 1568 // this object is removed from the root window (i.e. this object loses access |
1564 // to the input method). | 1569 // to the input method). |
1565 DetachFromInputMethod(); | 1570 DetachFromInputMethod(); |
1566 | 1571 |
1567 if (overscroll_controller_) | 1572 if (overscroll_controller_) |
1568 overscroll_controller_->Reset(); | 1573 overscroll_controller_->Reset(); |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2148 legacy_render_widget_host_HWND_->set_host(this); | 2153 legacy_render_widget_host_HWND_->set_host(this); |
2149 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); | 2154 legacy_render_widget_host_HWND_->UpdateParent(GetHostWindowHWND()); |
2150 legacy_render_widget_host_HWND_->SetBounds( | 2155 legacy_render_widget_host_HWND_->SetBounds( |
2151 window_->GetBoundsInRootWindow()); | 2156 window_->GetBoundsInRootWindow()); |
2152 // There are cases where the parent window is created, made visible and | 2157 // There are cases where the parent window is created, made visible and |
2153 // the associated RenderWidget is also visible before the | 2158 // the associated RenderWidget is also visible before the |
2154 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown | 2159 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown |
2155 // here. | 2160 // here. |
2156 if (!host_->is_hidden()) | 2161 if (!host_->is_hidden()) |
2157 legacy_render_widget_host_HWND_->Show(); | 2162 legacy_render_widget_host_HWND_->Show(); |
2163 ui::AXFakeCaretWin::Get()->SetTargetForNativeAccessibilityEvent( | |
2164 legacy_render_widget_host_HWND_->hwnd()); | |
2158 } | 2165 } |
2159 } | 2166 } |
2160 #endif | 2167 #endif |
2161 | 2168 |
2162 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 2169 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
2163 const gfx::Rect& rect, | 2170 const gfx::Rect& rect, |
2164 const gfx::Rect& clip) { | 2171 const gfx::Rect& clip) { |
2165 if (!clip.IsEmpty()) { | 2172 if (!clip.IsEmpty()) { |
2166 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); | 2173 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); |
2167 if (!to_paint.IsEmpty()) | 2174 if (!to_paint.IsEmpty()) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2326 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( | 2333 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( |
2327 TextInputManager* text_input_manager, | 2334 TextInputManager* text_input_manager, |
2328 RenderWidgetHostViewBase* updated_view) { | 2335 RenderWidgetHostViewBase* updated_view) { |
2329 if (GetInputMethod()) | 2336 if (GetInputMethod()) |
2330 GetInputMethod()->OnCaretBoundsChanged(this); | 2337 GetInputMethod()->OnCaretBoundsChanged(this); |
2331 } | 2338 } |
2332 | 2339 |
2333 void RenderWidgetHostViewAura::OnTextSelectionChanged( | 2340 void RenderWidgetHostViewAura::OnTextSelectionChanged( |
2334 TextInputManager* text_input_manager, | 2341 TextInputManager* text_input_manager, |
2335 RenderWidgetHostViewBase* updated_view) { | 2342 RenderWidgetHostViewBase* updated_view) { |
2336 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
2337 if (!GetTextInputManager()) | 2343 if (!GetTextInputManager()) |
2338 return; | 2344 return; |
2339 | 2345 |
2340 // We obtain the TextSelection from focused RWH which is obtained from the | 2346 // We obtain the TextSelection from focused RWH which is obtained from the |
2341 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree | 2347 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree |
2342 // and the focused RWH will be that of the embedder which is incorrect. In | 2348 // and the focused RWH will be that of the embedder which is incorrect. In |
2343 // this case we should use TextSelection for |this| since RWHV for guest | 2349 // this case we should use TextSelection for |this| since RWHV for guest |
2344 // forwards text selection information to its platform view. | 2350 // forwards text selection information to its platform view. |
2345 RenderWidgetHostViewBase* focused_view = | 2351 RenderWidgetHostViewBase* focused_view = |
2346 is_guest_view_hack_ ? this : GetFocusedWidget() | 2352 is_guest_view_hack_ ? this : GetFocusedWidget() |
2347 ? GetFocusedWidget()->GetView() | 2353 ? GetFocusedWidget()->GetView() |
2348 : nullptr; | 2354 : nullptr; |
2349 | 2355 |
2350 if (!focused_view) | 2356 if (!focused_view) |
2351 return; | 2357 return; |
2352 | 2358 |
2359 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
2353 const TextInputManager::TextSelection* selection = | 2360 const TextInputManager::TextSelection* selection = |
2354 GetTextInputManager()->GetTextSelection(focused_view); | 2361 GetTextInputManager()->GetTextSelection(focused_view); |
2355 if (selection->selected_text().length()) { | 2362 if (selection->selected_text().length()) { |
2356 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 2363 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
2357 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 2364 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
2358 clipboard_writer.WriteText(selection->selected_text()); | 2365 clipboard_writer.WriteText(selection->selected_text()); |
2359 } | 2366 } |
2360 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 2367 |
2368 // #endif defined(USE_X11) && !defined(OS_CHROMEOS) | |
2369 #elif defined(OS_WIN) | |
2370 // Some assistive software need to track the location of the caret. | |
2371 if (!GetRenderWidgetHost()) | |
2372 return; | |
2373 | |
2374 // Not using |GetCaretBounds| because it includes the whole of the selection, | |
2375 // not just the focus. | |
2376 const TextInputManager::SelectionRegion* region = | |
2377 GetTextInputManager()->GetSelectionRegion(focused_view); | |
2378 if (!region) | |
2379 return; | |
2380 gfx::Rect caret_rect = ConvertRectToScreen(gfx::Rect( | |
2381 region->focus.edge_top_rounded().x(), | |
2382 region->focus.edge_top_rounded().y(), 1, region->focus.GetHeight())); | |
2383 ui::AXFakeCaretWin::Get()->MoveCaretTo(caret_rect); | |
2384 #endif // defined(OS_WIN) | |
2361 } | 2385 } |
2362 | 2386 |
2363 void RenderWidgetHostViewAura::SetPopupChild( | 2387 void RenderWidgetHostViewAura::SetPopupChild( |
2364 RenderWidgetHostViewAura* popup_child_host_view) { | 2388 RenderWidgetHostViewAura* popup_child_host_view) { |
2365 popup_child_host_view_ = popup_child_host_view; | 2389 popup_child_host_view_ = popup_child_host_view; |
2366 event_handler_->SetPopupChild( | 2390 event_handler_->SetPopupChild( |
2367 popup_child_host_view, | 2391 popup_child_host_view, |
2368 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2392 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
2369 } | 2393 } |
2370 | 2394 |
2371 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { | 2395 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { |
2372 if (!delegated_frame_host_) | 2396 if (!delegated_frame_host_) |
2373 return; | 2397 return; |
2374 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || | 2398 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || |
2375 needs_flush_input_); | 2399 needs_flush_input_); |
2376 } | 2400 } |
2377 | 2401 |
2378 } // namespace content | 2402 } // namespace content |
OLD | NEW |