| Index: third_party/WebKit/Source/core/editing/Editor.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
|
| index 5c060f590f357a1d44737d05af7f9dbf27f4ba39..2fe0b570b376973f2fee55a21490b456fd26c893 100644
|
| --- a/third_party/WebKit/Source/core/editing/Editor.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/Editor.cpp
|
| @@ -916,13 +916,16 @@ static void DispatchEditableContentChangedEvents(Element* start_root,
|
| Event::Create(EventTypeNames::webkitEditableContentChanged));
|
| }
|
|
|
| -static VisibleSelection CorrectedVisibleSelection(
|
| - const VisibleSelection& passed_selection) {
|
| +static SelectionInDOMTree CorrectedSelectionAfterCommand(
|
| + const VisibleSelection& passed_selection,
|
| + Document* document) {
|
| if (!passed_selection.Base().IsConnected() ||
|
| - !passed_selection.Extent().IsConnected())
|
| - return VisibleSelection();
|
| - DCHECK(!passed_selection.Base().GetDocument()->NeedsLayoutTreeUpdate());
|
| - return CreateVisibleSelection(passed_selection.AsSelection());
|
| + !passed_selection.Extent().IsConnected() ||
|
| + passed_selection.Base().GetDocument() != document ||
|
| + passed_selection.Base().GetDocument() !=
|
| + passed_selection.Extent().GetDocument())
|
| + return SelectionInDOMTree();
|
| + return passed_selection.AsSelection();
|
| }
|
|
|
| void Editor::AppliedEditing(CompositeEditCommand* cmd) {
|
| @@ -942,19 +945,12 @@ void Editor::AppliedEditing(CompositeEditCommand* cmd) {
|
| undo_step->EndingRootEditableElement(), cmd->GetInputType(),
|
| cmd->TextDataForInputEvent(), IsComposingFromCommand(cmd));
|
|
|
| - // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| - // needs to be audited. See http://crbug.com/590369 for more details.
|
| - // The clean layout is consumed by |mostBackwardCaretPosition|, called through
|
| - // |changeSelectionAfterCommand|. In the long term, we should postpone visible
|
| - // selection canonicalization so that selection update does not need layout.
|
| - GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
| -
|
| - const VisibleSelection& new_selection =
|
| - CorrectedVisibleSelection(cmd->EndingSelection());
|
| + const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand(
|
| + cmd->EndingSelection(), GetFrame().GetDocument());
|
|
|
| // Don't clear the typing style with this selection change. We do those things
|
| // elsewhere if necessary.
|
| - ChangeSelectionAfterCommand(new_selection.AsSelection(), 0);
|
| + ChangeSelectionAfterCommand(new_selection, 0);
|
|
|
| if (!cmd->PreservesTypingStyle())
|
| ClearTypingStyle();
|
| @@ -976,7 +972,7 @@ void Editor::AppliedEditing(CompositeEditCommand* cmd) {
|
| undo_stack_->RegisterUndoStep(last_edit_command_->EnsureUndoStep());
|
| }
|
|
|
| - RespondToChangedContents(new_selection.Start());
|
| + RespondToChangedContents(new_selection.Base());
|
| }
|
|
|
| void Editor::UnappliedEditing(UndoStep* cmd) {
|
| @@ -989,22 +985,15 @@ void Editor::UnappliedEditing(UndoStep* cmd) {
|
| InputEvent::InputType::kHistoryUndo, g_null_atom,
|
| InputEvent::EventIsComposing::kNotComposing);
|
|
|
| - // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| - // needs to be audited. See http://crbug.com/590369 for more details.
|
| - // In the long term, we should stop editing commands from storing
|
| - // VisibleSelections as starting and ending selections.
|
| - GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
| -
|
| - const VisibleSelection& new_selection =
|
| - CorrectedVisibleSelection(cmd->StartingSelection());
|
| - DCHECK(new_selection.IsValidFor(*GetFrame().GetDocument())) << new_selection;
|
| + const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand(
|
| + cmd->StartingSelection(), GetFrame().GetDocument());
|
| ChangeSelectionAfterCommand(
|
| - new_selection.AsSelection(),
|
| + new_selection,
|
| FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle);
|
|
|
| last_edit_command_ = nullptr;
|
| undo_stack_->RegisterRedoStep(cmd);
|
| - RespondToChangedContents(new_selection.Start());
|
| + RespondToChangedContents(new_selection.Base());
|
| }
|
|
|
| void Editor::ReappliedEditing(UndoStep* cmd) {
|
| @@ -1017,21 +1006,15 @@ void Editor::ReappliedEditing(UndoStep* cmd) {
|
| InputEvent::InputType::kHistoryRedo, g_null_atom,
|
| InputEvent::EventIsComposing::kNotComposing);
|
|
|
| - // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
| - // needs to be audited. See http://crbug.com/590369 for more details.
|
| - // In the long term, we should stop editing commands from storing
|
| - // VisibleSelections as starting and ending selections.
|
| - GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
| - const VisibleSelection& new_selection =
|
| - CorrectedVisibleSelection(cmd->EndingSelection());
|
| - DCHECK(new_selection.IsValidFor(*GetFrame().GetDocument())) << new_selection;
|
| + const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand(
|
| + cmd->EndingSelection(), GetFrame().GetDocument());
|
| ChangeSelectionAfterCommand(
|
| - new_selection.AsSelection(),
|
| + new_selection,
|
| FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle);
|
|
|
| last_edit_command_ = nullptr;
|
| undo_stack_->RegisterUndoStep(cmd);
|
| - RespondToChangedContents(new_selection.Start());
|
| + RespondToChangedContents(new_selection.Base());
|
| }
|
|
|
| Editor* Editor::Create(LocalFrame& frame) {
|
|
|