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 * Copyright (C) 2011 Google, Inc. All rights reserved. | 4 * Copyright (C) 2011 Google, Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (!m_firstRun) | 74 if (!m_firstRun) |
75 m_firstRun = run; | 75 m_firstRun = run; |
76 else | 76 else |
77 m_lastRun->m_next = run; | 77 m_lastRun->m_next = run; |
78 m_lastRun = run; | 78 m_lastRun = run; |
79 m_runCount++; | 79 m_runCount++; |
80 } | 80 } |
81 | 81 |
82 template <class Run> | 82 template <class Run> |
83 inline void BidiRunList<Run>::prependRun(Run* run) { | 83 inline void BidiRunList<Run>::prependRun(Run* run) { |
84 ASSERT(!run->m_next); | 84 DCHECK(!run->m_next); |
85 | 85 |
86 if (!m_lastRun) | 86 if (!m_lastRun) |
87 m_lastRun = run; | 87 m_lastRun = run; |
88 else | 88 else |
89 run->m_next = m_firstRun; | 89 run->m_next = m_firstRun; |
90 m_firstRun = run; | 90 m_firstRun = run; |
91 m_runCount++; | 91 m_runCount++; |
92 } | 92 } |
93 | 93 |
94 template <class Run> | 94 template <class Run> |
95 inline void BidiRunList<Run>::moveRunToEnd(Run* run) { | 95 inline void BidiRunList<Run>::moveRunToEnd(Run* run) { |
96 ASSERT(m_firstRun); | 96 DCHECK(m_firstRun); |
97 ASSERT(m_lastRun); | 97 DCHECK(m_lastRun); |
98 ASSERT(run->m_next); | 98 DCHECK(run->m_next); |
99 | 99 |
100 Run* current = 0; | 100 Run* current = 0; |
101 Run* next = m_firstRun; | 101 Run* next = m_firstRun; |
102 while (next != run) { | 102 while (next != run) { |
103 current = next; | 103 current = next; |
104 next = current->next(); | 104 next = current->next(); |
105 } | 105 } |
106 | 106 |
107 if (!current) | 107 if (!current) |
108 m_firstRun = run->next(); | 108 m_firstRun = run->next(); |
109 else | 109 else |
110 current->m_next = run->m_next; | 110 current->m_next = run->m_next; |
111 | 111 |
112 run->m_next = 0; | 112 run->m_next = 0; |
113 m_lastRun->m_next = run; | 113 m_lastRun->m_next = run; |
114 m_lastRun = run; | 114 m_lastRun = run; |
115 } | 115 } |
116 | 116 |
117 template <class Run> | 117 template <class Run> |
118 inline void BidiRunList<Run>::moveRunToBeginning(Run* run) { | 118 inline void BidiRunList<Run>::moveRunToBeginning(Run* run) { |
119 ASSERT(m_firstRun); | 119 DCHECK(m_firstRun); |
120 ASSERT(m_lastRun); | 120 DCHECK(m_lastRun); |
121 ASSERT(run != m_firstRun); | 121 DCHECK_NE(run, m_firstRun); |
122 | 122 |
123 Run* current = m_firstRun; | 123 Run* current = m_firstRun; |
124 Run* next = current->next(); | 124 Run* next = current->next(); |
125 while (next != run) { | 125 while (next != run) { |
126 current = next; | 126 current = next; |
127 next = current->next(); | 127 next = current->next(); |
128 } | 128 } |
129 | 129 |
130 current->m_next = run->m_next; | 130 current->m_next = run->m_next; |
131 if (run == m_lastRun) | 131 if (run == m_lastRun) |
132 m_lastRun = current; | 132 m_lastRun = current; |
133 | 133 |
134 run->m_next = m_firstRun; | 134 run->m_next = m_firstRun; |
135 m_firstRun = run; | 135 m_firstRun = run; |
136 } | 136 } |
137 | 137 |
138 template <class Run> | 138 template <class Run> |
139 void BidiRunList<Run>::replaceRunWithRuns(Run* toReplace, | 139 void BidiRunList<Run>::replaceRunWithRuns(Run* toReplace, |
140 BidiRunList<Run>& newRuns) { | 140 BidiRunList<Run>& newRuns) { |
141 ASSERT(newRuns.runCount()); | 141 DCHECK(newRuns.runCount()); |
142 ASSERT(m_firstRun); | 142 DCHECK(m_firstRun); |
143 ASSERT(toReplace); | 143 DCHECK(toReplace); |
144 | 144 |
145 if (m_firstRun == toReplace) { | 145 if (m_firstRun == toReplace) { |
146 m_firstRun = newRuns.firstRun(); | 146 m_firstRun = newRuns.firstRun(); |
147 } else { | 147 } else { |
148 // Find the run just before "toReplace" in the list of runs. | 148 // Find the run just before "toReplace" in the list of runs. |
149 Run* previousRun = m_firstRun; | 149 Run* previousRun = m_firstRun; |
150 while (previousRun->next() != toReplace) | 150 while (previousRun->next() != toReplace) |
151 previousRun = previousRun->next(); | 151 previousRun = previousRun->next(); |
152 ASSERT(previousRun); | 152 DCHECK(previousRun); |
153 previousRun->setNext(newRuns.firstRun()); | 153 previousRun->setNext(newRuns.firstRun()); |
154 } | 154 } |
155 | 155 |
156 newRuns.lastRun()->setNext(toReplace->next()); | 156 newRuns.lastRun()->setNext(toReplace->next()); |
157 | 157 |
158 // Fix up any of other pointers which may now be stale. | 158 // Fix up any of other pointers which may now be stale. |
159 if (m_lastRun == toReplace) | 159 if (m_lastRun == toReplace) |
160 m_lastRun = newRuns.lastRun(); | 160 m_lastRun = newRuns.lastRun(); |
161 if (m_logicallyLastRun == toReplace) | 161 if (m_logicallyLastRun == toReplace) |
162 m_logicallyLastRun = newRuns.logicallyLastRun(); | 162 m_logicallyLastRun = newRuns.logicallyLastRun(); |
(...skipping 22 matching lines...) Expand all Loading... |
185 Run* s = curr->next(); | 185 Run* s = curr->next(); |
186 delete curr; | 186 delete curr; |
187 curr = s; | 187 curr = s; |
188 } | 188 } |
189 | 189 |
190 clearWithoutDestroyingRuns(); | 190 clearWithoutDestroyingRuns(); |
191 } | 191 } |
192 | 192 |
193 template <class Run> | 193 template <class Run> |
194 void BidiRunList<Run>::reverseRuns(unsigned start, unsigned end) { | 194 void BidiRunList<Run>::reverseRuns(unsigned start, unsigned end) { |
195 ASSERT(m_runCount); | 195 DCHECK(m_runCount); |
196 if (start >= end) | 196 if (start >= end) |
197 return; | 197 return; |
198 | 198 |
199 ASSERT(end < m_runCount); | 199 DCHECK_LT(end, m_runCount); |
200 | 200 |
201 // Get the item before the start of the runs to reverse and put it in | 201 // Get the item before the start of the runs to reverse and put it in |
202 // |beforeStart|. |curr| should point to the first run to reverse. | 202 // |beforeStart|. |curr| should point to the first run to reverse. |
203 Run* curr = m_firstRun; | 203 Run* curr = m_firstRun; |
204 Run* beforeStart = 0; | 204 Run* beforeStart = 0; |
205 unsigned i = 0; | 205 unsigned i = 0; |
206 while (i < start) { | 206 while (i < start) { |
207 i++; | 207 i++; |
208 beforeStart = curr; | 208 beforeStart = curr; |
209 curr = curr->next(); | 209 curr = curr->next(); |
(...skipping 26 matching lines...) Expand all Loading... |
236 m_firstRun = endRun; | 236 m_firstRun = endRun; |
237 | 237 |
238 startRun->m_next = afterEnd; | 238 startRun->m_next = afterEnd; |
239 if (!afterEnd) | 239 if (!afterEnd) |
240 m_lastRun = startRun; | 240 m_lastRun = startRun; |
241 } | 241 } |
242 | 242 |
243 } // namespace blink | 243 } // namespace blink |
244 | 244 |
245 #endif // BidiRunList | 245 #endif // BidiRunList |
OLD | NEW |