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

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

Issue 2646963002: Stop dismissing selection handles when selection is kept (Closed)
Patch Set: avoid control flow in IMC and rebase Created 3 years, 11 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 "wtf/Assertions.h" 7 #include "wtf/Assertions.h"
8 #include <ostream> // NOLINT 8 #include <ostream> // NOLINT
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 : m_base(other.m_base), 14 : m_base(other.m_base),
15 m_extent(other.m_extent), 15 m_extent(other.m_extent),
16 m_affinity(other.m_affinity), 16 m_affinity(other.m_affinity),
17 m_granularity(other.m_granularity), 17 m_granularity(other.m_granularity),
18 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace), 18 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace),
19 m_isDirectional(other.m_isDirectional) 19 m_isDirectional(other.m_isDirectional),
20 m_isHandleVisible(other.m_isHandleVisible)
yosin_UTC9 2017/01/25 03:49:08 Please move this change in another patch and test
Changwan Ryu 2017/02/08 00:40:33 This is fixed in amaralp@'s patch.
20 #if DCHECK_IS_ON() 21 #if DCHECK_IS_ON()
21 , 22 ,
22 m_domTreeVersion(other.m_domTreeVersion) 23 m_domTreeVersion(other.m_domTreeVersion)
23 #endif 24 #endif
24 { 25 {
25 DCHECK(other.assertValid()); 26 DCHECK(other.assertValid());
26 if (!m_hasTrailingWhitespace) 27 if (!m_hasTrailingWhitespace)
27 return; 28 return;
28 DCHECK_EQ(m_granularity, WordGranularity) << *this; 29 DCHECK_EQ(m_granularity, WordGranularity) << *this;
29 } 30 }
30 31
31 template <typename Strategy> 32 template <typename Strategy>
32 SelectionTemplate<Strategy>::SelectionTemplate() = default; 33 SelectionTemplate<Strategy>::SelectionTemplate() = default;
33 34
34 template <typename Strategy> 35 template <typename Strategy>
35 bool SelectionTemplate<Strategy>::operator==( 36 bool SelectionTemplate<Strategy>::operator==(
36 const SelectionTemplate& other) const { 37 const SelectionTemplate& other) const {
37 DCHECK(assertValid()); 38 DCHECK(assertValid());
38 DCHECK(other.assertValid()); 39 DCHECK(other.assertValid());
39 if (isNone()) 40 if (isNone())
40 return other.isNone(); 41 return other.isNone();
41 if (other.isNone()) 42 if (other.isNone())
42 return false; 43 return false;
43 DCHECK_EQ(m_base.document(), other.document()) << *this << ' ' << other; 44 DCHECK_EQ(m_base.document(), other.document()) << *this << ' ' << other;
44 return m_base == other.m_base && m_extent == other.m_extent && 45 return m_base == other.m_base && m_extent == other.m_extent &&
45 m_affinity == other.m_affinity && 46 m_affinity == other.m_affinity &&
46 m_granularity == other.m_granularity && 47 m_granularity == other.m_granularity &&
47 m_hasTrailingWhitespace == other.m_hasTrailingWhitespace && 48 m_hasTrailingWhitespace == other.m_hasTrailingWhitespace &&
48 m_isDirectional == other.m_isDirectional; 49 m_isDirectional == other.m_isDirectional &&
50 m_isHandleVisible == other.m_isHandleVisible;
49 } 51 }
50 52
51 template <typename Strategy> 53 template <typename Strategy>
52 bool SelectionTemplate<Strategy>::operator!=( 54 bool SelectionTemplate<Strategy>::operator!=(
53 const SelectionTemplate& other) const { 55 const SelectionTemplate& other) const {
54 return !operator==(other); 56 return !operator==(other);
55 } 57 }
56 58
57 template <typename Strategy> 59 template <typename Strategy>
58 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::base() const { 60 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::base() const {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return *this; 280 return *this;
279 } 281 }
280 282
281 template <typename Strategy> 283 template <typename Strategy>
282 typename SelectionTemplate<Strategy>::Builder& 284 typename SelectionTemplate<Strategy>::Builder&
283 SelectionTemplate<Strategy>::Builder::setIsDirectional(bool isDirectional) { 285 SelectionTemplate<Strategy>::Builder::setIsDirectional(bool isDirectional) {
284 m_selection.m_isDirectional = isDirectional; 286 m_selection.m_isDirectional = isDirectional;
285 return *this; 287 return *this;
286 } 288 }
287 289
290 template <typename Strategy>
291 typename SelectionTemplate<Strategy>::Builder&
292 SelectionTemplate<Strategy>::Builder::setIsHandleVisible(bool isHandleVisible) {
293 m_selection.m_isHandleVisible = isHandleVisible;
294 return *this;
295 }
296
288 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; 297 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>;
289 template class CORE_TEMPLATE_EXPORT 298 template class CORE_TEMPLATE_EXPORT
290 SelectionTemplate<EditingInFlatTreeStrategy>; 299 SelectionTemplate<EditingInFlatTreeStrategy>;
291 300
292 } // namespace blink 301 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698