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 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1261 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1262 if (!range) | 1262 if (!range) |
1263 return VisiblePosition(); | 1263 return VisiblePosition(); |
1264 return VisiblePosition(range->startPosition()); | 1264 return VisiblePosition(range->startPosition()); |
1265 } | 1265 } |
1266 | 1266 |
1267 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. | 1267 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. |
1268 // Call this function to determine whether a node is visibly fit inside selected
Range | 1268 // Call this function to determine whether a node is visibly fit inside selected
Range |
1269 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) | 1269 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) |
1270 { | 1270 { |
1271 // If the node is inside the range, then it surely is contained within | 1271 if (selectedRange.isNodeFullyContained(node)) |
1272 if (selectedRange.compareNode(&node, IGNORE_EXCEPTION) == Range::NODE_INSIDE
) | |
1273 return true; | 1272 return true; |
1274 | 1273 |
1275 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); | 1274 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); |
1276 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) | 1275 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) |
1277 return true; | 1276 return true; |
1278 | 1277 |
1279 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); | 1278 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); |
1280 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) | 1279 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) |
1281 return true; | 1280 return true; |
1282 | 1281 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 // if the selection starts just before a paragraph break, skip over it | 1347 // if the selection starts just before a paragraph break, skip over it |
1349 if (isEndOfParagraph(visiblePosition)) | 1348 if (isEndOfParagraph(visiblePosition)) |
1350 return visiblePosition.next().deepEquivalent().downstream(); | 1349 return visiblePosition.next().deepEquivalent().downstream(); |
1351 | 1350 |
1352 // otherwise, make sure to be at the start of the first selected node, | 1351 // otherwise, make sure to be at the start of the first selected node, |
1353 // instead of possibly at the end of the last node before the selection | 1352 // instead of possibly at the end of the last node before the selection |
1354 return visiblePosition.deepEquivalent().downstream(); | 1353 return visiblePosition.deepEquivalent().downstream(); |
1355 } | 1354 } |
1356 | 1355 |
1357 } // namespace blink | 1356 } // namespace blink |
OLD | NEW |