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

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

Issue 1187073014: Templatize PositionWithAffinity class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-17T16:31:27 Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 PositionWithAffinity_h 5 #ifndef PositionWithAffinity_h
6 #define PositionWithAffinity_h 6 #define PositionWithAffinity_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/dom/Position.h" 9 #include "core/dom/Position.h"
10 #include "core/editing/TextAffinity.h" 10 #include "core/editing/TextAffinity.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class CORE_EXPORT PositionWithAffinity { 14 template <typename Position>
15 class CORE_TEMPLATE_CLASS_EXPORT PositionWithAffinityTemplate {
15 DISALLOW_ALLOCATION(); 16 DISALLOW_ALLOCATION();
16 public: 17 public:
17 PositionWithAffinity(const Position&, EAffinity = DOWNSTREAM); 18 typedef Position PositionType;
18 PositionWithAffinity(); 19
19 ~PositionWithAffinity(); 20 PositionWithAffinityTemplate(const PositionType&, EAffinity = DOWNSTREAM);
21 PositionWithAffinityTemplate();
22 ~PositionWithAffinityTemplate();
20 23
21 EAffinity affinity() const { return m_affinity; } 24 EAffinity affinity() const { return m_affinity; }
22 const Position& position() const { return m_position; } 25 const PositionType& position() const { return m_position; }
23 26
24 DECLARE_TRACE(); 27 DEFINE_INLINE_TRACE()
28 {
29 visitor->trace(m_position);
30 }
25 31
26 private: 32 private:
27 Position m_position; 33 PositionType m_position;
28 EAffinity m_affinity; 34 EAffinity m_affinity;
29 }; 35 };
30 36
37 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<P osition>;
38
39 using PositionWithAffinity = PositionWithAffinityTemplate<Position>;
40
31 } // namespace blink 41 } // namespace blink
32 42
33 #endif // PositionWithAffinity_h 43 #endif // PositionWithAffinity_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698