| 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/BidiContext.h" | 25 #include "platform/text/BidiContext.h" |
| 26 #include "platform/text/BidiRunList.h" | 26 #include "platform/text/BidiRunList.h" |
| 27 #include "platform/text/TextDirection.h" | 27 #include "platform/text/TextDirection.h" |
| 28 #include "wtf/HashMap.h" |
| 28 #include "wtf/Noncopyable.h" | 29 #include "wtf/Noncopyable.h" |
| 29 #include "wtf/PassRefPtr.h" | 30 #include "wtf/PassRefPtr.h" |
| 30 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
| 31 | 32 |
| 32 namespace WebCore { | 33 namespace WebCore { |
| 33 | 34 |
| 34 template <class Iterator> struct MidpointState { | 35 template <class Iterator> struct MidpointState { |
| 35 MidpointState() | 36 MidpointState() |
| 36 { | 37 { |
| 37 reset(); | 38 reset(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // FIXME: This used to be part of deleteRuns() but was a layering violation. | 219 // FIXME: This used to be part of deleteRuns() but was a layering violation. |
| 219 // It's unclear if this is still needed. | 220 // It's unclear if this is still needed. |
| 220 void markCurrentRunEmpty() { m_emptyRun = true; } | 221 void markCurrentRunEmpty() { m_emptyRun = true; } |
| 221 | 222 |
| 222 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; } | 223 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; } |
| 223 | 224 |
| 224 bool isEndOfParagraph(const Iterator& end) { return m_current == end || m_cu
rrent.atEnd(); } | 225 bool isEndOfParagraph(const Iterator& end) { return m_current == end || m_cu
rrent.atEnd(); } |
| 225 | 226 |
| 226 TextDirection determineParagraphDirectionality(bool* hasStrongDirectionality
= 0); | 227 TextDirection determineParagraphDirectionality(bool* hasStrongDirectionality
= 0); |
| 227 | 228 |
| 229 void setMidpointStateForIsolatedRun(Run*, const MidpointState<Iterator>&); |
| 230 MidpointState<Iterator> midpointStateForIsolatedRun(Run*); |
| 231 |
| 228 protected: | 232 protected: |
| 229 void increment() { m_current.increment(); } | 233 void increment() { m_current.increment(); } |
| 230 // FIXME: Instead of InlineBidiResolvers subclassing this method, we should | 234 // FIXME: Instead of InlineBidiResolvers subclassing this method, we should |
| 231 // pass in some sort of Traits object which knows how to create runs for app
ending. | 235 // pass in some sort of Traits object which knows how to create runs for app
ending. |
| 232 void appendRun(); | 236 void appendRun(); |
| 233 | 237 |
| 234 Iterator m_current; | 238 Iterator m_current; |
| 235 // sor and eor are "start of run" and "end of run" respectively and correpon
d | 239 // sor and eor are "start of run" and "end of run" respectively and correpon
d |
| 236 // to abreviations used in UBA spec: http://unicode.org/reports/tr9/#BD7 | 240 // to abreviations used in UBA spec: http://unicode.org/reports/tr9/#BD7 |
| 237 Iterator m_sor; // Points to the first character in the current run. | 241 Iterator m_sor; // Points to the first character in the current run. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 255 | 259 |
| 256 private: | 260 private: |
| 257 void raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode:
:Direction to); | 261 void raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode:
:Direction to); |
| 258 void lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from); | 262 void lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from); |
| 259 void checkDirectionInLowerRaiseEmbeddingLevel(); | 263 void checkDirectionInLowerRaiseEmbeddingLevel(); |
| 260 | 264 |
| 261 void updateStatusLastFromCurrentDirection(WTF::Unicode::Direction); | 265 void updateStatusLastFromCurrentDirection(WTF::Unicode::Direction); |
| 262 void reorderRunsFromLevels(); | 266 void reorderRunsFromLevels(); |
| 263 | 267 |
| 264 Vector<BidiEmbedding, 8> m_currentExplicitEmbeddingSequence; | 268 Vector<BidiEmbedding, 8> m_currentExplicitEmbeddingSequence; |
| 269 HashMap<Run *, MidpointState<Iterator> > m_midpointStateForIsolatedRun; |
| 265 }; | 270 }; |
| 266 | 271 |
| 267 #ifndef NDEBUG | 272 #ifndef NDEBUG |
| 268 template <class Iterator, class Run> | 273 template <class Iterator, class Run> |
| 269 BidiResolver<Iterator, Run>::~BidiResolver() | 274 BidiResolver<Iterator, Run>::~BidiResolver() |
| 270 { | 275 { |
| 271 // The owner of this resolver should have handled the isolated runs. | 276 // The owner of this resolver should have handled the isolated runs. |
| 272 ASSERT(m_isolatedRuns.isEmpty()); | 277 ASSERT(m_isolatedRuns.isEmpty()); |
| 273 } | 278 } |
| 274 #endif | 279 #endif |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 break; | 955 break; |
| 951 } | 956 } |
| 952 } | 957 } |
| 953 } | 958 } |
| 954 | 959 |
| 955 m_runs.setLogicallyLastRun(m_runs.lastRun()); | 960 m_runs.setLogicallyLastRun(m_runs.lastRun()); |
| 956 reorderRunsFromLevels(); | 961 reorderRunsFromLevels(); |
| 957 endOfLine = Iterator(); | 962 endOfLine = Iterator(); |
| 958 } | 963 } |
| 959 | 964 |
| 965 template <class Iterator, class Run> |
| 966 void BidiResolver<Iterator, Run>::setMidpointStateForIsolatedRun(Run* run, const
MidpointState<Iterator>& midpoint) |
| 967 { |
| 968 ASSERT(!m_midpointStateForIsolatedRun.contains(run)); |
| 969 m_midpointStateForIsolatedRun.add(run, midpoint); |
| 970 } |
| 971 |
| 972 template<class Iterator, class Run> |
| 973 MidpointState<Iterator> BidiResolver<Iterator, Run>::midpointStateForIsolatedRun
(Run* run) |
| 974 { |
| 975 return m_midpointStateForIsolatedRun.take(run); |
| 976 } |
| 977 |
| 978 |
| 960 } // namespace WebCore | 979 } // namespace WebCore |
| 961 | 980 |
| 962 #endif // BidiResolver_h | 981 #endif // BidiResolver_h |
| OLD | NEW |