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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: Created 4 years, 2 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 7c250f89f2bdc925909e8aacc584568dc1cc4931..d6624bce84cf61e584336c432c39a86b91dab58c 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -27,6 +27,7 @@
#include "core/HTMLElementFactory.h"
#include "core/HTMLNames.h"
+#include "core/clipboard/DataObject.h"
#include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/NodeComputedStyle.h"
@@ -2091,6 +2092,35 @@ DispatchEventResult dispatchBeforeInputDataTransfer(
return target->dispatchEvent(beforeInputEvent);
}
+DispatchEventResult dispatchBeforeInputPlainText(
chongz 2016/10/27 16:41:24 Sorry for the confusion. I was imagining we could
+ EventTarget* target,
+ InputEvent::InputType inputType,
+ const String& data,
+ DataTransfer::DataTransferType dataTransferType,
+ DataTransferAccessPolicy dataTransferAccessPolicy,
+ const RangeVector* ranges) {
+ if (!RuntimeEnabledFeatures::inputEventEnabled())
+ return DispatchEventResult::NotCanceled;
+ if (!target)
+ return DispatchEventResult::NotCanceled;
+
+ if (hasRichlyEditableStyle(*(target->toNode()))) {
+ DataTransfer* dataTransfer =
+ DataTransfer::create(dataTransferType, dataTransferAccessPolicy,
+ DataObject::createFromString(data));
+
+ return dispatchBeforeInputDataTransfer(target, inputType, dataTransfer,
+ ranges);
+ } else {
+ // TODO(chongz): Pass appreciate |ranges| after it's defined on spec.
+ // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
+ InputEvent* beforeInputEvent = InputEvent::createBeforeInput(
+ inputType, data, InputEvent::EventCancelable::IsCancelable,
+ InputEvent::EventIsComposing::NotComposing, nullptr);
+ return target->dispatchEvent(beforeInputEvent);
+ }
+}
+
InputEvent::InputType deletionInputTypeFromTextGranularity(
DeleteDirection direction,
TextGranularity granularity) {

Powered by Google App Engine
This is Rietveld 408576698