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

Side by Side Diff: Source/core/editing/EphemeralRange.h

Issue 1318913004: [CodeHealth][Editing] Refactor EphemeralRange::isNull/isNotNull impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/core/editing/EphemeralRange.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef EphemeralRange_h 5 #ifndef EphemeralRange_h
6 #define EphemeralRange_h 6 #define EphemeralRange_h
7 7
8 #include "core/editing/Position.h" 8 #include "core/editing/Position.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 22 matching lines...) Expand all
33 // Because of |Range| objects consume heap memory and inserted into |Range| 33 // Because of |Range| objects consume heap memory and inserted into |Range|
34 // object list in |Document| for relocation. These operations are redundant 34 // object list in |Document| for relocation. These operations are redundant
35 // if |Range| objects doesn't live after DOM mutation. 35 // if |Range| objects doesn't live after DOM mutation.
36 // 36 //
37 template <typename Strategy> 37 template <typename Strategy>
38 class CORE_TEMPLATE_CLASS_EXPORT EphemeralRangeTemplate final { 38 class CORE_TEMPLATE_CLASS_EXPORT EphemeralRangeTemplate final {
39 STACK_ALLOCATED(); 39 STACK_ALLOCATED();
40 public: 40 public:
41 EphemeralRangeTemplate(const PositionAlgorithm<Strategy>& start, const Posit ionAlgorithm<Strategy>& end); 41 EphemeralRangeTemplate(const PositionAlgorithm<Strategy>& start, const Posit ionAlgorithm<Strategy>& end);
42 EphemeralRangeTemplate(const EphemeralRangeTemplate& other); 42 EphemeralRangeTemplate(const EphemeralRangeTemplate& other);
43 // |position| should be null or in-document. 43 // |position| should be |Position::isNull()| or in-document.
44 explicit EphemeralRangeTemplate(const PositionAlgorithm<Strategy>& /* positi on */); 44 explicit EphemeralRangeTemplate(const PositionAlgorithm<Strategy>& /* positi on */);
45 // When |range| is nullptr, |EphemeralRangeTemplate| is null. 45 // When |range| is nullptr, |EphemeralRangeTemplate| is |isNull()|.
46 explicit EphemeralRangeTemplate(const Range* /* range */); 46 explicit EphemeralRangeTemplate(const Range* /* range */);
47 EphemeralRangeTemplate(); 47 EphemeralRangeTemplate();
48 ~EphemeralRangeTemplate(); 48 ~EphemeralRangeTemplate();
49 49
50 EphemeralRangeTemplate<Strategy>& operator=(const EphemeralRangeTemplate<Str ategy>& other); 50 EphemeralRangeTemplate<Strategy>& operator=(const EphemeralRangeTemplate<Str ategy>& other);
51 51
52 bool operator==(const EphemeralRangeTemplate<Strategy>& other) const; 52 bool operator==(const EphemeralRangeTemplate<Strategy>& other) const;
53 bool operator!=(const EphemeralRangeTemplate<Strategy>& other) const; 53 bool operator!=(const EphemeralRangeTemplate<Strategy>& other) const;
54 54
55 Document& document() const; 55 Document& document() const;
56 PositionAlgorithm<Strategy> startPosition() const; 56 PositionAlgorithm<Strategy> startPosition() const;
57 PositionAlgorithm<Strategy> endPosition() const; 57 PositionAlgorithm<Strategy> endPosition() const;
58 58
59 // Returns true if |m_startPositoin| == |m_endPosition| or |isNull()|. 59 // Returns true if |m_startPositoin| == |m_endPosition| or |isNull()|.
60 bool isCollapsed() const; 60 bool isCollapsed() const;
61 bool isNull() const { return !isNotNull(); } 61 bool isNull() const
62 bool isNotNull() const; 62 {
63 ASSERT(isValid());
64 return m_startPosition.isNull();
65 }
66 bool isNotNull() const { return !isNull(); }
63 67
64 DEFINE_INLINE_TRACE() 68 DEFINE_INLINE_TRACE()
65 { 69 {
66 visitor->trace(m_startPosition); 70 visitor->trace(m_startPosition);
67 visitor->trace(m_endPosition); 71 visitor->trace(m_endPosition);
68 } 72 }
69 73
70 // |node| should be in-document and valid for anchor node of 74 // |node| should be in-document and valid for anchor node of
71 // |PositionAlgorithm<Strategy>|. 75 // |PositionAlgorithm<Strategy>|.
72 static EphemeralRangeTemplate<Strategy> rangeOfContents(const Node& /* node */); 76 static EphemeralRangeTemplate<Strategy> rangeOfContents(const Node& /* node */);
(...skipping 14 matching lines...) Expand all
87 extern template class CORE_EXTERN_TEMPLATE_EXPORT EphemeralRangeTemplate<Editing InComposedTreeStrategy>; 91 extern template class CORE_EXTERN_TEMPLATE_EXPORT EphemeralRangeTemplate<Editing InComposedTreeStrategy>;
88 using EphemeralRangeInComposedTree = EphemeralRangeTemplate<EditingInComposedTre eStrategy>; 92 using EphemeralRangeInComposedTree = EphemeralRangeTemplate<EditingInComposedTre eStrategy>;
89 93
90 // Returns a newly created |Range| object from |range| or |nullptr| if 94 // Returns a newly created |Range| object from |range| or |nullptr| if
91 // |range.isNull()| returns true. 95 // |range.isNull()| returns true.
92 CORE_EXPORT PassRefPtrWillBeRawPtr<Range> createRange(const EphemeralRange& /* r ange */); 96 CORE_EXPORT PassRefPtrWillBeRawPtr<Range> createRange(const EphemeralRange& /* r ange */);
93 97
94 } // namespace blink 98 } // namespace blink
95 99
96 #endif 100 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/EphemeralRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698