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

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

Issue 1301423005: Move lineDirectionPointForBlockDirectionNavigationOf() to FrameSelection.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-01T12:40:26 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 | « Source/core/editing/VisiblePosition.h ('k') | 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition) 618 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition)
619 { 619 {
620 LayoutObject* layoutObject; 620 LayoutObject* layoutObject;
621 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject); 621 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject);
622 if (localRect.isEmpty() || !layoutObject) 622 if (localRect.isEmpty() || !layoutObject)
623 return IntRect(); 623 return IntRect();
624 624
625 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 625 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
626 } 626 }
627 627
628 // TODO(yosin) We should move a global function
629 // |lineDirectionPointForBlockDirectionNavigationOf()| to "FrameSelection.h"
630 // as static function.
631 int lineDirectionPointForBlockDirectionNavigationOf(const VisiblePosition& visib lePosition)
632 {
633 if (visiblePosition.isNull())
634 return 0;
635
636 LayoutObject* layoutObject;
637 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject);
638 if (localRect.isEmpty() || !layoutObject)
639 return 0;
640
641 // This ignores transforms on purpose, for now. Vertical navigation is done
642 // without consulting transforms, so that 'up' in transformed text is 'up'
643 // relative to the text, not absolute 'up'.
644 FloatPoint caretPoint = layoutObject->localToAbsolute(FloatPoint(localRect.l ocation()));
645 LayoutObject* containingBlock = layoutObject->containingBlock();
646 if (!containingBlock)
647 containingBlock = layoutObject; // Just use ourselves to determine the w riting mode if we have no containing block.
648 return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPo int.y();
649 }
650
651 #ifndef NDEBUG 628 #ifndef NDEBUG
652 629
653 void VisiblePosition::debugPosition(const char* msg) const 630 void VisiblePosition::debugPosition(const char* msg) const
654 { 631 {
655 if (isNull()) { 632 if (isNull()) {
656 fprintf(stderr, "Position [%s]: null\n", msg); 633 fprintf(stderr, "Position [%s]: null\n", msg);
657 return; 634 return;
658 } 635 }
659 m_deepPosition.debugPosition(msg); 636 m_deepPosition.debugPosition(msg);
660 } 637 }
(...skipping 26 matching lines...) Expand all
687 else 664 else
688 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 665 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
689 } 666 }
690 667
691 void showTree(const blink::VisiblePosition& vpos) 668 void showTree(const blink::VisiblePosition& vpos)
692 { 669 {
693 vpos.showTreeForThis(); 670 vpos.showTreeForThis();
694 } 671 }
695 672
696 #endif 673 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698