OLD | NEW |
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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 if (position.isNull()) | 1148 if (position.isNull()) |
1149 return Position(); | 1149 return Position(); |
1150 | 1150 |
1151 Element* fromRootEditableElement = position.anchorNode()->rootEditableElemen
t(); | 1151 Element* fromRootEditableElement = position.anchorNode()->rootEditableElemen
t(); |
1152 | 1152 |
1153 bool atStartOfLine = isStartOfLine(VisiblePosition(position, affinity)); | 1153 bool atStartOfLine = isStartOfLine(VisiblePosition(position, affinity)); |
1154 bool rendered = isVisuallyEquivalentCandidate(position); | 1154 bool rendered = isVisuallyEquivalentCandidate(position); |
1155 | 1155 |
1156 Position currentPos = position; | 1156 Position currentPos = position; |
1157 while (!currentPos.atStartOfTree()) { | 1157 while (!currentPos.atStartOfTree()) { |
1158 currentPos = currentPos.previous(); | 1158 // TODO(yosin) When we use |previousCharacterPosition()| other than |
| 1159 // finding leading whitespace, we should use |Character| instead of |
| 1160 // |CodePoint|. |
| 1161 currentPos = previousPositionOf(currentPos, PositionMoveType::CodePoint)
; |
1159 | 1162 |
1160 if (currentPos.anchorNode()->rootEditableElement() != fromRootEditableEl
ement) | 1163 if (currentPos.anchorNode()->rootEditableElement() != fromRootEditableEl
ement) |
1161 return position; | 1164 return position; |
1162 | 1165 |
1163 if (atStartOfLine || !rendered) { | 1166 if (atStartOfLine || !rendered) { |
1164 if (isVisuallyEquivalentCandidate(currentPos)) | 1167 if (isVisuallyEquivalentCandidate(currentPos)) |
1165 return currentPos; | 1168 return currentPos; |
1166 } else if (rendersInDifferentPosition(position, currentPos)) { | 1169 } else if (rendersInDifferentPosition(position, currentPos)) { |
1167 return currentPos; | 1170 return currentPos; |
1168 } | 1171 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 // if the selection starts just before a paragraph break, skip over it | 1448 // if the selection starts just before a paragraph break, skip over it |
1446 if (isEndOfParagraph(visiblePosition)) | 1449 if (isEndOfParagraph(visiblePosition)) |
1447 return visiblePosition.next().deepEquivalent().downstream(); | 1450 return visiblePosition.next().deepEquivalent().downstream(); |
1448 | 1451 |
1449 // otherwise, make sure to be at the start of the first selected node, | 1452 // otherwise, make sure to be at the start of the first selected node, |
1450 // instead of possibly at the end of the last node before the selection | 1453 // instead of possibly at the end of the last node before the selection |
1451 return visiblePosition.deepEquivalent().downstream(); | 1454 return visiblePosition.deepEquivalent().downstream(); |
1452 } | 1455 } |
1453 | 1456 |
1454 } // namespace blink | 1457 } // namespace blink |
OLD | NEW |