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 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 if (shadowRoot) | 1504 if (shadowRoot) |
1505 scope = shadowRoot; | 1505 scope = shadowRoot; |
1506 else | 1506 else |
1507 scope = document.documentElement(); | 1507 scope = document.documentElement(); |
1508 | 1508 |
1509 RefPtrWillBeRawPtr<Range> range = Range::create(document, firstPositionInNod
e(scope.get()), p.parentAnchoredEquivalent()); | 1509 RefPtrWillBeRawPtr<Range> range = Range::create(document, firstPositionInNod
e(scope.get()), p.parentAnchoredEquivalent()); |
1510 | 1510 |
1511 return TextIterator::rangeLength(range->startPosition(), range->endPosition(
), true); | 1511 return TextIterator::rangeLength(range->startPosition(), range->endPosition(
), true); |
1512 } | 1512 } |
1513 | 1513 |
| 1514 EphemeralRange makeRange(const VisiblePosition &start, const VisiblePosition &en
d) |
| 1515 { |
| 1516 if (start.isNull() || end.isNull()) |
| 1517 return EphemeralRange(); |
| 1518 |
| 1519 Position s = start.deepEquivalent().parentAnchoredEquivalent(); |
| 1520 Position e = end.deepEquivalent().parentAnchoredEquivalent(); |
| 1521 if (s.isNull() || e.isNull()) |
| 1522 return EphemeralRange(); |
| 1523 |
| 1524 return EphemeralRange(s, e); |
| 1525 } |
| 1526 |
1514 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) | 1527 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) |
1515 { | 1528 { |
1516 if (!scope) | 1529 if (!scope) |
1517 return VisiblePosition(); | 1530 return VisiblePosition(); |
1518 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope)
; | 1531 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope)
; |
1519 // Check for an invalid index. Certain editing operations invalidate indices | 1532 // Check for an invalid index. Certain editing operations invalidate indices |
1520 // because of problems with | 1533 // because of problems with |
1521 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1534 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1522 if (range.isNull()) | 1535 if (range.isNull()) |
1523 return VisiblePosition(); | 1536 return VisiblePosition(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 // if the selection starts just before a paragraph break, skip over it | 1620 // if the selection starts just before a paragraph break, skip over it |
1608 if (isEndOfParagraph(visiblePosition)) | 1621 if (isEndOfParagraph(visiblePosition)) |
1609 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui
valent()); | 1622 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui
valent()); |
1610 | 1623 |
1611 // otherwise, make sure to be at the start of the first selected node, | 1624 // otherwise, make sure to be at the start of the first selected node, |
1612 // instead of possibly at the end of the last node before the selection | 1625 // instead of possibly at the end of the last node before the selection |
1613 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1626 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
1614 } | 1627 } |
1615 | 1628 |
1616 } // namespace blink | 1629 } // namespace blink |
OLD | NEW |