OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "wtf/text/CString.h" | 42 #include "wtf/text/CString.h" |
43 | 43 |
44 #ifndef NDEBUG | 44 #ifndef NDEBUG |
45 #include <stdio.h> | 45 #include <stdio.h> |
46 #endif | 46 #endif |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 using namespace HTMLNames; | 50 using namespace HTMLNames; |
51 | 51 |
52 VisiblePosition::VisiblePosition() | 52 template <typename Strategy> |
| 53 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate() |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
56 VisiblePosition::VisiblePosition(const PositionWithAffinity& positionWithAffinit
y) | 57 template <typename Strategy> |
| 58 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate(const PositionWithAff
inityTemplate<Strategy>& positionWithAffinity) |
57 : m_positionWithAffinity(positionWithAffinity) | 59 : m_positionWithAffinity(positionWithAffinity) |
58 { | 60 { |
59 } | 61 } |
60 | 62 |
61 VisiblePosition VisiblePosition::createWithoutCanonicalization(const PositionWit
hAffinity& canonicalized) | 63 template <typename Strategy> |
| 64 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::createWitho
utCanonicalization(const PositionWithAffinityTemplate<Strategy>& canonicalized) |
62 { | 65 { |
63 return VisiblePosition(canonicalized); | 66 return VisiblePositionTemplate<Strategy>(canonicalized); |
64 } | 67 } |
65 | 68 |
66 template<typename Strategy> | 69 template<typename Strategy> |
67 static PositionWithAffinityTemplate<Strategy> createVisiblePositionAlgorithm(con
st PositionAlgorithm<Strategy>& position, TextAffinity affinity) | 70 static PositionWithAffinityTemplate<Strategy> createVisiblePositionAlgorithm(con
st PositionAlgorithm<Strategy>& position, TextAffinity affinity) |
68 { | 71 { |
69 const PositionAlgorithm<Strategy> deepPosition = canonicalPositionOf(positio
n); | 72 const PositionAlgorithm<Strategy> deepPosition = canonicalPositionOf(positio
n); |
70 if (deepPosition.isNull()) | 73 if (deepPosition.isNull()) |
71 return PositionWithAffinityTemplate<Strategy>(); | 74 return PositionWithAffinityTemplate<Strategy>(); |
72 if (affinity == TextAffinity::Downstream) | 75 if (affinity == TextAffinity::Downstream) |
73 return PositionWithAffinityTemplate<Strategy>(deepPosition); | 76 return PositionWithAffinityTemplate<Strategy>(deepPosition); |
(...skipping 16 matching lines...) Expand all Loading... |
90 } | 93 } |
91 | 94 |
92 VisiblePosition createVisiblePosition(const PositionInComposedTree& position, Te
xtAffinity affinity) | 95 VisiblePosition createVisiblePosition(const PositionInComposedTree& position, Te
xtAffinity affinity) |
93 { | 96 { |
94 PositionInComposedTreeWithAffinity canonicalized = createVisiblePositionAlgo
rithm<EditingInComposedTreeStrategy>(position, affinity); | 97 PositionInComposedTreeWithAffinity canonicalized = createVisiblePositionAlgo
rithm<EditingInComposedTreeStrategy>(position, affinity); |
95 return VisiblePosition::createWithoutCanonicalization(PositionWithAffinity(t
oPositionInDOMTree(canonicalized.position()), canonicalized.affinity())); | 98 return VisiblePosition::createWithoutCanonicalization(PositionWithAffinity(t
oPositionInDOMTree(canonicalized.position()), canonicalized.affinity())); |
96 } | 99 } |
97 | 100 |
98 #ifndef NDEBUG | 101 #ifndef NDEBUG |
99 | 102 |
100 void VisiblePosition::debugPosition(const char* msg) const | 103 template<typename Strategy> |
| 104 void VisiblePositionTemplate<Strategy>::debugPosition(const char* msg) const |
101 { | 105 { |
102 if (isNull()) { | 106 if (isNull()) { |
103 fprintf(stderr, "Position [%s]: null\n", msg); | 107 fprintf(stderr, "Position [%s]: null\n", msg); |
104 return; | 108 return; |
105 } | 109 } |
106 deepEquivalent().debugPosition(msg); | 110 deepEquivalent().debugPosition(msg); |
107 } | 111 } |
108 | 112 |
109 void VisiblePosition::formatForDebugger(char* buffer, unsigned length) const | 113 template<typename Strategy> |
| 114 void VisiblePositionTemplate<Strategy>::formatForDebugger(char* buffer, unsigned
length) const |
110 { | 115 { |
111 deepEquivalent().formatForDebugger(buffer, length); | 116 deepEquivalent().formatForDebugger(buffer, length); |
112 } | 117 } |
113 | 118 |
114 void VisiblePosition::showTreeForThis() const | 119 template<typename Strategy> |
| 120 void VisiblePositionTemplate<Strategy>::showTreeForThis() const |
115 { | 121 { |
116 deepEquivalent().showTreeForThis(); | 122 deepEquivalent().showTreeForThis(); |
117 } | 123 } |
118 | 124 |
119 #endif | 125 #endif |
120 | 126 |
121 DEFINE_TRACE(VisiblePosition) | 127 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingStrategy>; |
122 { | |
123 visitor->trace(m_positionWithAffinity); | |
124 } | |
125 | 128 |
126 } // namespace blink | 129 } // namespace blink |
127 | 130 |
128 #ifndef NDEBUG | 131 #ifndef NDEBUG |
129 | 132 |
130 void showTree(const blink::VisiblePosition* vpos) | 133 void showTree(const blink::VisiblePosition* vpos) |
131 { | 134 { |
132 if (vpos) | 135 if (vpos) |
133 vpos->showTreeForThis(); | 136 vpos->showTreeForThis(); |
134 else | 137 else |
135 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); | 138 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); |
136 } | 139 } |
137 | 140 |
138 void showTree(const blink::VisiblePosition& vpos) | 141 void showTree(const blink::VisiblePosition& vpos) |
139 { | 142 { |
140 vpos.showTreeForThis(); | 143 vpos.showTreeForThis(); |
141 } | 144 } |
142 | 145 |
143 #endif | 146 #endif |
OLD | NEW |