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