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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 return 0; | 702 return 0; |
703 | 703 |
704 return textNode->data().characterStartingAt(offset); | 704 return textNode->data().characterStartingAt(offset); |
705 } | 705 } |
706 | 706 |
707 UChar32 characterBefore(const VisiblePosition& visiblePosition) | 707 UChar32 characterBefore(const VisiblePosition& visiblePosition) |
708 { | 708 { |
709 return characterAfter(previousPositionOf(visiblePosition)); | 709 return characterAfter(previousPositionOf(visiblePosition)); |
710 } | 710 } |
711 | 711 |
712 // TODO(yosin) We should move |localCaretRect()| to "VisibleUnits.cpp". | |
713 static LayoutRect localCaretRectOf(const VisiblePosition& visiblePosition, Layou
tObject*& layoutObject) | |
714 { | |
715 PositionWithAffinity positionWithAffinity(visiblePosition.deepEquivalent(),
visiblePosition.affinity()); | |
716 return localCaretRectOfPosition(positionWithAffinity, layoutObject); | |
717 } | |
718 | |
719 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition) | 712 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition) |
720 { | 713 { |
721 LayoutObject* layoutObject; | 714 LayoutObject* layoutObject; |
722 LayoutRect localRect = localCaretRectOf(visiblePosition, layoutObject); | 715 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi
thAffinity(), layoutObject); |
723 if (localRect.isEmpty() || !layoutObject) | 716 if (localRect.isEmpty() || !layoutObject) |
724 return IntRect(); | 717 return IntRect(); |
725 | 718 |
726 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun
dingBox(); | 719 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun
dingBox(); |
727 } | 720 } |
728 | 721 |
729 // TODO(yosin) We should move a global function | 722 // TODO(yosin) We should move a global function |
730 // |lineDirectionPointForBlockDirectionNavigationOf()| to "FrameSelection.h" | 723 // |lineDirectionPointForBlockDirectionNavigationOf()| to "FrameSelection.h" |
731 // as static function. | 724 // as static function. |
732 int lineDirectionPointForBlockDirectionNavigationOf(const VisiblePosition& visib
lePosition) | 725 int lineDirectionPointForBlockDirectionNavigationOf(const VisiblePosition& visib
lePosition) |
733 { | 726 { |
734 if (visiblePosition.isNull()) | 727 if (visiblePosition.isNull()) |
735 return 0; | 728 return 0; |
736 | 729 |
737 LayoutObject* layoutObject; | 730 LayoutObject* layoutObject; |
738 LayoutRect localRect = localCaretRectOf(visiblePosition, layoutObject); | 731 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi
thAffinity(), layoutObject); |
739 if (localRect.isEmpty() || !layoutObject) | 732 if (localRect.isEmpty() || !layoutObject) |
740 return 0; | 733 return 0; |
741 | 734 |
742 // This ignores transforms on purpose, for now. Vertical navigation is done | 735 // This ignores transforms on purpose, for now. Vertical navigation is done |
743 // without consulting transforms, so that 'up' in transformed text is 'up' | 736 // without consulting transforms, so that 'up' in transformed text is 'up' |
744 // relative to the text, not absolute 'up'. | 737 // relative to the text, not absolute 'up'. |
745 FloatPoint caretPoint = layoutObject->localToAbsolute(FloatPoint(localRect.l
ocation())); | 738 FloatPoint caretPoint = layoutObject->localToAbsolute(FloatPoint(localRect.l
ocation())); |
746 LayoutObject* containingBlock = layoutObject->containingBlock(); | 739 LayoutObject* containingBlock = layoutObject->containingBlock(); |
747 if (!containingBlock) | 740 if (!containingBlock) |
748 containingBlock = layoutObject; // Just use ourselves to determine the w
riting mode if we have no containing block. | 741 containingBlock = layoutObject; // Just use ourselves to determine the w
riting mode if we have no containing block. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 else | 781 else |
789 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); | 782 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); |
790 } | 783 } |
791 | 784 |
792 void showTree(const blink::VisiblePosition& vpos) | 785 void showTree(const blink::VisiblePosition& vpos) |
793 { | 786 { |
794 vpos.showTreeForThis(); | 787 vpos.showTreeForThis(); |
795 } | 788 } |
796 | 789 |
797 #endif | 790 #endif |
OLD | NEW |