| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 size_t docTextPosition = 0; | 76 size_t docTextPosition = 0; |
| 77 bool startRangeFound = false; | 77 bool startRangeFound = false; |
| 78 | 78 |
| 79 Position textRunStartPosition; | 79 Position textRunStartPosition; |
| 80 Position textRunEndPosition; | 80 Position textRunEndPosition; |
| 81 | 81 |
| 82 TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacement
Character; | 82 TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacement
Character; |
| 83 if (getRangeFor == ForSelection) | 83 if (getRangeFor == ForSelection) |
| 84 behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; | 84 behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; |
| 85 TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), b
ehaviorFlags); | 85 auto range = rangeOfContents(const_cast<ContainerNode*>(&scope)); |
| 86 TextIterator it(range->startPosition(), range->endPosition(), behaviorFlags)
; |
| 86 | 87 |
| 87 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b
ugs.webkit.org/show_bug.cgi?id=6289>. | 88 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b
ugs.webkit.org/show_bug.cgi?id=6289>. |
| 88 if (!start() && !length() && it.atEnd()) { | 89 if (!start() && !length() && it.atEnd()) { |
| 89 resultRange->setStart(it.startContainer(), 0, ASSERT_NO_EXCEPTION); | 90 resultRange->setStart(it.startContainer(), 0, ASSERT_NO_EXCEPTION); |
| 90 resultRange->setEnd(it.startContainer(), 0, ASSERT_NO_EXCEPTION); | 91 resultRange->setEnd(it.startContainer(), 0, ASSERT_NO_EXCEPTION); |
| 91 return resultRange.release(); | 92 return resultRange.release(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 for (; !it.atEnd(); it.advance()) { | 95 for (; !it.atEnd(); it.advance()) { |
| 95 int len = it.length(); | 96 int len = it.length(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // because of text fields and textareas. The DOM for those is not | 168 // because of text fields and textareas. The DOM for those is not |
| 168 // directly in the document DOM, so ensure that the range does not cross a | 169 // directly in the document DOM, so ensure that the range does not cross a |
| 169 // boundary of one of those. | 170 // boundary of one of those. |
| 170 if (range.startContainer() != &scope && !range.startContainer()->isDescendan
tOf(&scope)) | 171 if (range.startContainer() != &scope && !range.startContainer()->isDescendan
tOf(&scope)) |
| 171 return PlainTextRange(); | 172 return PlainTextRange(); |
| 172 if (range.endContainer() != scope && !range.endContainer()->isDescendantOf(&
scope)) | 173 if (range.endContainer() != scope && !range.endContainer()->isDescendantOf(&
scope)) |
| 173 return PlainTextRange(); | 174 return PlainTextRange(); |
| 174 | 175 |
| 175 RefPtrWillBeRawPtr<Range> testRange = Range::create(scope.document(), const_
cast<ContainerNode*>(&scope), 0, range.startContainer(), range.startOffset()); | 176 RefPtrWillBeRawPtr<Range> testRange = Range::create(scope.document(), const_
cast<ContainerNode*>(&scope), 0, range.startContainer(), range.startOffset()); |
| 176 ASSERT(testRange->startContainer() == &scope); | 177 ASSERT(testRange->startContainer() == &scope); |
| 177 size_t start = TextIterator::rangeLength(testRange.get()); | 178 size_t start = TextIterator::rangeLength(testRange->startPosition(), testRan
ge->endPosition()); |
| 178 | 179 |
| 179 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; | 180 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; |
| 180 ASSERT(testRange->startContainer() == &scope); | 181 ASSERT(testRange->startContainer() == &scope); |
| 181 size_t end = TextIterator::rangeLength(testRange.get()); | 182 size_t end = TextIterator::rangeLength(testRange->startPosition(), testRange
->endPosition()); |
| 182 | 183 |
| 183 return PlainTextRange(start, end); | 184 return PlainTextRange(start, end); |
| 184 } | 185 } |
| 185 | 186 |
| 186 } | 187 } |
| OLD | NEW |