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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (node.hasChildren()) | 518 if (node.hasChildren()) |
519 return VisiblePosition(lastPositionInOrAfterNode(&node), DOWNSTREAM); | 519 return VisiblePosition(lastPositionInOrAfterNode(&node), DOWNSTREAM); |
520 ASSERT(node.parentNode()); | 520 ASSERT(node.parentNode()); |
521 ASSERT(!node.parentNode()->isShadowRoot()); | 521 ASSERT(!node.parentNode()->isShadowRoot()); |
522 return VisiblePosition(positionInParentAfterNode(node)); | 522 return VisiblePosition(positionInParentAfterNode(node)); |
523 } | 523 } |
524 | 524 |
525 // Create a range object with two visible positions, start and end. | 525 // Create a range object with two visible positions, start and end. |
526 // create(Document*, const Position&, const Position&); will use deprecatedEditi
ngOffset | 526 // create(Document*, const Position&, const Position&); will use deprecatedEditi
ngOffset |
527 // Use this function instead of create a regular range object (avoiding editing
offset). | 527 // Use this function instead of create a regular range object (avoiding editing
offset). |
528 PassRefPtr<Range> createRange(Document& document, const VisiblePosition& start,
const VisiblePosition& end, ExceptionState& exceptionState) | 528 PassRefPtrWillBeRawPtr<Range> createRange(Document& document, const VisiblePosit
ion& start, const VisiblePosition& end, ExceptionState& exceptionState) |
529 { | 529 { |
530 RefPtr<Range> selectedRange = Range::create(document); | 530 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(document); |
531 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), exceptionState); | 531 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), exceptionState); |
532 if (!exceptionState.hadException()) | 532 if (!exceptionState.hadException()) |
533 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), exceptionState); | 533 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), exceptionState); |
534 return selectedRange.release(); | 534 return selectedRange.release(); |
535 } | 535 } |
536 | 536 |
537 bool isListElement(Node* n) | 537 bool isListElement(Node* n) |
538 { | 538 { |
539 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); | 539 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); |
540 } | 540 } |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 1007 |
1008 Position p(visiblePosition.deepEquivalent()); | 1008 Position p(visiblePosition.deepEquivalent()); |
1009 Document& document = *p.document(); | 1009 Document& document = *p.document(); |
1010 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); | 1010 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); |
1011 | 1011 |
1012 if (shadowRoot) | 1012 if (shadowRoot) |
1013 scope = shadowRoot; | 1013 scope = shadowRoot; |
1014 else | 1014 else |
1015 scope = document.documentElement(); | 1015 scope = document.documentElement(); |
1016 | 1016 |
1017 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get(
)), p.parentAnchoredEquivalent()); | 1017 RefPtrWillBeRawPtr<Range> range = Range::create(document, firstPositionInNod
e(scope.get()), p.parentAnchoredEquivalent()); |
1018 | 1018 |
1019 return TextIterator::rangeLength(range.get(), true); | 1019 return TextIterator::rangeLength(range.get(), true); |
1020 } | 1020 } |
1021 | 1021 |
1022 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) | 1022 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) |
1023 { | 1023 { |
1024 if (!scope) | 1024 if (!scope) |
1025 return VisiblePosition(); | 1025 return VisiblePosition(); |
1026 RefPtr<Range> range = PlainTextRange(index).createRangeForSelection(*scope); | 1026 RefPtrWillBeRawPtr<Range> range = PlainTextRange(index).createRangeForSelect
ion(*scope); |
1027 // Check for an invalid index. Certain editing operations invalidate indices
because | 1027 // Check for an invalid index. Certain editing operations invalidate indices
because |
1028 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1028 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1029 if (!range) | 1029 if (!range) |
1030 return VisiblePosition(); | 1030 return VisiblePosition(); |
1031 return VisiblePosition(range->startPosition()); | 1031 return VisiblePosition(range->startPosition()); |
1032 } | 1032 } |
1033 | 1033 |
1034 // Determines whether two positions are visibly next to each other (first then s
econd) | 1034 // Determines whether two positions are visibly next to each other (first then s
econd) |
1035 // while ignoring whitespaces and unrendered nodes | 1035 // while ignoring whitespaces and unrendered nodes |
1036 bool isVisiblyAdjacent(const Position& first, const Position& second) | 1036 bool isVisiblyAdjacent(const Position& first, const Position& second) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 // if the selection starts just before a paragraph break, skip over it | 1112 // if the selection starts just before a paragraph break, skip over it |
1113 if (isEndOfParagraph(visiblePosition)) | 1113 if (isEndOfParagraph(visiblePosition)) |
1114 return visiblePosition.next().deepEquivalent().downstream(); | 1114 return visiblePosition.next().deepEquivalent().downstream(); |
1115 | 1115 |
1116 // otherwise, make sure to be at the start of the first selected node, | 1116 // otherwise, make sure to be at the start of the first selected node, |
1117 // instead of possibly at the end of the last node before the selection | 1117 // instead of possibly at the end of the last node before the selection |
1118 return visiblePosition.deepEquivalent().downstream(); | 1118 return visiblePosition.deepEquivalent().downstream(); |
1119 } | 1119 } |
1120 | 1120 |
1121 } // namespace WebCore | 1121 } // namespace WebCore |
OLD | NEW |