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

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

Issue 2022863002: [InputEvent] Introduce |StaticRange| and use in |InputEvent::getRanges()| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce |StaticRange| and add tests Created 4 years, 6 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 inputEventInit.setRanges(*ranges); 83 inputEventInit.setRanges(*ranges);
84 84
85 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); 85 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit);
86 } 86 }
87 87
88 String InputEvent::inputType() const 88 String InputEvent::inputType() const
89 { 89 {
90 return convertInputTypeToString(m_inputType); 90 return convertInputTypeToString(m_inputType);
91 } 91 }
92 92
93 StaticRangeVector InputEvent::getRanges() const
94 {
95 StaticRangeVector staticRanges;
96 for (const auto& range : m_ranges) {
dtapuska 2016/06/02 15:26:29 brackets not needed.
chongz 2016/06/06 19:43:44 Done.
97 staticRanges.append(StaticRange::create(range->startContainer(), range-> startOffset(), range->endContainer(), range->endOffset()));
98 }
99 return staticRanges;
dtapuska 2016/06/02 15:26:29 Does this create a new object; or should std::move
chongz 2016/06/06 19:43:43 According to go/totw/11 I'd assume compiler is sma
100 }
101
93 bool InputEvent::isInputEvent() const 102 bool InputEvent::isInputEvent() const
94 { 103 {
95 return true; 104 return true;
96 } 105 }
97 106
98 // TODO(chongz): We should get rid of this |EventDispatchMediator| pattern and i ntroduce 107 // TODO(chongz): We should get rid of this |EventDispatchMediator| pattern and i ntroduce
99 // simpler interface such as |beforeDispatchEvent()| and |afterDispatchEvent()| virtual methods. 108 // simpler interface such as |beforeDispatchEvent()| and |afterDispatchEvent()| virtual methods.
100 EventDispatchMediator* InputEvent::createMediator() 109 EventDispatchMediator* InputEvent::createMediator()
101 { 110 {
102 return InputEventDispatchMediator::create(this); 111 return InputEventDispatchMediator::create(this);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // 3. We don't want authors to hold live |Range| indefinitely by holding | InputEvent|, so we 144 // 3. We don't want authors to hold live |Range| indefinitely by holding | InputEvent|, so we
136 // clear them after dispatch. 145 // clear them after dispatch.
137 // Authors should explicitly call |getRanges()|->|toRange()| if they want to keep a copy of |Range|. 146 // Authors should explicitly call |getRanges()|->|toRange()| if they want to keep a copy of |Range|.
138 // See Editing TF meeting notes: 147 // See Editing TF meeting notes:
139 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL G0AM58/edit?usp=sharing 148 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL G0AM58/edit?usp=sharing
140 event().m_ranges.clear(); 149 event().m_ranges.clear();
141 return result; 150 return result;
142 } 151 }
143 152
144 } // namespace blink 153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698