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

Side by Side Diff: Source/core/editing/TextIterator.h

Issue 565613002: Remove usages of temporary Range objects that end up registered on the (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
« no previous file with comments | « Source/core/editing/SpellChecker.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 bool m_emitsObjectReplacementCharacter; 225 bool m_emitsObjectReplacementCharacter;
226 }; 226 };
227 227
228 // Iterates through the DOM range, returning all the text, and 0-length boundari es 228 // Iterates through the DOM range, returning all the text, and 0-length boundari es
229 // at points where replaced elements break up the text flow. The text comes back in 229 // at points where replaced elements break up the text flow. The text comes back in
230 // chunks so as to optimize for performance of the iteration. 230 // chunks so as to optimize for performance of the iteration.
231 class SimplifiedBackwardsTextIterator { 231 class SimplifiedBackwardsTextIterator {
232 STACK_ALLOCATED(); 232 STACK_ALLOCATED();
233 public: 233 public:
234 explicit SimplifiedBackwardsTextIterator(const Range*, TextIteratorBehaviorF lags = TextIteratorDefaultBehavior); 234 explicit SimplifiedBackwardsTextIterator(const Range*, TextIteratorBehaviorF lags = TextIteratorDefaultBehavior);
235 SimplifiedBackwardsTextIterator(const Position& start, const Position& end, TextIteratorBehaviorFlags = TextIteratorDefaultBehavior);
235 236
236 bool atEnd() const { return !m_positionNode || m_shouldStop; } 237 bool atEnd() const { return !m_positionNode || m_shouldStop; }
237 void advance(); 238 void advance();
238 239
239 int length() const { return m_textLength; } 240 int length() const { return m_textLength; }
240 241
241 Node* node() const { return m_node; } 242 Node* node() const { return m_node; }
242 243
243 template<typename BufferType> 244 template<typename BufferType>
244 void prependTextTo(BufferType& output) 245 void prependTextTo(BufferType& output)
245 { 246 {
246 if (!m_textLength) 247 if (!m_textLength)
247 return; 248 return;
248 if (m_singleCharacterBuffer) 249 if (m_singleCharacterBuffer)
249 output.prepend(&m_singleCharacterBuffer, 1); 250 output.prepend(&m_singleCharacterBuffer, 1);
250 else 251 else
251 m_textContainer.prependTo(output, m_textOffset, m_textLength); 252 m_textContainer.prependTo(output, m_textOffset, m_textLength);
252 } 253 }
253 254
254 PassRefPtrWillBeRawPtr<Range> range() const; 255 PassRefPtrWillBeRawPtr<Range> range() const;
255 256
256 Node* startContainer() const; 257 Node* startContainer() const;
257 int endOffset() const; 258 int endOffset() const;
258 Position startPosition() const; 259 Position startPosition() const;
259 260
260 private: 261 private:
262 void init(Node* startNode, Node* endNode, int startOffset, int endOffset);
261 void exitNode(); 263 void exitNode();
262 bool handleTextNode(); 264 bool handleTextNode();
263 RenderText* handleFirstLetter(int& startOffset, int& offsetInNode); 265 RenderText* handleFirstLetter(int& startOffset, int& offsetInNode);
264 bool handleReplacedElement(); 266 bool handleReplacedElement();
265 bool handleNonTextNode(); 267 bool handleNonTextNode();
266 void emitCharacter(UChar, Node*, int startOffset, int endOffset); 268 void emitCharacter(UChar, Node*, int startOffset, int endOffset);
267 bool advanceRespectingRange(Node*); 269 bool advanceRespectingRange(Node*);
268 270
269 // Current position, not necessarily of the text being returned, but positio n 271 // Current position, not necessarily of the text being returned, but positio n
270 // as we walk through the DOM tree. 272 // as we walk through the DOM tree.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 int m_runOffset; 349 int m_runOffset;
348 bool m_atBreak; 350 bool m_atBreak;
349 351
350 TextIterator m_textIterator; 352 TextIterator m_textIterator;
351 }; 353 };
352 354
353 class BackwardsCharacterIterator { 355 class BackwardsCharacterIterator {
354 STACK_ALLOCATED(); 356 STACK_ALLOCATED();
355 public: 357 public:
356 explicit BackwardsCharacterIterator(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); 358 explicit BackwardsCharacterIterator(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBehavior);
359 BackwardsCharacterIterator(const Position&, const Position&, TextIteratorBeh aviorFlags = TextIteratorDefaultBehavior);
357 360
358 void advance(int); 361 void advance(int);
359 362
360 bool atEnd() const { return m_textIterator.atEnd(); } 363 bool atEnd() const { return m_textIterator.atEnd(); }
361 364
362 PassRefPtrWillBeRawPtr<Range> range() const; 365 PassRefPtrWillBeRawPtr<Range> range() const;
363 366
364 Position endPosition() const; 367 Position endPosition() const;
365 368
366 private: 369 private:
(...skipping 22 matching lines...) Expand all
389 private: 392 private:
390 Vector<UChar> m_buffer; 393 Vector<UChar> m_buffer;
391 // Did we have to look ahead in the textIterator to confirm the current chun k? 394 // Did we have to look ahead in the textIterator to confirm the current chun k?
392 bool m_didLookAhead; 395 bool m_didLookAhead;
393 TextIterator m_textIterator; 396 TextIterator m_textIterator;
394 }; 397 };
395 398
396 } 399 }
397 400
398 #endif 401 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/SpellChecker.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698