Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: Source/core/editing/PlainTextRange.cpp

Issue 342483002: The length of a TextIterator containing replaced element is at least 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style issues. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « LayoutTests/editing/inserting/insert-with-javascript-protocol-crash-expected.txt ('k') | Source/core/editing/TextIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698