OLD | NEW |
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return; | 100 return; |
101 if (m_singleCharacterBuffer) { | 101 if (m_singleCharacterBuffer) { |
102 ASSERT(!position); | 102 ASSERT(!position); |
103 ASSERT(length() == 1); | 103 ASSERT(length() == 1); |
104 output.append(&m_singleCharacterBuffer, 1); | 104 output.append(&m_singleCharacterBuffer, 1); |
105 } else { | 105 } else { |
106 string().appendTo(output, startOffset() + position, lengthToAppend); | 106 string().appendTo(output, startOffset() + position, lengthToAppend); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 PassRefPtrWillBeRawPtr<Range> range() const; | 110 PassRefPtrWillBeRawPtr<Range> createRange() const; |
111 Node* node() const; | 111 Node* node() const; |
112 | 112 |
| 113 Document* ownerDocument() const; |
| 114 Node* startContainer() const; |
| 115 Node* endContainer() const; |
113 int startOffset() const; | 116 int startOffset() const; |
114 int endOffset() const; | 117 int endOffset() const; |
115 Node* startContainer() const; | |
116 Position startPosition() const; | 118 Position startPosition() const; |
117 Position endPosition() const; | 119 Position endPosition() const; |
118 | 120 |
119 // Computes the length of the given range using a text iterator. The default | 121 // Computes the length of the given range using a text iterator. The default |
120 // iteration behavior is to always emit object replacement characters for | 122 // iteration behavior is to always emit object replacement characters for |
121 // replaced elements. When |forSelectionPreservation| is set to true, it | 123 // replaced elements. When |forSelectionPreservation| is set to true, it |
122 // also emits spaces for other non-text nodes using the | 124 // also emits spaces for other non-text nodes using the |
123 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode. | 125 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode. |
124 static int rangeLength(const Range*, bool forSelectionPreservation = false); | 126 static int rangeLength(const Range*, bool forSelectionPreservation = false); |
125 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac
terOffset, int characterCount); | 127 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac
terOffset, int characterCount); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 void prependTextTo(BufferType& output) | 247 void prependTextTo(BufferType& output) |
246 { | 248 { |
247 if (!m_textLength) | 249 if (!m_textLength) |
248 return; | 250 return; |
249 if (m_singleCharacterBuffer) | 251 if (m_singleCharacterBuffer) |
250 output.prepend(&m_singleCharacterBuffer, 1); | 252 output.prepend(&m_singleCharacterBuffer, 1); |
251 else | 253 else |
252 m_textContainer.prependTo(output, m_textOffset, m_textLength); | 254 m_textContainer.prependTo(output, m_textOffset, m_textLength); |
253 } | 255 } |
254 | 256 |
255 PassRefPtrWillBeRawPtr<Range> range() const; | |
256 | |
257 Node* startContainer() const; | 257 Node* startContainer() const; |
258 int endOffset() const; | 258 int endOffset() const; |
259 Position startPosition() const; | 259 Position startPosition() const; |
| 260 Position endPosition() const; |
260 | 261 |
261 private: | 262 private: |
262 void init(Node* startNode, Node* endNode, int startOffset, int endOffset); | 263 void init(Node* startNode, Node* endNode, int startOffset, int endOffset); |
263 void exitNode(); | 264 void exitNode(); |
264 bool handleTextNode(); | 265 bool handleTextNode(); |
265 RenderText* handleFirstLetter(int& startOffset, int& offsetInNode); | 266 RenderText* handleFirstLetter(int& startOffset, int& offsetInNode); |
266 bool handleReplacedElement(); | 267 bool handleReplacedElement(); |
267 bool handleNonTextNode(); | 268 bool handleNonTextNode(); |
268 void emitCharacter(UChar, Node*, int startOffset, int endOffset); | 269 void emitCharacter(UChar, Node*, int startOffset, int endOffset); |
269 bool advanceRespectingRange(Node*); | 270 bool advanceRespectingRange(Node*); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 bool atBreak() const { return m_atBreak; } | 329 bool atBreak() const { return m_atBreak; } |
329 bool atEnd() const { return m_textIterator.atEnd(); } | 330 bool atEnd() const { return m_textIterator.atEnd(); } |
330 | 331 |
331 int length() const { return m_textIterator.length() - m_runOffset; } | 332 int length() const { return m_textIterator.length() - m_runOffset; } |
332 UChar characterAt(unsigned index) const { return m_textIterator.characterAt(
m_runOffset + index); } | 333 UChar characterAt(unsigned index) const { return m_textIterator.characterAt(
m_runOffset + index); } |
333 | 334 |
334 template<typename BufferType> | 335 template<typename BufferType> |
335 void appendTextTo(BufferType& output) { m_textIterator.appendTextTo(output,
m_runOffset); } | 336 void appendTextTo(BufferType& output) { m_textIterator.appendTextTo(output,
m_runOffset); } |
336 | 337 |
337 int characterOffset() const { return m_offset; } | 338 int characterOffset() const { return m_offset; } |
338 PassRefPtrWillBeRawPtr<Range> range() const; | 339 PassRefPtrWillBeRawPtr<Range> createRange() const; |
339 | 340 |
| 341 Document* ownerDocument() const; |
340 Node* startContainer() const; | 342 Node* startContainer() const; |
| 343 Node* endContainer() const; |
341 int startOffset() const; | 344 int startOffset() const; |
| 345 int endOffset() const; |
342 Position startPosition() const; | 346 Position startPosition() const; |
343 Position endPosition() const; | 347 Position endPosition() const; |
344 | 348 |
345 private: | 349 private: |
346 void initialize(); | 350 void initialize(); |
347 | 351 |
348 int m_offset; | 352 int m_offset; |
349 int m_runOffset; | 353 int m_runOffset; |
350 bool m_atBreak; | 354 bool m_atBreak; |
351 | 355 |
352 TextIterator m_textIterator; | 356 TextIterator m_textIterator; |
353 }; | 357 }; |
354 | 358 |
355 class BackwardsCharacterIterator { | 359 class BackwardsCharacterIterator { |
356 STACK_ALLOCATED(); | 360 STACK_ALLOCATED(); |
357 public: | 361 public: |
358 explicit BackwardsCharacterIterator(const Range*, TextIteratorBehaviorFlags
= TextIteratorDefaultBehavior); | 362 explicit BackwardsCharacterIterator(const Range*, TextIteratorBehaviorFlags
= TextIteratorDefaultBehavior); |
359 BackwardsCharacterIterator(const Position&, const Position&, TextIteratorBeh
aviorFlags = TextIteratorDefaultBehavior); | 363 BackwardsCharacterIterator(const Position&, const Position&, TextIteratorBeh
aviorFlags = TextIteratorDefaultBehavior); |
360 | 364 |
361 void advance(int); | 365 void advance(int); |
362 | 366 |
363 bool atEnd() const { return m_textIterator.atEnd(); } | 367 bool atEnd() const { return m_textIterator.atEnd(); } |
364 | 368 |
365 PassRefPtrWillBeRawPtr<Range> range() const; | |
366 | |
367 Position endPosition() const; | 369 Position endPosition() const; |
368 | 370 |
369 private: | 371 private: |
370 int m_offset; | 372 int m_offset; |
371 int m_runOffset; | 373 int m_runOffset; |
372 bool m_atBreak; | 374 bool m_atBreak; |
373 | 375 |
374 SimplifiedBackwardsTextIterator m_textIterator; | 376 SimplifiedBackwardsTextIterator m_textIterator; |
375 }; | 377 }; |
376 | 378 |
(...skipping 15 matching lines...) Expand all Loading... |
392 private: | 394 private: |
393 Vector<UChar> m_buffer; | 395 Vector<UChar> m_buffer; |
394 // Did we have to look ahead in the textIterator to confirm the current chun
k? | 396 // Did we have to look ahead in the textIterator to confirm the current chun
k? |
395 bool m_didLookAhead; | 397 bool m_didLookAhead; |
396 TextIterator m_textIterator; | 398 TextIterator m_textIterator; |
397 }; | 399 }; |
398 | 400 |
399 } | 401 } |
400 | 402 |
401 #endif | 403 #endif |
OLD | NEW |