OLD | NEW |
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 Loading... |
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 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This | 495 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // But the selection range actually takes effect. | 542 // But the selection range actually takes effect. |
543 inputMethodController.setComposition(String(text), | 543 inputMethodController.setComposition(String(text), |
544 CompositionUnderlineVectorBuilder(underlines), | 544 CompositionUnderlineVectorBuilder(underlines), |
545 selectionStart, selectionEnd); | 545 selectionStart, selectionEnd); |
546 | 546 |
547 return text.isEmpty() || inputMethodController.hasComposition(); | 547 return text.isEmpty() || inputMethodController.hasComposition(); |
548 } | 548 } |
549 | 549 |
550 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. | 550 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. |
551 // This code needs to be refactored (http://crbug.com/629721). | 551 // This code needs to be refactored (http://crbug.com/629721). |
552 bool WebFrameWidgetImpl::confirmComposition() | 552 bool WebFrameWidgetImpl::commitText(const WebString& text, int relativeCaretPosi
tion) |
553 { | 553 { |
554 return confirmComposition(DoNotKeepSelection); | 554 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 555 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 556 if (!focused) |
| 557 return false; |
| 558 |
| 559 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 560 return plugin->commitText(text, relativeCaretPosition); |
| 561 |
| 562 return focused->inputMethodController().commitText(text, relativeCaretPositi
on); |
555 } | 563 } |
556 | 564 |
557 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection
Behavior) | 565 bool WebFrameWidgetImpl::finishComposingText(ConfirmCompositionBehavior selectio
nBehavior) |
558 { | |
559 return confirmComposition(WebString(), selectionBehavior); | |
560 } | |
561 | |
562 bool WebFrameWidgetImpl::confirmComposition(const WebString& text) | |
563 { | |
564 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
565 return confirmComposition(text, DoNotKeepSelection); | |
566 } | |
567 | |
568 bool WebFrameWidgetImpl::confirmComposition(const WebString& text, ConfirmCompos
itionBehavior selectionBehavior) const | |
569 { | 566 { |
570 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 567 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
571 if (!focused) | 568 if (!focused) |
572 return false; | 569 return false; |
573 | 570 |
574 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 571 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
575 return plugin->confirmComposition(text, selectionBehavior); | 572 return plugin->finishComposingText(selectionBehavior); |
576 | 573 |
577 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 574 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
578 // needs to be audited. See http://crbug.com/590369 for more details. | 575 // needs to be audited. See http://crbug.com/590369 for more details. |
579 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 576 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
580 | 577 |
581 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 578 return focused->inputMethodController().finishComposingText(selectionBehavio
r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle
r::DoNotKeepSelection); |
582 } | 579 } |
583 | 580 |
584 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This | 581 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
585 // code needs to be refactored (http://crbug.com/629721). | 582 // code needs to be refactored (http://crbug.com/629721). |
586 WebRange WebFrameWidgetImpl::compositionRange() | 583 WebRange WebFrameWidgetImpl::compositionRange() |
587 { | 584 { |
588 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 585 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
589 if (!focused) | 586 if (!focused) |
590 return WebRange(); | 587 return WebRange(); |
591 | 588 |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 } | 1478 } |
1482 | 1479 |
1483 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const | 1480 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const |
1484 { | 1481 { |
1485 if (!m_imeAcceptEvents) | 1482 if (!m_imeAcceptEvents) |
1486 return nullptr; | 1483 return nullptr; |
1487 return focusedLocalFrameInWidget(); | 1484 return focusedLocalFrameInWidget(); |
1488 } | 1485 } |
1489 | 1486 |
1490 } // namespace blink | 1487 } // namespace blink |
OLD | NEW |