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

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

Issue 544083002: Avoid allocating temporary ranges in connection with text and character iterators. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacement Character; 81 TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacement Character;
82 if (getRangeFor == ForSelection) 82 if (getRangeFor == ForSelection)
83 behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; 83 behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions;
84 TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), b ehaviorFlags); 84 TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), b ehaviorFlags);
85 85
86 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b ugs.webkit.org/show_bug.cgi?id=6289>. 86 // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://b ugs.webkit.org/show_bug.cgi?id=6289>.
87 if (!start() && !length() && it.atEnd()) { 87 if (!start() && !length() && it.atEnd()) {
88 textRunRange = it.range(); 88 textRunRange = it.range();
89 89
90 resultRange->setStart(textRunRange->startContainer(), 0, ASSERT_NO_EXCEP TION); 90 resultRange->setStart(it.startContainer(), 0, ASSERT_NO_EXCEPTION);
91 resultRange->setEnd(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTI ON); 91 resultRange->setEnd(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTI ON);
yosin_UTC9 2014/09/08 01:55:19 nit: It seems we can replace L91 |textRunRange->st
Mads Ager (chromium) 2014/09/08 08:50:46 Yes, good catch, not sure why I didn't notice that
92 92
93 return resultRange.release(); 93 return resultRange.release();
94 } 94 }
95 95
96 for (; !it.atEnd(); it.advance()) { 96 for (; !it.atEnd(); it.advance()) {
97 int len = it.length(); 97 int len = it.length();
98 textRunRange = it.range(); 98 textRunRange = it.range();
99 99
100 bool foundStart = start() >= docTextPosition && start() <= docTextPositi on + len; 100 bool foundStart = start() >= docTextPosition && start() <= docTextPositi on + len;
101 bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + l en; 101 bool foundEnd = end() >= docTextPosition && end() <= docTextPosition + l en;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 size_t start = TextIterator::rangeLength(testRange.get()); 179 size_t start = TextIterator::rangeLength(testRange.get());
180 180
181 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION) ; 181 testRange->setEnd(range.endContainer(), range.endOffset(), IGNORE_EXCEPTION) ;
182 ASSERT(testRange->startContainer() == &scope); 182 ASSERT(testRange->startContainer() == &scope);
183 size_t end = TextIterator::rangeLength(testRange.get()); 183 size_t end = TextIterator::rangeLength(testRange.get());
184 184
185 return PlainTextRange(start, end); 185 return PlainTextRange(start, end);
186 } 186 }
187 187
188 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698