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 bool nodeFullySelected = Range::compareBoundaryPoints(node.parentNode(), nod e.nodeIndex(), selectedRange.startContainer(), selectedRange.startOffset(), IGNO RE_EXCEPTION) >= 0 |
philipj_slow
2015/06/08 10:12:27
Could this be written as a static helper and used
deepak.s
2015/06/08 11:44:02
Done.
| |
1106 if (selectedRange.compareNode(&node, IGNORE_EXCEPTION) == Range::NODE_INSIDE ) | 1106 && Range::compareBoundaryPoints(node.parentNode(), node.nodeIndex() + 1, selectedRange.endContainer(), selectedRange.endOffset(), IGNORE_EXCEPTION) <= 0 ; |
1107 if (nodeFullySelected) | |
1107 return true; | 1108 return true; |
1108 | 1109 |
1109 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio n(selectedRange.startPosition()); | 1110 bool startIsVisuallySame = visiblePositionBeforeNode(node) == VisiblePositio n(selectedRange.startPosition()); |
1110 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node), selectedRange.endPosition()) < 0) | 1111 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node), selectedRange.endPosition()) < 0) |
1111 return true; | 1112 return true; |
1112 | 1113 |
1113 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s electedRange.endPosition()); | 1114 bool endIsVisuallySame = visiblePositionAfterNode(node) == VisiblePosition(s electedRange.endPosition()); |
1114 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos itionInParentBeforeNode(node)) < 0) | 1115 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos itionInParentBeforeNode(node)) < 0) |
1115 return true; | 1116 return true; |
1116 | 1117 |
(...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 | 1183 // if the selection starts just before a paragraph break, skip over it |
1183 if (isEndOfParagraph(visiblePosition)) | 1184 if (isEndOfParagraph(visiblePosition)) |
1184 return visiblePosition.next().deepEquivalent().downstream(); | 1185 return visiblePosition.next().deepEquivalent().downstream(); |
1185 | 1186 |
1186 // otherwise, make sure to be at the start of the first selected node, | 1187 // 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 | 1188 // instead of possibly at the end of the last node before the selection |
1188 return visiblePosition.deepEquivalent().downstream(); | 1189 return visiblePosition.deepEquivalent().downstream(); |
1189 } | 1190 } |
1190 | 1191 |
1191 } // namespace blink | 1192 } // namespace blink |
OLD | NEW |