| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } else { | 471 } else { |
| 472 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); | 472 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); |
| 473 if (focusedFrame) { | 473 if (focusedFrame) { |
| 474 // Finish an ongoing composition to delete the composition node. | 474 // Finish an ongoing composition to delete the composition node. |
| 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 focusedFrame->inputMethodController().confirmComposition(); | 481 focusedFrame->inputMethodController().replaceComposition(); |
| 482 | 482 |
| 483 if (autofillClient) | 483 if (autofillClient) |
| 484 autofillClient->setIgnoreTextChanges(false); | 484 autofillClient->setIgnoreTextChanges(false); |
| 485 } | 485 } |
| 486 m_imeAcceptEvents = false; | 486 m_imeAcceptEvents = false; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool WebFrameWidgetImpl::setComposition( | 491 bool WebFrameWidgetImpl::setComposition( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 return text.isEmpty() || inputMethodController.hasComposition(); | 541 return text.isEmpty() || inputMethodController.hasComposition(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 bool WebFrameWidgetImpl::confirmComposition() | 544 bool WebFrameWidgetImpl::confirmComposition() |
| 545 { | 545 { |
| 546 return confirmComposition(DoNotKeepSelection); | 546 return confirmComposition(DoNotKeepSelection); |
| 547 } | 547 } |
| 548 | 548 |
| 549 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection
Behavior) | 549 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection
Behavior) |
| 550 { | 550 { |
| 551 return confirmComposition(WebString(), selectionBehavior); | 551 return confirmComposition(WebString(), selectionBehavior, 1); |
| 552 } | 552 } |
| 553 | 553 |
| 554 bool WebFrameWidgetImpl::confirmComposition(const WebString& text) | 554 bool WebFrameWidgetImpl::confirmComposition(const WebString& text, int relativeC
ursorPosition) |
| 555 { | 555 { |
| 556 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 556 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 557 return confirmComposition(text, DoNotKeepSelection); | 557 return confirmComposition(text, DoNotKeepSelection, relativeCursorPosition); |
| 558 } | 558 } |
| 559 | 559 |
| 560 bool WebFrameWidgetImpl::confirmComposition(const WebString& text, ConfirmCompos
itionBehavior selectionBehavior) const | 560 bool WebFrameWidgetImpl::confirmComposition(const WebString& text, ConfirmCompos
itionBehavior selectionBehavior, int relativeCursorPosition) const |
| 561 { | 561 { |
| 562 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 562 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 563 if (!focused) | 563 if (!focused) |
| 564 return false; | 564 return false; |
| 565 | 565 |
| 566 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 566 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 567 return plugin->confirmComposition(text, selectionBehavior); | 567 return plugin->confirmComposition(text, selectionBehavior, relativeCurso
rPosition); |
| 568 | 568 |
| 569 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 569 if (selectionBehavior == KeepSelection) |
| 570 return focused->inputMethodController().confirmComposition(text); |
| 571 |
| 572 return focused->inputMethodController().confirmCompositionWithCursor(text, r
elativeCursorPosition); |
| 570 } | 573 } |
| 571 | 574 |
| 572 bool WebFrameWidgetImpl::compositionRange(size_t* location, size_t* length) | 575 bool WebFrameWidgetImpl::compositionRange(size_t* location, size_t* length) |
| 573 { | 576 { |
| 574 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 577 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 575 if (!focused) | 578 if (!focused) |
| 576 return false; | 579 return false; |
| 577 | 580 |
| 578 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 581 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
| 579 if (range.isNull()) | 582 if (range.isNull()) |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 } | 1460 } |
| 1458 | 1461 |
| 1459 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const | 1462 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const |
| 1460 { | 1463 { |
| 1461 if (!m_imeAcceptEvents) | 1464 if (!m_imeAcceptEvents) |
| 1462 return nullptr; | 1465 return nullptr; |
| 1463 return focusedLocalFrameInWidget(); | 1466 return focusedLocalFrameInWidget(); |
| 1464 } | 1467 } |
| 1465 | 1468 |
| 1466 } // namespace blink | 1469 } // namespace blink |
| OLD | NEW |