Commit ad9144ea authored by yosin's avatar yosin Committed by Commit bot

Re-factor Editor::unappliedEditing()

This patch changes |Editor::unappliedEditing()| to use |isNone()| predicate
rather than checking |Document| equality of |Position| to simplify source code
for improving code health.

Since |correctVisibleSelection()| always returns |VisibileSlection| which
is an empty or valid for specified |Document|, checking equality of |Document|
between selection start and |frame.document()| is equivalent to empty selection
check.

BUG=n/a
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2540613002
Cr-Commit-Position: refs/heads/master@{#434961}
parent acbd50fc
...@@ -875,13 +875,14 @@ void Editor::unappliedEditing(EditCommandComposition* cmd) { ...@@ -875,13 +875,14 @@ void Editor::unappliedEditing(EditCommandComposition* cmd) {
// VisibleSelections as starting and ending selections. // VisibleSelections as starting and ending selections.
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
VisibleSelection newSelection = const VisibleSelection& newSelection =
correctedVisibleSelection(cmd->startingSelection()); correctedVisibleSelection(cmd->startingSelection());
if (newSelection.start().document() == frame().document() && DCHECK(newSelection.isValidFor(*frame().document())) << newSelection;
newSelection.end().document() == frame().document()) if (!newSelection.isNone()) {
changeSelectionAfterCommand( changeSelectionAfterCommand(
newSelection, newSelection,
FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
}
m_lastEditCommand = nullptr; m_lastEditCommand = nullptr;
m_undoStack->registerRedoStep(cmd); m_undoStack->registerRedoStep(cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment