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

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

Issue 1309963003: Introduce composed tree version of isFirstPositionAfterTable() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-08T15:06:09 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/EditingUtilities.h ('k') | Source/core/editing/EditingUtilitiesTest.cpp » ('j') | 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 if (!n) 855 if (!n)
856 return pos; 856 return pos;
857 Position result = positionInParentAfterNode(*n); 857 Position result = positionInParentAfterNode(*n);
858 if (result.isNull() || result.anchorNode()->rootEditableElement() != pos.anc horNode()->rootEditableElement()) 858 if (result.isNull() || result.anchorNode()->rootEditableElement() != pos.anc horNode()->rootEditableElement())
859 return pos; 859 return pos;
860 if (containingSpecialElement) 860 if (containingSpecialElement)
861 *containingSpecialElement = n; 861 *containingSpecialElement = n;
862 return result; 862 return result;
863 } 863 }
864 864
865 template <typename Strategy>
866 static Element* isFirstPositionAfterTableAlgorithm(const VisiblePositionTemplate <Strategy>& visiblePosition)
867 {
868 const PositionAlgorithm<Strategy> upstream(mostBackwardCaretPosition(visible Position.deepEquivalent()));
869 if (isRenderedTableElement(upstream.anchorNode()) && upstream.atLastEditingP ositionForNode())
870 return toElement(upstream.anchorNode());
871
872 return nullptr;
873 }
874
865 Element* isFirstPositionAfterTable(const VisiblePosition& visiblePosition) 875 Element* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
866 { 876 {
867 Position upstream(mostBackwardCaretPosition(visiblePosition.deepEquivalent() )); 877 return isFirstPositionAfterTableAlgorithm<EditingStrategy>(visiblePosition);
868 if (isRenderedTableElement(upstream.anchorNode()) && upstream.atLastEditingP ositionForNode()) 878 }
869 return toElement(upstream.anchorNode());
870 879
871 return 0; 880 Element* isFirstPositionAfterTable(const VisiblePositionInComposedTree& visibleP osition)
881 {
882 return isFirstPositionAfterTableAlgorithm<EditingInComposedTreeStrategy>(vis iblePosition);
872 } 883 }
873 884
874 Element* isLastPositionBeforeTable(const VisiblePosition& visiblePosition) 885 Element* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
875 { 886 {
876 Position downstream(mostForwardCaretPosition(visiblePosition.deepEquivalent( ))); 887 Position downstream(mostForwardCaretPosition(visiblePosition.deepEquivalent( )));
877 if (isRenderedTableElement(downstream.anchorNode()) && downstream.atFirstEdi tingPositionForNode()) 888 if (isRenderedTableElement(downstream.anchorNode()) && downstream.atFirstEdi tingPositionForNode())
878 return toElement(downstream.anchorNode()); 889 return toElement(downstream.anchorNode());
879 890
880 return 0; 891 return 0;
881 } 892 }
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 // if the selection starts just before a paragraph break, skip over it 1670 // if the selection starts just before a paragraph break, skip over it
1660 if (isEndOfParagraph(visiblePosition)) 1671 if (isEndOfParagraph(visiblePosition))
1661 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui valent()); 1672 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui valent());
1662 1673
1663 // otherwise, make sure to be at the start of the first selected node, 1674 // otherwise, make sure to be at the start of the first selected node,
1664 // instead of possibly at the end of the last node before the selection 1675 // instead of possibly at the end of the last node before the selection
1665 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); 1676 return mostForwardCaretPosition(visiblePosition.deepEquivalent());
1666 } 1677 }
1667 1678
1668 } // namespace blink 1679 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/EditingUtilities.h ('k') | Source/core/editing/EditingUtilitiesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698