| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 , m_needsAnotherNewline(false) | 243 , m_needsAnotherNewline(false) |
| 244 , m_textBox(0) | 244 , m_textBox(0) |
| 245 , m_lastTextNode(nullptr) | 245 , m_lastTextNode(nullptr) |
| 246 , m_lastTextNodeEndedWithCollapsedSpace(false) | 246 , m_lastTextNodeEndedWithCollapsedSpace(false) |
| 247 , m_lastCharacter(0) | 247 , m_lastCharacter(0) |
| 248 , m_sortedTextBoxesPosition(0) | 248 , m_sortedTextBoxesPosition(0) |
| 249 , m_hasEmitted(false) | 249 , m_hasEmitted(false) |
| 250 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) | 250 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) |
| 251 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) | 251 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) |
| 252 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) | 252 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) |
| 253 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) | |
| 254 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) | 253 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) |
| 255 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac
ementCharacter) | 254 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac
ementCharacter) |
| 256 { | 255 { |
| 257 if (range) | 256 if (range) |
| 258 initialize(range->startPosition(), range->endPosition()); | 257 initialize(range->startPosition(), range->endPosition()); |
| 259 } | 258 } |
| 260 | 259 |
| 261 TextIterator::TextIterator(const Position& start, const Position& end, TextItera
torBehaviorFlags behavior) | 260 TextIterator::TextIterator(const Position& start, const Position& end, TextItera
torBehaviorFlags behavior) |
| 262 : m_startContainer(nullptr) | 261 : m_startContainer(nullptr) |
| 263 , m_startOffset(0) | 262 , m_startOffset(0) |
| 264 , m_endContainer(nullptr) | 263 , m_endContainer(nullptr) |
| 265 , m_endOffset(0) | 264 , m_endOffset(0) |
| 266 , m_positionNode(nullptr) | 265 , m_positionNode(nullptr) |
| 267 , m_textLength(0) | 266 , m_textLength(0) |
| 268 , m_needsAnotherNewline(false) | 267 , m_needsAnotherNewline(false) |
| 269 , m_textBox(0) | 268 , m_textBox(0) |
| 270 , m_lastTextNode(nullptr) | 269 , m_lastTextNode(nullptr) |
| 271 , m_lastTextNodeEndedWithCollapsedSpace(false) | 270 , m_lastTextNodeEndedWithCollapsedSpace(false) |
| 272 , m_lastCharacter(0) | 271 , m_lastCharacter(0) |
| 273 , m_sortedTextBoxesPosition(0) | 272 , m_sortedTextBoxesPosition(0) |
| 274 , m_hasEmitted(false) | 273 , m_hasEmitted(false) |
| 275 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) | 274 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh
aractersBetweenAllVisiblePositions) |
| 276 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) | 275 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) |
| 277 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) | 276 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) |
| 278 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) | |
| 279 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) | 277 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) |
| 280 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac
ementCharacter) | 278 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac
ementCharacter) |
| 281 { | 279 { |
| 282 initialize(start, end); | 280 initialize(start, end); |
| 283 } | 281 } |
| 284 | 282 |
| 285 void TextIterator::initialize(const Position& start, const Position& end) | 283 void TextIterator::initialize(const Position& start, const Position& end) |
| 286 { | 284 { |
| 287 ASSERT(comparePositions(start, end) <= 0); | 285 ASSERT(comparePositions(start, end) <= 0); |
| 288 | 286 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 if (renderer->containsReversedText()) | 663 if (renderer->containsReversedText()) |
| 666 ++m_sortedTextBoxesPosition; | 664 ++m_sortedTextBoxesPosition; |
| 667 } | 665 } |
| 668 } | 666 } |
| 669 | 667 |
| 670 bool TextIterator::handleReplacedElement() | 668 bool TextIterator::handleReplacedElement() |
| 671 { | 669 { |
| 672 if (m_fullyClippedStack.top()) | 670 if (m_fullyClippedStack.top()) |
| 673 return false; | 671 return false; |
| 674 | 672 |
| 675 RenderObject* renderer = m_node->renderer(); | |
| 676 if (m_emitsObjectReplacementCharacter) { | 673 if (m_emitsObjectReplacementCharacter) { |
| 677 emitCharacter(objectReplacementCharacter, m_node->parentNode(), m_node,
0, 1); | 674 emitCharacter(objectReplacementCharacter, m_node->parentNode(), m_node,
0, 1); |
| 678 return true; | 675 return true; |
| 679 } | 676 } |
| 680 | 677 |
| 681 if (m_lastTextNodeEndedWithCollapsedSpace) { | 678 if (m_lastTextNodeEndedWithCollapsedSpace) { |
| 682 emitCharacter(space, m_lastTextNode->parentNode(), m_lastTextNode, 1, 1)
; | 679 emitCharacter(space, m_lastTextNode->parentNode(), m_lastTextNode, 1, 1)
; |
| 683 return false; | 680 return false; |
| 684 } | 681 } |
| 685 | 682 |
| 686 m_hasEmitted = true; | 683 m_hasEmitted = true; |
| 687 | 684 |
| 688 if (m_emitsCharactersBetweenAllVisiblePositions) { | 685 if (m_emitsCharactersBetweenAllVisiblePositions) { |
| 689 // We want replaced elements to behave like punctuation for boundary | 686 // We want replaced elements to behave like punctuation for boundary |
| 690 // finding, and to simply take up space for the selection preservation | 687 // finding, and to simply take up space for the selection preservation |
| 691 // code in moveParagraphs, so we use a comma. | 688 // code in moveParagraphs, so we use a comma. |
| 692 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); | 689 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); |
| 693 return true; | 690 return true; |
| 694 } | 691 } |
| 695 | 692 |
| 696 m_positionNode = m_node->parentNode(); | 693 m_positionNode = m_node->parentNode(); |
| 697 m_positionOffsetBaseNode = m_node; | 694 m_positionOffsetBaseNode = m_node; |
| 698 m_positionStartOffset = 0; | 695 m_positionStartOffset = 0; |
| 699 m_positionEndOffset = 1; | 696 m_positionEndOffset = 1; |
| 700 m_singleCharacterBuffer = 0; | 697 m_singleCharacterBuffer = 0; |
| 701 | |
| 702 if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage())
{ | |
| 703 m_text = toRenderImage(renderer)->altText(); | |
| 704 if (!m_text.isEmpty()) { | |
| 705 m_textLength = m_text.length(); | |
| 706 m_lastCharacter = m_text[m_textLength - 1]; | |
| 707 return true; | |
| 708 } | |
| 709 } | |
| 710 | |
| 711 m_textLength = 0; | 698 m_textLength = 0; |
| 712 m_lastCharacter = 0; | 699 m_lastCharacter = 0; |
| 713 | 700 |
| 714 return true; | 701 return true; |
| 715 } | 702 } |
| 716 | 703 |
| 717 bool TextIterator::hasVisibleTextNode(RenderText* renderer) | 704 bool TextIterator::hasVisibleTextNode(RenderText* renderer) |
| 718 { | 705 { |
| 719 return true; | 706 return true; |
| 720 } | 707 } |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 resultEnd = collapseTo; | 1893 resultEnd = collapseTo; |
| 1907 return; | 1894 return; |
| 1908 } | 1895 } |
| 1909 } | 1896 } |
| 1910 | 1897 |
| 1911 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); | 1898 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); |
| 1912 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); | 1899 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); |
| 1913 } | 1900 } |
| 1914 | 1901 |
| 1915 } | 1902 } |
| OLD | NEW |