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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 if (visiblePosition.isNull()) | 830 if (visiblePosition.isNull()) |
831 return 0; | 831 return 0; |
832 | 832 |
833 Position p(visiblePosition.deepEquivalent()); | 833 Position p(visiblePosition.deepEquivalent()); |
834 Document& document = *p.document(); | 834 Document& document = *p.document(); |
835 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); | 835 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); |
836 | 836 |
837 if (shadowRoot) | 837 if (shadowRoot) |
838 scope = shadowRoot; | 838 scope = shadowRoot; |
839 else | 839 else |
840 scope = document.documentElement(); | 840 scope = &document; |
841 | 841 |
842 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get(
)), p.parentAnchoredEquivalent()); | 842 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get(
)), p.parentAnchoredEquivalent()); |
843 | 843 |
844 return TextIterator::rangeLength(range.get(), true); | 844 return TextIterator::rangeLength(range.get(), true); |
845 } | 845 } |
846 | 846 |
847 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) | 847 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) |
848 { | 848 { |
849 if (!scope) | 849 if (!scope) |
850 return VisiblePosition(); | 850 return VisiblePosition(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 // if the selection starts just before a paragraph break, skip over it | 925 // if the selection starts just before a paragraph break, skip over it |
926 if (isEndOfParagraph(visiblePosition)) | 926 if (isEndOfParagraph(visiblePosition)) |
927 return visiblePosition.next().deepEquivalent().downstream(); | 927 return visiblePosition.next().deepEquivalent().downstream(); |
928 | 928 |
929 // otherwise, make sure to be at the start of the first selected node, | 929 // otherwise, make sure to be at the start of the first selected node, |
930 // instead of possibly at the end of the last node before the selection | 930 // instead of possibly at the end of the last node before the selection |
931 return visiblePosition.deepEquivalent().downstream(); | 931 return visiblePosition.deepEquivalent().downstream(); |
932 } | 932 } |
933 | 933 |
934 } // namespace blink | 934 } // namespace blink |
OLD | NEW |