| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 return; | 551 return; |
| 552 | 552 |
| 553 // An open typing command that disagrees about current selection would cause | 553 // An open typing command that disagrees about current selection would cause |
| 554 // issues with typing later on. | 554 // issues with typing later on. |
| 555 TypingCommand::CloseTyping(frame_); | 555 TypingCommand::CloseTyping(frame_); |
| 556 | 556 |
| 557 // No DOM update after 'compositionend'. | 557 // No DOM update after 'compositionend'. |
| 558 DispatchCompositionEndEvent(GetFrame(), g_empty_string); | 558 DispatchCompositionEndEvent(GetFrame(), g_empty_string); |
| 559 } | 559 } |
| 560 | 560 |
| 561 void InputMethodController::CancelCompositionIfSelectionIsInvalid() { |
| 562 if (!has_composition_) |
| 563 return; |
| 564 |
| 565 /*if (composition_range_) |
| 566 LOG(INFO) << composition_range_->toString(); |
| 567 else |
| 568 LOG(INFO) << "null range"; |
| 569 if (!HasComposition() || GetEditor().PreventRevealSelection()) |
| 570 return; |
| 571 |
| 572 // Check if selection start and selection end are valid. |
| 573 FrameSelection& selection = GetFrame().Selection(); |
| 574 if (selection.IsAvailable() && !composition_range_->collapsed()) { |
| 575 const SelectionInDOMTree& selection_in_dom = selection.GetSelectionInDOMT
ree(); |
| 576 if (selection_in_dom.Base().CompareTo(composition_range_->StartPosition
()) >= 0 && |
| 577 selection_in_dom.Extent().CompareTo(composition_range_->EndPosition()
) <= 0) |
| 578 return; |
| 579 |
| 580 }*/ |
| 581 |
| 582 Clear(); |
| 583 GetFrame().GetChromeClient().DidCancelCompositionOnSelectionChange(); |
| 584 |
| 585 } |
| 586 |
| 561 void InputMethodController::SetComposition( | 587 void InputMethodController::SetComposition( |
| 562 const String& text, | 588 const String& text, |
| 563 const Vector<CompositionUnderline>& underlines, | 589 const Vector<CompositionUnderline>& underlines, |
| 564 int selection_start, | 590 int selection_start, |
| 565 int selection_end) { | 591 int selection_end) { |
| 566 Editor::RevealSelectionScope reveal_selection_scope(&GetEditor()); | 592 Editor::RevealSelectionScope reveal_selection_scope(&GetEditor()); |
| 567 | 593 |
| 568 // Updates styles before setting selection for composition to prevent | 594 // Updates styles before setting selection for composition to prevent |
| 569 // inserting the previous composition text into text nodes oddly. | 595 // inserting the previous composition text into text nodes oddly. |
| 570 // See https://bugs.webkit.org/show_bug.cgi?id=46868 | 596 // See https://bugs.webkit.org/show_bug.cgi?id=46868 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 FinishComposingText(kKeepSelection); | 1256 FinishComposingText(kKeepSelection); |
| 1231 } | 1257 } |
| 1232 | 1258 |
| 1233 DEFINE_TRACE(InputMethodController) { | 1259 DEFINE_TRACE(InputMethodController) { |
| 1234 visitor->Trace(frame_); | 1260 visitor->Trace(frame_); |
| 1235 visitor->Trace(composition_range_); | 1261 visitor->Trace(composition_range_); |
| 1236 SynchronousMutationObserver::Trace(visitor); | 1262 SynchronousMutationObserver::Trace(visitor); |
| 1237 } | 1263 } |
| 1238 | 1264 |
| 1239 } // namespace blink | 1265 } // namespace blink |
| OLD | NEW |