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

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: adjust selection in confirmCompositionOrInsertText() 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
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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 2360 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
2361 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 2361 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
2362 // But the selection range actually takes effect. 2362 // But the selection range actually takes effect.
2363 inputMethodController.setComposition(String(text), 2363 inputMethodController.setComposition(String(text),
2364 CompositionUnderlineVectorBuilder(underlines), 2364 CompositionUnderlineVectorBuilder(underlines),
2365 selectionStart, selectionEnd); 2365 selectionStart, selectionEnd);
2366 2366
2367 return text.isEmpty() || inputMethodController.hasComposition(); 2367 return text.isEmpty() || inputMethodController.hasComposition();
2368 } 2368 }
2369 2369
2370 bool WebViewImpl::confirmComposition() 2370 bool WebViewImpl::confirmComposition(int newCursorPosition)
2371 { 2371 {
2372 return confirmComposition(DoNotKeepSelection); 2372 return confirmComposition(DoNotKeepSelection, newCursorPosition);
2373 } 2373 }
2374 2374
2375 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio r) 2375 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio r, int newCursorPosition)
2376 { 2376 {
2377 return confirmComposition(WebString(), selectionBehavior); 2377 return confirmComposition(WebString(), selectionBehavior, newCursorPosition) ;
2378 } 2378 }
2379 2379
2380 bool WebViewImpl::confirmComposition(const WebString& text) 2380 bool WebViewImpl::confirmComposition(const WebString& text, int newCursorPositio n)
2381 { 2381 {
2382 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2382 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2383 return confirmComposition(text, DoNotKeepSelection); 2383 return confirmComposition(text, DoNotKeepSelection, newCursorPosition);
2384 } 2384 }
2385 2385
2386 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) 2386 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior, int newCursorPosition)
2387 { 2387 {
2388 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2388 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2389 if (!focused) 2389 if (!focused)
2390 return false; 2390 return false;
2391 2391
2392 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2392 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2393 return plugin->confirmComposition(text, selectionBehavior); 2393 return plugin->confirmComposition(text, selectionBehavior, newCursorPosi tion);
2394 2394
2395 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2395 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection, newCursorPosition);
2396 } 2396 }
2397 2397
2398 bool WebViewImpl::compositionRange(size_t* location, size_t* length) 2398 bool WebViewImpl::compositionRange(size_t* location, size_t* length)
2399 { 2399 {
2400 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2400 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2401 if (!focused) 2401 if (!focused)
2402 return false; 2402 return false;
2403 2403
2404 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange(); 2404 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange();
2405 if (range.isNull()) 2405 if (range.isNull())
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
4620 return nullptr; 4620 return nullptr;
4621 return focusedFrame; 4621 return focusedFrame;
4622 } 4622 }
4623 4623
4624 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4624 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4625 { 4625 {
4626 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4626 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4627 } 4627 }
4628 4628
4629 } // namespace blink 4629 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698