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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1095 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1096 if (!range) | 1096 if (!range) |
1097 return VisiblePosition(); | 1097 return VisiblePosition(); |
1098 return VisiblePosition(range->startPosition()); | 1098 return VisiblePosition(range->startPosition()); |
1099 } | 1099 } |
1100 | 1100 |
1101 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. | 1101 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. |
1102 // Call this function to determine whether a node is visibly fit inside selected
Range | 1102 // Call this function to determine whether a node is visibly fit inside selected
Range |
1103 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) | 1103 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) |
1104 { | 1104 { |
1105 // If the node is inside the range, then it surely is contained within | 1105 if (selectedRange.isNodeFullySelected(node)) |
1106 if (selectedRange.compareNode(&node, IGNORE_EXCEPTION) == Range::NODE_INSIDE
) | |
1107 return true; | 1106 return true; |
1108 | 1107 |
1109 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); | 1108 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio
n(selectedRange.startPosition()); |
1110 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) | 1109 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange.endPosition()) < 0) |
1111 return true; | 1110 return true; |
1112 | 1111 |
1113 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); | 1112 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s
electedRange.endPosition()); |
1114 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) | 1113 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) |
1115 return true; | 1114 return true; |
1116 | 1115 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 // if the selection starts just before a paragraph break, skip over it | 1181 // if the selection starts just before a paragraph break, skip over it |
1183 if (isEndOfParagraph(visiblePosition)) | 1182 if (isEndOfParagraph(visiblePosition)) |
1184 return visiblePosition.next().deepEquivalent().downstream(); | 1183 return visiblePosition.next().deepEquivalent().downstream(); |
1185 | 1184 |
1186 // otherwise, make sure to be at the start of the first selected node, | 1185 // otherwise, make sure to be at the start of the first selected node, |
1187 // instead of possibly at the end of the last node before the selection | 1186 // instead of possibly at the end of the last node before the selection |
1188 return visiblePosition.deepEquivalent().downstream(); | 1187 return visiblePosition.deepEquivalent().downstream(); |
1189 } | 1188 } |
1190 | 1189 |
1191 } // namespace blink | 1190 } // namespace blink |
OLD | NEW |