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::ReplaceContent, "replaceContent" }, | 21 { InputEvent::InputType::InsertNonText, "insertNonText" }, |
22 { InputEvent::InputType::DeleteContent, "deleteContent" }, | 22 { InputEvent::InputType::InsertLineBreak, "insertLineBreak" }, |
23 { InputEvent::InputType::DeleteComposedCharacter, "deleteComposedCharacter"
}, | 23 { InputEvent::InputType::InsertParagraph, "insertParagraph" }, |
| 24 { InputEvent::InputType::InsertOrderedList, "insertOrderedList" }, |
| 25 { InputEvent::InputType::InsertUnorderedList, "insertUnorderedList" }, |
| 26 { InputEvent::InputType::InsertHorizontalRule, "insertHorizontalRule" }, |
| 27 { InputEvent::InputType::DeleteComposedCharacterForward, "deleteComposedChar
acterForward" }, |
| 28 { InputEvent::InputType::DeleteComposedCharacterBackward, "deleteComposedCha
racterBackward" }, |
| 29 { InputEvent::InputType::DeleteWordBackward, "deleteWordBackward" }, |
| 30 { InputEvent::InputType::DeleteWordForward, "deleteWordForward" }, |
| 31 { InputEvent::InputType::DeleteLineBackward, "deleteLineBackward" }, |
| 32 { InputEvent::InputType::DeleteLineForward, "deleteLineForward" }, |
| 33 { InputEvent::InputType::DeleteContentBackward, "deleteContentBackward" }, |
| 34 { InputEvent::InputType::DeleteContentForward, "deleteContentForward" }, |
24 { InputEvent::InputType::Undo, "undo" }, | 35 { InputEvent::InputType::Undo, "undo" }, |
25 { InputEvent::InputType::Redo, "redo" }, | 36 { InputEvent::InputType::Redo, "redo" }, |
| 37 { InputEvent::InputType::Copy, "copy" }, |
| 38 { InputEvent::InputType::Cut, "cut" }, |
| 39 { InputEvent::InputType::Paste, "paste" }, |
26 { InputEvent::InputType::Bold, "bold" }, | 40 { InputEvent::InputType::Bold, "bold" }, |
27 { InputEvent::InputType::Italic, "italic" }, | 41 { InputEvent::InputType::Italic, "italic" }, |
28 { InputEvent::InputType::Underline, "underline" }, | 42 { InputEvent::InputType::Underline, "underline" }, |
29 { InputEvent::InputType::StrikeThrough, "strikeThrough" }, | 43 { InputEvent::InputType::StrikeThrough, "strikeThrough" }, |
30 { InputEvent::InputType::Superscript, "superscript" }, | 44 { InputEvent::InputType::Superscript, "superscript" }, |
31 { InputEvent::InputType::Subscript, "subscript" }, | 45 { InputEvent::InputType::Subscript, "subscript" }, |
| 46 { InputEvent::InputType::JustifyCenter, "justifyCenter" }, |
| 47 { InputEvent::InputType::JustifyRight, "justifyRight" }, |
| 48 { InputEvent::InputType::JustifyLeft, "justifyLeft" }, |
| 49 { InputEvent::InputType::Indent, "indent" }, |
| 50 { InputEvent::InputType::Outdent, "outdent" }, |
| 51 { InputEvent::InputType::RemoveFormat, "removeFormat" }, |
| 52 { InputEvent::InputType::Drag, "drag" }, |
| 53 { InputEvent::InputType::JustifyFull, "justifyFull" }, |
| 54 { InputEvent::InputType::SetColor, "setColor" }, |
| 55 { InputEvent::InputType::SetBackgroundColor, "setBackgroundColor" }, |
| 56 { InputEvent::InputType::SetFont, "setFont" }, |
| 57 { InputEvent::InputType::ChangeAttributes, "changeAttributes" }, |
| 58 { InputEvent::InputType::SetWritingDirection, "setWritingDirection" }, |
| 59 { InputEvent::InputType::Unscript, "unscript" }, |
| 60 { InputEvent::InputType::CreateLink, "createLink" }, |
| 61 { InputEvent::InputType::Unlink, "unlink" }, |
| 62 { InputEvent::InputType::FormatBlock, "formatBlock" }, |
32 }; | 63 }; |
33 | 64 |
34 static_assert(arraysize(kInputTypeStringNameMap) == static_cast<size_t>(InputEve
nt::InputType::NumberOfInputTypes), | 65 static_assert(arraysize(kInputTypeStringNameMap) == static_cast<size_t>(InputEve
nt::InputType::NumberOfInputTypes), |
35 "must handle all InputEvent::InputType"); | 66 "must handle all InputEvent::InputType"); |
36 | 67 |
37 String convertInputTypeToString(InputEvent::InputType inputType) | 68 String convertInputTypeToString(InputEvent::InputType inputType) |
38 { | 69 { |
39 const auto& it = std::begin(kInputTypeStringNameMap) + static_cast<size_t>(i
nputType); | 70 const auto& it = std::begin(kInputTypeStringNameMap) + static_cast<size_t>(i
nputType); |
40 if (it >= std::begin(kInputTypeStringNameMap) && it < std::end(kInputTypeStr
ingNameMap)) | 71 if (it >= std::begin(kInputTypeStringNameMap) && it < std::end(kInputTypeStr
ingNameMap)) |
41 return AtomicString(it->stringName); | 72 return AtomicString(it->stringName); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // 3. We don't want authors to hold live |Range| indefinitely by holding |
InputEvent|, so we | 198 // 3. We don't want authors to hold live |Range| indefinitely by holding |
InputEvent|, so we |
168 // clear them after dispatch. | 199 // clear them after dispatch. |
169 // Authors should explicitly call |getRanges()|->|toRange()| if they want to
keep a copy of |Range|. | 200 // Authors should explicitly call |getRanges()|->|toRange()| if they want to
keep a copy of |Range|. |
170 // See Editing TF meeting notes: | 201 // See Editing TF meeting notes: |
171 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL
G0AM58/edit?usp=sharing | 202 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL
G0AM58/edit?usp=sharing |
172 event().m_ranges.clear(); | 203 event().m_ranges.clear(); |
173 return result; | 204 return result; |
174 } | 205 } |
175 | 206 |
176 } // namespace blink | 207 } // namespace blink |
OLD | NEW |