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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionTemplate.cpp

Issue 2973583002: Get rid of SelectionTemplate::has_trailing_whitespace_ (Closed)
Patch Set: 2017-07-05T15:40:09 Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/SelectionTemplate.h" 5 #include "core/editing/SelectionTemplate.h"
6 6
7 #include <ostream> // NOLINT 7 #include <ostream> // NOLINT
8 #include "platform/wtf/Assertions.h" 8 #include "platform/wtf/Assertions.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 template <typename Strategy> 12 template <typename Strategy>
13 SelectionTemplate<Strategy>::SelectionTemplate(const SelectionTemplate& other) 13 SelectionTemplate<Strategy>::SelectionTemplate(const SelectionTemplate& other)
14 : base_(other.base_), 14 : base_(other.base_),
15 extent_(other.extent_), 15 extent_(other.extent_),
16 affinity_(other.affinity_), 16 affinity_(other.affinity_),
17 granularity_(other.granularity_), 17 granularity_(other.granularity_),
18 has_trailing_whitespace_(other.has_trailing_whitespace_),
19 is_directional_(other.is_directional_), 18 is_directional_(other.is_directional_),
20 is_handle_visible_(other.is_handle_visible_) 19 is_handle_visible_(other.is_handle_visible_)
21 #if DCHECK_IS_ON() 20 #if DCHECK_IS_ON()
22 , 21 ,
23 dom_tree_version_(other.dom_tree_version_) 22 dom_tree_version_(other.dom_tree_version_)
24 #endif 23 #endif
25 { 24 {
26 DCHECK(other.AssertValid()); 25 DCHECK(other.AssertValid());
27 if (!has_trailing_whitespace_)
28 return;
29 DCHECK_EQ(granularity_, kWordGranularity) << *this;
30 } 26 }
31 27
32 template <typename Strategy> 28 template <typename Strategy>
33 SelectionTemplate<Strategy>::SelectionTemplate() = default; 29 SelectionTemplate<Strategy>::SelectionTemplate() = default;
34 30
35 template <typename Strategy> 31 template <typename Strategy>
36 bool SelectionTemplate<Strategy>::operator==( 32 bool SelectionTemplate<Strategy>::operator==(
37 const SelectionTemplate& other) const { 33 const SelectionTemplate& other) const {
38 DCHECK(AssertValid()); 34 DCHECK(AssertValid());
39 DCHECK(other.AssertValid()); 35 DCHECK(other.AssertValid());
40 if (IsNone()) 36 if (IsNone())
41 return other.IsNone(); 37 return other.IsNone();
42 if (other.IsNone()) 38 if (other.IsNone())
43 return false; 39 return false;
44 DCHECK_EQ(base_.GetDocument(), other.GetDocument()) << *this << ' ' << other; 40 DCHECK_EQ(base_.GetDocument(), other.GetDocument()) << *this << ' ' << other;
45 return base_ == other.base_ && extent_ == other.extent_ && 41 return base_ == other.base_ && extent_ == other.extent_ &&
46 affinity_ == other.affinity_ && granularity_ == other.granularity_ && 42 affinity_ == other.affinity_ && granularity_ == other.granularity_ &&
47 has_trailing_whitespace_ == other.has_trailing_whitespace_ &&
48 is_directional_ == other.is_directional_ && 43 is_directional_ == other.is_directional_ &&
49 is_handle_visible_ == other.is_handle_visible_; 44 is_handle_visible_ == other.is_handle_visible_;
50 } 45 }
51 46
52 template <typename Strategy> 47 template <typename Strategy>
53 bool SelectionTemplate<Strategy>::operator!=( 48 bool SelectionTemplate<Strategy>::operator!=(
54 const SelectionTemplate& other) const { 49 const SelectionTemplate& other) const {
55 return !operator==(other); 50 return !operator==(other);
56 } 51 }
57 52
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 template <typename Strategy> 305 template <typename Strategy>
311 typename SelectionTemplate<Strategy>::Builder& 306 typename SelectionTemplate<Strategy>::Builder&
312 SelectionTemplate<Strategy>::Builder::SetGranularity( 307 SelectionTemplate<Strategy>::Builder::SetGranularity(
313 TextGranularity granularity) { 308 TextGranularity granularity) {
314 selection_.granularity_ = granularity; 309 selection_.granularity_ = granularity;
315 return *this; 310 return *this;
316 } 311 }
317 312
318 template <typename Strategy> 313 template <typename Strategy>
319 typename SelectionTemplate<Strategy>::Builder& 314 typename SelectionTemplate<Strategy>::Builder&
320 SelectionTemplate<Strategy>::Builder::SetHasTrailingWhitespace(
321 bool has_trailing_whitespace) {
322 selection_.has_trailing_whitespace_ = has_trailing_whitespace;
323 return *this;
324 }
325
326 template <typename Strategy>
327 typename SelectionTemplate<Strategy>::Builder&
328 SelectionTemplate<Strategy>::Builder::SetIsDirectional(bool is_directional) { 315 SelectionTemplate<Strategy>::Builder::SetIsDirectional(bool is_directional) {
329 selection_.is_directional_ = is_directional; 316 selection_.is_directional_ = is_directional;
330 return *this; 317 return *this;
331 } 318 }
332 319
333 template <typename Strategy> 320 template <typename Strategy>
334 typename SelectionTemplate<Strategy>::Builder& 321 typename SelectionTemplate<Strategy>::Builder&
335 SelectionTemplate<Strategy>::Builder::SetIsHandleVisible( 322 SelectionTemplate<Strategy>::Builder::SetIsHandleVisible(
336 bool is_handle_visible) { 323 bool is_handle_visible) {
337 selection_.is_handle_visible_ = is_handle_visible; 324 selection_.is_handle_visible_ = is_handle_visible;
338 return *this; 325 return *this;
339 } 326 }
340 327
341 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; 328 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>;
342 template class CORE_TEMPLATE_EXPORT 329 template class CORE_TEMPLATE_EXPORT
343 SelectionTemplate<EditingInFlatTreeStrategy>; 330 SelectionTemplate<EditingInFlatTreeStrategy>;
344 331
345 } // namespace blink 332 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698