OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRange(const ContainerNode& s
cope) const | 60 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRange(const ContainerNode& s
cope) const |
61 { | 61 { |
62 return createRangeFor(scope, ForGeneric); | 62 return createRangeFor(scope, ForGeneric); |
63 } | 63 } |
64 | 64 |
65 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeForSelection(const Cont
ainerNode& scope) const | 65 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeForSelection(const Cont
ainerNode& scope) const |
66 { | 66 { |
67 return createRangeFor(scope, ForSelection); | 67 return createRangeFor(scope, ForSelection); |
68 } | 68 } |
69 | 69 |
| 70 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeForInputMethod(const Co
ntainerNode& scope) const |
| 71 { |
| 72 return createRangeFor(scope, ForInputMethod); |
| 73 } |
| 74 |
70 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeFor(const ContainerNode
& scope, GetRangeFor getRangeFor) const | 75 PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeFor(const ContainerNode
& scope, GetRangeFor getRangeFor) const |
71 { | 76 { |
72 ASSERT(isNotNull()); | 77 ASSERT(isNotNull()); |
73 | 78 |
74 RefPtrWillBeRawPtr<Range> resultRange = scope.document().createRange(); | 79 RefPtrWillBeRawPtr<Range> resultRange = scope.document().createRange(); |
75 | 80 |
76 size_t docTextPosition = 0; | 81 size_t docTextPosition = 0; |
77 bool startRangeFound = false; | 82 bool startRangeFound = false; |
78 | 83 |
79 RefPtrWillBeRawPtr<Range> textRunRange = nullptr; | 84 RefPtrWillBeRawPtr<Range> textRunRange = nullptr; |
80 | 85 |
81 TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), g
etRangeFor == ForSelection ? TextIteratorEmitsCharactersBetweenAllVisiblePositio
ns : TextIteratorDefaultBehavior); | 86 TextIteratorBehavior behaviorFlags = TextIteratorDefaultBehavior; |
| 87 if (getRangeFor == ForSelection) |
| 88 behaviorFlags = TextIteratorEmitsCharactersBetweenAllVisiblePositions; |
| 89 else if (getRangeFor == ForInputMethod) |
| 90 behaviorFlags = TextIteratorEmitsObjectReplacementCharacter; |
| 91 TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), b
ehaviorFlags); |
82 | 92 |
83 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b
ugs.webkit.org/show_bug.cgi?id=6289>. | 93 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b
ugs.webkit.org/show_bug.cgi?id=6289>. |
84 if (!start() && !length() && it.atEnd()) { | 94 if (!start() && !length() && it.atEnd()) { |
85 textRunRange = it.range(); | 95 textRunRange = it.range(); |
86 | 96 |
87 resultRange->setStart(textRunRange->startContainer(), 0, ASSERT_NO_EXCEP
TION); | 97 resultRange->setStart(textRunRange->startContainer(), 0, ASSERT_NO_EXCEP
TION); |
88 resultRange->setEnd(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTI
ON); | 98 resultRange->setEnd(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTI
ON); |
89 | 99 |
90 return resultRange.release(); | 100 return resultRange.release(); |
91 } | 101 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 size_t start = TextIterator::rangeLength(testRange.get()); | 186 size_t start = TextIterator::rangeLength(testRange.get()); |
177 | 187 |
178 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; | 188 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; |
179 ASSERT(testRange->startContainer() == &scope); | 189 ASSERT(testRange->startContainer() == &scope); |
180 size_t end = TextIterator::rangeLength(testRange.get()); | 190 size_t end = TextIterator::rangeLength(testRange.get()); |
181 | 191 |
182 return PlainTextRange(start, end); | 192 return PlainTextRange(start, end); |
183 } | 193 } |
184 | 194 |
185 } | 195 } |
OLD | NEW |