| 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 LayoutObject* 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->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->renderer(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RenderObject* renderer = &box->renderer(); | 302 LayoutObject* renderer = &box->renderer(); |
| 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->renderer(); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 638 } |
| 639 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode()); | 639 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode()); |
| 640 Text* textNode = pos.containerText(); | 640 Text* textNode = pos.containerText(); |
| 641 unsigned length = textNode->length(); | 641 unsigned length = textNode->length(); |
| 642 if (offset >= length) | 642 if (offset >= length) |
| 643 return 0; | 643 return 0; |
| 644 | 644 |
| 645 return textNode->data().characterStartingAt(offset); | 645 return textNode->data().characterStartingAt(offset); |
| 646 } | 646 } |
| 647 | 647 |
| 648 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const | 648 LayoutRect VisiblePosition::localCaretRect(LayoutObject*& renderer) const |
| 649 { | 649 { |
| 650 PositionWithAffinity positionWithAffinity(m_deepPosition, m_affinity); | 650 PositionWithAffinity positionWithAffinity(m_deepPosition, m_affinity); |
| 651 return localCaretRectOfPosition(positionWithAffinity, renderer); | 651 return localCaretRectOfPosition(positionWithAffinity, renderer); |
| 652 } | 652 } |
| 653 | 653 |
| 654 IntRect VisiblePosition::absoluteCaretBounds() const | 654 IntRect VisiblePosition::absoluteCaretBounds() const |
| 655 { | 655 { |
| 656 RenderObject* renderer; | 656 LayoutObject* renderer; |
| 657 LayoutRect localRect = localCaretRect(renderer); | 657 LayoutRect localRect = localCaretRect(renderer); |
| 658 if (localRect.isEmpty() || !renderer) | 658 if (localRect.isEmpty() || !renderer) |
| 659 return IntRect(); | 659 return IntRect(); |
| 660 | 660 |
| 661 return renderer->localToAbsoluteQuad(FloatRect(localRect)).enclosingBounding
Box(); | 661 return renderer->localToAbsoluteQuad(FloatRect(localRect)).enclosingBounding
Box(); |
| 662 } | 662 } |
| 663 | 663 |
| 664 int VisiblePosition::lineDirectionPointForBlockDirectionNavigation() const | 664 int VisiblePosition::lineDirectionPointForBlockDirectionNavigation() const |
| 665 { | 665 { |
| 666 RenderObject* renderer; | 666 LayoutObject* renderer; |
| 667 LayoutRect localRect = localCaretRect(renderer); | 667 LayoutRect localRect = localCaretRect(renderer); |
| 668 if (localRect.isEmpty() || !renderer) | 668 if (localRect.isEmpty() || !renderer) |
| 669 return 0; | 669 return 0; |
| 670 | 670 |
| 671 // This ignores transforms on purpose, for now. Vertical navigation is done | 671 // This ignores transforms on purpose, for now. Vertical navigation is done |
| 672 // without consulting transforms, so that 'up' in transformed text is 'up' | 672 // without consulting transforms, so that 'up' in transformed text is 'up' |
| 673 // relative to the text, not absolute 'up'. | 673 // relative to the text, not absolute 'up'. |
| 674 FloatPoint caretPoint = renderer->localToAbsolute(FloatPoint(localRect.locat
ion())); | 674 FloatPoint caretPoint = renderer->localToAbsolute(FloatPoint(localRect.locat
ion())); |
| 675 RenderObject* containingBlock = renderer->containingBlock(); | 675 LayoutObject* containingBlock = renderer->containingBlock(); |
| 676 if (!containingBlock) | 676 if (!containingBlock) |
| 677 containingBlock = renderer; // Just use ourselves to determine the writi
ng mode if we have no containing block. | 677 containingBlock = renderer; // Just use ourselves to determine the writi
ng mode if we have no containing block. |
| 678 return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPo
int.y(); | 678 return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPo
int.y(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 #ifndef NDEBUG | 681 #ifndef NDEBUG |
| 682 | 682 |
| 683 void VisiblePosition::debugPosition(const char* msg) const | 683 void VisiblePosition::debugPosition(const char* msg) const |
| 684 { | 684 { |
| 685 if (isNull()) | 685 if (isNull()) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |