Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: Source/core/editing/VisiblePosition.cpp

Issue 1321183002: Get rid of static function localCaretRectOf() in VisiblePosition.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-31T17:51:24 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698