OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // |createVisiblePositionDeprecated()|, we should not use |create()|. | 75 // |createVisiblePositionDeprecated()|, we should not use |create()|. |
76 static VisiblePositionTemplate create(const PositionWithAffinityTemplate<Str
ategy>&); | 76 static VisiblePositionTemplate create(const PositionWithAffinityTemplate<Str
ategy>&); |
77 | 77 |
78 // Intentionally delete |operator==()| and |operator!=()| for reducing | 78 // Intentionally delete |operator==()| and |operator!=()| for reducing |
79 // compilation error message. | 79 // compilation error message. |
80 // TODO(yosin) We'll have |equals()| when we have use cases of checking | 80 // TODO(yosin) We'll have |equals()| when we have use cases of checking |
81 // equality of both position and affinity. | 81 // equality of both position and affinity. |
82 bool operator==(const VisiblePositionTemplate&) const = delete; | 82 bool operator==(const VisiblePositionTemplate&) const = delete; |
83 bool operator!=(const VisiblePositionTemplate&) const = delete; | 83 bool operator!=(const VisiblePositionTemplate&) const = delete; |
84 | 84 |
| 85 bool isValid() const; |
| 86 |
| 87 // TODO(xiaochengh): We should have |DCHECK(isValid())| in the following |
| 88 // functions. However, there are some clients storing a VisiblePosition and |
| 89 // inspecting its properties after mutation. This should be fixed. |
85 bool isNull() const { return m_positionWithAffinity.isNull(); } | 90 bool isNull() const { return m_positionWithAffinity.isNull(); } |
86 bool isNotNull() const { return m_positionWithAffinity.isNotNull(); } | 91 bool isNotNull() const { return m_positionWithAffinity.isNotNull(); } |
87 bool isOrphan() const { return deepEquivalent().isOrphan(); } | 92 bool isOrphan() const { return deepEquivalent().isOrphan(); } |
88 | 93 |
89 PositionTemplate<Strategy> deepEquivalent() const { return m_positionWithAff
inity.position(); } | 94 PositionTemplate<Strategy> deepEquivalent() const { return m_positionWithAff
inity.position(); } |
90 PositionTemplate<Strategy> toParentAnchoredPosition() const { return deepEqu
ivalent().parentAnchoredEquivalent(); } | 95 PositionTemplate<Strategy> toParentAnchoredPosition() const { return deepEqu
ivalent().parentAnchoredEquivalent(); } |
91 PositionWithAffinityTemplate<Strategy> toPositionWithAffinity() const { retu
rn m_positionWithAffinity; } | 96 PositionWithAffinityTemplate<Strategy> toPositionWithAffinity() const { retu
rn m_positionWithAffinity; } |
92 TextAffinity affinity() const { return m_positionWithAffinity.affinity(); } | 97 TextAffinity affinity() const { return m_positionWithAffinity.affinity(); } |
93 | 98 |
94 static VisiblePositionTemplate<Strategy> afterNode(Node*); | 99 static VisiblePositionTemplate<Strategy> afterNode(Node*); |
95 static VisiblePositionTemplate<Strategy> beforeNode(Node*); | 100 static VisiblePositionTemplate<Strategy> beforeNode(Node*); |
96 static VisiblePositionTemplate<Strategy> firstPositionInNode(Node*); | 101 static VisiblePositionTemplate<Strategy> firstPositionInNode(Node*); |
97 static VisiblePositionTemplate<Strategy> inParentAfterNode(const Node&); | 102 static VisiblePositionTemplate<Strategy> inParentAfterNode(const Node&); |
98 static VisiblePositionTemplate<Strategy> inParentBeforeNode(const Node&); | 103 static VisiblePositionTemplate<Strategy> inParentBeforeNode(const Node&); |
99 static VisiblePositionTemplate<Strategy> lastPositionInNode(Node*); | 104 static VisiblePositionTemplate<Strategy> lastPositionInNode(Node*); |
100 | 105 |
101 DEFINE_INLINE_TRACE() | 106 DEFINE_INLINE_TRACE() |
102 { | 107 { |
103 visitor->trace(m_positionWithAffinity); | 108 visitor->trace(m_positionWithAffinity); |
104 } | 109 } |
105 | 110 |
106 #ifndef NDEBUG | 111 #ifndef NDEBUG |
107 void showTreeForThis() const; | 112 void showTreeForThis() const; |
108 #endif | 113 #endif |
109 | 114 |
110 private: | 115 private: |
111 explicit VisiblePositionTemplate(const PositionWithAffinityTemplate<Strategy
>&); | 116 explicit VisiblePositionTemplate(const PositionWithAffinityTemplate<Strategy
>&); |
112 | 117 |
113 PositionWithAffinityTemplate<Strategy> m_positionWithAffinity; | 118 PositionWithAffinityTemplate<Strategy> m_positionWithAffinity; |
| 119 |
| 120 #if DCHECK_IS_ON() |
| 121 uint64_t m_domTreeVersion; |
| 122 uint64_t m_styleVersion; |
| 123 #endif |
114 }; | 124 }; |
115 | 125 |
116 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin
gStrategy>; | 126 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin
gStrategy>; |
117 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin
gInFlatTreeStrategy>; | 127 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin
gInFlatTreeStrategy>; |
118 | 128 |
119 using VisiblePosition = VisiblePositionTemplate<EditingStrategy>; | 129 using VisiblePosition = VisiblePositionTemplate<EditingStrategy>; |
120 using VisiblePositionInFlatTree = VisiblePositionTemplate<EditingInFlatTreeStrat
egy>; | 130 using VisiblePositionInFlatTree = VisiblePositionTemplate<EditingInFlatTreeStrat
egy>; |
121 | 131 |
122 // |createVisiblePositionDeprecated| updates layout before creating the | 132 // |createVisiblePositionDeprecated| updates layout before creating the |
123 // VisiblePosition, which messes up the rendering pipeline. The callers should | 133 // VisiblePosition, which messes up the rendering pipeline. The callers should |
(...skipping 13 matching lines...) Expand all Loading... |
137 | 147 |
138 } // namespace blink | 148 } // namespace blink |
139 | 149 |
140 #ifndef NDEBUG | 150 #ifndef NDEBUG |
141 // Outside the WebCore namespace for ease of invocation from gdb. | 151 // Outside the WebCore namespace for ease of invocation from gdb. |
142 void showTree(const blink::VisiblePosition*); | 152 void showTree(const blink::VisiblePosition*); |
143 void showTree(const blink::VisiblePosition&); | 153 void showTree(const blink::VisiblePosition&); |
144 #endif | 154 #endif |
145 | 155 |
146 #endif // VisiblePosition_h | 156 #endif // VisiblePosition_h |
OLD | NEW |