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

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

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue 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 if (focusedFrame->inputMethodController().hasComposition()) { 2293 if (focusedFrame->inputMethodController().hasComposition()) {
2294 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient(); 2294 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient();
2295 2295
2296 if (autofillClient) 2296 if (autofillClient)
2297 autofillClient->setIgnoreTextChanges(true); 2297 autofillClient->setIgnoreTextChanges(true);
2298 2298
2299 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin gStylesheets 2299 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin gStylesheets
2300 // needs to be audited. See http://crbug.com/590369 for more de tails. 2300 // needs to be audited. See http://crbug.com/590369 for more de tails.
2301 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle sheets(); 2301 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle sheets();
2302 2302
2303 focusedFrame->inputMethodController().confirmComposition(); 2303 focusedFrame->inputMethodController().finishComposingText(InputM ethodController::KeepSelection);
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 2356 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
2357 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 2357 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
2358 // But the selection range actually takes effect. 2358 // But the selection range actually takes effect.
2359 inputMethodController.setComposition(String(text), 2359 inputMethodController.setComposition(String(text),
2360 CompositionUnderlineVectorBuilder(underlines), 2360 CompositionUnderlineVectorBuilder(underlines),
2361 selectionStart, selectionEnd); 2361 selectionStart, selectionEnd);
2362 2362
2363 return text.isEmpty() || inputMethodController.hasComposition(); 2363 return text.isEmpty() || inputMethodController.hasComposition();
2364 } 2364 }
2365 2365
2366 bool WebViewImpl::confirmComposition() 2366 bool WebViewImpl::finishComposingText(ConfirmCompositionBehavior selectionBehavi or)
2367 {
2368 return confirmComposition(DoNotKeepSelection);
2369 }
2370
2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio r)
2372 {
2373 return confirmComposition(WebString(), selectionBehavior);
2374 }
2375
2376 bool WebViewImpl::confirmComposition(const WebString& text)
2377 {
2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2379 return confirmComposition(text, DoNotKeepSelection);
2380 }
2381
2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior)
2383 { 2367 {
2384 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2368 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2385 if (!focused) 2369 if (!focused)
2386 return false; 2370 return false;
2387 2371
2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2372 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2389 return plugin->confirmComposition(text, selectionBehavior); 2373 return plugin->finishComposingText(selectionBehavior);
2374
2375 return focused->inputMethodController().finishComposingText(selectionBehavio r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle r::DoNotKeepSelection);
2376 }
2377
2378 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition)
2379 {
2380 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2381
2382 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2383 if (!focused)
2384 return false;
2385
2386 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2387 return plugin->commitText(text, relativeCaretPosition);
2390 2388
2391 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 2389 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
2392 // needs to be audited. See http://crbug.com/590369 for more details. 2390 // needs to be audited. See http://crbug.com/590369 for more details.
2393 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 2391 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets();
2394 2392
2395 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2393 return focused->inputMethodController().commitText(text, relativeCaretPositi on);
2396 } 2394 }
2397 2395
2398 WebRange WebViewImpl::compositionRange() 2396 WebRange WebViewImpl::compositionRange()
2399 { 2397 {
2400 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2398 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2401 if (!focused) 2399 if (!focused)
2402 return WebRange(); 2400 return WebRange();
2403 2401
2404 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange(); 2402 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange();
2405 if (range.isNull()) 2403 if (range.isNull())
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after
4611 return nullptr; 4609 return nullptr;
4612 return focusedFrame; 4610 return focusedFrame;
4613 } 4611 }
4614 4612
4615 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4613 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4616 { 4614 {
4617 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4615 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4618 } 4616 }
4619 4617
4620 } // namespace blink 4618 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698