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

Side by Side Diff: Source/core/editing/VisiblePosition.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/TypingCommand.cpp ('k') | Source/core/editing/VisibleSelection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Position downstreamStart = p.downstream(); 128 Position downstreamStart = p.downstream();
129 TextDirection primaryDirection = p.primaryDirection(); 129 TextDirection primaryDirection = p.primaryDirection();
130 130
131 while (true) { 131 while (true) {
132 InlineBox* box; 132 InlineBox* box;
133 int offset; 133 int offset;
134 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset); 134 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset);
135 if (!box) 135 if (!box)
136 return primaryDirection == LTR ? previousVisuallyDistinctCandidate(m _deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); 136 return primaryDirection == LTR ? previousVisuallyDistinctCandidate(m _deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
137 137
138 LayoutObject* renderer = &box->renderer(); 138 LayoutObject* renderer = &box->layoutObject();
139 139
140 while (true) { 140 while (true) {
141 if ((renderer->isReplaced() || renderer->isBR()) && offset == box->c aretRightmostOffset()) 141 if ((renderer->isReplaced() || renderer->isBR()) && offset == box->c aretRightmostOffset())
142 return box->isLeftToRightDirection() ? previousVisuallyDistinctC andidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); 142 return box->isLeftToRightDirection() ? previousVisuallyDistinctC andidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
143 143
144 if (!renderer->node()) { 144 if (!renderer->node()) {
145 box = box->prevLeafChild(); 145 box = box->prevLeafChild();
146 if (!box) 146 if (!box)
147 return primaryDirection == LTR ? previousVisuallyDistinctCan didate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); 147 return primaryDirection == LTR ? previousVisuallyDistinctCan didate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
148 renderer = &box->renderer(); 148 renderer = &box->layoutObject();
149 offset = box->caretRightmostOffset(); 149 offset = box->caretRightmostOffset();
150 continue; 150 continue;
151 } 151 }
152 152
153 offset = box->isLeftToRightDirection() ? renderer->previousOffset(of fset) : renderer->nextOffset(offset); 153 offset = box->isLeftToRightDirection() ? renderer->previousOffset(of fset) : renderer->nextOffset(offset);
154 154
155 int caretMinOffset = box->caretMinOffset(); 155 int caretMinOffset = box->caretMinOffset();
156 int caretMaxOffset = box->caretMaxOffset(); 156 int caretMaxOffset = box->caretMaxOffset();
157 157
158 if (offset > caretMinOffset && offset < caretMaxOffset) 158 if (offset > caretMinOffset && offset < caretMaxOffset)
(...skipping 10 matching lines...) Expand all
169 InlineBox* boxOnLeft; 169 InlineBox* boxOnLeft;
170 int offsetOnLeft; 170 int offsetOnLeft;
171 positionOnLeft.getInlineBoxAndOffset(m_affinity, primaryDire ction, boxOnLeft, offsetOnLeft); 171 positionOnLeft.getInlineBoxAndOffset(m_affinity, primaryDire ction, boxOnLeft, offsetOnLeft);
172 if (boxOnLeft && boxOnLeft->root() == box->root()) 172 if (boxOnLeft && boxOnLeft->root() == box->root())
173 return Position(); 173 return Position();
174 return positionOnLeft; 174 return positionOnLeft;
175 } 175 }
176 176
177 // Reposition at the other logical position corresponding to our edge's visual position and go for another round. 177 // Reposition at the other logical position corresponding to our edge's visual position and go for another round.
178 box = prevBox; 178 box = prevBox;
179 renderer = &box->renderer(); 179 renderer = &box->layoutObject();
180 offset = prevBox->caretRightmostOffset(); 180 offset = prevBox->caretRightmostOffset();
181 continue; 181 continue;
182 } 182 }
183 183
184 ASSERT(offset == box->caretLeftmostOffset()); 184 ASSERT(offset == box->caretLeftmostOffset());
185 185
186 unsigned char level = box->bidiLevel(); 186 unsigned char level = box->bidiLevel();
187 InlineBox* prevBox = box->prevLeafChild(); 187 InlineBox* prevBox = box->prevLeafChild();
188 188
189 if (box->direction() == primaryDirection) { 189 if (box->direction() == primaryDirection) {
190 if (!prevBox) { 190 if (!prevBox) {
191 InlineBox* logicalStart = 0; 191 InlineBox* logicalStart = 0;
192 if (primaryDirection == LTR ? box->root().getLogicalStartBox WithNode(logicalStart) : box->root().getLogicalEndBoxWithNode(logicalStart)) { 192 if (primaryDirection == LTR ? box->root().getLogicalStartBox WithNode(logicalStart) : box->root().getLogicalEndBoxWithNode(logicalStart)) {
193 box = logicalStart; 193 box = logicalStart;
194 renderer = &box->renderer(); 194 renderer = &box->layoutObject();
195 offset = primaryDirection == LTR ? box->caretMinOffset() : box->caretMaxOffset(); 195 offset = primaryDirection == LTR ? box->caretMinOffset() : box->caretMaxOffset();
196 } 196 }
197 break; 197 break;
198 } 198 }
199 if (prevBox->bidiLevel() >= level) 199 if (prevBox->bidiLevel() >= level)
200 break; 200 break;
201 201
202 level = prevBox->bidiLevel(); 202 level = prevBox->bidiLevel();
203 203
204 InlineBox* nextBox = box; 204 InlineBox* nextBox = box;
205 do { 205 do {
206 nextBox = nextBox->nextLeafChild(); 206 nextBox = nextBox->nextLeafChild();
207 } while (nextBox && nextBox->bidiLevel() > level); 207 } while (nextBox && nextBox->bidiLevel() > level);
208 208
209 if (nextBox && nextBox->bidiLevel() == level) 209 if (nextBox && nextBox->bidiLevel() == level)
210 break; 210 break;
211 211
212 box = prevBox; 212 box = prevBox;
213 renderer = &box->renderer(); 213 renderer = &box->layoutObject();
214 offset = box->caretRightmostOffset(); 214 offset = box->caretRightmostOffset();
215 if (box->direction() == primaryDirection) 215 if (box->direction() == primaryDirection)
216 break; 216 break;
217 continue; 217 continue;
218 } 218 }
219 219
220 while (prevBox && !prevBox->renderer().node()) 220 while (prevBox && !prevBox->layoutObject().node())
221 prevBox = prevBox->prevLeafChild(); 221 prevBox = prevBox->prevLeafChild();
222 222
223 if (prevBox) { 223 if (prevBox) {
224 box = prevBox; 224 box = prevBox;
225 renderer = &box->renderer(); 225 renderer = &box->layoutObject();
226 offset = box->caretRightmostOffset(); 226 offset = box->caretRightmostOffset();
227 if (box->bidiLevel() > level) { 227 if (box->bidiLevel() > level) {
228 do { 228 do {
229 prevBox = prevBox->prevLeafChild(); 229 prevBox = prevBox->prevLeafChild();
230 } while (prevBox && prevBox->bidiLevel() > level); 230 } while (prevBox && prevBox->bidiLevel() > level);
231 231
232 if (!prevBox || prevBox->bidiLevel() < level) 232 if (!prevBox || prevBox->bidiLevel() < level)
233 continue; 233 continue;
234 } 234 }
235 } else { 235 } else {
236 // Trailing edge of a secondary run. Set to the leading edge of the entire run. 236 // Trailing edge of a secondary run. Set to the leading edge of the entire run.
237 while (true) { 237 while (true) {
238 while (InlineBox* nextBox = box->nextLeafChild()) { 238 while (InlineBox* nextBox = box->nextLeafChild()) {
239 if (nextBox->bidiLevel() < level) 239 if (nextBox->bidiLevel() < level)
240 break; 240 break;
241 box = nextBox; 241 box = nextBox;
242 } 242 }
243 if (box->bidiLevel() == level) 243 if (box->bidiLevel() == level)
244 break; 244 break;
245 level = box->bidiLevel(); 245 level = box->bidiLevel();
246 while (InlineBox* prevBox = box->prevLeafChild()) { 246 while (InlineBox* prevBox = box->prevLeafChild()) {
247 if (prevBox->bidiLevel() < level) 247 if (prevBox->bidiLevel() < level)
248 break; 248 break;
249 box = prevBox; 249 box = prevBox;
250 } 250 }
251 if (box->bidiLevel() == level) 251 if (box->bidiLevel() == level)
252 break; 252 break;
253 level = box->bidiLevel(); 253 level = box->bidiLevel();
254 } 254 }
255 renderer = &box->renderer(); 255 renderer = &box->layoutObject();
256 offset = primaryDirection == LTR ? box->caretMinOffset() : box-> caretMaxOffset(); 256 offset = primaryDirection == LTR ? box->caretMinOffset() : box-> caretMaxOffset();
257 } 257 }
258 break; 258 break;
259 } 259 }
260 260
261 p = createLegacyEditingPosition(renderer->node(), offset); 261 p = createLegacyEditingPosition(renderer->node(), offset);
262 262
263 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) 263 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree())
264 return p; 264 return p;
265 265
(...skipping 26 matching lines...) Expand all
292 Position downstreamStart = p.downstream(); 292 Position downstreamStart = p.downstream();
293 TextDirection primaryDirection = p.primaryDirection(); 293 TextDirection primaryDirection = p.primaryDirection();
294 294
295 while (true) { 295 while (true) {
296 InlineBox* box; 296 InlineBox* box;
297 int offset; 297 int offset;
298 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset); 298 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset);
299 if (!box) 299 if (!box)
300 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee pPosition) : previousVisuallyDistinctCandidate(m_deepPosition); 300 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee pPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
301 301
302 LayoutObject* renderer = &box->renderer(); 302 LayoutObject* renderer = &box->layoutObject();
303 303
304 while (true) { 304 while (true) {
305 if ((renderer->isReplaced() || renderer->isBR()) && offset == box->c aretLeftmostOffset()) 305 if ((renderer->isReplaced() || renderer->isBR()) && offset == box->c aretLeftmostOffset())
306 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); 306 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
307 307
308 if (!renderer->node()) { 308 if (!renderer->node()) {
309 box = box->nextLeafChild(); 309 box = box->nextLeafChild();
310 if (!box) 310 if (!box)
311 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); 311 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
312 renderer = &box->renderer(); 312 renderer = &box->layoutObject();
313 offset = box->caretLeftmostOffset(); 313 offset = box->caretLeftmostOffset();
314 continue; 314 continue;
315 } 315 }
316 316
317 offset = box->isLeftToRightDirection() ? renderer->nextOffset(offset ) : renderer->previousOffset(offset); 317 offset = box->isLeftToRightDirection() ? renderer->nextOffset(offset ) : renderer->previousOffset(offset);
318 318
319 int caretMinOffset = box->caretMinOffset(); 319 int caretMinOffset = box->caretMinOffset();
320 int caretMaxOffset = box->caretMaxOffset(); 320 int caretMaxOffset = box->caretMaxOffset();
321 321
322 if (offset > caretMinOffset && offset < caretMaxOffset) 322 if (offset > caretMinOffset && offset < caretMaxOffset)
(...skipping 10 matching lines...) Expand all
333 InlineBox* boxOnRight; 333 InlineBox* boxOnRight;
334 int offsetOnRight; 334 int offsetOnRight;
335 positionOnRight.getInlineBoxAndOffset(m_affinity, primaryDir ection, boxOnRight, offsetOnRight); 335 positionOnRight.getInlineBoxAndOffset(m_affinity, primaryDir ection, boxOnRight, offsetOnRight);
336 if (boxOnRight && boxOnRight->root() == box->root()) 336 if (boxOnRight && boxOnRight->root() == box->root())
337 return Position(); 337 return Position();
338 return positionOnRight; 338 return positionOnRight;
339 } 339 }
340 340
341 // Reposition at the other logical position corresponding to our edge's visual position and go for another round. 341 // Reposition at the other logical position corresponding to our edge's visual position and go for another round.
342 box = nextBox; 342 box = nextBox;
343 renderer = &box->renderer(); 343 renderer = &box->layoutObject();
344 offset = nextBox->caretLeftmostOffset(); 344 offset = nextBox->caretLeftmostOffset();
345 continue; 345 continue;
346 } 346 }
347 347
348 ASSERT(offset == box->caretRightmostOffset()); 348 ASSERT(offset == box->caretRightmostOffset());
349 349
350 unsigned char level = box->bidiLevel(); 350 unsigned char level = box->bidiLevel();
351 InlineBox* nextBox = box->nextLeafChild(); 351 InlineBox* nextBox = box->nextLeafChild();
352 352
353 if (box->direction() == primaryDirection) { 353 if (box->direction() == primaryDirection) {
354 if (!nextBox) { 354 if (!nextBox) {
355 InlineBox* logicalEnd = 0; 355 InlineBox* logicalEnd = 0;
356 if (primaryDirection == LTR ? box->root().getLogicalEndBoxWi thNode(logicalEnd) : box->root().getLogicalStartBoxWithNode(logicalEnd)) { 356 if (primaryDirection == LTR ? box->root().getLogicalEndBoxWi thNode(logicalEnd) : box->root().getLogicalStartBoxWithNode(logicalEnd)) {
357 box = logicalEnd; 357 box = logicalEnd;
358 renderer = &box->renderer(); 358 renderer = &box->layoutObject();
359 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset(); 359 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset();
360 } 360 }
361 break; 361 break;
362 } 362 }
363 363
364 if (nextBox->bidiLevel() >= level) 364 if (nextBox->bidiLevel() >= level)
365 break; 365 break;
366 366
367 level = nextBox->bidiLevel(); 367 level = nextBox->bidiLevel();
368 368
369 InlineBox* prevBox = box; 369 InlineBox* prevBox = box;
370 do { 370 do {
371 prevBox = prevBox->prevLeafChild(); 371 prevBox = prevBox->prevLeafChild();
372 } while (prevBox && prevBox->bidiLevel() > level); 372 } while (prevBox && prevBox->bidiLevel() > level);
373 373
374 if (prevBox && prevBox->bidiLevel() == level) // For example, abc FED 123 ^ CBA 374 if (prevBox && prevBox->bidiLevel() == level) // For example, abc FED 123 ^ CBA
375 break; 375 break;
376 376
377 // For example, abc 123 ^ CBA or 123 ^ CBA abc 377 // For example, abc 123 ^ CBA or 123 ^ CBA abc
378 box = nextBox; 378 box = nextBox;
379 renderer = &box->renderer(); 379 renderer = &box->layoutObject();
380 offset = box->caretLeftmostOffset(); 380 offset = box->caretLeftmostOffset();
381 if (box->direction() == primaryDirection) 381 if (box->direction() == primaryDirection)
382 break; 382 break;
383 continue; 383 continue;
384 } 384 }
385 385
386 while (nextBox && !nextBox->renderer().node()) 386 while (nextBox && !nextBox->layoutObject().node())
387 nextBox = nextBox->nextLeafChild(); 387 nextBox = nextBox->nextLeafChild();
388 388
389 if (nextBox) { 389 if (nextBox) {
390 box = nextBox; 390 box = nextBox;
391 renderer = &box->renderer(); 391 renderer = &box->layoutObject();
392 offset = box->caretLeftmostOffset(); 392 offset = box->caretLeftmostOffset();
393 393
394 if (box->bidiLevel() > level) { 394 if (box->bidiLevel() > level) {
395 do { 395 do {
396 nextBox = nextBox->nextLeafChild(); 396 nextBox = nextBox->nextLeafChild();
397 } while (nextBox && nextBox->bidiLevel() > level); 397 } while (nextBox && nextBox->bidiLevel() > level);
398 398
399 if (!nextBox || nextBox->bidiLevel() < level) 399 if (!nextBox || nextBox->bidiLevel() < level)
400 continue; 400 continue;
401 } 401 }
(...skipping 10 matching lines...) Expand all
412 level = box->bidiLevel(); 412 level = box->bidiLevel();
413 while (InlineBox* nextBox = box->nextLeafChild()) { 413 while (InlineBox* nextBox = box->nextLeafChild()) {
414 if (nextBox->bidiLevel() < level) 414 if (nextBox->bidiLevel() < level)
415 break; 415 break;
416 box = nextBox; 416 box = nextBox;
417 } 417 }
418 if (box->bidiLevel() == level) 418 if (box->bidiLevel() == level)
419 break; 419 break;
420 level = box->bidiLevel(); 420 level = box->bidiLevel();
421 } 421 }
422 renderer = &box->renderer(); 422 renderer = &box->layoutObject();
423 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset(); 423 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset();
424 } 424 }
425 break; 425 break;
426 } 426 }
427 427
428 p = createLegacyEditingPosition(renderer->node(), offset); 428 p = createLegacyEditingPosition(renderer->node(), offset);
429 429
430 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) 430 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree())
431 return p; 431 return p;
432 432
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (vpos) 786 if (vpos)
787 vpos->showTreeForThis(); 787 vpos->showTreeForThis();
788 } 788 }
789 789
790 void showTree(const blink::VisiblePosition& vpos) 790 void showTree(const blink::VisiblePosition& vpos)
791 { 791 {
792 vpos.showTreeForThis(); 792 vpos.showTreeForThis();
793 } 793 }
794 794
795 #endif 795 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/TypingCommand.cpp ('k') | Source/core/editing/VisibleSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698