Commit e9cfc439 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Remove select_inserted_text param from Insert[Incremental]TextCommand

After https://chromium-review.googlesource.com/c/chromium/src/+/801979, we no
longer need the select_inserted_text functionality on either InsertTextCommand
or InsertIncrementalTextCommand, so we can remove the parameter.

Bug: 784039
Change-Id: Icfb2688a83383cea9e295186f351b6f43ffadf6c
Reviewed-on: https://chromium-review.googlesource.com/807286
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523288}
parent ec0fdd91
......@@ -119,18 +119,15 @@ SelectionInDOMTree ComputeSelectionForInsertion(
InsertIncrementalTextCommand* InsertIncrementalTextCommand::Create(
Document& document,
const String& text,
bool select_inserted_text,
RebalanceType rebalance_type) {
return new InsertIncrementalTextCommand(document, text, select_inserted_text,
rebalance_type);
return new InsertIncrementalTextCommand(document, text, rebalance_type);
}
InsertIncrementalTextCommand::InsertIncrementalTextCommand(
Document& document,
const String& text,
bool select_inserted_text,
RebalanceType rebalance_type)
: InsertTextCommand(document, text, select_inserted_text, rebalance_type) {}
: InsertTextCommand(document, text, rebalance_type) {}
void InsertIncrementalTextCommand::DoApply(EditingState* editing_state) {
DCHECK(!GetDocument().NeedsLayoutTreeUpdate());
......
......@@ -15,13 +15,11 @@ class CORE_EXPORT InsertIncrementalTextCommand final
static InsertIncrementalTextCommand* Create(
Document&,
const String&,
bool select_inserted_text = false,
RebalanceType = kRebalanceLeadingAndTrailingWhitespaces);
private:
InsertIncrementalTextCommand(Document&,
const String& text,
bool select_inserted_text,
RebalanceType);
void DoApply(EditingState*) override;
};
......
......@@ -40,11 +40,9 @@ namespace blink {
InsertTextCommand::InsertTextCommand(Document& document,
const String& text,
bool select_inserted_text,
RebalanceType rebalance_type)
: CompositeEditCommand(document),
text_(text),
select_inserted_text_(select_inserted_text),
rebalance_type_(rebalance_type) {}
String InsertTextCommand::TextDataForInputEvent() const {
......@@ -92,8 +90,7 @@ void InsertTextCommand::SetEndingSelectionWithoutValidation(
// This avoids the expense of a full fledged delete operation, and avoids a
// layout that typically results from text removal.
bool InsertTextCommand::PerformTrivialReplace(const String& text,
bool select_inserted_text) {
bool InsertTextCommand::PerformTrivialReplace(const String& text) {
// We may need to manipulate neighboring whitespace if we're deleting text.
// This case is tested in
// InsertTextCommandTest_InsertEmptyTextAfterWhitespaceThatNeedsFixup.
......@@ -112,8 +109,6 @@ bool InsertTextCommand::PerformTrivialReplace(const String& text,
return false;
SetEndingSelectionWithoutValidation(start, end_position);
if (select_inserted_text)
return true;
SetEndingSelection(SelectionForUndoStep::From(
SelectionInDOMTree::Builder()
.Collapse(EndingVisibleSelection().End())
......@@ -122,8 +117,7 @@ bool InsertTextCommand::PerformTrivialReplace(const String& text,
return true;
}
bool InsertTextCommand::PerformOverwrite(const String& text,
bool select_inserted_text) {
bool InsertTextCommand::PerformOverwrite(const String& text) {
Position start = EndingVisibleSelection().Start();
if (start.IsNull() || !start.IsOffsetInAnchor() ||
!start.ComputeContainerNode()->IsTextNode())
......@@ -142,7 +136,7 @@ bool InsertTextCommand::PerformOverwrite(const String& text,
Position end_position =
Position(text_node, start.OffsetInContainerNode() + text.length());
SetEndingSelectionWithoutValidation(start, end_position);
if (select_inserted_text || EndingSelection().IsNone())
if (EndingSelection().IsNone())
return true;
SetEndingSelection(SelectionForUndoStep::From(
SelectionInDOMTree::Builder()
......@@ -165,7 +159,7 @@ void InsertTextCommand::DoApply(EditingState* editing_state) {
// Delete the current selection.
// FIXME: This delete operation blows away the typing style.
if (EndingSelection().IsRange()) {
if (PerformTrivialReplace(text_, select_inserted_text_))
if (PerformTrivialReplace(text_))
return;
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
bool end_of_selection_was_at_start_of_block =
......@@ -185,7 +179,7 @@ void InsertTextCommand::DoApply(EditingState* editing_state) {
typing_style->RemoveBlockProperties();
}
} else if (GetDocument().GetFrame()->GetEditor().IsOverwriteModeEnabled()) {
if (PerformOverwrite(text_, select_inserted_text_))
if (PerformOverwrite(text_))
return;
}
......@@ -300,15 +294,13 @@ void InsertTextCommand::DoApply(EditingState* editing_state) {
}
}
if (!select_inserted_text_) {
SelectionInDOMTree::Builder builder;
const VisibleSelection& selection = EndingVisibleSelection();
builder.SetAffinity(selection.Affinity());
builder.SetIsDirectional(EndingSelection().IsDirectional());
if (selection.End().IsNotNull())
builder.Collapse(selection.End());
SetEndingSelection(SelectionForUndoStep::From(builder.Build()));
}
SelectionInDOMTree::Builder builder;
const VisibleSelection& selection = EndingVisibleSelection();
builder.SetAffinity(selection.Affinity());
builder.SetIsDirectional(EndingSelection().IsDirectional());
if (selection.End().IsNotNull())
builder.Collapse(selection.End());
SetEndingSelection(SelectionForUndoStep::From(builder.Build()));
}
Position InsertTextCommand::InsertTab(const Position& pos,
......
......@@ -40,10 +40,8 @@ class CORE_EXPORT InsertTextCommand : public CompositeEditCommand {
static InsertTextCommand* Create(
Document& document,
const String& text,
bool select_inserted_text = false,
RebalanceType rebalance_type = kRebalanceLeadingAndTrailingWhitespaces) {
return new InsertTextCommand(document, text, select_inserted_text,
rebalance_type);
return new InsertTextCommand(document, text, rebalance_type);
}
String TextDataForInputEvent() const final;
......@@ -51,7 +49,6 @@ class CORE_EXPORT InsertTextCommand : public CompositeEditCommand {
protected:
InsertTextCommand(Document&,
const String& text,
bool select_inserted_text,
RebalanceType);
void DoApply(EditingState*) override;
......@@ -59,15 +56,14 @@ class CORE_EXPORT InsertTextCommand : public CompositeEditCommand {
Position PositionInsideTextNode(const Position&, EditingState*);
Position InsertTab(const Position&, EditingState*);
bool PerformTrivialReplace(const String&, bool select_inserted_text);
bool PerformOverwrite(const String&, bool select_inserted_text);
bool PerformTrivialReplace(const String&);
bool PerformOverwrite(const String&);
void SetEndingSelectionWithoutValidation(const Position& start_position,
const Position& end_position);
friend class TypingCommand;
String text_;
bool select_inserted_text_;
RebalanceType rebalance_type_;
};
......
......@@ -663,14 +663,14 @@ void TypingCommand::InsertTextRunWithoutNewlines(const String& text,
CompositeEditCommand* command;
if (IsIncrementalInsertion()) {
command = InsertIncrementalTextCommand::Create(
GetDocument(), text, false,
GetDocument(), text,
composition_type_ == kTextCompositionNone
? InsertIncrementalTextCommand::
kRebalanceLeadingAndTrailingWhitespaces
: InsertIncrementalTextCommand::kRebalanceAllWhitespaces);
} else {
command = InsertTextCommand::Create(
GetDocument(), text, false,
GetDocument(), text,
composition_type_ == kTextCompositionNone
? InsertTextCommand::kRebalanceLeadingAndTrailingWhitespaces
: InsertTextCommand::kRebalanceAllWhitespaces);
......
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