Commit e37d7184 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Hoist VisibleSelection creation from...

Hoist VisibleSelection creation from SelectionController::SetNonDirectionalSelectionIfNeeded() to callers

This patch hoists the creation of VisibleSelection |new_selection| from
the function to its callers, so that the elimination of VisibleSelection
canonicalization is easier.

Bug: 657237
Change-Id: Ic1c25d9474f1ade210c4389862bafc87e8e8d7b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1502152Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarShimi Zhang <ctzsm@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638257}
parent 3ec708ec
...@@ -547,7 +547,7 @@ void SelectionController::UpdateSelectionForMouseDrag( ...@@ -547,7 +547,7 @@ void SelectionController::UpdateSelectionForMouseDrag(
const bool selection_is_directional = const bool selection_is_directional =
should_extend_selection ? Selection().IsDirectional() : false; should_extend_selection ? Selection().IsDirectional() : false;
SetNonDirectionalSelectionIfNeeded( SetNonDirectionalSelectionIfNeeded(
adjusted_selection, CreateVisibleSelection(adjusted_selection).AsSelection(),
SetSelectionOptions::Builder() SetSelectionOptions::Builder()
.SetGranularity(Selection().Granularity()) .SetGranularity(Selection().Granularity())
.SetIsDirectional(selection_is_directional) .SetIsDirectional(selection_is_directional)
...@@ -581,13 +581,13 @@ bool SelectionController::UpdateSelectionForMouseDownDispatchingSelectStart( ...@@ -581,13 +581,13 @@ bool SelectionController::UpdateSelectionForMouseDownDispatchingSelectStart(
if (visible_selection.IsRange()) { if (visible_selection.IsRange()) {
selection_state_ = SelectionState::kExtendedSelection; selection_state_ = SelectionState::kExtendedSelection;
SetNonDirectionalSelectionIfNeeded(selection, set_selection_options, SetNonDirectionalSelectionIfNeeded(visible_selection, set_selection_options,
kDoNotAdjustEndpoints); kDoNotAdjustEndpoints);
return true; return true;
} }
selection_state_ = SelectionState::kPlacedCaret; selection_state_ = SelectionState::kPlacedCaret;
SetNonDirectionalSelectionIfNeeded(selection, set_selection_options, SetNonDirectionalSelectionIfNeeded(visible_selection, set_selection_options,
kDoNotAdjustEndpoints); kDoNotAdjustEndpoints);
return true; return true;
} }
...@@ -792,15 +792,11 @@ void SelectionController::SelectClosestWordOrLinkFromMouseEvent( ...@@ -792,15 +792,11 @@ void SelectionController::SelectClosestWordOrLinkFromMouseEvent(
// We should rename this function to appropriate name because // We should rename this function to appropriate name because
// set_selection_options has selection directional value in few cases. // set_selection_options has selection directional value in few cases.
void SelectionController::SetNonDirectionalSelectionIfNeeded( void SelectionController::SetNonDirectionalSelectionIfNeeded(
const SelectionInFlatTree& passed_selection, const SelectionInFlatTree& new_selection,
const SetSelectionOptions& set_selection_options, const SetSelectionOptions& set_selection_options,
EndPointsAdjustmentMode endpoints_adjustment_mode) { EndPointsAdjustmentMode endpoints_adjustment_mode) {
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets DCHECK(!GetDocument().NeedsLayoutTreeUpdate());
// needs to be audited. See http://crbug.com/590369 for more details.
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
const SelectionInFlatTree new_selection =
CreateVisibleSelection(passed_selection).AsSelection();
// TODO(editing-dev): We should use |PositionWithAffinity| to pass affinity // TODO(editing-dev): We should use |PositionWithAffinity| to pass affinity
// to |CreateVisiblePosition()| for |original_base|. // to |CreateVisiblePosition()| for |original_base|.
const PositionInFlatTree& base_position = const PositionInFlatTree& base_position =
......
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