| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 , m_sortedTextBoxesPosition(0) | 252 , m_sortedTextBoxesPosition(0) |
| 253 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) | 253 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) |
| 254 , m_entersTextControls(behavior & TextIteratorEntersTextControls) | 254 , m_entersTextControls(behavior & TextIteratorEntersTextControls) |
| 255 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) | 255 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) |
| 256 , m_handledFirstLetter(false) | 256 , m_handledFirstLetter(false) |
| 257 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) | 257 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) |
| 258 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) | 258 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) |
| 259 , m_shouldStop(false) | 259 , m_shouldStop(false) |
| 260 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) | 260 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) |
| 261 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) | 261 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) |
| 262 , m_hasNodesFollowing(behavior & TextIteratorBehavesAsIfNodesFollowing) |
| 262 { | 263 { |
| 263 if (!range) | 264 if (!range) |
| 264 return; | 265 return; |
| 265 | 266 |
| 266 // get and validate the range endpoints | 267 // get and validate the range endpoints |
| 267 Node* startContainer = range->startContainer(); | 268 Node* startContainer = range->startContainer(); |
| 268 if (!startContainer) | 269 if (!startContainer) |
| 269 return; | 270 return; |
| 270 int startOffset = range->startOffset(); | 271 int startOffset = range->startOffset(); |
| 271 Node* endContainer = range->endContainer(); | 272 Node* endContainer = range->endContainer(); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 657 |
| 657 if (runStart < runEnd) { | 658 if (runStart < runEnd) { |
| 658 // Handle either a single newline character (which becomes a space), | 659 // Handle either a single newline character (which becomes a space), |
| 659 // or a run of characters that does not include a newline. | 660 // or a run of characters that does not include a newline. |
| 660 // This effectively translates newlines to spaces without copying th
e text. | 661 // This effectively translates newlines to spaces without copying th
e text. |
| 661 if (str[runStart] == '\n') { | 662 if (str[runStart] == '\n') { |
| 662 emitCharacter(' ', m_node, 0, runStart, runStart + 1); | 663 emitCharacter(' ', m_node, 0, runStart, runStart + 1); |
| 663 m_offset = runStart + 1; | 664 m_offset = runStart + 1; |
| 664 } else { | 665 } else { |
| 665 size_t subrunEnd = str.find('\n', runStart); | 666 size_t subrunEnd = str.find('\n', runStart); |
| 666 if (subrunEnd == kNotFound || subrunEnd > runEnd) | 667 if (subrunEnd == kNotFound || subrunEnd > runEnd) { |
| 667 subrunEnd = runEnd; | 668 subrunEnd = runEnd; |
| 668 | 669 bool lastSpaceCollapsedByNextNonTextBox = !nextTextBox && m_
hasNodesFollowing && (str.length() == runEnd + 1); |
| 670 if (lastSpaceCollapsedByNextNonTextBox) |
| 671 subrunEnd++; // runEnd stopped before last space. Increm
ent by one to restore the space. |
| 672 } |
| 669 m_offset = subrunEnd; | 673 m_offset = subrunEnd; |
| 670 emitText(m_node, renderer, runStart, subrunEnd); | 674 emitText(m_node, renderer, runStart, subrunEnd); |
| 671 } | 675 } |
| 672 | 676 |
| 673 // If we are doing a subrun that doesn't go to the end of the text b
ox, | 677 // If we are doing a subrun that doesn't go to the end of the text b
ox, |
| 674 // come back again to finish handling this text box; don't advance t
o the next one. | 678 // come back again to finish handling this text box; don't advance t
o the next one. |
| 675 if (static_cast<unsigned>(m_positionEndOffset) < textBoxEnd) | 679 if (static_cast<unsigned>(m_positionEndOffset) < textBoxEnd) |
| 676 return; | 680 return; |
| 677 | 681 |
| 678 // Advance and return | 682 // Advance and return |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 if (!matchLength) | 2081 if (!matchLength) |
| 2078 return collapsedToBoundary(range, !(options & Backwards)); | 2082 return collapsedToBoundary(range, !(options & Backwards)); |
| 2079 } | 2083 } |
| 2080 | 2084 |
| 2081 // Then, find the document position of the start and the end of the text. | 2085 // Then, find the document position of the start and the end of the text. |
| 2082 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); | 2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); |
| 2083 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2087 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
| 2084 } | 2088 } |
| 2085 | 2089 |
| 2086 } | 2090 } |
| OLD | NEW |