OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #ifndef BidiResolver_h | 22 #ifndef BidiResolver_h |
23 #define BidiResolver_h | 23 #define BidiResolver_h |
24 | 24 |
25 #include "platform/text/BidiCharacterRun.h" | 25 #include "platform/text/BidiCharacterRun.h" |
26 #include "platform/text/BidiContext.h" | 26 #include "platform/text/BidiContext.h" |
27 #include "platform/text/BidiRunList.h" | 27 #include "platform/text/BidiRunList.h" |
28 #include "platform/text/TextDirection.h" | 28 #include "platform/text/TextDirection.h" |
| 29 #include "wtf/Allocator.h" |
29 #include "wtf/HashMap.h" | 30 #include "wtf/HashMap.h" |
30 #include "wtf/Noncopyable.h" | 31 #include "wtf/Noncopyable.h" |
31 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
32 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 class LayoutObject; | 37 class LayoutObject; |
37 | 38 |
38 template <class Iterator> class MidpointState { | 39 template <class Iterator> class MidpointState final { |
| 40 DISALLOW_NEW(); |
39 public: | 41 public: |
40 MidpointState() | 42 MidpointState() |
41 { | 43 { |
42 reset(); | 44 reset(); |
43 } | 45 } |
44 | 46 |
45 void reset() | 47 void reset() |
46 { | 48 { |
47 m_numMidpoints = 0; | 49 m_numMidpoints = 0; |
48 m_currentMidpoint = 0; | 50 m_currentMidpoint = 0; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (m_midpoints.size() <= m_numMidpoints) | 111 if (m_midpoints.size() <= m_numMidpoints) |
110 m_midpoints.grow(m_numMidpoints + 10); | 112 m_midpoints.grow(m_numMidpoints + 10); |
111 | 113 |
112 Iterator* midpointsIterator = m_midpoints.data(); | 114 Iterator* midpointsIterator = m_midpoints.data(); |
113 midpointsIterator[m_numMidpoints++] = midpoint; | 115 midpointsIterator[m_numMidpoints++] = midpoint; |
114 } | 116 } |
115 }; | 117 }; |
116 | 118 |
117 // The BidiStatus at a given position (typically the end of a line) can | 119 // The BidiStatus at a given position (typically the end of a line) can |
118 // be cached and then used to restart bidi resolution at that position. | 120 // be cached and then used to restart bidi resolution at that position. |
119 struct BidiStatus { | 121 struct BidiStatus final { |
| 122 DISALLOW_NEW(); |
120 BidiStatus() | 123 BidiStatus() |
121 : eor(WTF::Unicode::OtherNeutral) | 124 : eor(WTF::Unicode::OtherNeutral) |
122 , lastStrong(WTF::Unicode::OtherNeutral) | 125 , lastStrong(WTF::Unicode::OtherNeutral) |
123 , last(WTF::Unicode::OtherNeutral) | 126 , last(WTF::Unicode::OtherNeutral) |
124 { | 127 { |
125 } | 128 } |
126 | 129 |
127 // Creates a BidiStatus representing a new paragraph root with a default dir
ection. | 130 // Creates a BidiStatus representing a new paragraph root with a default dir
ection. |
128 // Uses TextDirection as it only has two possibilities instead of WTF::Unico
de::Direction which has 19. | 131 // Uses TextDirection as it only has two possibilities instead of WTF::Unico
de::Direction which has 19. |
129 BidiStatus(TextDirection textDirection, bool isOverride) | 132 BidiStatus(TextDirection textDirection, bool isOverride) |
(...skipping 29 matching lines...) Expand all Loading... |
159 // I doubt it matters. | 162 // I doubt it matters. |
160 return BidiStatus(direction, direction, direction, context.release()); | 163 return BidiStatus(direction, direction, direction, context.release()); |
161 } | 164 } |
162 | 165 |
163 WTF::Unicode::Direction eor; | 166 WTF::Unicode::Direction eor; |
164 WTF::Unicode::Direction lastStrong; | 167 WTF::Unicode::Direction lastStrong; |
165 WTF::Unicode::Direction last; | 168 WTF::Unicode::Direction last; |
166 RefPtr<BidiContext> context; | 169 RefPtr<BidiContext> context; |
167 }; | 170 }; |
168 | 171 |
169 class BidiEmbedding { | 172 class BidiEmbedding final { |
| 173 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
170 public: | 174 public: |
171 BidiEmbedding(WTF::Unicode::Direction direction, BidiEmbeddingSource source) | 175 BidiEmbedding(WTF::Unicode::Direction direction, BidiEmbeddingSource source) |
172 : m_direction(direction) | 176 : m_direction(direction) |
173 , m_source(source) | 177 , m_source(source) |
174 { | 178 { |
175 } | 179 } |
176 | 180 |
177 WTF::Unicode::Direction direction() const { return m_direction; } | 181 WTF::Unicode::Direction direction() const { return m_direction; } |
178 BidiEmbeddingSource source() const { return m_source; } | 182 BidiEmbeddingSource source() const { return m_source; } |
179 private: | 183 private: |
(...skipping 15 matching lines...) Expand all Loading... |
195 NoVisualOverride, | 199 NoVisualOverride, |
196 VisualLeftToRightOverride, | 200 VisualLeftToRightOverride, |
197 VisualRightToLeftOverride | 201 VisualRightToLeftOverride |
198 }; | 202 }; |
199 | 203 |
200 class NoIsolatedRun { | 204 class NoIsolatedRun { |
201 }; | 205 }; |
202 | 206 |
203 // BidiResolver is WebKit's implementation of the Unicode Bidi Algorithm | 207 // BidiResolver is WebKit's implementation of the Unicode Bidi Algorithm |
204 // http://unicode.org/reports/tr9 | 208 // http://unicode.org/reports/tr9 |
205 template <class Iterator, class Run, class IsolatedRun = NoIsolatedRun> class Bi
diResolver { | 209 template <class Iterator, class Run, class IsolatedRun = NoIsolatedRun> class Bi
diResolver final { |
| 210 DISALLOW_NEW(); |
206 WTF_MAKE_NONCOPYABLE(BidiResolver); | 211 WTF_MAKE_NONCOPYABLE(BidiResolver); |
207 public: | 212 public: |
208 BidiResolver() | 213 BidiResolver() |
209 : m_direction(WTF::Unicode::OtherNeutral) | 214 : m_direction(WTF::Unicode::OtherNeutral) |
210 , m_reachedEndOfLine(false) | 215 , m_reachedEndOfLine(false) |
211 , m_emptyRun(true) | 216 , m_emptyRun(true) |
212 , m_nestedIsolateCount(0) | 217 , m_nestedIsolateCount(0) |
213 , m_trailingSpaceRun(0) | 218 , m_trailingSpaceRun(0) |
214 { | 219 { |
215 } | 220 } |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 | 1127 |
1123 template<class Iterator, class Run, class IsolatedRun> | 1128 template<class Iterator, class Run, class IsolatedRun> |
1124 MidpointState<Iterator> BidiResolver<Iterator, Run, IsolatedRun>::midpointStateF
orIsolatedRun(Run& run) | 1129 MidpointState<Iterator> BidiResolver<Iterator, Run, IsolatedRun>::midpointStateF
orIsolatedRun(Run& run) |
1125 { | 1130 { |
1126 return m_midpointStateForIsolatedRun.take(&run); | 1131 return m_midpointStateForIsolatedRun.take(&run); |
1127 } | 1132 } |
1128 | 1133 |
1129 } // namespace blink | 1134 } // namespace blink |
1130 | 1135 |
1131 #endif // BidiResolver_h | 1136 #endif // BidiResolver_h |
OLD | NEW |