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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1995333002: Handle newCursorPosition correctly for Android's commitText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change for aelias@'s review Created 4 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 2293
2294 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); 2294 LocalFrame* focusedFrame = focusedLocalFrameInWidget();
2295 if (focusedFrame) { 2295 if (focusedFrame) {
2296 // Finish an ongoing composition to delete the composition node. 2296 // Finish an ongoing composition to delete the composition node.
2297 if (focusedFrame->inputMethodController().hasComposition()) { 2297 if (focusedFrame->inputMethodController().hasComposition()) {
2298 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient(); 2298 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient();
2299 2299
2300 if (autofillClient) 2300 if (autofillClient)
2301 autofillClient->setIgnoreTextChanges(true); 2301 autofillClient->setIgnoreTextChanges(true);
2302 2302
2303 focusedFrame->inputMethodController().confirmComposition(); 2303 focusedFrame->inputMethodController().replaceComposition();
2304 2304
2305 if (autofillClient) 2305 if (autofillClient)
2306 autofillClient->setIgnoreTextChanges(false); 2306 autofillClient->setIgnoreTextChanges(false);
2307 } 2307 }
2308 m_imeAcceptEvents = false; 2308 m_imeAcceptEvents = false;
2309 } 2309 }
2310 } 2310 }
2311 } 2311 }
2312 2312
2313 bool WebViewImpl::setComposition( 2313 bool WebViewImpl::setComposition(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 return text.isEmpty() || inputMethodController.hasComposition(); 2363 return text.isEmpty() || inputMethodController.hasComposition();
2364 } 2364 }
2365 2365
2366 bool WebViewImpl::confirmComposition() 2366 bool WebViewImpl::confirmComposition()
2367 { 2367 {
2368 return confirmComposition(DoNotKeepSelection); 2368 return confirmComposition(DoNotKeepSelection);
2369 } 2369 }
2370 2370
2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio r) 2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio r)
2372 { 2372 {
2373 return confirmComposition(WebString(), selectionBehavior); 2373 return confirmComposition(WebString(), selectionBehavior, 1);
2374 } 2374 }
2375 2375
2376 bool WebViewImpl::confirmComposition(const WebString& text) 2376 bool WebViewImpl::confirmComposition(const WebString& text, int relativeCursorPo sition)
2377 { 2377 {
2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2379 return confirmComposition(text, DoNotKeepSelection); 2379 return confirmComposition(text, DoNotKeepSelection, relativeCursorPosition);
2380 } 2380 }
2381 2381
2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) 2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior, int relativeCursorPosition)
2383 { 2383 {
2384 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2384 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2385 if (!focused) 2385 if (!focused)
2386 return false; 2386 return false;
2387 2387
2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2389 return plugin->confirmComposition(text, selectionBehavior); 2389 return plugin->confirmComposition(text, selectionBehavior, relativeCurso rPosition);
2390 2390
2391 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2391 if (selectionBehavior == KeepSelection)
2392 return focused->inputMethodController().confirmComposition(text);
2393
2394 return focused->inputMethodController().confirmCompositionWithCursor(text, r elativeCursorPosition);
2392 } 2395 }
2393 2396
2394 bool WebViewImpl::compositionRange(size_t* location, size_t* length) 2397 bool WebViewImpl::compositionRange(size_t* location, size_t* length)
2395 { 2398 {
2396 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2399 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2397 if (!focused) 2400 if (!focused)
2398 return false; 2401 return false;
2399 2402
2400 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange(); 2403 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange();
2401 if (range.isNull()) 2404 if (range.isNull())
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4602 return nullptr; 4605 return nullptr;
4603 return focusedFrame; 4606 return focusedFrame;
4604 } 4607 }
4605 4608
4606 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4609 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4607 { 4610 {
4608 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4611 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4609 } 4612 }
4610 4613
4611 } // namespace blink 4614 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698