Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/VisibleSelection.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp |
| index 0e97a53bbdfc97cdace1472b789514adcbadc861..79ad13f667cbb6ae63c71963af90dfaf716abf19 100644 |
| --- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp |
| +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp |
| @@ -473,32 +473,36 @@ bool VisibleSelectionTemplate<Strategy>::IsValidFor( |
| // |VisibleSelection| or create a new class for editing to use that can |
| // manipulate selections that are not currently valid. |
| template <typename Strategy> |
| -void VisibleSelectionTemplate<Strategy>::SetWithoutValidation( |
| +VisibleSelectionTemplate<Strategy> |
| +VisibleSelectionTemplate<Strategy>::CreateWithoutValidationDeprecated( |
| const PositionTemplate<Strategy>& base, |
| - const PositionTemplate<Strategy>& extent) { |
| - if (base.IsNull() || extent.IsNull()) { |
| - base_ = extent_ = start_ = end_ = PositionTemplate<Strategy>(); |
| - UpdateSelectionType(); |
| - return; |
| - } |
| - |
| - base_ = base; |
| - extent_ = extent; |
| - base_is_first_ = base.CompareTo(extent) <= 0; |
| - if (base_is_first_) { |
| - start_ = base; |
| - end_ = extent; |
| + const PositionTemplate<Strategy>& extent, |
| + TextAffinity affinity) { |
| + DCHECK(base.IsNotNull()); |
| + DCHECK(extent.IsNotNull()); |
| + |
| + VisibleSelectionTemplate<Strategy> visible_selection; |
| + visible_selection.base_ = base; |
| + visible_selection.extent_ = extent; |
| + visible_selection.base_is_first_ = base.CompareTo(extent) <= 0; |
| + if (visible_selection.base_is_first_) { |
| + visible_selection.start_ = base; |
| + visible_selection.end_ = extent; |
| } else { |
| - start_ = extent; |
| - end_ = base; |
| + visible_selection.start_ = extent; |
| + visible_selection.end_ = base; |
| } |
| - selection_type_ = base == extent ? kCaretSelection : kRangeSelection; |
| - if (selection_type_ != kCaretSelection) { |
| - // Since |m_affinity| for non-|CaretSelection| is always |Downstream|, |
| - // we should keep this invariant. Note: This function can be called with |
| - // |m_affinity| is |TextAffinity::Upstream|. |
| - affinity_ = TextAffinity::kDownstream; |
| + if (base == extent) { |
| + visible_selection.selection_type_ = kCaretSelection; |
| + visible_selection.affinity_ = affinity; |
| + return visible_selection; |
| } |
| + // Since |m_affinity| for non-|CaretSelection| is always |Downstream|, |
|
Xiaocheng
2017/06/22 18:20:10
nits:
s/m_affinity/affinity/
s/Downstream/kDownstr
yosin_UTC9
2017/06/23 00:57:32
Done.
|
| + // we should keep this invariant. Note: This function can be called with |
| + // |m_affinity| is |TextAffinity::Upstream|. |
|
Xiaocheng
2017/06/22 18:20:10
nits:
s/m_affinity/affinity/
s/Upstream/kUpstream/
yosin_UTC9
2017/06/23 00:57:32
Done.
|
| + visible_selection.selection_type_ = kRangeSelection; |
| + visible_selection.affinity_ = TextAffinity::kDownstream; |
| + return visible_selection; |
| } |
| template <typename Strategy> |