| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/events/InputEvent.h" | 5 #include "core/events/InputEvent.h" |
| 6 | 6 |
| 7 #include "core/dom/Range.h" | 7 #include "core/dom/Range.h" |
| 8 #include "core/events/EventDispatcher.h" | 8 #include "core/events/EventDispatcher.h" |
| 9 #include "public/platform/WebEditingCommandType.h" | 9 #include "public/platform/WebEditingCommandType.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const struct { | 15 const struct { |
| 16 InputEvent::InputType inputType; | 16 InputEvent::InputType inputType; |
| 17 const char* stringName; | 17 const char* stringName; |
| 18 } kInputTypeStringNameMap[] = { | 18 } kInputTypeStringNameMap[] = { |
| 19 {InputEvent::InputType::None, ""}, | 19 {InputEvent::InputType::None, ""}, |
| 20 {InputEvent::InputType::InsertText, "insertText"}, | 20 {InputEvent::InputType::InsertText, "insertText"}, |
| 21 {InputEvent::InputType::InsertNonText, "insertNonText"}, | |
| 22 {InputEvent::InputType::InsertLineBreak, "insertLineBreak"}, | 21 {InputEvent::InputType::InsertLineBreak, "insertLineBreak"}, |
| 23 {InputEvent::InputType::InsertParagraph, "insertParagraph"}, | 22 {InputEvent::InputType::InsertParagraph, "insertParagraph"}, |
| 24 {InputEvent::InputType::InsertOrderedList, "insertOrderedList"}, | 23 {InputEvent::InputType::InsertOrderedList, "insertOrderedList"}, |
| 25 {InputEvent::InputType::InsertUnorderedList, "insertUnorderedList"}, | 24 {InputEvent::InputType::InsertUnorderedList, "insertUnorderedList"}, |
| 26 {InputEvent::InputType::InsertHorizontalRule, "insertHorizontalRule"}, | 25 {InputEvent::InputType::InsertHorizontalRule, "insertHorizontalRule"}, |
| 27 {InputEvent::InputType::InsertFromPaste, "insertFromPaste"}, | 26 {InputEvent::InputType::InsertFromPaste, "insertFromPaste"}, |
| 28 {InputEvent::InputType::InsertFromDrop, "insertFromDrop"}, | 27 {InputEvent::InputType::InsertFromDrop, "insertFromDrop"}, |
| 29 {InputEvent::InputType::DeleteComposedCharacterForward, | 28 {InputEvent::InputType::DeleteComposedCharacterForward, |
| 30 "deleteComposedCharacterForward"}, | 29 "deleteComposedCharacterForward"}, |
| 31 {InputEvent::InputType::DeleteComposedCharacterBackward, | 30 {InputEvent::InputType::DeleteComposedCharacterBackward, |
| 32 "deleteComposedCharacterBackward"}, | 31 "deleteComposedCharacterBackward"}, |
| 33 {InputEvent::InputType::DeleteWordBackward, "deleteWordBackward"}, | 32 {InputEvent::InputType::DeleteWordBackward, "deleteWordBackward"}, |
| 34 {InputEvent::InputType::DeleteWordForward, "deleteWordForward"}, | 33 {InputEvent::InputType::DeleteWordForward, "deleteWordForward"}, |
| 35 {InputEvent::InputType::DeleteLineBackward, "deleteLineBackward"}, | 34 {InputEvent::InputType::DeleteLineBackward, "deleteLineBackward"}, |
| 36 {InputEvent::InputType::DeleteLineForward, "deleteLineForward"}, | 35 {InputEvent::InputType::DeleteLineForward, "deleteLineForward"}, |
| 37 {InputEvent::InputType::DeleteContentBackward, "deleteContentBackward"}, | 36 {InputEvent::InputType::DeleteContentBackward, "deleteContentBackward"}, |
| 38 {InputEvent::InputType::DeleteContentForward, "deleteContentForward"}, | 37 {InputEvent::InputType::DeleteContentForward, "deleteContentForward"}, |
| 39 {InputEvent::InputType::DeleteByCut, "deleteByCut"}, | 38 {InputEvent::InputType::DeleteByCut, "deleteByCut"}, |
| 40 {InputEvent::InputType::DeleteByDrag, "deleteByDrag"}, | 39 {InputEvent::InputType::DeleteByDrag, "deleteByDrag"}, |
| 41 {InputEvent::InputType::Undo, "undo"}, | 40 {InputEvent::InputType::HistoryUndo, "historyUndo"}, |
| 42 {InputEvent::InputType::Redo, "redo"}, | 41 {InputEvent::InputType::HistoryRedo, "historyRedo"}, |
| 43 {InputEvent::InputType::Bold, "bold"}, | 42 {InputEvent::InputType::FormatBold, "formatBold"}, |
| 44 {InputEvent::InputType::Italic, "italic"}, | 43 {InputEvent::InputType::FormatItalic, "formatItalic"}, |
| 45 {InputEvent::InputType::Underline, "underline"}, | 44 {InputEvent::InputType::FormatUnderline, "formatUnderline"}, |
| 46 {InputEvent::InputType::StrikeThrough, "strikeThrough"}, | 45 {InputEvent::InputType::FormatStrikeThrough, "formatStrikeThrough"}, |
| 47 {InputEvent::InputType::Superscript, "superscript"}, | 46 {InputEvent::InputType::FormatSuperscript, "formatSuperscript"}, |
| 48 {InputEvent::InputType::Subscript, "subscript"}, | 47 {InputEvent::InputType::FormatSubscript, "formatSubscript"}, |
| 49 {InputEvent::InputType::JustifyCenter, "justifyCenter"}, | 48 {InputEvent::InputType::FormatJustifyCenter, "formatJustifyCenter"}, |
| 50 {InputEvent::InputType::JustifyRight, "justifyRight"}, | 49 {InputEvent::InputType::FormatJustifyFull, "formatJustifyFull"}, |
| 51 {InputEvent::InputType::JustifyLeft, "justifyLeft"}, | 50 {InputEvent::InputType::FormatJustifyRight, "formatJustifyRight"}, |
| 52 {InputEvent::InputType::Indent, "indent"}, | 51 {InputEvent::InputType::FormatJustifyLeft, "formatJustifyLeft"}, |
| 53 {InputEvent::InputType::Outdent, "outdent"}, | 52 {InputEvent::InputType::FormatIndent, "formatIndent"}, |
| 54 {InputEvent::InputType::RemoveFormat, "removeFormat"}, | 53 {InputEvent::InputType::FormatOutdent, "formatOutdent"}, |
| 55 {InputEvent::InputType::JustifyFull, "justifyFull"}, | 54 {InputEvent::InputType::FormatRemove, "formatRemove"}, |
| 56 {InputEvent::InputType::SetColor, "setColor"}, | 55 {InputEvent::InputType::FormatSetBlockTextDirection, |
| 57 {InputEvent::InputType::SetBackgroundColor, "setBackgroundColor"}, | 56 "formatSetBlockTextDirection"}, |
| 58 {InputEvent::InputType::SetFont, "setFont"}, | |
| 59 {InputEvent::InputType::ChangeAttributes, "changeAttributes"}, | |
| 60 {InputEvent::InputType::SetWritingDirection, "setWritingDirection"}, | |
| 61 {InputEvent::InputType::Unscript, "unscript"}, | |
| 62 {InputEvent::InputType::CreateLink, "createLink"}, | |
| 63 {InputEvent::InputType::Unlink, "unlink"}, | |
| 64 {InputEvent::InputType::FormatBlock, "formatBlock"}, | |
| 65 }; | 57 }; |
| 66 | 58 |
| 67 static_assert( | 59 static_assert( |
| 68 arraysize(kInputTypeStringNameMap) == | 60 arraysize(kInputTypeStringNameMap) == |
| 69 static_cast<size_t>(InputEvent::InputType::NumberOfInputTypes), | 61 static_cast<size_t>(InputEvent::InputType::NumberOfInputTypes), |
| 70 "must handle all InputEvent::InputType"); | 62 "must handle all InputEvent::InputType"); |
| 71 | 63 |
| 72 String convertInputTypeToString(InputEvent::InputType inputType) { | 64 String convertInputTypeToString(InputEvent::InputType inputType) { |
| 73 const auto& it = | 65 const auto& it = |
| 74 std::begin(kInputTypeStringNameMap) + static_cast<size_t>(inputType); | 66 std::begin(kInputTypeStringNameMap) + static_cast<size_t>(inputType); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // 3. We don't want authors to hold live |Range| indefinitely by holding | 216 // 3. We don't want authors to hold live |Range| indefinitely by holding |
| 225 // |InputEvent|, so we clear them after dispatch. | 217 // |InputEvent|, so we clear them after dispatch. |
| 226 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they | 218 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they |
| 227 // want to keep a copy of |Range|. See Editing TF meeting notes: | 219 // want to keep a copy of |Range|. See Editing TF meeting notes: |
| 228 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0
AM58/edit?usp=sharing | 220 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0
AM58/edit?usp=sharing |
| 229 event().m_ranges.clear(); | 221 event().m_ranges.clear(); |
| 230 return result; | 222 return result; |
| 231 } | 223 } |
| 232 | 224 |
| 233 } // namespace blink | 225 } // namespace blink |
| OLD | NEW |