Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 using namespace HTMLNames; | 95 using namespace HTMLNames; |
| 96 using namespace WTF; | 96 using namespace WTF; |
| 97 using namespace Unicode; | 97 using namespace Unicode; |
| 98 | 98 |
| 99 namespace { | 99 namespace { |
| 100 | 100 |
| 101 void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComposing isComposing) | 101 void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComposing isComposing) |
| 102 { | 102 { |
| 103 if (!RuntimeEnabledFeatures::inputEventEnabled()) | 103 if (!RuntimeEnabledFeatures::inputEventEnabled()) |
| 104 return; | 104 return; |
| 105 if (!target) | 105 if (!target || !target->isConnected()) |
|
yosin_UTC9
2016/09/08 04:34:40
One more.
Could you make |disaptchInputEvent()| to
chongz
2016/09/08 22:37:50
I've added check for |ownerDocument()| but I don't
chongz
2016/09/13 17:17:12
dtapuska@ I'm not sure if I understood the issue c
dtapuska
2016/09/13 17:27:50
Ya this change seems odd to me. The old code use t
yosin_UTC9
2016/09/14 01:57:37
I changed mind, we should verify source and target
| |
| 106 return; | 106 return; |
| 107 // TODO(chongz): Pass appreciate |ranges| after it's defined on spec. | |
| 108 // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype | |
| 109 InputEvent* inputEvent = InputEvent::createInput(inputType, data, isComposin g, nullptr); | 107 InputEvent* inputEvent = InputEvent::createInput(inputType, data, isComposin g, nullptr); |
| 110 target->dispatchScopedEvent(inputEvent); | 108 target->dispatchScopedEvent(inputEvent); |
| 111 } | 109 } |
| 112 | 110 |
| 113 void dispatchInputEventEditableContentChanged(Element* startRoot, Element* endRo ot, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComp osing isComposing) | 111 void dispatchInputEventEditableContentChanged(Element* startRoot, Element* endRo ot, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComp osing isComposing) |
| 114 { | 112 { |
| 115 if (startRoot) | 113 if (inputType == InputEvent::InputType::MoveByDragDrop) { |
| 116 dispatchInputEvent(startRoot, inputType, data, isComposing); | 114 // Drag&Drop will be combined into one |MoveSelectionCommand|, we need t o split it into |DeleteByDrag| and |InsertFromDrop|. |
| 117 if (endRoot && endRoot != startRoot) | 115 dispatchInputEvent(startRoot, InputEvent::InputType::DeleteByDrag, data, isComposing); |
| 116 dispatchInputEvent(endRoot, InputEvent::InputType::InsertFromDrop, data, isComposing); | |
| 117 return; | |
| 118 } | |
| 119 | |
| 120 dispatchInputEvent(startRoot, inputType, data, isComposing); | |
| 121 if (endRoot != startRoot) | |
| 118 dispatchInputEvent(endRoot, inputType, data, isComposing); | 122 dispatchInputEvent(endRoot, inputType, data, isComposing); |
| 119 } | 123 } |
| 120 | 124 |
| 121 InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command) | 125 InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command) |
| 122 { | 126 { |
| 123 if (command->isTypingCommand() && toTypingCommand(command)->compositionType( ) != TypingCommand::TextCompositionNone) | 127 if (command->isTypingCommand() && toTypingCommand(command)->compositionType( ) != TypingCommand::TextCompositionNone) |
| 124 return InputEvent::EventIsComposing::IsComposing; | 128 return InputEvent::EventIsComposing::IsComposing; |
| 125 return InputEvent::EventIsComposing::NotComposing; | 129 return InputEvent::EventIsComposing::NotComposing; |
| 126 } | 130 } |
| 127 | 131 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 | 557 |
| 554 // TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|. | 558 // TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|. |
| 555 void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, bool smar tReplace, bool plainText) | 559 void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, bool smar tReplace, bool plainText) |
| 556 { | 560 { |
| 557 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting; | 561 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting; |
| 558 if (smartReplace) | 562 if (smartReplace) |
| 559 options |= ReplaceSelectionCommand::SmartReplace; | 563 options |= ReplaceSelectionCommand::SmartReplace; |
| 560 if (plainText) | 564 if (plainText) |
| 561 options |= ReplaceSelectionCommand::MatchStyle; | 565 options |= ReplaceSelectionCommand::MatchStyle; |
| 562 DCHECK(frame().document()); | 566 DCHECK(frame().document()); |
| 563 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Inpu tEvent::InputType::Drag)->apply(); | 567 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Inpu tEvent::InputType::InsertFromDrop)->apply(); |
| 564 } | 568 } |
| 565 | 569 |
| 566 void Editor::moveSelectionAfterDragging(DocumentFragment* fragment, const Positi on& pos, bool smartInsert, bool smartDelete) | 570 void Editor::moveSelectionAfterDragging(DocumentFragment* fragment, const Positi on& pos, bool smartInsert, bool smartDelete) |
| 567 { | 571 { |
| 568 MoveSelectionCommand::create(fragment, pos, smartInsert, smartDelete)->apply (); | 572 MoveSelectionCommand::create(fragment, pos, smartInsert, smartDelete)->apply (); |
| 569 } | 573 } |
| 570 | 574 |
| 571 EphemeralRange Editor::selectedRange() | 575 EphemeralRange Editor::selectedRange() |
| 572 { | 576 { |
| 573 return frame().selection().selection().toNormalizedEphemeralRange(); | 577 return frame().selection().selection().toNormalizedEphemeralRange(); |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1418 | 1422 |
| 1419 DEFINE_TRACE(Editor) | 1423 DEFINE_TRACE(Editor) |
| 1420 { | 1424 { |
| 1421 visitor->trace(m_frame); | 1425 visitor->trace(m_frame); |
| 1422 visitor->trace(m_lastEditCommand); | 1426 visitor->trace(m_lastEditCommand); |
| 1423 visitor->trace(m_undoStack); | 1427 visitor->trace(m_undoStack); |
| 1424 visitor->trace(m_mark); | 1428 visitor->trace(m_mark); |
| 1425 } | 1429 } |
| 1426 | 1430 |
| 1427 } // namespace blink | 1431 } // namespace blink |
| OLD | NEW |