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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "content/public/browser/render_view_host.h" | 56 #include "content/public/browser/render_view_host.h" |
| 57 #include "content/public/browser/user_metrics.h" | 57 #include "content/public/browser/user_metrics.h" |
| 58 #include "content/public/common/content_switches.h" | 58 #include "content/public/common/content_switches.h" |
| 59 #include "gpu/ipc/common/gpu_messages.h" | 59 #include "gpu/ipc/common/gpu_messages.h" |
| 60 #include "media/base/video_frame.h" | 60 #include "media/base/video_frame.h" |
| 61 #include "services/service_manager/public/cpp/interface_provider.h" | 61 #include "services/service_manager/public/cpp/interface_provider.h" |
| 62 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 62 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 63 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 63 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 64 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 64 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 65 #include "ui/accessibility/platform/aura_window_properties.h" | 65 #include "ui/accessibility/platform/aura_window_properties.h" |
| 66 #include "ui/accessibility/platform/ax_fake_caret_win.h" | |
|
dmazzoni
2017/03/28 15:41:21
I think this needs to go in the #if defined(OS_WIN
| |
| 66 #include "ui/aura/client/aura_constants.h" | 67 #include "ui/aura/client/aura_constants.h" |
| 67 #include "ui/aura/client/cursor_client.h" | 68 #include "ui/aura/client/cursor_client.h" |
| 68 #include "ui/aura/client/cursor_client_observer.h" | 69 #include "ui/aura/client/cursor_client_observer.h" |
| 69 #include "ui/aura/client/focus_client.h" | 70 #include "ui/aura/client/focus_client.h" |
| 70 #include "ui/aura/client/screen_position_client.h" | 71 #include "ui/aura/client/screen_position_client.h" |
| 71 #include "ui/aura/client/transient_window_client.h" | 72 #include "ui/aura/client/transient_window_client.h" |
| 72 #include "ui/aura/client/window_parenting_client.h" | 73 #include "ui/aura/client/window_parenting_client.h" |
| 73 #include "ui/aura/env.h" | 74 #include "ui/aura/env.h" |
| 74 #include "ui/aura/mus/window_port_mus.h" | 75 #include "ui/aura/mus/window_port_mus.h" |
| 75 #include "ui/aura/window.h" | 76 #include "ui/aura/window.h" |
| (...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2331 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( | 2332 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( |
| 2332 TextInputManager* text_input_manager, | 2333 TextInputManager* text_input_manager, |
| 2333 RenderWidgetHostViewBase* updated_view) { | 2334 RenderWidgetHostViewBase* updated_view) { |
| 2334 if (GetInputMethod()) | 2335 if (GetInputMethod()) |
| 2335 GetInputMethod()->OnCaretBoundsChanged(this); | 2336 GetInputMethod()->OnCaretBoundsChanged(this); |
| 2336 } | 2337 } |
| 2337 | 2338 |
| 2338 void RenderWidgetHostViewAura::OnTextSelectionChanged( | 2339 void RenderWidgetHostViewAura::OnTextSelectionChanged( |
| 2339 TextInputManager* text_input_manager, | 2340 TextInputManager* text_input_manager, |
| 2340 RenderWidgetHostViewBase* updated_view) { | 2341 RenderWidgetHostViewBase* updated_view) { |
| 2341 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
| 2342 if (!GetTextInputManager()) | 2342 if (!GetTextInputManager()) |
| 2343 return; | 2343 return; |
| 2344 | 2344 |
| 2345 // We obtain the TextSelection from focused RWH which is obtained from the | 2345 // We obtain the TextSelection from focused RWH which is obtained from the |
| 2346 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree | 2346 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree |
| 2347 // and the focused RWH will be that of the embedder which is incorrect. In | 2347 // and the focused RWH will be that of the embedder which is incorrect. In |
| 2348 // this case we should use TextSelection for |this| since RWHV for guest | 2348 // this case we should use TextSelection for |this| since RWHV for guest |
| 2349 // forwards text selection information to its platform view. | 2349 // forwards text selection information to its platform view. |
| 2350 RenderWidgetHostViewBase* focused_view = | 2350 RenderWidgetHostViewBase* focused_view = |
| 2351 is_guest_view_hack_ ? this : GetFocusedWidget() | 2351 is_guest_view_hack_ ? this : GetFocusedWidget() |
| 2352 ? GetFocusedWidget()->GetView() | 2352 ? GetFocusedWidget()->GetView() |
| 2353 : nullptr; | 2353 : nullptr; |
| 2354 | 2354 |
| 2355 if (!focused_view) | 2355 if (!focused_view) |
| 2356 return; | 2356 return; |
| 2357 | 2357 |
| 2358 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
| 2358 const TextInputManager::TextSelection* selection = | 2359 const TextInputManager::TextSelection* selection = |
| 2359 GetTextInputManager()->GetTextSelection(focused_view); | 2360 GetTextInputManager()->GetTextSelection(focused_view); |
| 2360 if (selection->selected_text().length()) { | 2361 if (selection->selected_text().length()) { |
| 2361 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 2362 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
| 2362 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 2363 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
| 2363 clipboard_writer.WriteText(selection->selected_text()); | 2364 clipboard_writer.WriteText(selection->selected_text()); |
| 2364 } | 2365 } |
| 2365 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 2366 |
| 2367 // #endif defined(USE_X11) && !defined(OS_CHROMEOS) | |
| 2368 #elseif defined(OS_WIN) | |
| 2369 // Some assistive software need to track the location of the caret. | |
| 2370 if (!GetRenderWidgetHost() || | |
| 2371 !GetRenderWidgetHost()->GetRootBrowserAccessibilityManager()) | |
|
dmazzoni
2017/03/28 15:41:21
Would it be possible to make this code work withou
| |
| 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::SetBounds(caret_rect); | |
| 2384 #endif // defined(OS_WIN) | |
| 2366 } | 2385 } |
| 2367 | 2386 |
| 2368 void RenderWidgetHostViewAura::SetPopupChild( | 2387 void RenderWidgetHostViewAura::SetPopupChild( |
| 2369 RenderWidgetHostViewAura* popup_child_host_view) { | 2388 RenderWidgetHostViewAura* popup_child_host_view) { |
| 2370 popup_child_host_view_ = popup_child_host_view; | 2389 popup_child_host_view_ = popup_child_host_view; |
| 2371 event_handler_->SetPopupChild( | 2390 event_handler_->SetPopupChild( |
| 2372 popup_child_host_view, | 2391 popup_child_host_view, |
| 2373 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2392 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
| 2374 } | 2393 } |
| 2375 | 2394 |
| 2376 } // namespace content | 2395 } // namespace content |
| OLD | NEW |