OLD | NEW |
---|---|
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 Loading... | |
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 RenderObject* renderer = box->renderer(); | 138 RenderObject& renderer = box->renderer(); |
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->car etRightmostOffset()) |
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->renderer(); |
Inactive
2014/02/28 20:26:45
not lgtm, you are reassigning a reference here. Th
ostap
2014/02/28 20:41:38
Done.
| |
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(off set) : 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) |
159 break; | 159 break; |
160 | 160 |
161 if (box->isLeftToRightDirection() ? offset < caretMinOffset : offset > caretMaxOffset) { | 161 if (box->isLeftToRightDirection() ? offset < caretMinOffset : offset > caretMaxOffset) { |
162 // Overshot to the left. | 162 // Overshot to the left. |
163 InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); | 163 InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 break; | 210 break; |
211 | 211 |
212 box = prevBox; | 212 box = prevBox; |
213 renderer = box->renderer(); | 213 renderer = box->renderer(); |
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->renderer().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->renderer(); |
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); |
(...skipping 20 matching lines...) Expand all Loading... | |
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->renderer(); |
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 |
266 ASSERT(p != m_deepPosition); | 266 ASSERT(p != m_deepPosition); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const | 270 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const |
271 { | 271 { |
(...skipping 21 matching lines...) Expand all Loading... | |
293 Position downstreamStart = p.downstream(); | 293 Position downstreamStart = p.downstream(); |
294 TextDirection primaryDirection = p.primaryDirection(); | 294 TextDirection primaryDirection = p.primaryDirection(); |
295 | 295 |
296 while (true) { | 296 while (true) { |
297 InlineBox* box; | 297 InlineBox* box; |
298 int offset; | 298 int offset; |
299 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset); | 299 p.getInlineBoxAndOffset(m_affinity, primaryDirection, box, offset); |
300 if (!box) | 300 if (!box) |
301 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee pPosition) : previousVisuallyDistinctCandidate(m_deepPosition); | 301 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee pPosition) : previousVisuallyDistinctCandidate(m_deepPosition); |
302 | 302 |
303 RenderObject* renderer = box->renderer(); | 303 RenderObject& renderer = box->renderer(); |
304 | 304 |
305 while (true) { | 305 while (true) { |
306 if ((renderer->isReplaced() || renderer->isBR()) && offset == box->c aretLeftmostOffset()) | 306 if ((renderer.isReplaced() || renderer.isBR()) && offset == box->car etLeftmostOffset()) |
307 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); | 307 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); |
308 | 308 |
309 if (!renderer->node()) { | 309 if (!renderer.node()) { |
310 box = box->nextLeafChild(); | 310 box = box->nextLeafChild(); |
311 if (!box) | 311 if (!box) |
312 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); | 312 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); |
313 renderer = box->renderer(); | 313 renderer = box->renderer(); |
314 offset = box->caretLeftmostOffset(); | 314 offset = box->caretLeftmostOffset(); |
315 continue; | 315 continue; |
316 } | 316 } |
317 | 317 |
318 offset = box->isLeftToRightDirection() ? renderer->nextOffset(offset ) : renderer->previousOffset(offset); | 318 offset = box->isLeftToRightDirection() ? renderer.nextOffset(offset) : renderer.previousOffset(offset); |
319 | 319 |
320 int caretMinOffset = box->caretMinOffset(); | 320 int caretMinOffset = box->caretMinOffset(); |
321 int caretMaxOffset = box->caretMaxOffset(); | 321 int caretMaxOffset = box->caretMaxOffset(); |
322 | 322 |
323 if (offset > caretMinOffset && offset < caretMaxOffset) | 323 if (offset > caretMinOffset && offset < caretMaxOffset) |
324 break; | 324 break; |
325 | 325 |
326 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset < caretMinOffset) { | 326 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset < caretMinOffset) { |
327 // Overshot to the right. | 327 // Overshot to the right. |
328 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); | 328 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 | 377 |
378 // For example, abc 123 ^ CBA or 123 ^ CBA abc | 378 // For example, abc 123 ^ CBA or 123 ^ CBA abc |
379 box = nextBox; | 379 box = nextBox; |
380 renderer = box->renderer(); | 380 renderer = box->renderer(); |
381 offset = box->caretLeftmostOffset(); | 381 offset = box->caretLeftmostOffset(); |
382 if (box->direction() == primaryDirection) | 382 if (box->direction() == primaryDirection) |
383 break; | 383 break; |
384 continue; | 384 continue; |
385 } | 385 } |
386 | 386 |
387 while (nextBox && !nextBox->renderer()->node()) | 387 while (nextBox && !nextBox->renderer().node()) |
388 nextBox = nextBox->nextLeafChild(); | 388 nextBox = nextBox->nextLeafChild(); |
389 | 389 |
390 if (nextBox) { | 390 if (nextBox) { |
391 box = nextBox; | 391 box = nextBox; |
392 renderer = box->renderer(); | 392 renderer = box->renderer(); |
393 offset = box->caretLeftmostOffset(); | 393 offset = box->caretLeftmostOffset(); |
394 | 394 |
395 if (box->bidiLevel() > level) { | 395 if (box->bidiLevel() > level) { |
396 do { | 396 do { |
397 nextBox = nextBox->nextLeafChild(); | 397 nextBox = nextBox->nextLeafChild(); |
(...skipping 21 matching lines...) Expand all Loading... | |
419 if (box->bidiLevel() == level) | 419 if (box->bidiLevel() == level) |
420 break; | 420 break; |
421 level = box->bidiLevel(); | 421 level = box->bidiLevel(); |
422 } | 422 } |
423 renderer = box->renderer(); | 423 renderer = box->renderer(); |
424 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset(); | 424 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset(); |
425 } | 425 } |
426 break; | 426 break; |
427 } | 427 } |
428 | 428 |
429 p = createLegacyEditingPosition(renderer->node(), offset); | 429 p = createLegacyEditingPosition(renderer.node(), offset); |
430 | 430 |
431 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) | 431 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) |
432 return p; | 432 return p; |
433 | 433 |
434 ASSERT(p != m_deepPosition); | 434 ASSERT(p != m_deepPosition); |
435 } | 435 } |
436 } | 436 } |
437 | 437 |
438 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const | 438 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const |
439 { | 439 { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 | 657 |
658 renderer = node->renderer(); | 658 renderer = node->renderer(); |
659 if (!renderer) | 659 if (!renderer) |
660 return LayoutRect(); | 660 return LayoutRect(); |
661 | 661 |
662 InlineBox* inlineBox; | 662 InlineBox* inlineBox; |
663 int caretOffset; | 663 int caretOffset; |
664 getInlineBoxAndOffset(inlineBox, caretOffset); | 664 getInlineBoxAndOffset(inlineBox, caretOffset); |
665 | 665 |
666 if (inlineBox) | 666 if (inlineBox) |
667 renderer = inlineBox->renderer(); | 667 renderer = &inlineBox->renderer(); |
668 | 668 |
669 return renderer->localCaretRect(inlineBox, caretOffset); | 669 return renderer->localCaretRect(inlineBox, caretOffset); |
670 } | 670 } |
671 | 671 |
672 IntRect VisiblePosition::absoluteCaretBounds() const | 672 IntRect VisiblePosition::absoluteCaretBounds() const |
673 { | 673 { |
674 RenderObject* renderer; | 674 RenderObject* renderer; |
675 LayoutRect localRect = localCaretRect(renderer); | 675 LayoutRect localRect = localCaretRect(renderer); |
676 if (localRect.isEmpty() || !renderer) | 676 if (localRect.isEmpty() || !renderer) |
677 return IntRect(); | 677 return IntRect(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 if (vpos) | 799 if (vpos) |
800 vpos->showTreeForThis(); | 800 vpos->showTreeForThis(); |
801 } | 801 } |
802 | 802 |
803 void showTree(const WebCore::VisiblePosition& vpos) | 803 void showTree(const WebCore::VisiblePosition& vpos) |
804 { | 804 { |
805 vpos.showTreeForThis(); | 805 vpos.showTreeForThis(); |
806 } | 806 } |
807 | 807 |
808 #endif | 808 #endif |
OLD | NEW |