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 bfd1a9634913f1e8b65a58c433aa38f45b9bc062..391cec7018e11f0cbff565570b940aa93edd2a65 100644 |
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
@@ -41,6 +41,8 @@ |
#include "core/editing/VisiblePosition.h" |
#include "core/editing/VisibleSelection.h" |
#include "core/editing/VisibleUnits.h" |
+#include "core/editing/commands/CompositeEditCommand.h" |
+#include "core/editing/commands/TypingCommand.h" |
#include "core/editing/iterators/TextIterator.h" |
#include "core/editing/serializers/HTMLInterchange.h" |
#include "core/editing/state_machines/BackspaceStateMachine.h" |
@@ -58,7 +60,6 @@ |
#include "core/html/HTMLUListElement.h" |
#include "core/layout/LayoutObject.h" |
#include "core/layout/LayoutTableCell.h" |
-#include "platform/clipboard/ClipboardMimeTypes.h" |
#include "wtf/Assertions.h" |
#include "wtf/StdLibExtras.h" |
#include "wtf/text/StringBuilder.h" |
@@ -2047,85 +2048,6 @@ bool isTextSecurityNode(const Node* node) { |
node->layoutObject()->style()->textSecurity() != TSNONE; |
} |
-DispatchEventResult dispatchBeforeInputInsertText(EventTarget* target, |
- const String& data) { |
- if (!RuntimeEnabledFeatures::inputEventEnabled()) |
- return DispatchEventResult::NotCanceled; |
- if (!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); |
- return target->dispatchEvent(beforeInputEvent); |
-} |
- |
-DispatchEventResult dispatchBeforeInputFromComposition( |
- EventTarget* target, |
- InputEvent::InputType inputType, |
- const String& data, |
- InputEvent::EventCancelable cancelable) { |
- if (!RuntimeEnabledFeatures::inputEventEnabled()) |
- return DispatchEventResult::NotCanceled; |
- if (!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( |
- inputType, data, cancelable, InputEvent::EventIsComposing::IsComposing, |
- nullptr); |
- return target->dispatchEvent(beforeInputEvent); |
-} |
- |
-DispatchEventResult dispatchBeforeInputEditorCommand( |
- EventTarget* target, |
- InputEvent::InputType inputType, |
- const RangeVector* ranges) { |
- if (!RuntimeEnabledFeatures::inputEventEnabled()) |
- return DispatchEventResult::NotCanceled; |
- if (!target) |
- return DispatchEventResult::NotCanceled; |
- InputEvent* beforeInputEvent = InputEvent::createBeforeInput( |
- inputType, nullAtom, InputEvent::EventCancelable::IsCancelable, |
- InputEvent::EventIsComposing::NotComposing, ranges); |
- return target->dispatchEvent(beforeInputEvent); |
-} |
- |
-DispatchEventResult dispatchBeforeInputDataTransfer( |
- EventTarget* target, |
- InputEvent::InputType inputType, |
- DataTransfer* dataTransfer, |
- const RangeVector* ranges) { |
- if (!RuntimeEnabledFeatures::inputEventEnabled()) |
- return DispatchEventResult::NotCanceled; |
- if (!target) |
- return DispatchEventResult::NotCanceled; |
- |
- DCHECK(inputType == InputEvent::InputType::InsertFromPaste || |
- inputType == InputEvent::InputType::InsertReplacementText || |
- inputType == InputEvent::InputType::InsertFromDrop || |
- inputType == InputEvent::InputType::DeleteByCut) |
- << "Unsupported inputType: " << (int)inputType; |
- |
- InputEvent* beforeInputEvent; |
- |
- if (hasRichlyEditableStyle(*(target->toNode())) || !dataTransfer) { |
- beforeInputEvent = InputEvent::createBeforeInput( |
- inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable, |
- InputEvent::EventIsComposing::NotComposing, ranges); |
- } 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); |
- } |
- return target->dispatchEvent(beforeInputEvent); |
-} |
- |
InputEvent::InputType deletionInputTypeFromTextGranularity( |
DeleteDirection direction, |
TextGranularity granularity) { |
@@ -2148,4 +2070,22 @@ InputEvent::InputType deletionInputTypeFromTextGranularity( |
} |
} |
+InputEvent::EventIsComposing isComposingFromCommand( |
+ const CompositeEditCommand* command) { |
+ if (command->isTypingCommand() && |
+ toTypingCommand(command)->compositionType() != |
+ TypingCommand::TextCompositionNone) |
+ return InputEvent::IsComposing; |
+ return InputEvent::NotComposing; |
+} |
+ |
+InputEvent::EventCancelable isCancelableFromCommand( |
+ const CompositeEditCommand* command) { |
+ if (command->isTypingCommand() && |
+ toTypingCommand(command)->compositionType() == |
+ TypingCommand::TextCompositionUpdate) |
+ return InputEvent::NotCancelable; |
+ return InputEvent::IsCancelable; |
+} |
+ |
} // namespace blink |