Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: third_party/WebKit/Source/core/events/InputEvent.cpp

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 arraysize(kInputTypeStringNameMap) == 61 arraysize(kInputTypeStringNameMap) ==
62 static_cast<size_t>(InputEvent::InputType::NumberOfInputTypes), 62 static_cast<size_t>(InputEvent::InputType::NumberOfInputTypes),
63 "must handle all InputEvent::InputType"); 63 "must handle all InputEvent::InputType");
64 64
65 String convertInputTypeToString(InputEvent::InputType inputType) { 65 String convertInputTypeToString(InputEvent::InputType inputType) {
66 const auto& it = 66 const auto& it =
67 std::begin(kInputTypeStringNameMap) + static_cast<size_t>(inputType); 67 std::begin(kInputTypeStringNameMap) + static_cast<size_t>(inputType);
68 if (it >= std::begin(kInputTypeStringNameMap) && 68 if (it >= std::begin(kInputTypeStringNameMap) &&
69 it < std::end(kInputTypeStringNameMap)) 69 it < std::end(kInputTypeStringNameMap))
70 return AtomicString(it->stringName); 70 return AtomicString(it->stringName);
71 return emptyString(); 71 return emptyString;
72 } 72 }
73 73
74 InputEvent::InputType convertStringToInputType(const String& stringName) { 74 InputEvent::InputType convertStringToInputType(const String& stringName) {
75 // TODO(chongz): Use binary search if the map goes larger. 75 // TODO(chongz): Use binary search if the map goes larger.
76 for (const auto& entry : kInputTypeStringNameMap) { 76 for (const auto& entry : kInputTypeStringNameMap) {
77 if (stringName == entry.stringName) 77 if (stringName == entry.stringName)
78 return entry.inputType; 78 return entry.inputType;
79 } 79 }
80 return InputEvent::InputType::None; 80 return InputEvent::InputType::None;
81 } 81 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // 3. We don't want authors to hold live |Range| indefinitely by holding 217 // 3. We don't want authors to hold live |Range| indefinitely by holding
218 // |InputEvent|, so we clear them after dispatch. 218 // |InputEvent|, so we clear them after dispatch.
219 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they 219 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they
220 // want to keep a copy of |Range|. See Editing TF meeting notes: 220 // want to keep a copy of |Range|. See Editing TF meeting notes:
221 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0 AM58/edit?usp=sharing 221 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0 AM58/edit?usp=sharing
222 event().m_ranges.clear(); 222 event().m_ranges.clear();
223 return result; 223 return result;
224 } 224 }
225 225
226 } // namespace blink 226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventListener.h ('k') | third_party/WebKit/Source/core/frame/Deprecation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698