| 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 027696a4695704a32d8da47d893b47b09e518d03..bf4daaaf9a321e9b1321f64c11cbd4a168e9cb55 100644
|
| --- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
|
| @@ -109,7 +109,8 @@ WebEditingCommandType WebEditingCommandTypeFromCommandName(
|
| return WebEditingCommandType::Invalid;
|
| }
|
|
|
| -// |frame| is only used for |InsertNewline| due to how |executeInsertNewline()| works.
|
| +// |frame| is only used for |InsertNewline| due to how |executeInsertNewline()|
|
| +// works.
|
| InputEvent::InputType InputTypeFromCommandType(
|
| WebEditingCommandType commandType,
|
| LocalFrame& frame) {
|
| @@ -118,7 +119,8 @@ InputEvent::InputType InputTypeFromCommandType(
|
| using CommandType = WebEditingCommandType;
|
| using InputType = InputEvent::InputType;
|
|
|
| - // |executeInsertNewline()| could do two things but we have no other ways to predict.
|
| + // |executeInsertNewline()| could do two things but we have no other ways to
|
| + // predict.
|
| if (commandType == CommandType::InsertNewline)
|
| return frame.editor().canEditRichly() ? InputType::InsertParagraph
|
| : InputType::InsertLineBreak;
|
| @@ -228,8 +230,8 @@ static const bool allowExecutionWhenDisabled = true;
|
| static const bool doNotAllowExecutionWhenDisabled = false;
|
|
|
| // Related to Editor::selectionForCommand.
|
| -// Certain operations continue to use the target control's selection even if the event handler
|
| -// already moved the selection outside of the text control.
|
| +// Certain operations continue to use the target control's selection even if the
|
| +// event handler already moved the selection outside of the text control.
|
| static LocalFrame* targetFrame(LocalFrame& frame, Event* event) {
|
| if (!event)
|
| return &frame;
|
| @@ -243,7 +245,8 @@ static bool applyCommandToFrame(LocalFrame& frame,
|
| EditorCommandSource source,
|
| InputEvent::InputType inputType,
|
| StylePropertySet* style) {
|
| - // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
|
| + // 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);
|
| @@ -278,9 +281,10 @@ static bool executeApplyStyle(LocalFrame& frame,
|
| return applyCommandToFrame(frame, source, inputType, style);
|
| }
|
|
|
| -// FIXME: executeToggleStyleInList does not handle complicated cases such as <b><u>hello</u>world</b> properly.
|
| -// This function must use Editor::selectionHasStyle to determine the current style but we cannot fix this
|
| -// until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved.
|
| +// FIXME: executeToggleStyleInList does not handle complicated cases such as
|
| +// <b><u>hello</u>world</b> properly. This function must use
|
| +// 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,
|
| InputEvent::InputType inputType,
|
| @@ -306,7 +310,8 @@ static bool executeToggleStyleInList(LocalFrame& frame,
|
| newStyle = value->cssText();
|
| }
|
|
|
| - // FIXME: We shouldn't be having to convert new style into text. We should have setPropertyCSSValue.
|
| + // FIXME: We shouldn't be having to convert new style into text. We should
|
| + // have setPropertyCSSValue.
|
| MutableStylePropertySet* newMutableStyle =
|
| MutableStylePropertySet::create(HTMLQuirksMode);
|
| newMutableStyle->setProperty(propertyID, newStyle);
|
| @@ -343,7 +348,8 @@ static bool executeApplyParagraphStyle(LocalFrame& frame,
|
| MutableStylePropertySet* style =
|
| MutableStylePropertySet::create(HTMLQuirksMode);
|
| style->setProperty(propertyID, propertyValue);
|
| - // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
|
| + // 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);
|
| @@ -359,7 +365,8 @@ static bool executeApplyParagraphStyle(LocalFrame& frame,
|
| static bool executeInsertFragment(LocalFrame& frame,
|
| DocumentFragment* fragment) {
|
| DCHECK(frame.document());
|
| - // TODO(chongz): |InputType| should be |InsertNonText| or corresponding type if exists.
|
| + // TODO(chongz): |InputType| should be |InsertNonText| or corresponding type
|
| + // if exists.
|
| return ReplaceSelectionCommand::create(
|
| *frame.document(), fragment,
|
| ReplaceSelectionCommand::PreventNesting,
|
| @@ -409,7 +416,8 @@ static TriState selectionListState(const FrameSelection& selection,
|
| enclosingElementWithTag(selection.selection().end(), tagName);
|
|
|
| if (startElement && endElement && startElement == endElement) {
|
| - // If the selected list has the different type of list as child, return |FalseTriState|.
|
| + // If the selected list has the different type of list as child, return
|
| + // |FalseTriState|.
|
| // See http://crbug.com/385374
|
| if (hasChildTags(*startElement, tagName.matches(ulTag) ? olTag : ulTag))
|
| return FalseTriState;
|
| @@ -431,8 +439,9 @@ static TriState stateStyle(LocalFrame& frame,
|
| }
|
|
|
| static String valueStyle(LocalFrame& frame, CSSPropertyID propertyID) {
|
| - // FIXME: Rather than retrieving the style at the start of the current selection,
|
| - // we should retrieve the style present throughout the selection for non-Mac platforms.
|
| + // FIXME: Rather than retrieving the style at the start of the current
|
| + // selection, we should retrieve the style present throughout the selection
|
| + // for non-Mac platforms.
|
| return frame.editor().selectionStartCSSPropertyValue(propertyID);
|
| }
|
|
|
| @@ -444,7 +453,8 @@ static TriState stateTextWritingDirection(LocalFrame& frame,
|
| WritingDirection selectionDirection = EditingStyle::textDirectionForSelection(
|
| frame.selection().selection(), frame.selection().typingStyle(),
|
| hasNestedOrMultipleEmbeddings);
|
| - // FXIME: We should be returning MixedTriState when selectionDirection == direction && hasNestedOrMultipleEmbeddings
|
| + // FXIME: We should be returning MixedTriState when selectionDirection ==
|
| + // direction && hasNestedOrMultipleEmbeddings
|
| return (selectionDirection == direction && !hasNestedOrMultipleEmbeddings)
|
| ? TrueTriState
|
| : FalseTriState;
|
| @@ -569,8 +579,10 @@ static bool executeDelete(LocalFrame& frame,
|
| return true;
|
| }
|
| case CommandFromDOM:
|
| - // 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).
|
| + // 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
|
| @@ -634,8 +646,9 @@ static bool executeDeleteToEndOfLine(LocalFrame& frame,
|
| Event*,
|
| EditorCommandSource,
|
| 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).
|
| + // 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);
|
| return true;
|
| @@ -767,8 +780,9 @@ static bool executeForwardDelete(LocalFrame& frame,
|
| return true;
|
| case CommandFromDOM:
|
| // 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.
|
| + // 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);
|
| if (editingState.isAborted())
|
| @@ -848,8 +862,9 @@ static bool executeInsertLineBreak(LocalFrame& frame,
|
| .handleTextInputEvent("\n", event, TextEventInputLineBreak);
|
| case CommandFromDOM:
|
| // 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.
|
| + // 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());
|
| }
|
| @@ -1807,7 +1822,8 @@ static bool enabled(LocalFrame&, Event*, EditorCommandSource) {
|
| static bool enabledVisibleSelection(LocalFrame& frame,
|
| Event* event,
|
| EditorCommandSource) {
|
| - // The term "visible" here includes a caret in editable text or a range in any text.
|
| + // The term "visible" here includes a caret in editable text or a range in any
|
| + // text.
|
| const VisibleSelection& selection = frame.editor().selectionForCommand(event);
|
| return (selection.isCaret() && selection.isContentEditable()) ||
|
| selection.isRange();
|
| @@ -1823,7 +1839,8 @@ static EditorCommandSource dummyEditorCommandSource =
|
| static bool enabledVisibleSelectionOrCaretBrowsing(LocalFrame& frame,
|
| Event* event,
|
| EditorCommandSource) {
|
| - // The EditorCommandSource parameter is unused in enabledVisibleSelection, so just pass a dummy variable
|
| + // The EditorCommandSource parameter is unused in enabledVisibleSelection, so
|
| + // just pass a dummy variable
|
| return caretBrowsingEnabled(frame) ||
|
| enabledVisibleSelection(frame, event, dummyEditorCommandSource);
|
| }
|
| @@ -1872,8 +1889,8 @@ static bool enabledDelete(LocalFrame& frame,
|
| case CommandFromMenuOrKeyBinding:
|
| return frame.editor().canDelete();
|
| case CommandFromDOM:
|
| - // "Delete" from DOM is like delete/backspace keypress, affects selected range if non-empty,
|
| - // otherwise removes a character
|
| + // "Delete" from DOM is like delete/backspace keypress, affects selected
|
| + // range if non-empty, otherwise removes a character
|
| return enabledInEditableText(frame, event, source);
|
| }
|
| NOTREACHED();
|
| @@ -1883,7 +1900,8 @@ static bool enabledDelete(LocalFrame& frame,
|
| static bool enabledInEditableTextOrCaretBrowsing(LocalFrame& frame,
|
| Event* event,
|
| EditorCommandSource) {
|
| - // The EditorCommandSource parameter is unused in enabledInEditableText, so just pass a dummy variable
|
| + // The EditorCommandSource parameter is unused in enabledInEditableText, so
|
| + // just pass a dummy variable
|
| return caretBrowsingEnabled(frame) ||
|
| enabledInEditableText(frame, event, dummyEditorCommandSource);
|
| }
|
| @@ -2076,10 +2094,10 @@ static const EditorInternalCommand* internalCommand(const String& commandName) {
|
| {WebEditingCommandType::BackColor, executeBackColor, supported,
|
| enabledInRichlyEditableText, stateNone, valueBackColor, notTextInsertion,
|
| doNotAllowExecutionWhenDisabled},
|
| + // FIXME: remove BackwardDelete when Safari for Windows stops using it.
|
| {WebEditingCommandType::BackwardDelete, executeDeleteBackward,
|
| supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
|
| - valueNull, notTextInsertion,
|
| - doNotAllowExecutionWhenDisabled}, // FIXME: remove BackwardDelete when Safari for Windows stops using it.
|
| + valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
|
| {WebEditingCommandType::Bold, executeToggleBold, supported,
|
| enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion,
|
| doNotAllowExecutionWhenDisabled},
|
| @@ -2557,16 +2575,18 @@ bool Editor::executeCommand(const String& commandName) {
|
| if (commandName == "DeleteForward")
|
| return createCommand(AtomicString("ForwardDelete")).execute();
|
| if (commandName == "AdvanceToNextMisspelling") {
|
| - // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
|
| - // see http://crbug.com/590369 for more details.
|
| + // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| + // needs to be audited. see http://crbug.com/590369 for more details.
|
| frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| - // We need to pass false here or else the currently selected word will never be skipped.
|
| + // We need to pass false here or else the currently selected word will never
|
| + // be skipped.
|
| spellChecker().advanceToNextMisspelling(false);
|
| return true;
|
| }
|
| if (commandName == "ToggleSpellPanel") {
|
| - // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
|
| + // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| + // needs to be audited.
|
| // see http://crbug.com/590369 for more details.
|
| frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| @@ -2577,7 +2597,8 @@ bool Editor::executeCommand(const String& commandName) {
|
| }
|
|
|
| bool Editor::executeCommand(const String& commandName, const String& value) {
|
| - // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebKit for editable nodes.
|
| + // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebKit
|
| + // for editable nodes.
|
| if (!canEdit() && commandName == "moveToBeginningOfDocument")
|
| return frame().eventHandler().bubblingScroll(ScrollUpIgnoringWritingMode,
|
| ScrollByDocument);
|
| @@ -2587,8 +2608,8 @@ bool Editor::executeCommand(const String& commandName, const String& value) {
|
| ScrollByDocument);
|
|
|
| if (commandName == "showGuessPanel") {
|
| - // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
|
| - // see http://crbug.com/590369 for more details.
|
| + // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| + // needs to be audited. see http://crbug.com/590369 for more details.
|
| frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| spellChecker().showSpellingGuessPanel();
|
| @@ -2618,7 +2639,8 @@ bool Editor::Command::execute(const String& parameter,
|
| // |allowExecutionWhenDisabled| is for "Copy", "Cut" and "Paste" commands
|
| // only.
|
| if (!isEnabled(triggeringEvent)) {
|
| - // Let certain commands be executed when performed explicitly even if they are disabled.
|
| + // Let certain commands be executed when performed explicitly even if they
|
| + // are disabled.
|
| if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled)
|
| return false;
|
| }
|
|
|