Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/test/text_input_test_utils.h" | 5 #include "content/public/test/text_input_test_utils.h" |
| 6 | 6 |
| 7 #include <unordered_set> | 7 #include <unordered_set> |
| 8 | 8 |
| 9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 manager->GetActiveWidget()->Send(new InputMsg_RequestCompositionUpdate( | 255 manager->GetActiveWidget()->Send(new InputMsg_RequestCompositionUpdate( |
| 256 manager->GetActiveWidget()->GetRoutingID(), true, false)); | 256 manager->GetActiveWidget()->GetRoutingID(), true, false)); |
| 257 return true; | 257 return true; |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool DoesFrameHaveFocusedEditableElement(RenderFrameHost* frame) { | 260 bool DoesFrameHaveFocusedEditableElement(RenderFrameHost* frame) { |
| 261 return static_cast<RenderFrameHostImpl*>(frame) | 261 return static_cast<RenderFrameHostImpl*>(frame) |
| 262 ->has_focused_editable_element(); | 262 ->has_focused_editable_element(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void SendImeCommitTextToWidget( | |
| 266 RenderWidgetHost* rwh, | |
| 267 const base::string16& text, | |
| 268 const std::vector<ui::CompositionUnderline>& underlines, | |
| 269 const gfx::Range& replacement_range, | |
| 270 int relative_cursor_pos) { | |
| 271 std::vector<blink::WebCompositionUnderline> web_composition_underlines; | |
| 272 for (auto underline : underlines) { | |
| 273 web_composition_underlines.push_back(blink::WebCompositionUnderline( | |
|
alexmos
2017/02/08 02:16:23
optional: emplace_back would let you avoid explici
EhsanK
2017/02/09 00:50:34
Sorry I just saw this suggestion. Thanks (And Done
| |
| 274 static_cast<int>(underline.start_offset), | |
| 275 static_cast<int>(underline.end_offset), underline.color, | |
| 276 underline.thick, underline.background_color)); | |
| 277 } | |
| 278 RenderWidgetHostImpl::From(rwh)->ImeCommitText( | |
| 279 text, web_composition_underlines, replacement_range, relative_cursor_pos); | |
| 280 } | |
| 281 | |
| 265 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) { | 282 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) { |
| 266 std::unordered_set<RenderWidgetHostView*> views; | 283 std::unordered_set<RenderWidgetHostView*> views; |
| 267 TextInputManager* manager = | 284 TextInputManager* manager = |
| 268 static_cast<WebContentsImpl*>(web_contents)->GetTextInputManager(); | 285 static_cast<WebContentsImpl*>(web_contents)->GetTextInputManager(); |
| 269 return !!manager ? manager->GetRegisteredViewsCountForTesting() : 0; | 286 return !!manager ? manager->GetRegisteredViewsCountForTesting() : 0; |
| 270 } | 287 } |
| 271 | 288 |
| 272 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { | 289 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { |
| 273 return static_cast<WebContentsImpl*>(web_contents) | 290 return static_cast<WebContentsImpl*>(web_contents) |
| 274 ->GetTextInputManager() | 291 ->GetTextInputManager() |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 424 |
| 408 #ifdef USE_AURA | 425 #ifdef USE_AURA |
| 409 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( | 426 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( |
| 410 web_contents->GetRenderWidgetHostView()); | 427 web_contents->GetRenderWidgetHostView()); |
| 411 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); | 428 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); |
| 412 #endif | 429 #endif |
| 413 return observer; | 430 return observer; |
| 414 } | 431 } |
| 415 | 432 |
| 416 } // namespace content | 433 } // namespace content |
| OLD | NEW |