| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 m_lastTextNode = m_node; | 452 m_lastTextNode = m_node; |
| 453 String str = renderer->text(); | 453 String str = renderer->text(); |
| 454 | 454 |
| 455 // handle pre-formatted text | 455 // handle pre-formatted text |
| 456 if (!renderer->style()->collapseWhiteSpace()) { | 456 if (!renderer->style()->collapseWhiteSpace()) { |
| 457 int runStart = m_offset; | 457 int runStart = m_offset; |
| 458 if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(renderer
)) { | 458 if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(renderer
)) { |
| 459 emitCharacter(' ', m_node, 0, runStart, runStart); | 459 emitCharacter(' ', m_node, 0, runStart, runStart); |
| 460 return false; | 460 return false; |
| 461 } | 461 } |
| 462 if (!m_handledFirstLetter && renderer->isTextFragment()) { | 462 if (!m_handledFirstLetter && renderer->isTextFragment() && !m_offset) { |
| 463 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)
); | 463 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)
); |
| 464 if (m_firstLetterText) { | 464 if (m_firstLetterText) { |
| 465 String firstLetter = m_firstLetterText->text(); | 465 String firstLetter = m_firstLetterText->text(); |
| 466 emitText(m_node, m_firstLetterText, m_offset, m_offset + firstLe
tter.length()); | 466 emitText(m_node, m_firstLetterText, m_offset, m_offset + firstLe
tter.length()); |
| 467 m_firstLetterText = 0; | 467 m_firstLetterText = 0; |
| 468 m_textBox = 0; | 468 m_textBox = 0; |
| 469 return false; | 469 return false; |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) | 472 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 489 handleTextBox(); | 489 handleTextBox(); |
| 490 return false; | 490 return false; |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) | 493 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) |
| 494 return false; | 494 return false; |
| 495 m_lastTextNodeEndedWithCollapsedSpace = true; // entire block is collaps
ed space | 495 m_lastTextNodeEndedWithCollapsedSpace = true; // entire block is collaps
ed space |
| 496 return true; | 496 return true; |
| 497 } | 497 } |
| 498 | 498 |
| 499 |
| 500 m_textBox = renderer->firstTextBox(); |
| 501 if (!m_handledFirstLetter && renderer->isTextFragment() && !m_offset) |
| 502 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)); |
| 503 |
| 504 if (m_firstLetterText) |
| 505 renderer = m_firstLetterText; |
| 506 |
| 499 // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text) | 507 // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text) |
| 500 if (renderer->containsReversedText()) { | 508 if (renderer->containsReversedText()) { |
| 501 m_sortedTextBoxes.clear(); | 509 m_sortedTextBoxes.clear(); |
| 502 for (InlineTextBox* textBox = renderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) { | 510 for (InlineTextBox* textBox = renderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) { |
| 503 m_sortedTextBoxes.append(textBox); | 511 m_sortedTextBoxes.append(textBox); |
| 504 } | 512 } |
| 505 std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), InlineText
Box::compareByStart); | 513 std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), InlineText
Box::compareByStart); |
| 506 m_sortedTextBoxesPosition = 0; | 514 m_sortedTextBoxesPosition = 0; |
| 515 m_textBox = m_sortedTextBoxes.isEmpty() ? 0 : m_sortedTextBoxes[0]; |
| 507 } | 516 } |
| 508 | 517 |
| 509 m_textBox = renderer->containsReversedText() ? (m_sortedTextBoxes.isEmpty()
? 0 : m_sortedTextBoxes[0]) : renderer->firstTextBox(); | |
| 510 if (!m_handledFirstLetter && renderer->isTextFragment() && !m_offset) | |
| 511 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)); | |
| 512 handleTextBox(); | 518 handleTextBox(); |
| 513 return true; | 519 return true; |
| 514 } | 520 } |
| 515 | 521 |
| 516 void TextIterator::handleTextBox() | 522 void TextIterator::handleTextBox() |
| 517 { | 523 { |
| 518 RenderText* renderer = m_firstLetterText ? m_firstLetterText : toRenderText(
m_node->renderer()); | 524 RenderText* renderer = m_firstLetterText ? m_firstLetterText : toRenderText(
m_node->renderer()); |
| 519 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
{ | 525 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
{ |
| 520 m_textBox = 0; | 526 m_textBox = 0; |
| 521 return; | 527 return; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 // remember some iteration state | 974 // remember some iteration state |
| 969 m_lastTextNodeEndedWithCollapsedSpace = false; | 975 m_lastTextNodeEndedWithCollapsedSpace = false; |
| 970 m_lastCharacter = c; | 976 m_lastCharacter = c; |
| 971 } | 977 } |
| 972 | 978 |
| 973 void TextIterator::emitText(Node* textNode, RenderObject* renderObject, int text
StartOffset, int textEndOffset) | 979 void TextIterator::emitText(Node* textNode, RenderObject* renderObject, int text
StartOffset, int textEndOffset) |
| 974 { | 980 { |
| 975 RenderText* renderer = toRenderText(renderObject); | 981 RenderText* renderer = toRenderText(renderObject); |
| 976 m_text = m_emitsTextWithoutTranscoding ? renderer->textWithoutTranscoding()
: renderer->text(); | 982 m_text = m_emitsTextWithoutTranscoding ? renderer->textWithoutTranscoding()
: renderer->text(); |
| 977 ASSERT(m_text.characters()); | 983 ASSERT(m_text.characters()); |
| 984 ASSERT(0 <= textStartOffset && textStartOffset < static_cast<int>(m_text.len
gth())); |
| 985 ASSERT(0 <= textEndOffset && textEndOffset <= static_cast<int>(m_text.length
())); |
| 986 ASSERT(textStartOffset <= textEndOffset); |
| 978 | 987 |
| 979 m_positionNode = textNode; | 988 m_positionNode = textNode; |
| 980 m_positionOffsetBaseNode = 0; | 989 m_positionOffsetBaseNode = 0; |
| 981 m_positionStartOffset = textStartOffset; | 990 m_positionStartOffset = textStartOffset; |
| 982 m_positionEndOffset = textEndOffset; | 991 m_positionEndOffset = textEndOffset; |
| 983 m_textCharacters = m_text.characters() + textStartOffset; | 992 m_textCharacters = m_text.characters() + textStartOffset; |
| 984 m_textLength = textEndOffset - textStartOffset; | 993 m_textLength = textEndOffset - textStartOffset; |
| 985 m_lastCharacter = m_text[textEndOffset - 1]; | 994 m_lastCharacter = m_text[textEndOffset - 1]; |
| 986 | 995 |
| 987 m_lastTextNodeEndedWithCollapsedSpace = false; | 996 m_lastTextNodeEndedWithCollapsedSpace = false; |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2569 if (!matchLength) | 2578 if (!matchLength) |
| 2570 return collapsedToBoundary(range, !(options & Backwards)); | 2579 return collapsedToBoundary(range, !(options & Backwards)); |
| 2571 } | 2580 } |
| 2572 | 2581 |
| 2573 // Then, find the document position of the start and the end of the text. | 2582 // Then, find the document position of the start and the end of the text. |
| 2574 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); | 2583 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); |
| 2575 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2584 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
| 2576 } | 2585 } |
| 2577 | 2586 |
| 2578 } | 2587 } |
| OLD | NEW |