Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1048)

Unified Diff: third_party/WebKit/Source/core/editing/VisibleSelection.cpp

Issue 2952973002: Introduce VisibleSelection::CreateWithoutValidationDeprecated() (Closed)
Patch Set: 2017-06-23T09:54:35 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c145886ea0bbc223994cd0fdea7489e15ea9aa9d 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 |affinity_| for non-|CaretSelection| is always |kDownstream|,
+ // we should keep this invariant. Note: This function can be called with
+ // |affinity_| is |kUpstream|.
+ visible_selection.selection_type_ = kRangeSelection;
+ visible_selection.affinity_ = TextAffinity::kDownstream;
+ return visible_selection;
}
template <typename Strategy>

Powered by Google App Engine
This is Rietveld 408576698