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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameWidgetImpl.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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (focusedFrame->inputMethodController().hasComposition()) { 475 if (focusedFrame->inputMethodController().hasComposition()) {
476 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient(); 476 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame (focusedFrame)->autofillClient();
477 477
478 if (autofillClient) 478 if (autofillClient)
479 autofillClient->setIgnoreTextChanges(true); 479 autofillClient->setIgnoreTextChanges(true);
480 480
481 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin gStylesheets 481 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin gStylesheets
482 // needs to be audited. See http://crbug.com/590369 for more de tails. 482 // needs to be audited. See http://crbug.com/590369 for more de tails.
483 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle sheets(); 483 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle sheets();
484 484
485 focusedFrame->inputMethodController().confirmComposition(); 485 focusedFrame->inputMethodController().finishComposingText(InputM ethodController::KeepSelection);
486 486
487 if (autofillClient) 487 if (autofillClient)
488 autofillClient->setIgnoreTextChanges(false); 488 autofillClient->setIgnoreTextChanges(false);
489 } 489 }
490 m_imeAcceptEvents = false; 490 m_imeAcceptEvents = false;
491 } 491 }
492 } 492 }
493 } 493 }
494 494
495 bool WebFrameWidgetImpl::setComposition( 495 bool WebFrameWidgetImpl::setComposition(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 538 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
539 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 539 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
540 // But the selection range actually takes effect. 540 // But the selection range actually takes effect.
541 inputMethodController.setComposition(String(text), 541 inputMethodController.setComposition(String(text),
542 CompositionUnderlineVectorBuilder(underlines), 542 CompositionUnderlineVectorBuilder(underlines),
543 selectionStart, selectionEnd); 543 selectionStart, selectionEnd);
544 544
545 return text.isEmpty() || inputMethodController.hasComposition(); 545 return text.isEmpty() || inputMethodController.hasComposition();
546 } 546 }
547 547
548 bool WebFrameWidgetImpl::confirmComposition() 548 bool WebFrameWidgetImpl::commitText(const WebString& text, int relativeCaretPosi tion)
549 { 549 {
550 return confirmComposition(DoNotKeepSelection); 550 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
551 LocalFrame* focused = focusedLocalFrameAvailableForIme();
552 if (!focused)
553 return false;
554
555 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
556 return plugin->commitText(text, relativeCaretPosition);
557
558 return focused->inputMethodController().commitText(text, relativeCaretPositi on);
551 } 559 }
552 560
553 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection Behavior) 561 bool WebFrameWidgetImpl::finishComposingText(ConfirmCompositionBehavior selectio nBehavior)
554 {
555 return confirmComposition(WebString(), selectionBehavior);
556 }
557
558 bool WebFrameWidgetImpl::confirmComposition(const WebString& text)
559 {
560 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
561 return confirmComposition(text, DoNotKeepSelection);
562 }
563
564 bool WebFrameWidgetImpl::confirmComposition(const WebString& text, ConfirmCompos itionBehavior selectionBehavior) const
565 { 562 {
566 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 563 LocalFrame* focused = focusedLocalFrameAvailableForIme();
567 if (!focused) 564 if (!focused)
568 return false; 565 return false;
569 566
570 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 567 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
571 return plugin->confirmComposition(text, selectionBehavior); 568 return plugin->finishComposingText(selectionBehavior);
572 569
573 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 570 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
574 // needs to be audited. See http://crbug.com/590369 for more details. 571 // needs to be audited. See http://crbug.com/590369 for more details.
575 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 572 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets();
576 573
577 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 574 return focused->inputMethodController().finishComposingText(selectionBehavio r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle r::DoNotKeepSelection);
578 } 575 }
579 576
580 WebRange WebFrameWidgetImpl::compositionRange() 577 WebRange WebFrameWidgetImpl::compositionRange()
581 { 578 {
582 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 579 LocalFrame* focused = focusedLocalFrameAvailableForIme();
583 if (!focused) 580 if (!focused)
584 return WebRange(); 581 return WebRange();
585 582
586 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange(); 583 const EphemeralRange range = focused->inputMethodController().compositionEph emeralRange();
587 if (range.isNull()) 584 if (range.isNull())
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 } 1455 }
1459 1456
1460 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const 1457 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const
1461 { 1458 {
1462 if (!m_imeAcceptEvents) 1459 if (!m_imeAcceptEvents)
1463 return nullptr; 1460 return nullptr;
1464 return focusedLocalFrameInWidget(); 1461 return focusedLocalFrameInWidget();
1465 } 1462 }
1466 1463
1467 } // namespace blink 1464 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebFrameWidgetImpl.h ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698