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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 ASSERT(node->parentNode()); | 524 ASSERT(node->parentNode()); |
525 ASSERT(!node->parentNode()->isShadowRoot()); | 525 ASSERT(!node->parentNode()->isShadowRoot()); |
526 return positionInParentAfterNode(node); | 526 return positionInParentAfterNode(node); |
527 } | 527 } |
528 | 528 |
529 // Create a range object with two visible positions, start and end. | 529 // Create a range object with two visible positions, start and end. |
530 // create(Document*, const Position&, const Position&); will use deprecatedEditi
ngOffset | 530 // create(Document*, const Position&, const Position&); will use deprecatedEditi
ngOffset |
531 // Use this function instead of create a regular range object (avoiding editing
offset). | 531 // Use this function instead of create a regular range object (avoiding editing
offset). |
532 PassRefPtr<Range> createRange(Document& document, const VisiblePosition& start,
const VisiblePosition& end, ExceptionState& es) | 532 PassRefPtr<Range> createRange(Document& document, const VisiblePosition& start,
const VisiblePosition& end, ExceptionState& es) |
533 { | 533 { |
534 RefPtr<Range> selectedRange = Range::create(&document); | 534 RefPtr<Range> selectedRange = Range::create(document); |
535 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), es); | 535 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), es); |
536 if (!es.hadException()) | 536 if (!es.hadException()) |
537 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), es); | 537 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), es); |
538 return selectedRange.release(); | 538 return selectedRange.release(); |
539 } | 539 } |
540 | 540 |
541 bool isListElement(Node *n) | 541 bool isListElement(Node *n) |
542 { | 542 { |
543 return (n && (n->hasTagName(ulTag) || n->hasTagName(olTag) || n->hasTagName(
dlTag))); | 543 return (n && (n->hasTagName(ulTag) || n->hasTagName(olTag) || n->hasTagName(
dlTag))); |
544 } | 544 } |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1059 |
1060 Position p(visiblePosition.deepEquivalent()); | 1060 Position p(visiblePosition.deepEquivalent()); |
1061 Document& document = p.anchorNode()->document(); | 1061 Document& document = p.anchorNode()->document(); |
1062 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); | 1062 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); |
1063 | 1063 |
1064 if (shadowRoot) | 1064 if (shadowRoot) |
1065 scope = shadowRoot; | 1065 scope = shadowRoot; |
1066 else | 1066 else |
1067 scope = document.documentElement(); | 1067 scope = document.documentElement(); |
1068 | 1068 |
1069 RefPtr<Range> range = Range::create(&document, firstPositionInNode(scope.get
()), p.parentAnchoredEquivalent()); | 1069 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get(
)), p.parentAnchoredEquivalent()); |
1070 | 1070 |
1071 return TextIterator::rangeLength(range.get(), true); | 1071 return TextIterator::rangeLength(range.get(), true); |
1072 } | 1072 } |
1073 | 1073 |
1074 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) | 1074 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) |
1075 { | 1075 { |
1076 RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, index,
0, true); | 1076 RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, index,
0, true); |
1077 // Check for an invalid index. Certain editing operations invalidate indices
because | 1077 // Check for an invalid index. Certain editing operations invalidate indices
because |
1078 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1078 // of problems with TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1079 if (!range) | 1079 if (!range) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 // if the selection starts just before a paragraph break, skip over it | 1164 // if the selection starts just before a paragraph break, skip over it |
1165 if (isEndOfParagraph(visiblePosition)) | 1165 if (isEndOfParagraph(visiblePosition)) |
1166 return visiblePosition.next().deepEquivalent().downstream(); | 1166 return visiblePosition.next().deepEquivalent().downstream(); |
1167 | 1167 |
1168 // otherwise, make sure to be at the start of the first selected node, | 1168 // otherwise, make sure to be at the start of the first selected node, |
1169 // instead of possibly at the end of the last node before the selection | 1169 // instead of possibly at the end of the last node before the selection |
1170 return visiblePosition.deepEquivalent().downstream(); | 1170 return visiblePosition.deepEquivalent().downstream(); |
1171 } | 1171 } |
1172 | 1172 |
1173 } // namespace WebCore | 1173 } // namespace WebCore |
OLD | NEW |