| Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| index 29a17ac75d586f4724334baaaa8010122d4aa1ac..0d3491ae747074864785411961b9d3b5c3338351 100644
|
| --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| @@ -43,7 +43,6 @@
|
| #include "core/editing/commands/DeleteFromTextNodeCommand.h"
|
| #include "core/editing/commands/DeleteSelectionCommand.h"
|
| #include "core/editing/commands/InsertIntoTextNodeCommand.h"
|
| -#include "core/editing/commands/InsertLineBreakCommand.h"
|
| #include "core/editing/commands/InsertNodeBeforeCommand.h"
|
| #include "core/editing/commands/InsertParagraphSeparatorCommand.h"
|
| #include "core/editing/commands/MergeIdenticalElementsCommand.h"
|
| @@ -180,8 +179,9 @@ DEFINE_TRACE(EditCommandComposition) {
|
| UndoStep::trace(visitor);
|
| }
|
|
|
| -CompositeEditCommand::CompositeEditCommand(Document& document)
|
| - : EditCommand(document) {}
|
| +CompositeEditCommand::CompositeEditCommand(Document& document,
|
| + CommandSource source)
|
| + : EditCommand(document), m_source(source) {}
|
|
|
| CompositeEditCommand::~CompositeEditCommand() {
|
| DCHECK(isTopLevelCommand() || !m_composition);
|
| @@ -315,7 +315,8 @@ void CompositeEditCommand::appendCommandToComposite(
|
| void CompositeEditCommand::applyStyle(const EditingStyle* style,
|
| EditingState* editingState) {
|
| applyCommandToComposite(
|
| - ApplyStyleCommand::create(document(), style, InputEvent::InputType::None),
|
| + ApplyStyleCommand::create(document(), commandSource(), style,
|
| + InputEvent::InputType::None),
|
| editingState);
|
| }
|
|
|
| @@ -324,29 +325,31 @@ void CompositeEditCommand::applyStyle(const EditingStyle* style,
|
| const Position& end,
|
| EditingState* editingState) {
|
| applyCommandToComposite(
|
| - ApplyStyleCommand::create(document(), style, start, end), editingState);
|
| + ApplyStyleCommand::create(document(), commandSource(), style, start, end),
|
| + editingState);
|
| }
|
|
|
| void CompositeEditCommand::applyStyledElement(Element* element,
|
| EditingState* editingState) {
|
| - applyCommandToComposite(ApplyStyleCommand::create(element, false),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + ApplyStyleCommand::create(commandSource(), element, false), editingState);
|
| }
|
|
|
| void CompositeEditCommand::removeStyledElement(Element* element,
|
| EditingState* editingState) {
|
| - applyCommandToComposite(ApplyStyleCommand::create(element, true),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + ApplyStyleCommand::create(commandSource(), element, true), editingState);
|
| }
|
|
|
| void CompositeEditCommand::insertParagraphSeparator(
|
| EditingState* editingState,
|
| bool useDefaultParagraphElement,
|
| bool pasteBlockqutoeIntoUnquotedArea) {
|
| - applyCommandToComposite(InsertParagraphSeparatorCommand::create(
|
| - document(), useDefaultParagraphElement,
|
| - pasteBlockqutoeIntoUnquotedArea),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + InsertParagraphSeparatorCommand::create(document(), commandSource(),
|
| + useDefaultParagraphElement,
|
| + pasteBlockqutoeIntoUnquotedArea),
|
| + editingState);
|
| }
|
|
|
| bool CompositeEditCommand::isRemovableBlock(const Node* node) {
|
| @@ -485,9 +488,10 @@ void CompositeEditCommand::removeNodePreservingChildren(
|
| EditingState* editingState,
|
| ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) {
|
| ABORT_EDITING_COMMAND_IF(!node->document().frame());
|
| - applyCommandToComposite(RemoveNodePreservingChildrenCommand::create(
|
| - node, shouldAssumeContentIsAlwaysEditable),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + RemoveNodePreservingChildrenCommand::create(
|
| + commandSource(), node, shouldAssumeContentIsAlwaysEditable),
|
| + editingState);
|
| }
|
|
|
| void CompositeEditCommand::removeNodeAndPruneAncestors(
|
| @@ -596,9 +600,9 @@ void CompositeEditCommand::wrapContentsInDummySpan(Element* element) {
|
| void CompositeEditCommand::splitTextNodeContainingElement(Text* text,
|
| unsigned offset) {
|
| // SplitTextNodeContainingElementCommand is never aborted.
|
| - applyCommandToComposite(
|
| - SplitTextNodeContainingElementCommand::create(text, offset),
|
| - ASSERT_NO_EDITING_ABORT);
|
| + applyCommandToComposite(SplitTextNodeContainingElementCommand::create(
|
| + commandSource(), text, offset),
|
| + ASSERT_NO_EDITING_ABORT);
|
| }
|
|
|
| void CompositeEditCommand::insertTextIntoNode(Text* node,
|
| @@ -739,11 +743,13 @@ void CompositeEditCommand::deleteSelection(EditingState* editingState,
|
| bool mergeBlocksAfterDelete,
|
| bool expandForSpecialElements,
|
| bool sanitizeMarkup) {
|
| - if (endingSelection().isRange())
|
| - applyCommandToComposite(DeleteSelectionCommand::create(
|
| - document(), smartDelete, mergeBlocksAfterDelete,
|
| - expandForSpecialElements, sanitizeMarkup),
|
| - editingState);
|
| + if (endingSelection().isRange()) {
|
| + applyCommandToComposite(
|
| + DeleteSelectionCommand::create(
|
| + document(), commandSource(), smartDelete, mergeBlocksAfterDelete,
|
| + expandForSpecialElements, sanitizeMarkup),
|
| + editingState);
|
| + }
|
| }
|
|
|
| void CompositeEditCommand::deleteSelection(const VisibleSelection& selection,
|
| @@ -752,11 +758,13 @@ void CompositeEditCommand::deleteSelection(const VisibleSelection& selection,
|
| bool mergeBlocksAfterDelete,
|
| bool expandForSpecialElements,
|
| bool sanitizeMarkup) {
|
| - if (selection.isRange())
|
| - applyCommandToComposite(DeleteSelectionCommand::create(
|
| - selection, smartDelete, mergeBlocksAfterDelete,
|
| - expandForSpecialElements, sanitizeMarkup),
|
| - editingState);
|
| + if (selection.isRange()) {
|
| + applyCommandToComposite(
|
| + DeleteSelectionCommand::create(
|
| + commandSource(), selection, smartDelete, mergeBlocksAfterDelete,
|
| + expandForSpecialElements, sanitizeMarkup),
|
| + editingState);
|
| + }
|
| }
|
|
|
| void CompositeEditCommand::removeCSSProperty(Element* element,
|
| @@ -1667,9 +1675,9 @@ void CompositeEditCommand::moveParagraphs(
|
| ReplaceSelectionCommand::MovingParagraph;
|
| if (shouldPreserveStyle == DoNotPreserveStyle)
|
| options |= ReplaceSelectionCommand::MatchStyle;
|
| - applyCommandToComposite(
|
| - ReplaceSelectionCommand::create(document(), fragment, options),
|
| - editingState);
|
| + applyCommandToComposite(ReplaceSelectionCommand::create(
|
| + document(), commandSource(), fragment, options),
|
| + editingState);
|
| if (editingState->isAborted())
|
| return;
|
|
|
| @@ -2029,6 +2037,12 @@ Node* CompositeEditCommand::splitTreeToNode(Node* start,
|
| return node;
|
| }
|
|
|
| +CommandSource CompositeEditCommand::commandSource() const {
|
| + if (!parent())
|
| + return m_source;
|
| + return parent()->commandSource();
|
| +}
|
| +
|
| DEFINE_TRACE(CompositeEditCommand) {
|
| visitor->trace(m_commands);
|
| visitor->trace(m_composition);
|
|
|