| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (!hasComposition()) | 263 if (!hasComposition()) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 266 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 267 | 267 |
| 268 if (frame().selection().isNone()) | 268 if (frame().selection().isNone()) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 clear(); | 271 clear(); |
| 272 | 272 |
| 273 // TODO(chongz): Update InputType::DeleteComposedCharacter with latest discu
ssion. | 273 // TODO(chongz): Figure out which InputType should we use here. |
| 274 dispatchBeforeInputFromComposition(frame().document()->focusedElement(), Inp
utEvent::InputType::DeleteComposedCharacter, emptyString(), InputEvent::EventCan
celable::NotCancelable); | 274 dispatchBeforeInputFromComposition(frame().document()->focusedElement(), Inp
utEvent::InputType::DeleteComposedCharacterBackward, emptyString(), InputEvent::
EventCancelable::NotCancelable); |
| 275 dispatchCompositionUpdateEvent(frame(), emptyString()); | 275 dispatchCompositionUpdateEvent(frame(), emptyString()); |
| 276 insertTextDuringCompositionWithEvents(frame(), emptyString(), 0, TypingComma
nd::TextCompositionType::TextCompositionConfirm); | 276 insertTextDuringCompositionWithEvents(frame(), emptyString(), 0, TypingComma
nd::TextCompositionType::TextCompositionConfirm); |
| 277 // Event handler might destroy document. | 277 // Event handler might destroy document. |
| 278 if (!frame().document()) | 278 if (!frame().document()) |
| 279 return; | 279 return; |
| 280 | 280 |
| 281 // An open typing command that disagrees about current selection would cause | 281 // An open typing command that disagrees about current selection would cause |
| 282 // issues with typing later on. | 282 // issues with typing later on. |
| 283 TypingCommand::closeTyping(m_frame); | 283 TypingCommand::closeTyping(m_frame); |
| 284 | 284 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // only the last code-point so that it's possible for a user to correct | 547 // only the last code-point so that it's possible for a user to correct |
| 548 // a composition without starting it from the beginning. | 548 // a composition without starting it from the beginning. |
| 549 // http://crbug.com/37993 | 549 // http://crbug.com/37993 |
| 550 do { | 550 do { |
| 551 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) | 551 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) |
| 552 return; | 552 return; |
| 553 if (before == 0) | 553 if (before == 0) |
| 554 break; | 554 break; |
| 555 ++before; | 555 ++before; |
| 556 } while (frame().selection().start() == frame().selection().end() && before
<= static_cast<int>(selectionOffsets.start())); | 556 } while (frame().selection().start() == frame().selection().end() && before
<= static_cast<int>(selectionOffsets.start())); |
| 557 // TODO(chongz): New spec might want to change InputType. | 557 // TODO(chongz): Find a way to distinguish Forward and Backward. |
| 558 // https://github.com/w3c/editing/issues/125#issuecomment-213041256 | 558 dispatchBeforeInputEditorCommand(m_frame->document()->focusedElement(), Inpu
tEvent::InputType::DeleteContentBackward, emptyString(), new RangeVector(1, m_fr
ame->selection().firstRange())); |
| 559 dispatchBeforeInputEditorCommand(m_frame->document()->focusedElement(), Inpu
tEvent::InputType::DeleteContent, emptyString(), new RangeVector(1, m_frame->sel
ection().firstRange())); | |
| 560 TypingCommand::deleteSelection(*frame().document()); | 559 TypingCommand::deleteSelection(*frame().document()); |
| 561 } | 560 } |
| 562 | 561 |
| 563 DEFINE_TRACE(InputMethodController) | 562 DEFINE_TRACE(InputMethodController) |
| 564 { | 563 { |
| 565 visitor->trace(m_frame); | 564 visitor->trace(m_frame); |
| 566 visitor->trace(m_compositionRange); | 565 visitor->trace(m_compositionRange); |
| 567 } | 566 } |
| 568 | 567 |
| 569 } // namespace blink | 568 } // namespace blink |
| OLD | NEW |