Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| index da67f2e09b2b17bd4384ac0f8785146477f2e336..03481f6dc02e0f8e4a9842d685f2aad6d0074c71 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| @@ -213,9 +213,9 @@ RangeVector* RangesFromCurrentSelectionOrExtendCaret( |
| class EditorInternalCommand { |
| public: |
| WebEditingCommandType commandType; |
| - bool (*execute)(LocalFrame&, Event*, EditorCommandSource, const String&); |
| + bool (*execute)(LocalFrame&, Event*, CommandSource, const String&); |
| bool (*isSupportedFromDOM)(LocalFrame*); |
| - bool (*isEnabled)(LocalFrame&, Event*, EditorCommandSource); |
| + bool (*isEnabled)(LocalFrame&, Event*, CommandSource); |
| TriState (*state)(LocalFrame&, Event*); |
| String (*value)(LocalFrame&, Event*); |
| bool isTextInsertion; |
| @@ -243,17 +243,17 @@ static LocalFrame* targetFrame(LocalFrame& frame, Event* event) { |
| } |
| static bool applyCommandToFrame(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| StylePropertySet* style) { |
| // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a |
| // good reason for that? |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: |
| - frame.editor().applyStyleToSelection(style, inputType); |
| + case CommandSource::MenuOrKeyBinding: |
| + frame.editor().applyStyleToSelection(source, style, inputType); |
| return true; |
| - case CommandFromDOM: |
| - frame.editor().applyStyle(style, inputType); |
| + case CommandSource::Dom: |
| + frame.editor().applyStyle(source, style, inputType); |
| return true; |
| } |
| NOTREACHED(); |
| @@ -261,7 +261,7 @@ static bool applyCommandToFrame(LocalFrame& frame, |
| } |
| static bool executeApplyStyle(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| CSSPropertyID propertyID, |
| const String& propertyValue) { |
| @@ -272,7 +272,7 @@ static bool executeApplyStyle(LocalFrame& frame, |
| } |
| static bool executeApplyStyle(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| CSSPropertyID propertyID, |
| CSSValueID propertyValue) { |
| @@ -287,7 +287,7 @@ static bool executeApplyStyle(LocalFrame& frame, |
| // Editor::selectionHasStyle to determine the current style but we cannot fix |
| // this until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved. |
| static bool executeToggleStyleInList(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| CSSPropertyID propertyID, |
| CSSValue* value) { |
| @@ -320,7 +320,7 @@ static bool executeToggleStyleInList(LocalFrame& frame, |
| } |
| static bool executeToggleStyle(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| CSSPropertyID propertyID, |
| const char* offValue, |
| @@ -342,7 +342,7 @@ static bool executeToggleStyle(LocalFrame& frame, |
| } |
| static bool executeApplyParagraphStyle(LocalFrame& frame, |
| - EditorCommandSource source, |
| + CommandSource source, |
| InputEvent::InputType inputType, |
| CSSPropertyID propertyID, |
| const String& propertyValue) { |
| @@ -352,11 +352,11 @@ static bool executeApplyParagraphStyle(LocalFrame& frame, |
| // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a |
| // good reason for that? |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: |
| - frame.editor().applyParagraphStyleToSelection(style, inputType); |
| + case CommandSource::MenuOrKeyBinding: |
| + frame.editor().applyParagraphStyleToSelection(source, style, inputType); |
| return true; |
| - case CommandFromDOM: |
| - frame.editor().applyParagraphStyle(style, inputType); |
| + case CommandSource::Dom: |
| + frame.editor().applyParagraphStyle(source, style, inputType); |
| return true; |
| } |
| NOTREACHED(); |
| @@ -364,23 +364,26 @@ static bool executeApplyParagraphStyle(LocalFrame& frame, |
| } |
| static bool executeInsertFragment(LocalFrame& frame, |
| + CommandSource source, |
| DocumentFragment* fragment) { |
| DCHECK(frame.document()); |
| return ReplaceSelectionCommand::create( |
| - *frame.document(), fragment, |
| + *frame.document(), source, fragment, |
| ReplaceSelectionCommand::PreventNesting, |
| InputEvent::InputType::None) |
| ->apply(); |
| } |
| -static bool executeInsertElement(LocalFrame& frame, HTMLElement* content) { |
| +static bool executeInsertElement(LocalFrame& frame, |
| + CommandSource source, |
| + HTMLElement* content) { |
| DCHECK(frame.document()); |
| DocumentFragment* fragment = DocumentFragment::create(*frame.document()); |
| DummyExceptionStateForTesting exceptionState; |
| fragment->appendChild(content, exceptionState); |
| if (exceptionState.hadException()) |
| return false; |
| - return executeInsertFragment(frame, fragment); |
| + return executeInsertFragment(frame, source, fragment); |
| } |
| static bool expandSelectionToGranularity(LocalFrame& frame, |
| @@ -506,14 +509,14 @@ static EphemeralRange unionEphemeralRanges(const EphemeralRange& range1, |
| static bool executeBackColor(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String& value) { |
| return executeApplyStyle(frame, source, InputEvent::InputType::None, |
| CSSPropertyBackgroundColor, value); |
| } |
| -static bool canWriteClipboard(LocalFrame& frame, EditorCommandSource source) { |
| - if (source == CommandFromMenuOrKeyBinding) |
| +static bool canWriteClipboard(LocalFrame& frame, CommandSource source) { |
| + if (source == CommandSource::MenuOrKeyBinding) |
| return true; |
| Settings* settings = frame.settings(); |
| bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) || |
| @@ -523,7 +526,7 @@ static bool canWriteClipboard(LocalFrame& frame, EditorCommandSource source) { |
| static bool executeCopy(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| // To support |allowExecutionWhenDisabled|, we need to check clipboard |
| // accessibility here rather than |Editor::Command::execute()|. |
| @@ -538,17 +541,17 @@ static bool executeCopy(LocalFrame& frame, |
| static bool executeCreateLink(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| if (value.isEmpty()) |
| return false; |
| DCHECK(frame.document()); |
| - return CreateLinkCommand::create(*frame.document(), value)->apply(); |
| + return CreateLinkCommand::create(*frame.document(), source, value)->apply(); |
| } |
| static bool executeCut(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| // To support |allowExecutionWhenDisabled|, we need to check clipboard |
| // accessibility here rather than |Editor::Command::execute()|. |
| @@ -563,7 +566,7 @@ static bool executeCut(LocalFrame& frame, |
| static bool executeDefaultParagraphSeparator(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String& value) { |
| if (equalIgnoringCase(value, "div")) |
| frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsDiv); |
| @@ -575,24 +578,25 @@ static bool executeDefaultParagraphSeparator(LocalFrame& frame, |
| static bool executeDelete(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: { |
| + case CommandSource::MenuOrKeyBinding: { |
| // Doesn't modify the text if the current selection isn't a range. |
| - frame.editor().performDelete(); |
| + frame.editor().performDelete(source); |
| return true; |
| } |
| - case CommandFromDOM: |
| + case CommandSource::Dom: |
| // If the current selection is a caret, delete the preceding character. IE |
| // performs forwardDelete, but we currently side with Firefox. Doesn't |
| // scroll to make the selection visible, or modify the kill ring (this |
| // time, siding with IE, not Firefox). |
| DCHECK(frame.document()); |
| TypingCommand::deleteKeyPressed( |
| - *frame.document(), frame.selection().granularity() == WordGranularity |
| - ? TypingCommand::SmartDelete |
| - : 0); |
| + *frame.document(), source, |
| + frame.selection().granularity() == WordGranularity |
| + ? TypingCommand::SmartDelete |
| + : 0); |
| return true; |
| } |
| NOTREACHED(); |
| @@ -601,9 +605,9 @@ static bool executeDelete(LocalFrame& frame, |
| static bool executeDeleteBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Backward, |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Backward, |
| CharacterGranularity, false, true); |
| return true; |
| } |
| @@ -611,68 +615,68 @@ static bool executeDeleteBackward(LocalFrame& frame, |
| static bool executeDeleteBackwardByDecomposingPreviousCharacter( |
| LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DLOG(ERROR) << "DeleteBackwardByDecomposingPreviousCharacter is not " |
| "implemented, doing DeleteBackward instead"; |
| - frame.editor().deleteWithDirection(DeleteDirection::Backward, |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Backward, |
| CharacterGranularity, false, true); |
| return true; |
| } |
| static bool executeDeleteForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Forward, |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Forward, |
| CharacterGranularity, false, true); |
| return true; |
| } |
| static bool executeDeleteToBeginningOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Backward, LineBoundary, |
| - true, false); |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Backward, |
| + LineBoundary, true, false); |
| return true; |
| } |
| static bool executeDeleteToBeginningOfParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Backward, |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Backward, |
| ParagraphBoundary, true, false); |
| return true; |
| } |
| static bool executeDeleteToEndOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| // Despite its name, this command should delete the newline at the end of a |
| // paragraph if you are at the end of a paragraph (like |
| // DeleteToEndOfParagraph). |
| - frame.editor().deleteWithDirection(DeleteDirection::Forward, LineBoundary, |
| - true, false); |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Forward, |
| + LineBoundary, true, false); |
| return true; |
| } |
| static bool executeDeleteToEndOfParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| // Despite its name, this command should delete the newline at the end of |
| // a paragraph if you are at the end of a paragraph. |
| - frame.editor().deleteWithDirection(DeleteDirection::Forward, |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Forward, |
| ParagraphBoundary, true, false); |
| return true; |
| } |
| static bool executeDeleteToMark(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| const EphemeralRange mark = |
| frame.editor().mark().toNormalizedEphemeralRange(); |
| @@ -685,39 +689,40 @@ static bool executeDeleteToMark(LocalFrame& frame, |
| if (!selected) |
| return false; |
| } |
| - frame.editor().performDelete(); |
| - frame.editor().setMark(frame.selection().selection()); |
| + frame.editor().performDelete(source); |
| + if (frame.selection().isAvailable()) |
|
Xiaocheng
2016/12/14 04:19:50
Seems irrelevant to this patch.
chongz
2016/12/15 00:53:33
Will remove.
|
| + frame.editor().setMark(frame.selection().selection()); |
| return true; |
| } |
| static bool executeDeleteWordBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Backward, WordGranularity, |
| - true, false); |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Backward, |
| + WordGranularity, true, false); |
| return true; |
| } |
| static bool executeDeleteWordForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().deleteWithDirection(DeleteDirection::Forward, WordGranularity, |
| - true, false); |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Forward, |
| + WordGranularity, true, false); |
| return true; |
| } |
| static bool executeFindString(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String& value) { |
| return frame.editor().findString(value, CaseInsensitive | WrapAround); |
| } |
| static bool executeFontName(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String& value) { |
| return executeApplyStyle(frame, source, InputEvent::InputType::None, |
| CSSPropertyFontFamily, value); |
| @@ -725,7 +730,7 @@ static bool executeFontName(LocalFrame& frame, |
| static bool executeFontSize(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String& value) { |
| CSSValueID size; |
| if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) |
| @@ -736,7 +741,7 @@ static bool executeFontSize(LocalFrame& frame, |
| static bool executeFontSizeDelta(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String& value) { |
| return executeApplyStyle(frame, source, InputEvent::InputType::None, |
| CSSPropertyWebkitFontSizeDelta, value); |
| @@ -744,7 +749,7 @@ static bool executeFontSizeDelta(LocalFrame& frame, |
| static bool executeForeColor(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String& value) { |
| return executeApplyStyle(frame, source, InputEvent::InputType::None, |
| CSSPropertyColor, value); |
| @@ -752,7 +757,7 @@ static bool executeForeColor(LocalFrame& frame, |
| static bool executeFormatBlock(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| String tagName = value.lower(); |
| if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>') |
| @@ -766,28 +771,29 @@ static bool executeFormatBlock(LocalFrame& frame, |
| DCHECK(frame.document()); |
| FormatBlockCommand* command = |
| - FormatBlockCommand::create(*frame.document(), qualifiedTagName); |
| + FormatBlockCommand::create(*frame.document(), source, qualifiedTagName); |
| command->apply(); |
| return command->didApply(); |
| } |
| static bool executeForwardDelete(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| EditingState editingState; |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: |
| - frame.editor().deleteWithDirection(DeleteDirection::Forward, |
| + case CommandSource::MenuOrKeyBinding: |
| + frame.editor().deleteWithDirection(source, DeleteDirection::Forward, |
| CharacterGranularity, false, true); |
| return true; |
| - case CommandFromDOM: |
| + case CommandSource::Dom: |
| // Doesn't scroll to make the selection visible, or modify the kill ring. |
| // ForwardDelete is not implemented in IE or Firefox, so this behavior is |
| // only needed for backward compatibility with ourselves, and for |
| // consistency with Delete. |
| DCHECK(frame.document()); |
| - TypingCommand::forwardDeleteKeyPressed(*frame.document(), &editingState); |
| + TypingCommand::forwardDeleteKeyPressed(*frame.document(), source, |
| + &editingState); |
| if (editingState.isAborted()) |
| return false; |
| return true; |
| @@ -798,7 +804,7 @@ static bool executeForwardDelete(LocalFrame& frame, |
| static bool executeIgnoreSpelling(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.spellChecker().ignoreSpelling(); |
| return true; |
| @@ -806,18 +812,19 @@ static bool executeIgnoreSpelling(LocalFrame& frame, |
| static bool executeIndent(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return IndentOutdentCommand::create(*frame.document(), |
| + return IndentOutdentCommand::create(*frame.document(), source, |
| IndentOutdentCommand::Indent) |
| ->apply(); |
| } |
| static bool executeInsertBacktab(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| + DCHECK_EQ(source, CommandSource::MenuOrKeyBinding); |
|
chongz
2016/12/13 20:08:12
|executeInsertBacktab()| is only supported from me
|
| return targetFrame(frame, event) |
| ->eventHandler() |
| .handleTextInputEvent("\t", event, TextEventInputBackTab); |
| @@ -825,51 +832,51 @@ static bool executeInsertBacktab(LocalFrame& frame, |
| static bool executeInsertHorizontalRule(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| DCHECK(frame.document()); |
| HTMLHRElement* rule = HTMLHRElement::create(*frame.document()); |
| if (!value.isEmpty()) |
| rule->setIdAttribute(AtomicString(value)); |
| - return executeInsertElement(frame, rule); |
| + return executeInsertElement(frame, source, rule); |
| } |
| static bool executeInsertHTML(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| DCHECK(frame.document()); |
| return executeInsertFragment( |
| - frame, createFragmentFromMarkup(*frame.document(), value, "")); |
| + frame, source, createFragmentFromMarkup(*frame.document(), value, "")); |
| } |
| static bool executeInsertImage(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| DCHECK(frame.document()); |
| HTMLImageElement* image = HTMLImageElement::create(*frame.document()); |
| if (!value.isEmpty()) |
| image->setSrc(value); |
| - return executeInsertElement(frame, image); |
| + return executeInsertElement(frame, source, image); |
| } |
| static bool executeInsertLineBreak(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: |
| + case CommandSource::MenuOrKeyBinding: |
| return targetFrame(frame, event) |
| ->eventHandler() |
| .handleTextInputEvent("\n", event, TextEventInputLineBreak); |
| - case CommandFromDOM: |
| + case CommandSource::Dom: |
| // Doesn't scroll to make the selection visible, or modify the kill ring. |
| // InsertLineBreak is not implemented in IE or Firefox, so this behavior |
| // is only needed for backward compatibility with ourselves, and for |
| // consistency with other commands. |
| DCHECK(frame.document()); |
| - return TypingCommand::insertLineBreak(*frame.document()); |
| + return TypingCommand::insertLineBreak(*frame.document(), source); |
| } |
| NOTREACHED(); |
| return false; |
| @@ -877,8 +884,9 @@ static bool executeInsertLineBreak(LocalFrame& frame, |
| static bool executeInsertNewline(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| + DCHECK_EQ(source, CommandSource::MenuOrKeyBinding); |
| LocalFrame* targetFrame = blink::targetFrame(frame, event); |
| return targetFrame->eventHandler().handleTextInputEvent( |
| "\n", event, targetFrame->editor().canEditRichly() |
| @@ -888,35 +896,36 @@ static bool executeInsertNewline(LocalFrame& frame, |
| static bool executeInsertNewlineInQuotedContent(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| return TypingCommand::insertParagraphSeparatorInQuotedContent( |
| - *frame.document()); |
| + *frame.document(), source); |
| } |
| static bool executeInsertOrderedList(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return InsertListCommand::create(*frame.document(), |
| + return InsertListCommand::create(*frame.document(), source, |
| InsertListCommand::OrderedList) |
| ->apply(); |
| } |
| static bool executeInsertParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return TypingCommand::insertParagraphSeparator(*frame.document()); |
| + return TypingCommand::insertParagraphSeparator(*frame.document(), source); |
| } |
| static bool executeInsertTab(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| + DCHECK_EQ(source, CommandSource::MenuOrKeyBinding); |
| return targetFrame(frame, event) |
| ->eventHandler() |
| .handleTextInputEvent("\t", event); |
| @@ -924,26 +933,26 @@ static bool executeInsertTab(LocalFrame& frame, |
| static bool executeInsertText(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String& value) { |
| DCHECK(frame.document()); |
| - TypingCommand::insertText(*frame.document(), value, 0); |
| + TypingCommand::insertText(*frame.document(), source, value, 0); |
| return true; |
| } |
| static bool executeInsertUnorderedList(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return InsertListCommand::create(*frame.document(), |
| + return InsertListCommand::create(*frame.document(), source, |
| InsertListCommand::UnorderedList) |
| ->apply(); |
| } |
| static bool executeJustifyCenter(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeApplyParagraphStyle(frame, source, |
| InputEvent::InputType::FormatJustifyCenter, |
| @@ -952,7 +961,7 @@ static bool executeJustifyCenter(LocalFrame& frame, |
| static bool executeJustifyFull(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeApplyParagraphStyle(frame, source, |
| InputEvent::InputType::FormatJustifyFull, |
| @@ -961,7 +970,7 @@ static bool executeJustifyFull(LocalFrame& frame, |
| static bool executeJustifyLeft(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeApplyParagraphStyle(frame, source, |
| InputEvent::InputType::FormatJustifyLeft, |
| @@ -970,7 +979,7 @@ static bool executeJustifyLeft(LocalFrame& frame, |
| static bool executeJustifyRight(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeApplyParagraphStyle(frame, source, |
| InputEvent::InputType::FormatJustifyRight, |
| @@ -979,45 +988,45 @@ static bool executeJustifyRight(LocalFrame& frame, |
| static bool executeMakeTextWritingDirectionLeftToRight(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| MutableStylePropertySet* style = |
| MutableStylePropertySet::create(HTMLQuirksMode); |
| style->setProperty(CSSPropertyUnicodeBidi, CSSValueIsolate); |
| style->setProperty(CSSPropertyDirection, CSSValueLtr); |
| - frame.editor().applyStyle(style, |
| + frame.editor().applyStyle(source, style, |
| InputEvent::InputType::FormatSetBlockTextDirection); |
| return true; |
| } |
| static bool executeMakeTextWritingDirectionNatural(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| MutableStylePropertySet* style = |
| MutableStylePropertySet::create(HTMLQuirksMode); |
| style->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); |
| - frame.editor().applyStyle(style, |
| + frame.editor().applyStyle(source, style, |
| InputEvent::InputType::FormatSetBlockTextDirection); |
| return true; |
| } |
| static bool executeMakeTextWritingDirectionRightToLeft(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| MutableStylePropertySet* style = |
| MutableStylePropertySet::create(HTMLQuirksMode); |
| style->setProperty(CSSPropertyUnicodeBidi, CSSValueIsolate); |
| style->setProperty(CSSPropertyDirection, CSSValueRtl); |
| - frame.editor().applyStyle(style, |
| + frame.editor().applyStyle(source, style, |
| InputEvent::InputType::FormatSetBlockTextDirection); |
| return true; |
| } |
| static bool executeMoveBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| CharacterGranularity, UserTriggered); |
| @@ -1026,7 +1035,7 @@ static bool executeMoveBackward(LocalFrame& frame, |
| static bool executeMoveBackwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| CharacterGranularity, UserTriggered); |
| @@ -1035,7 +1044,7 @@ static bool executeMoveBackwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveDown(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.selection().modify(FrameSelection::AlterationMove, |
| DirectionForward, LineGranularity, |
| @@ -1044,7 +1053,7 @@ static bool executeMoveDown(LocalFrame& frame, |
| static bool executeMoveDownAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| LineGranularity, UserTriggered); |
| @@ -1053,7 +1062,7 @@ static bool executeMoveDownAndModifySelection(LocalFrame& frame, |
| static bool executeMoveForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| CharacterGranularity, UserTriggered); |
| @@ -1062,7 +1071,7 @@ static bool executeMoveForward(LocalFrame& frame, |
| static bool executeMoveForwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| CharacterGranularity, UserTriggered); |
| @@ -1071,7 +1080,7 @@ static bool executeMoveForwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveLeft(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, |
| CharacterGranularity, UserTriggered); |
| @@ -1079,7 +1088,7 @@ static bool executeMoveLeft(LocalFrame& frame, |
| static bool executeMoveLeftAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, |
| CharacterGranularity, UserTriggered); |
| @@ -1088,7 +1097,7 @@ static bool executeMoveLeftAndModifySelection(LocalFrame& frame, |
| static bool executeMovePageDown(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| unsigned distance = verticalScrollDistance(frame); |
| if (!distance) |
| @@ -1099,7 +1108,7 @@ static bool executeMovePageDown(LocalFrame& frame, |
| static bool executeMovePageDownAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| unsigned distance = verticalScrollDistance(frame); |
| if (!distance) |
| @@ -1110,7 +1119,7 @@ static bool executeMovePageDownAndModifySelection(LocalFrame& frame, |
| static bool executeMovePageUp(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| unsigned distance = verticalScrollDistance(frame); |
| if (!distance) |
| @@ -1121,7 +1130,7 @@ static bool executeMovePageUp(LocalFrame& frame, |
| static bool executeMovePageUpAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| unsigned distance = verticalScrollDistance(frame); |
| if (!distance) |
| @@ -1132,7 +1141,7 @@ static bool executeMovePageUpAndModifySelection(LocalFrame& frame, |
| static bool executeMoveRight(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.selection().modify(FrameSelection::AlterationMove, |
| DirectionRight, CharacterGranularity, |
| @@ -1141,7 +1150,7 @@ static bool executeMoveRight(LocalFrame& frame, |
| static bool executeMoveRightAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, |
| CharacterGranularity, UserTriggered); |
| @@ -1150,7 +1159,7 @@ static bool executeMoveRightAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToBeginningOfDocument(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| DocumentBoundary, UserTriggered); |
| @@ -1160,7 +1169,7 @@ static bool executeMoveToBeginningOfDocument(LocalFrame& frame, |
| static bool executeMoveToBeginningOfDocumentAndModifySelection( |
| LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| DocumentBoundary, UserTriggered); |
| @@ -1169,7 +1178,7 @@ static bool executeMoveToBeginningOfDocumentAndModifySelection( |
| static bool executeMoveToBeginningOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| LineBoundary, UserTriggered); |
| @@ -1178,7 +1187,7 @@ static bool executeMoveToBeginningOfLine(LocalFrame& frame, |
| static bool executeMoveToBeginningOfLineAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| LineBoundary, UserTriggered); |
| @@ -1187,7 +1196,7 @@ static bool executeMoveToBeginningOfLineAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToBeginningOfParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| ParagraphBoundary, UserTriggered); |
| @@ -1197,7 +1206,7 @@ static bool executeMoveToBeginningOfParagraph(LocalFrame& frame, |
| static bool executeMoveToBeginningOfParagraphAndModifySelection( |
| LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| ParagraphBoundary, UserTriggered); |
| @@ -1206,7 +1215,7 @@ static bool executeMoveToBeginningOfParagraphAndModifySelection( |
| static bool executeMoveToBeginningOfSentence(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| SentenceBoundary, UserTriggered); |
| @@ -1216,7 +1225,7 @@ static bool executeMoveToBeginningOfSentence(LocalFrame& frame, |
| static bool executeMoveToBeginningOfSentenceAndModifySelection( |
| LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| SentenceBoundary, UserTriggered); |
| @@ -1225,7 +1234,7 @@ static bool executeMoveToBeginningOfSentenceAndModifySelection( |
| static bool executeMoveToEndOfDocument(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| DocumentBoundary, UserTriggered); |
| @@ -1234,7 +1243,7 @@ static bool executeMoveToEndOfDocument(LocalFrame& frame, |
| static bool executeMoveToEndOfDocumentAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| DocumentBoundary, UserTriggered); |
| @@ -1243,7 +1252,7 @@ static bool executeMoveToEndOfDocumentAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToEndOfSentence(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| SentenceBoundary, UserTriggered); |
| @@ -1252,7 +1261,7 @@ static bool executeMoveToEndOfSentence(LocalFrame& frame, |
| static bool executeMoveToEndOfSentenceAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| SentenceBoundary, UserTriggered); |
| @@ -1261,7 +1270,7 @@ static bool executeMoveToEndOfSentenceAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToEndOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| LineBoundary, UserTriggered); |
| @@ -1270,7 +1279,7 @@ static bool executeMoveToEndOfLine(LocalFrame& frame, |
| static bool executeMoveToEndOfLineAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| LineBoundary, UserTriggered); |
| @@ -1279,7 +1288,7 @@ static bool executeMoveToEndOfLineAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToEndOfParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| ParagraphBoundary, UserTriggered); |
| @@ -1288,7 +1297,7 @@ static bool executeMoveToEndOfParagraph(LocalFrame& frame, |
| static bool executeMoveToEndOfParagraphAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| ParagraphBoundary, UserTriggered); |
| @@ -1297,7 +1306,7 @@ static bool executeMoveToEndOfParagraphAndModifySelection(LocalFrame& frame, |
| static bool executeMoveParagraphBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| ParagraphGranularity, UserTriggered); |
| @@ -1306,7 +1315,7 @@ static bool executeMoveParagraphBackward(LocalFrame& frame, |
| static bool executeMoveParagraphBackwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| ParagraphGranularity, UserTriggered); |
| @@ -1315,7 +1324,7 @@ static bool executeMoveParagraphBackwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveParagraphForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| ParagraphGranularity, UserTriggered); |
| @@ -1324,7 +1333,7 @@ static bool executeMoveParagraphForward(LocalFrame& frame, |
| static bool executeMoveParagraphForwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| ParagraphGranularity, UserTriggered); |
| @@ -1333,7 +1342,7 @@ static bool executeMoveParagraphForwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveUp(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.selection().modify(FrameSelection::AlterationMove, |
| DirectionBackward, LineGranularity, |
| @@ -1342,7 +1351,7 @@ static bool executeMoveUp(LocalFrame& frame, |
| static bool executeMoveUpAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| LineGranularity, UserTriggered); |
| @@ -1351,7 +1360,7 @@ static bool executeMoveUpAndModifySelection(LocalFrame& frame, |
| static bool executeMoveWordBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, |
| WordGranularity, UserTriggered); |
| @@ -1360,7 +1369,7 @@ static bool executeMoveWordBackward(LocalFrame& frame, |
| static bool executeMoveWordBackwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, |
| WordGranularity, UserTriggered); |
| @@ -1369,7 +1378,7 @@ static bool executeMoveWordBackwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveWordForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, |
| WordGranularity, UserTriggered); |
| @@ -1378,7 +1387,7 @@ static bool executeMoveWordForward(LocalFrame& frame, |
| static bool executeMoveWordForwardAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, |
| WordGranularity, UserTriggered); |
| @@ -1387,7 +1396,7 @@ static bool executeMoveWordForwardAndModifySelection(LocalFrame& frame, |
| static bool executeMoveWordLeft(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, |
| WordGranularity, UserTriggered); |
| @@ -1396,7 +1405,7 @@ static bool executeMoveWordLeft(LocalFrame& frame, |
| static bool executeMoveWordLeftAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, |
| WordGranularity, UserTriggered); |
| @@ -1405,7 +1414,7 @@ static bool executeMoveWordLeftAndModifySelection(LocalFrame& frame, |
| static bool executeMoveWordRight(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionRight, |
| WordGranularity, UserTriggered); |
| @@ -1414,7 +1423,7 @@ static bool executeMoveWordRight(LocalFrame& frame, |
| static bool executeMoveWordRightAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, |
| WordGranularity, UserTriggered); |
| @@ -1423,7 +1432,7 @@ static bool executeMoveWordRightAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToLeftEndOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, |
| LineBoundary, UserTriggered); |
| @@ -1432,7 +1441,7 @@ static bool executeMoveToLeftEndOfLine(LocalFrame& frame, |
| static bool executeMoveToLeftEndOfLineAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, |
| LineBoundary, UserTriggered); |
| @@ -1441,7 +1450,7 @@ static bool executeMoveToLeftEndOfLineAndModifySelection(LocalFrame& frame, |
| static bool executeMoveToRightEndOfLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationMove, DirectionRight, |
| LineBoundary, UserTriggered); |
| @@ -1450,7 +1459,7 @@ static bool executeMoveToRightEndOfLine(LocalFrame& frame, |
| static bool executeMoveToRightEndOfLineAndModifySelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, |
| LineBoundary, UserTriggered); |
| @@ -1459,24 +1468,24 @@ static bool executeMoveToRightEndOfLineAndModifySelection(LocalFrame& frame, |
| static bool executeOutdent(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return IndentOutdentCommand::create(*frame.document(), |
| + return IndentOutdentCommand::create(*frame.document(), source, |
| IndentOutdentCommand::Outdent) |
| ->apply(); |
| } |
| static bool executeToggleOverwrite(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.editor().toggleOverwriteModeEnabled(); |
| return true; |
| } |
| -static bool canReadClipboard(LocalFrame& frame, EditorCommandSource source) { |
| - if (source == CommandFromMenuOrKeyBinding) |
| +static bool canReadClipboard(LocalFrame& frame, CommandSource source) { |
| + if (source == CommandSource::MenuOrKeyBinding) |
| return true; |
| Settings* settings = frame.settings(); |
| bool defaultValue = settings && settings->javaScriptCanAccessClipboard() && |
| @@ -1486,7 +1495,7 @@ static bool canReadClipboard(LocalFrame& frame, EditorCommandSource source) { |
| static bool executePaste(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| // To support |allowExecutionWhenDisabled|, we need to check clipboard |
| // accessibility here rather than |Editor::Command::execute()|. |
| @@ -1501,7 +1510,7 @@ static bool executePaste(LocalFrame& frame, |
| static bool executePasteGlobalSelection(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| // To support |allowExecutionWhenDisabled|, we need to check clipboard |
| // accessibility here rather than |Editor::Command::execute()|. |
| @@ -1512,7 +1521,7 @@ static bool executePasteGlobalSelection(LocalFrame& frame, |
| return false; |
| if (!frame.editor().behavior().supportsGlobalSelection()) |
| return false; |
| - DCHECK_EQ(source, CommandFromMenuOrKeyBinding); |
| + DCHECK_EQ(source, CommandSource::MenuOrKeyBinding); |
| bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); |
| Pasteboard::generalPasteboard()->setSelectionMode(true); |
| @@ -1523,7 +1532,7 @@ static bool executePasteGlobalSelection(LocalFrame& frame, |
| static bool executePasteAndMatchStyle(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| frame.editor().pasteAsPlainText(source); |
| return true; |
| @@ -1531,7 +1540,7 @@ static bool executePasteAndMatchStyle(LocalFrame& frame, |
| static bool executePrint(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| FrameHost* host = frame.host(); |
| if (!host) |
| @@ -1541,23 +1550,23 @@ static bool executePrint(LocalFrame& frame, |
| static bool executeRedo(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().redo(); |
| + frame.editor().redo(source); |
| return true; |
| } |
| static bool executeRemoveFormat(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().removeFormattingAndStyle(); |
| + frame.editor().removeFormattingAndStyle(source); |
| return true; |
| } |
| static bool executeScrollPageBackward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollBlockDirectionBackward, |
| ScrollByPage); |
| @@ -1565,7 +1574,7 @@ static bool executeScrollPageBackward(LocalFrame& frame, |
| static bool executeScrollPageForward(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollBlockDirectionForward, |
| ScrollByPage); |
| @@ -1573,7 +1582,7 @@ static bool executeScrollPageForward(LocalFrame& frame, |
| static bool executeScrollLineUp(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollUpIgnoringWritingMode, |
| ScrollByLine); |
| @@ -1581,7 +1590,7 @@ static bool executeScrollLineUp(LocalFrame& frame, |
| static bool executeScrollLineDown(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollDownIgnoringWritingMode, |
| ScrollByLine); |
| @@ -1589,7 +1598,7 @@ static bool executeScrollLineDown(LocalFrame& frame, |
| static bool executeScrollToBeginningOfDocument(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollBlockDirectionBackward, |
| ScrollByDocument); |
| @@ -1597,7 +1606,7 @@ static bool executeScrollToBeginningOfDocument(LocalFrame& frame, |
| static bool executeScrollToEndOfDocument(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return frame.eventHandler().bubblingScroll(ScrollBlockDirectionForward, |
| ScrollByDocument); |
| @@ -1605,7 +1614,7 @@ static bool executeScrollToEndOfDocument(LocalFrame& frame, |
| static bool executeSelectAll(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().selectAll(); |
| return true; |
| @@ -1613,28 +1622,28 @@ static bool executeSelectAll(LocalFrame& frame, |
| static bool executeSelectLine(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return expandSelectionToGranularity(frame, LineGranularity); |
| } |
| static bool executeSelectParagraph(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return expandSelectionToGranularity(frame, ParagraphGranularity); |
| } |
| static bool executeSelectSentence(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return expandSelectionToGranularity(frame, SentenceGranularity); |
| } |
| static bool executeSelectToMark(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| const EphemeralRange mark = |
| frame.editor().mark().toNormalizedEphemeralRange(); |
| @@ -1649,14 +1658,14 @@ static bool executeSelectToMark(LocalFrame& frame, |
| static bool executeSelectWord(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| return expandSelectionToGranularity(frame, WordGranularity); |
| } |
| static bool executeSetMark(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.editor().setMark(frame.selection().selection()); |
| return true; |
| @@ -1664,7 +1673,7 @@ static bool executeSetMark(LocalFrame& frame, |
| static bool executeStrikethrough(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| CSSIdentifierValue* lineThrough = |
| CSSIdentifierValue::create(CSSValueLineThrough); |
| @@ -1675,7 +1684,7 @@ static bool executeStrikethrough(LocalFrame& frame, |
| static bool executeStyleWithCSS(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String& value) { |
| frame.editor().setShouldStyleWithCSS(!equalIgnoringCase(value, "false")); |
| return true; |
| @@ -1683,7 +1692,7 @@ static bool executeStyleWithCSS(LocalFrame& frame, |
| static bool executeUseCSS(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String& value) { |
| frame.editor().setShouldStyleWithCSS(equalIgnoringCase(value, "false")); |
| return true; |
| @@ -1691,7 +1700,7 @@ static bool executeUseCSS(LocalFrame& frame, |
| static bool executeSubscript(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeToggleStyle(frame, source, |
| InputEvent::InputType::FormatSubscript, |
| @@ -1700,7 +1709,7 @@ static bool executeSubscript(LocalFrame& frame, |
| static bool executeSuperscript(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeToggleStyle(frame, source, |
| InputEvent::InputType::FormatSuperscript, |
| @@ -1709,7 +1718,7 @@ static bool executeSuperscript(LocalFrame& frame, |
| static bool executeSwapWithMark(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| const VisibleSelection& mark = frame.editor().mark(); |
| const VisibleSelection& selection = frame.selection().selection(); |
| @@ -1722,7 +1731,7 @@ static bool executeSwapWithMark(LocalFrame& frame, |
| static bool executeToggleBold(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeToggleStyle(frame, source, InputEvent::InputType::FormatBold, |
| CSSPropertyFontWeight, "normal", "bold"); |
| @@ -1730,7 +1739,7 @@ static bool executeToggleBold(LocalFrame& frame, |
| static bool executeToggleItalic(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeToggleStyle(frame, source, InputEvent::InputType::FormatItalic, |
| CSSPropertyFontStyle, "normal", "italic"); |
| @@ -1738,15 +1747,15 @@ static bool executeToggleItalic(LocalFrame& frame, |
| static bool executeTranspose(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().transpose(); |
| + frame.editor().transpose(source); |
| return true; |
| } |
| static bool executeUnderline(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| CSSIdentifierValue* underline = CSSIdentifierValue::create(CSSValueUnderline); |
| return executeToggleStyleInList( |
| @@ -1756,23 +1765,23 @@ static bool executeUnderline(LocalFrame& frame, |
| static bool executeUndo(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| - frame.editor().undo(); |
| + frame.editor().undo(source); |
| return true; |
| } |
| static bool executeUnlink(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| DCHECK(frame.document()); |
| - return UnlinkCommand::create(*frame.document())->apply(); |
| + return UnlinkCommand::create(*frame.document(), source)->apply(); |
| } |
| static bool executeUnscript(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource source, |
| + CommandSource source, |
| const String&) { |
| return executeApplyStyle(frame, source, InputEvent::InputType::None, |
| CSSPropertyVerticalAlign, "baseline"); |
| @@ -1780,7 +1789,7 @@ static bool executeUnscript(LocalFrame& frame, |
| static bool executeUnselect(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource, |
| const String&) { |
| frame.selection().clear(); |
| return true; |
| @@ -1788,20 +1797,20 @@ static bool executeUnselect(LocalFrame& frame, |
| static bool executeYank(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| frame.editor().insertTextWithoutSendingTextEvent( |
| - frame.editor().killRing().yank(), false, 0); |
| + source, frame.editor().killRing().yank(), false, 0); |
| frame.editor().killRing().setToYankedState(); |
| return true; |
| } |
| static bool executeYankAndSelect(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource, |
| + CommandSource source, |
| const String&) { |
| frame.editor().insertTextWithoutSendingTextEvent( |
| - frame.editor().killRing().yank(), true, 0); |
| + source, frame.editor().killRing().yank(), true, 0); |
| frame.editor().killRing().setToYankedState(); |
| return true; |
| } |
| @@ -1818,13 +1827,13 @@ static bool supportedFromMenuOrKeyBinding(LocalFrame*) { |
| // Enabled functions |
| -static bool enabled(LocalFrame&, Event*, EditorCommandSource) { |
| +static bool enabled(LocalFrame&, Event*, CommandSource) { |
| return true; |
| } |
| static bool enabledVisibleSelection(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| // The term "visible" here includes a caret in editable text or a range in any |
| @@ -1836,7 +1845,7 @@ static bool enabledVisibleSelection(LocalFrame& frame, |
| static bool enabledVisibleSelectionAndMark(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| const VisibleSelection& selection = frame.editor().selectionForCommand(event); |
| @@ -1847,20 +1856,20 @@ static bool enabledVisibleSelectionAndMark(LocalFrame& frame, |
| static bool enableCaretInEditableText(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| const VisibleSelection& selection = frame.editor().selectionForCommand(event); |
| return selection.isCaret() && selection.isContentEditable(); |
| } |
| -static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource source) { |
| +static bool enabledCopy(LocalFrame& frame, Event*, CommandSource source) { |
| if (!canWriteClipboard(frame, source)) |
| return false; |
| return frame.editor().canDHTMLCopy() || frame.editor().canCopy(); |
| } |
| -static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource source) { |
| +static bool enabledCut(LocalFrame& frame, Event*, CommandSource source) { |
| if (!canWriteClipboard(frame, source)) |
| return false; |
| return frame.editor().canDHTMLCut() || frame.editor().canCut(); |
| @@ -1868,7 +1877,7 @@ static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource source) { |
| static bool enabledInEditableText(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| // We should update selection to canonicalize with current layout and style, |
| @@ -1879,11 +1888,11 @@ static bool enabledInEditableText(LocalFrame& frame, |
| static bool enabledDelete(LocalFrame& frame, |
| Event* event, |
| - EditorCommandSource source) { |
| + CommandSource source) { |
| switch (source) { |
| - case CommandFromMenuOrKeyBinding: |
| + case CommandSource::MenuOrKeyBinding: |
| return frame.editor().canDelete(); |
| - case CommandFromDOM: |
| + case CommandSource::Dom: |
| // "Delete" from DOM is like delete/backspace keypress, affects selected |
| // range if non-empty, otherwise removes a character |
| return enabledInEditableText(frame, event, source); |
| @@ -1894,7 +1903,7 @@ static bool enabledDelete(LocalFrame& frame, |
| static bool enabledInRichlyEditableText(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| // We should update selection to canonicalize with current layout and style, |
| @@ -1905,9 +1914,7 @@ static bool enabledInRichlyEditableText(LocalFrame& frame, |
| frame.selection().rootEditableElement(); |
| } |
| -static bool enabledPaste(LocalFrame& frame, |
| - Event*, |
| - EditorCommandSource source) { |
| +static bool enabledPaste(LocalFrame& frame, Event*, CommandSource source) { |
| if (!canReadClipboard(frame, source)) |
| return false; |
| return frame.editor().canPaste(); |
| @@ -1915,7 +1922,7 @@ static bool enabledPaste(LocalFrame& frame, |
| static bool enabledRangeInEditableText(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| // We should update selection to canonicalize with current layout and style, |
| @@ -1926,7 +1933,7 @@ static bool enabledRangeInEditableText(LocalFrame& frame, |
| static bool enabledRangeInRichlyEditableText(LocalFrame& frame, |
| Event*, |
| - EditorCommandSource) { |
| + CommandSource) { |
| frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| // We should update selection to canonicalize with current layout and style, |
| @@ -1936,11 +1943,11 @@ static bool enabledRangeInRichlyEditableText(LocalFrame& frame, |
| frame.selection().isContentRichlyEditable(); |
| } |
| -static bool enabledRedo(LocalFrame& frame, Event*, EditorCommandSource) { |
| +static bool enabledRedo(LocalFrame& frame, Event*, CommandSource) { |
| return frame.editor().canRedo(); |
| } |
| -static bool enabledUndo(LocalFrame& frame, Event*, EditorCommandSource) { |
| +static bool enabledUndo(LocalFrame& frame, Event*, CommandSource) { |
| return frame.editor().canUndo(); |
| } |
| @@ -2543,22 +2550,23 @@ static const EditorInternalCommand* internalCommand(const String& commandName) { |
| } |
| Editor::Command Editor::createCommand(const String& commandName) { |
| - return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, |
| + return Command(internalCommand(commandName), CommandSource::MenuOrKeyBinding, |
| m_frame); |
| } |
| -Editor::Command Editor::createCommand(const String& commandName, |
| - EditorCommandSource source) { |
| - return Command(internalCommand(commandName), source, m_frame); |
| +Editor::Command Editor::createCommandFromDOM(const String& commandName) { |
| + return Command(internalCommand(commandName), CommandSource::Dom, m_frame); |
| } |
| bool Editor::executeCommand(const String& commandName) { |
| // Specially handling commands that Editor::execCommand does not directly |
|
chongz
2016/12/13 20:08:12
Note: This is for |WebFrame::executeCommand()| rat
|
| // support. |
| if (commandName == "DeleteToEndOfParagraph") { |
| - if (!deleteWithDirection(DeleteDirection::Forward, ParagraphBoundary, true, |
| + if (!deleteWithDirection(CommandSource::MenuOrKeyBinding, |
| + DeleteDirection::Forward, ParagraphBoundary, true, |
| false)) |
| - deleteWithDirection(DeleteDirection::Forward, CharacterGranularity, true, |
| + deleteWithDirection(CommandSource::MenuOrKeyBinding, |
| + DeleteDirection::Forward, CharacterGranularity, true, |
| false); |
| return true; |
| } |
| @@ -2614,7 +2622,7 @@ bool Editor::executeCommand(const String& commandName, const String& value) { |
| Editor::Command::Command() : m_command(0) {} |
| Editor::Command::Command(const EditorInternalCommand* command, |
| - EditorCommandSource source, |
| + CommandSource source, |
| LocalFrame* frame) |
| : m_command(command), m_source(source), m_frame(command ? frame : nullptr) { |
| // Use separate assertions so we can tell which bad thing happened. |
| @@ -2637,7 +2645,7 @@ bool Editor::Command::execute(const String& parameter, |
| return false; |
| } |
| - if (m_source == CommandFromMenuOrKeyBinding) { |
| + if (m_source == CommandSource::MenuOrKeyBinding) { |
| InputEvent::InputType inputType = |
| InputTypeFromCommandType(m_command->commandType, *m_frame); |
| if (inputType != InputEvent::InputType::None) { |
| @@ -2667,9 +2675,9 @@ bool Editor::Command::isSupported() const { |
| if (!m_command) |
| return false; |
| switch (m_source) { |
| - case CommandFromMenuOrKeyBinding: |
| + case CommandSource::MenuOrKeyBinding: |
| return true; |
| - case CommandFromDOM: |
| + case CommandSource::Dom: |
| return m_command->isSupportedFromDOM(m_frame.get()); |
| } |
| NOTREACHED(); |