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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 Text* textNode = pos.containerText(); | 642 Text* textNode = pos.containerText(); |
643 unsigned length = textNode->length(); | 643 unsigned length = textNode->length(); |
644 if (offset >= length) | 644 if (offset >= length) |
645 return 0; | 645 return 0; |
646 | 646 |
647 return textNode->data().characterStartingAt(offset); | 647 return textNode->data().characterStartingAt(offset); |
648 } | 648 } |
649 | 649 |
650 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const | 650 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const |
651 { | 651 { |
652 if (m_deepPosition.isNull()) { | 652 PositionWithAffinity positionWithAffinity(m_deepPosition, m_affinity); |
653 renderer = 0; | 653 return localCaretRectOfPosition(positionWithAffinity, renderer); |
654 return IntRect(); | |
655 } | |
656 Node* node = m_deepPosition.anchorNode(); | |
657 | |
658 renderer = node->renderer(); | |
659 if (!renderer) | |
660 return LayoutRect(); | |
661 | |
662 InlineBox* inlineBox; | |
663 int caretOffset; | |
664 getInlineBoxAndOffset(inlineBox, caretOffset); | |
665 | |
666 if (inlineBox) | |
667 renderer = &inlineBox->renderer(); | |
668 | |
669 return renderer->localCaretRect(inlineBox, caretOffset); | |
670 } | 654 } |
671 | 655 |
672 IntRect VisiblePosition::absoluteCaretBounds() const | 656 IntRect VisiblePosition::absoluteCaretBounds() const |
673 { | 657 { |
674 RenderObject* renderer; | 658 RenderObject* renderer; |
675 LayoutRect localRect = localCaretRect(renderer); | 659 LayoutRect localRect = localCaretRect(renderer); |
676 if (localRect.isEmpty() || !renderer) | 660 if (localRect.isEmpty() || !renderer) |
677 return IntRect(); | 661 return IntRect(); |
678 | 662 |
679 return renderer->localToAbsoluteQuad(FloatRect(localRect)).enclosingBounding
Box(); | 663 return renderer->localToAbsoluteQuad(FloatRect(localRect)).enclosingBounding
Box(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 if (vpos) | 788 if (vpos) |
805 vpos->showTreeForThis(); | 789 vpos->showTreeForThis(); |
806 } | 790 } |
807 | 791 |
808 void showTree(const blink::VisiblePosition& vpos) | 792 void showTree(const blink::VisiblePosition& vpos) |
809 { | 793 { |
810 vpos.showTreeForThis(); | 794 vpos.showTreeForThis(); |
811 } | 795 } |
812 | 796 |
813 #endif | 797 #endif |
OLD | NEW |