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

Side by Side Diff: third_party/WebKit/Source/platform/text/BidiRunList.h

Issue 2811453002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text (Closed)
Patch Set: fix Created 3 years, 8 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 /* 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
74 if (!first_run_) 74 if (!first_run_)
75 first_run_ = run; 75 first_run_ = run;
76 else 76 else
77 last_run_->next_ = run; 77 last_run_->next_ = run;
78 last_run_ = run; 78 last_run_ = run;
79 run_count_++; 79 run_count_++;
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->next_); 84 DCHECK(!run->next_);
85 85
86 if (!last_run_) 86 if (!last_run_)
87 last_run_ = run; 87 last_run_ = run;
88 else 88 else
89 run->next_ = first_run_; 89 run->next_ = first_run_;
90 first_run_ = run; 90 first_run_ = run;
91 run_count_++; 91 run_count_++;
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(first_run_); 96 DCHECK(first_run_);
97 ASSERT(last_run_); 97 DCHECK(last_run_);
98 ASSERT(run->next_); 98 DCHECK(run->next_);
99 99
100 Run* current = 0; 100 Run* current = 0;
101 Run* next = first_run_; 101 Run* next = first_run_;
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 first_run_ = run->Next(); 108 first_run_ = run->Next();
109 else 109 else
110 current->next_ = run->next_; 110 current->next_ = run->next_;
111 111
112 run->next_ = 0; 112 run->next_ = 0;
113 last_run_->next_ = run; 113 last_run_->next_ = run;
114 last_run_ = run; 114 last_run_ = 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(first_run_); 119 DCHECK(first_run_);
120 ASSERT(last_run_); 120 DCHECK(last_run_);
121 ASSERT(run != first_run_); 121 DCHECK_NE(run, first_run_);
122 122
123 Run* current = first_run_; 123 Run* current = first_run_;
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->next_ = run->next_; 130 current->next_ = run->next_;
131 if (run == last_run_) 131 if (run == last_run_)
132 last_run_ = current; 132 last_run_ = current;
133 133
134 run->next_ = first_run_; 134 run->next_ = first_run_;
135 first_run_ = run; 135 first_run_ = run;
136 } 136 }
137 137
138 template <class Run> 138 template <class Run>
139 void BidiRunList<Run>::ReplaceRunWithRuns(Run* to_replace, 139 void BidiRunList<Run>::ReplaceRunWithRuns(Run* to_replace,
140 BidiRunList<Run>& new_runs) { 140 BidiRunList<Run>& new_runs) {
141 ASSERT(new_runs.RunCount()); 141 DCHECK(new_runs.RunCount());
142 ASSERT(first_run_); 142 DCHECK(first_run_);
143 ASSERT(to_replace); 143 DCHECK(to_replace);
144 144
145 if (first_run_ == to_replace) { 145 if (first_run_ == to_replace) {
146 first_run_ = new_runs.FirstRun(); 146 first_run_ = new_runs.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* previous_run = first_run_; 149 Run* previous_run = first_run_;
150 while (previous_run->Next() != to_replace) 150 while (previous_run->Next() != to_replace)
151 previous_run = previous_run->Next(); 151 previous_run = previous_run->Next();
152 ASSERT(previous_run); 152 DCHECK(previous_run);
153 previous_run->SetNext(new_runs.FirstRun()); 153 previous_run->SetNext(new_runs.FirstRun());
154 } 154 }
155 155
156 new_runs.LastRun()->SetNext(to_replace->Next()); 156 new_runs.LastRun()->SetNext(to_replace->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 (last_run_ == to_replace) 159 if (last_run_ == to_replace)
160 last_run_ = new_runs.LastRun(); 160 last_run_ = new_runs.LastRun();
161 if (logically_last_run_ == to_replace) 161 if (logically_last_run_ == to_replace)
162 logically_last_run_ = new_runs.LogicallyLastRun(); 162 logically_last_run_ = new_runs.LogicallyLastRun();
(...skipping 22 matching lines...) Expand all
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(run_count_); 195 DCHECK(run_count_);
196 if (start >= end) 196 if (start >= end)
197 return; 197 return;
198 198
199 ASSERT(end < run_count_); 199 DCHECK_LT(end, run_count_);
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 = first_run_; 203 Run* curr = first_run_;
204 Run* before_start = 0; 204 Run* before_start = 0;
205 unsigned i = 0; 205 unsigned i = 0;
206 while (i < start) { 206 while (i < start) {
207 i++; 207 i++;
208 before_start = curr; 208 before_start = curr;
209 curr = curr->Next(); 209 curr = curr->Next();
(...skipping 26 matching lines...) Expand all
236 first_run_ = end_run; 236 first_run_ = end_run;
237 237
238 start_run->next_ = after_end; 238 start_run->next_ = after_end;
239 if (!after_end) 239 if (!after_end)
240 last_run_ = start_run; 240 last_run_ = start_run;
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
244 244
245 #endif // BidiRunList 245 #endif // BidiRunList
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/BidiResolverTest.cpp ('k') | third_party/WebKit/Source/platform/text/Character.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698