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

Unified Diff: third_party/WebKit/Source/core/editing/EditingUtilities.cpp

Issue 2693863003: [InputEvent] Change |getTargetRanges()| to return current selection by default (Closed)
Patch Set: yosin's review: Use const Node&, add null checks 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index 73f1e72302a9aff5c715f94c7e0fe592d361548d..3ef32f17b55f43ce3b675d5d7470db5f7b110407 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -2042,7 +2042,14 @@ bool isTextSecurityNode(const Node* node) {
node->layoutObject()->style()->textSecurity() != TSNONE;
}
-DispatchEventResult dispatchBeforeInputInsertText(EventTarget* target,
+const RangeVector* targetRangesForInputEvent(const Node& node) {
+ if (!hasRichlyEditableStyle(node))
+ return nullptr;
+ return new RangeVector(
+ 1, firstRangeOf(node.document().frame()->selection().selection()));
+}
+
+DispatchEventResult dispatchBeforeInputInsertText(Node* target,
const String& data) {
if (!RuntimeEnabledFeatures::inputEventEnabled())
return DispatchEventResult::NotCanceled;
@@ -2050,15 +2057,16 @@ DispatchEventResult dispatchBeforeInputInsertText(EventTarget* target,
return DispatchEventResult::NotCanceled;
// TODO(chongz): Pass appropriate |ranges| after it's defined on spec.
// http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
- InputEvent* beforeInputEvent = InputEvent::createBeforeInput(
- InputEvent::InputType::InsertText, data,
- InputEvent::EventCancelable::IsCancelable,
- InputEvent::EventIsComposing::NotComposing, nullptr);
+ InputEvent* beforeInputEvent =
+ InputEvent::createBeforeInput(InputEvent::InputType::InsertText, data,
+ InputEvent::EventCancelable::IsCancelable,
+ InputEvent::EventIsComposing::NotComposing,
+ targetRangesForInputEvent(*target));
return target->dispatchEvent(beforeInputEvent);
}
DispatchEventResult dispatchBeforeInputEditorCommand(
- EventTarget* target,
+ Node* target,
InputEvent::InputType inputType,
const RangeVector* ranges) {
if (!RuntimeEnabledFeatures::inputEventEnabled())
@@ -2072,10 +2080,9 @@ DispatchEventResult dispatchBeforeInputEditorCommand(
}
DispatchEventResult dispatchBeforeInputDataTransfer(
- EventTarget* target,
+ Node* target,
InputEvent::InputType inputType,
- DataTransfer* dataTransfer,
- const RangeVector* ranges) {
+ DataTransfer* dataTransfer) {
if (!RuntimeEnabledFeatures::inputEventEnabled())
return DispatchEventResult::NotCanceled;
if (!target)
@@ -2092,14 +2099,16 @@ DispatchEventResult dispatchBeforeInputDataTransfer(
if (hasRichlyEditableStyle(*(target->toNode())) || !dataTransfer) {
beforeInputEvent = InputEvent::createBeforeInput(
inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable,
- InputEvent::EventIsComposing::NotComposing, ranges);
+ InputEvent::EventIsComposing::NotComposing,
+ targetRangesForInputEvent(*target));
} else {
const String& data = dataTransfer->getData(mimeTypeTextPlain);
// TODO(chongz): Pass appropriate |ranges| after it's defined on spec.
// http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
beforeInputEvent = InputEvent::createBeforeInput(
inputType, data, InputEvent::EventCancelable::IsCancelable,
- InputEvent::EventIsComposing::NotComposing, nullptr);
+ InputEvent::EventIsComposing::NotComposing,
+ targetRangesForInputEvent(*target));
}
return target->dispatchEvent(beforeInputEvent);
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('k') | third_party/WebKit/Source/core/editing/Editor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698