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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1156 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1157 if (!range) | 1157 if (!range) |
1158 return VisiblePosition(); | 1158 return VisiblePosition(); |
1159 return VisiblePosition(range->startPosition()); | 1159 return VisiblePosition(range->startPosition()); |
1160 } | 1160 } |
1161 | 1161 |
1162 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. | 1162 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. |
1163 // Call this function to determine whether a node is visibly fit inside selected
Range | 1163 // Call this function to determine whether a node is visibly fit inside selected
Range |
1164 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) | 1164 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) |
1165 { | 1165 { |
1166 // If the node is inside the range, then it surely is contained within | 1166 if (selectedRange.isNodeFullyContained(node, IGNORE_EXCEPTION)) |
1167 if (selectedRange.compareNode(&node, IGNORE_EXCEPTION) == Range::NODE_INSIDE
) | |
1168 return true; | 1167 return true; |
1169 | 1168 |
1170 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); | 1169 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); |
1171 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) | 1170 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) |
1172 return true; | 1171 return true; |
1173 | 1172 |
1174 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); | 1173 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); |
1175 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) | 1174 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) |
1176 return true; | 1175 return true; |
1177 | 1176 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 // if the selection starts just before a paragraph break, skip over it | 1242 // if the selection starts just before a paragraph break, skip over it |
1244 if (isEndOfParagraph(visiblePosition)) | 1243 if (isEndOfParagraph(visiblePosition)) |
1245 return visiblePosition.next().deepEquivalent().downstream(); | 1244 return visiblePosition.next().deepEquivalent().downstream(); |
1246 | 1245 |
1247 // otherwise, make sure to be at the start of the first selected node, | 1246 // otherwise, make sure to be at the start of the first selected node, |
1248 // instead of possibly at the end of the last node before the selection | 1247 // instead of possibly at the end of the last node before the selection |
1249 return visiblePosition.deepEquivalent().downstream(); | 1248 return visiblePosition.deepEquivalent().downstream(); |
1250 } | 1249 } |
1251 | 1250 |
1252 } // namespace blink | 1251 } // namespace blink |
OLD | NEW |