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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 for (; !it.atEnd(); it.advance()) { | 103 for (; !it.atEnd(); it.advance()) { |
104 int len = it.length(); | 104 int len = it.length(); |
105 textRunRange = it.range(); | 105 textRunRange = it.range(); |
106 | 106 |
107 bool foundStart = start() >= docTextPosition && start() <= docTextPositi
on + len; | 107 bool foundStart = start() >= docTextPosition && start() <= docTextPositi
on + len; |
108 bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + l
en; | 108 bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + l
en; |
109 | 109 |
110 // Fix textRunRange->endPosition(), but only if foundStart || foundEnd,
because it is only | 110 // Fix textRunRange->endPosition(), but only if foundStart || foundEnd,
because it is only |
111 // in those cases that textRunRange is used. | 111 // in those cases that textRunRange is used. |
112 if (foundEnd) { | 112 if (foundEnd) { |
113 // FIXME: This is a workaround for the fact that the end of a run is
often at the wrong | 113 // FIXME: This is a workaround for the fact that the end of a run |
114 // position for emitted '\n's. | 114 // is often at the wrong position for emitted '\n's or if the |
115 if (len == 1 && it.characterAt(0) == '\n') { | 115 // renderer of the current node is a replaced element. |
| 116 if (len == 1 && (it.characterAt(0) == '\n' || it.isInsideReplacedEle
ment())) { |
116 scope.document().updateLayoutIgnorePendingStylesheets(); | 117 scope.document().updateLayoutIgnorePendingStylesheets(); |
117 it.advance(); | 118 it.advance(); |
118 if (!it.atEnd()) { | 119 if (!it.atEnd()) { |
119 RefPtrWillBeRawPtr<Range> range = it.range(); | 120 RefPtrWillBeRawPtr<Range> range = it.range(); |
120 textRunRange->setEnd(range->startContainer(), range->startOf
fset(), ASSERT_NO_EXCEPTION); | 121 textRunRange->setEnd(range->startContainer(), range->startOf
fset(), ASSERT_NO_EXCEPTION); |
121 } else { | 122 } else { |
122 Position runStart = textRunRange->startPosition(); | 123 Position runStart = textRunRange->startPosition(); |
123 Position runEnd = VisiblePosition(runStart).next().deepEquiv
alent(); | 124 Position runEnd = VisiblePosition(runStart).next().deepEquiv
alent(); |
124 if (runEnd.isNotNull()) | 125 if (runEnd.isNotNull()) |
125 textRunRange->setEnd(runEnd.containerNode(), runEnd.comp
uteOffsetInContainerNode(), ASSERT_NO_EXCEPTION); | 126 textRunRange->setEnd(runEnd.containerNode(), runEnd.comp
uteOffsetInContainerNode(), ASSERT_NO_EXCEPTION); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 size_t start = TextIterator::rangeLength(testRange.get()); | 187 size_t start = TextIterator::rangeLength(testRange.get()); |
187 | 188 |
188 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; | 189 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION)
; |
189 ASSERT(testRange->startContainer() == &scope); | 190 ASSERT(testRange->startContainer() == &scope); |
190 size_t end = TextIterator::rangeLength(testRange.get()); | 191 size_t end = TextIterator::rangeLength(testRange.get()); |
191 | 192 |
192 return PlainTextRange(start, end); | 193 return PlainTextRange(start, end); |
193 } | 194 } |
194 | 195 |
195 } | 196 } |
OLD | NEW |