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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 Position VisiblePosition::leftVisuallyDistinctCandidate() const | 117 Position VisiblePosition::leftVisuallyDistinctCandidate() const |
118 { | 118 { |
119 Position p = m_deepPosition; | 119 Position p = m_deepPosition; |
120 if (p.isNull()) | 120 if (p.isNull()) |
121 return Position(); | 121 return Position(); |
122 | 122 |
123 Position downstreamStart = p.downstream(); | 123 Position downstreamStart = p.downstream(); |
124 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode()); | 124 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode()); |
125 | 125 |
126 while (true) { | 126 while (true) { |
127 InlineBoxPosition boxPosition = p.computeInlineBoxPosition(m_affinity, p
rimaryDirection); | 127 InlineBoxPosition boxPosition = computeInlineBoxPosition(p, m_affinity,
primaryDirection); |
128 InlineBox* box = boxPosition.inlineBox; | 128 InlineBox* box = boxPosition.inlineBox; |
129 int offset = boxPosition.offsetInBox; | 129 int offset = boxPosition.offsetInBox; |
130 if (!box) | 130 if (!box) |
131 return primaryDirection == LTR ? previousVisuallyDistinctCandidate(m
_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); | 131 return primaryDirection == LTR ? previousVisuallyDistinctCandidate(m
_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); |
132 | 132 |
133 LayoutObject* layoutObject = &box->layoutObject(); | 133 LayoutObject* layoutObject = &box->layoutObject(); |
134 | 134 |
135 while (true) { | 135 while (true) { |
136 if ((layoutObject->isReplaced() || layoutObject->isBR()) && offset =
= box->caretRightmostOffset()) | 136 if ((layoutObject->isReplaced() || layoutObject->isBR()) && offset =
= box->caretRightmostOffset()) |
137 return box->isLeftToRightDirection() ? previousVisuallyDistinctC
andidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); | 137 return box->isLeftToRightDirection() ? previousVisuallyDistinctC
andidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition); |
(...skipping 16 matching lines...) Expand all Loading... |
154 break; | 154 break; |
155 | 155 |
156 if (box->isLeftToRightDirection() ? offset < caretMinOffset : offset
> caretMaxOffset) { | 156 if (box->isLeftToRightDirection() ? offset < caretMinOffset : offset
> caretMaxOffset) { |
157 // Overshot to the left. | 157 // Overshot to the left. |
158 InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); | 158 InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); |
159 if (!prevBox) { | 159 if (!prevBox) { |
160 Position positionOnLeft = primaryDirection == LTR ? previous
VisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deep
Position); | 160 Position positionOnLeft = primaryDirection == LTR ? previous
VisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deep
Position); |
161 if (positionOnLeft.isNull()) | 161 if (positionOnLeft.isNull()) |
162 return Position(); | 162 return Position(); |
163 | 163 |
164 InlineBox* boxOnLeft = positionOnLeft.computeInlineBoxPositi
on(m_affinity, primaryDirection).inlineBox; | 164 InlineBox* boxOnLeft = computeInlineBoxPosition(positionOnLe
ft, m_affinity, primaryDirection).inlineBox; |
165 if (boxOnLeft && boxOnLeft->root() == box->root()) | 165 if (boxOnLeft && boxOnLeft->root() == box->root()) |
166 return Position(); | 166 return Position(); |
167 return positionOnLeft; | 167 return positionOnLeft; |
168 } | 168 } |
169 | 169 |
170 // Reposition at the other logical position corresponding to our
edge's visual position and go for another round. | 170 // Reposition at the other logical position corresponding to our
edge's visual position and go for another round. |
171 box = prevBox; | 171 box = prevBox; |
172 layoutObject = &box->layoutObject(); | 172 layoutObject = &box->layoutObject(); |
173 offset = prevBox->caretRightmostOffset(); | 173 offset = prevBox->caretRightmostOffset(); |
174 continue; | 174 continue; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 Position VisiblePosition::rightVisuallyDistinctCandidate() const | 276 Position VisiblePosition::rightVisuallyDistinctCandidate() const |
277 { | 277 { |
278 Position p = m_deepPosition; | 278 Position p = m_deepPosition; |
279 if (p.isNull()) | 279 if (p.isNull()) |
280 return Position(); | 280 return Position(); |
281 | 281 |
282 Position downstreamStart = p.downstream(); | 282 Position downstreamStart = p.downstream(); |
283 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode()); | 283 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode()); |
284 | 284 |
285 while (true) { | 285 while (true) { |
286 InlineBoxPosition boxPosition = p.computeInlineBoxPosition(m_affinity, p
rimaryDirection); | 286 InlineBoxPosition boxPosition = computeInlineBoxPosition(p, m_affinity,
primaryDirection); |
287 InlineBox* box = boxPosition.inlineBox; | 287 InlineBox* box = boxPosition.inlineBox; |
288 int offset = boxPosition.offsetInBox; | 288 int offset = boxPosition.offsetInBox; |
289 if (!box) | 289 if (!box) |
290 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee
pPosition) : previousVisuallyDistinctCandidate(m_deepPosition); | 290 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_dee
pPosition) : previousVisuallyDistinctCandidate(m_deepPosition); |
291 | 291 |
292 LayoutObject* layoutObject = &box->layoutObject(); | 292 LayoutObject* layoutObject = &box->layoutObject(); |
293 | 293 |
294 while (true) { | 294 while (true) { |
295 if ((layoutObject->isReplaced() || layoutObject->isBR()) && offset =
= box->caretLeftmostOffset()) | 295 if ((layoutObject->isReplaced() || layoutObject->isBR()) && offset =
= box->caretLeftmostOffset()) |
296 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi
date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); | 296 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi
date(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition); |
(...skipping 16 matching lines...) Expand all Loading... |
313 break; | 313 break; |
314 | 314 |
315 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset
< caretMinOffset) { | 315 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset
< caretMinOffset) { |
316 // Overshot to the right. | 316 // Overshot to the right. |
317 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); | 317 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); |
318 if (!nextBox) { | 318 if (!nextBox) { |
319 Position positionOnRight = primaryDirection == LTR ? nextVis
uallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_dee
pPosition); | 319 Position positionOnRight = primaryDirection == LTR ? nextVis
uallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_dee
pPosition); |
320 if (positionOnRight.isNull()) | 320 if (positionOnRight.isNull()) |
321 return Position(); | 321 return Position(); |
322 | 322 |
323 InlineBox* boxOnRight = positionOnRight.computeInlineBoxPosi
tion(m_affinity, primaryDirection).inlineBox; | 323 InlineBox* boxOnRight = computeInlineBoxPosition(positionOnR
ight, m_affinity, primaryDirection).inlineBox; |
324 if (boxOnRight && boxOnRight->root() == box->root()) | 324 if (boxOnRight && boxOnRight->root() == box->root()) |
325 return Position(); | 325 return Position(); |
326 return positionOnRight; | 326 return positionOnRight; |
327 } | 327 } |
328 | 328 |
329 // Reposition at the other logical position corresponding to our
edge's visual position and go for another round. | 329 // Reposition at the other logical position corresponding to our
edge's visual position and go for another round. |
330 box = nextBox; | 330 box = nextBox; |
331 layoutObject = &box->layoutObject(); | 331 layoutObject = &box->layoutObject(); |
332 offset = nextBox->caretLeftmostOffset(); | 332 offset = nextBox->caretLeftmostOffset(); |
333 continue; | 333 continue; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 else | 769 else |
770 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); | 770 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); |
771 } | 771 } |
772 | 772 |
773 void showTree(const blink::VisiblePosition& vpos) | 773 void showTree(const blink::VisiblePosition& vpos) |
774 { | 774 { |
775 vpos.showTreeForThis(); | 775 vpos.showTreeForThis(); |
776 } | 776 } |
777 | 777 |
778 #endif | 778 #endif |
OLD | NEW |