Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: content/public/test/text_input_test_utils.cc

Issue 2208583005: Request to start/stop calculating composition info from RenderWidget when it is active/inactive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased (nona@'s patch relanded) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/test/text_input_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer_host/render_widget_host_impl.h" 9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
11 #include "content/browser/renderer_host/render_widget_host_view_base.h" 11 #include "content/browser/renderer_host/render_widget_host_view_base.h"
12 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" 12 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
13 #include "content/browser/renderer_host/text_input_manager.h" 13 #include "content/browser/renderer_host/text_input_manager.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/common/input_messages.h"
15 #include "content/common/text_input_state.h" 16 #include "content/common/text_input_state.h"
16 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
17 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
21 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 22 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
22 #include "ui/base/ime/composition_underline.h" 23 #include "ui/base/ime/composition_underline.h"
23 #include "ui/base/ime/input_method.h" 24 #include "ui/base/ime/input_method.h"
24 #include "ui/base/ime/input_method_observer.h" 25 #include "ui/base/ime/input_method_observer.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 RenderWidgetHostViewBase* view_base = 238 RenderWidgetHostViewBase* view_base =
238 static_cast<RenderWidgetHostViewBase*>(view); 239 static_cast<RenderWidgetHostViewBase*>(view);
239 if (!manager || !manager->IsRegistered(view_base)) 240 if (!manager || !manager->IsRegistered(view_base))
240 return false; 241 return false;
241 242
242 *type = manager->GetTextInputTypeForViewForTesting(view_base); 243 *type = manager->GetTextInputTypeForViewForTesting(view_base);
243 244
244 return true; 245 return true;
245 } 246 }
246 247
247 void SetCompositionForRenderWidgetHost( 248 bool RequestCompositionInfoFromActiveWidget(WebContents* web_contents) {
248 RenderWidgetHost* render_widget_host, 249 TextInputManager* manager =
249 const base::string16& text, 250 static_cast<WebContentsImpl*>(web_contents)->GetTextInputManager();
250 const std::vector<ui::CompositionUnderline>& underlines, 251 if (!manager || !manager->GetActiveWidget())
251 const gfx::Range& replacement_range, 252 return false;
252 int selection_start,
253 int selection_end) {
254 std::vector<blink::WebCompositionUnderline> web_underlines;
255 for (auto underline : underlines) {
256 web_underlines.emplace_back(blink::WebCompositionUnderline(
257 underline.start_offset, underline.end_offset, underline.color,
258 underline.thick, underline.background_color));
259 }
260 253
261 static_cast<RenderWidgetHostImpl*>(render_widget_host) 254 manager->GetActiveWidget()->Send(new InputMsg_RequestCompositionUpdate(
262 ->ImeSetComposition(text, web_underlines, replacement_range, 255 manager->GetActiveWidget()->GetRoutingID(), true, true));
263 selection_start, selection_end); 256 return true;
264 } 257 }
265 258
266 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) { 259 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) {
267 std::unordered_set<RenderWidgetHostView*> views; 260 std::unordered_set<RenderWidgetHostView*> views;
268 TextInputManager* manager = 261 TextInputManager* manager =
269 static_cast<WebContentsImpl*>(web_contents)->GetTextInputManager(); 262 static_cast<WebContentsImpl*>(web_contents)->GetTextInputManager();
270 return !!manager ? manager->GetRegisteredViewsCountForTesting() : 0; 263 return !!manager ? manager->GetRegisteredViewsCountForTesting() : 0;
271 } 264 }
272 265
273 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { 266 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 405
413 #ifdef USE_AURA 406 #ifdef USE_AURA
414 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( 407 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
415 web_contents->GetRenderWidgetHostView()); 408 web_contents->GetRenderWidgetHostView());
416 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); 409 observer.reset(new InputMethodObserverAura(view->GetInputMethod()));
417 #endif 410 #endif
418 return observer; 411 return observer;
419 } 412 }
420 413
421 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/text_input_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698