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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 int end = (m_node == m_endContainer) ? m_endOffset : INT_MAX; | 480 int end = (m_node == m_endContainer) ? m_endOffset : INT_MAX; |
481 int runEnd = min(strLength, end); | 481 int runEnd = min(strLength, end); |
482 | 482 |
483 if (runStart >= runEnd) | 483 if (runStart >= runEnd) |
484 return true; | 484 return true; |
485 | 485 |
486 emitText(m_node, runStart, runEnd); | 486 emitText(m_node, runStart, runEnd); |
487 return true; | 487 return true; |
488 } | 488 } |
489 | 489 |
490 if (!renderer->firstTextBox() && str.length() > 0) { | 490 if (renderer->firstTextBox()) |
491 if (!m_handledFirstLetter && renderer->isTextFragment()) { | 491 m_textBox = renderer->firstTextBox(); |
492 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)
); | 492 |
493 if (m_firstLetterText) { | 493 bool shouldHandleFirstLetter = !m_handledFirstLetter && renderer->isTextFrag
ment() && !m_offset; |
494 handleTextBox(); | 494 if (shouldHandleFirstLetter) |
495 return false; | 495 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)); |
496 } | 496 |
497 } | 497 if (!renderer->firstTextBox() && str.length() > 0 && !shouldHandleFirstLette
r) { |
498 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) | 498 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibil
ity) |
499 return false; | 499 return false; |
500 m_lastTextNodeEndedWithCollapsedSpace = true; // entire block is collaps
ed space | 500 m_lastTextNodeEndedWithCollapsedSpace = true; // entire block is collaps
ed space |
501 return true; | 501 return true; |
502 } | 502 } |
503 | 503 |
504 | |
505 m_textBox = renderer->firstTextBox(); | |
506 if (!m_handledFirstLetter && renderer->isTextFragment() && !m_offset) | |
507 handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer)); | |
508 | |
509 if (m_firstLetterText) | 504 if (m_firstLetterText) |
510 renderer = m_firstLetterText; | 505 renderer = m_firstLetterText; |
511 | 506 |
512 // 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) |
513 if (renderer->containsReversedText()) { | 508 if (renderer->containsReversedText()) { |
514 m_sortedTextBoxes.clear(); | 509 m_sortedTextBoxes.clear(); |
515 for (InlineTextBox* textBox = renderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) { | 510 for (InlineTextBox* textBox = renderer->firstTextBox(); textBox; textBox
= textBox->nextTextBox()) { |
516 m_sortedTextBoxes.append(textBox); | 511 m_sortedTextBoxes.append(textBox); |
517 } | 512 } |
518 std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), InlineText
Box::compareByStart); | 513 std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), InlineText
Box::compareByStart); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 unsigned textBoxEnd = textBoxStart + m_textBox->len(); | 550 unsigned textBoxEnd = textBoxStart + m_textBox->len(); |
556 unsigned runEnd = min(textBoxEnd, end); | 551 unsigned runEnd = min(textBoxEnd, end); |
557 | 552 |
558 // Determine what the next text box will be, but don't advance yet | 553 // Determine what the next text box will be, but don't advance yet |
559 InlineTextBox* nextTextBox = 0; | 554 InlineTextBox* nextTextBox = 0; |
560 if (renderer->containsReversedText()) { | 555 if (renderer->containsReversedText()) { |
561 if (m_sortedTextBoxesPosition + 1 < m_sortedTextBoxes.size()) | 556 if (m_sortedTextBoxesPosition + 1 < m_sortedTextBoxes.size()) |
562 nextTextBox = m_sortedTextBoxes[m_sortedTextBoxesPosition + 1]; | 557 nextTextBox = m_sortedTextBoxes[m_sortedTextBoxesPosition + 1]; |
563 } else | 558 } else |
564 nextTextBox = m_textBox->nextTextBox(); | 559 nextTextBox = m_textBox->nextTextBox(); |
| 560 ASSERT(!nextTextBox || nextTextBox->renderer() == renderer); |
565 | 561 |
566 if (runStart < runEnd) { | 562 if (runStart < runEnd) { |
567 // Handle either a single newline character (which becomes a space), | 563 // Handle either a single newline character (which becomes a space), |
568 // or a run of characters that does not include a newline. | 564 // or a run of characters that does not include a newline. |
569 // This effectively translates newlines to spaces without copying th
e text. | 565 // This effectively translates newlines to spaces without copying th
e text. |
570 if (str[runStart] == '\n') { | 566 if (str[runStart] == '\n') { |
571 emitCharacter(' ', m_node, 0, runStart, runStart + 1); | 567 emitCharacter(' ', m_node, 0, runStart, runStart + 1); |
572 m_offset = runStart + 1; | 568 m_offset = runStart + 1; |
573 } else { | 569 } else { |
574 size_t subrunEnd = str.find('\n', runStart); | 570 size_t subrunEnd = str.find('\n', runStart); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer) | 619 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer) |
624 { | 620 { |
625 if (renderer->firstLetter()) { | 621 if (renderer->firstLetter()) { |
626 RenderObject* r = renderer->firstLetter(); | 622 RenderObject* r = renderer->firstLetter(); |
627 if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility) | 623 if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility) |
628 return; | 624 return; |
629 if (RenderText* firstLetter = firstRenderTextInFirstLetter(r)) { | 625 if (RenderText* firstLetter = firstRenderTextInFirstLetter(r)) { |
630 m_handledFirstLetter = true; | 626 m_handledFirstLetter = true; |
631 m_remainingTextBox = m_textBox; | 627 m_remainingTextBox = m_textBox; |
632 m_textBox = firstLetter->firstTextBox(); | 628 m_textBox = firstLetter->firstTextBox(); |
| 629 m_sortedTextBoxes.clear(); |
633 m_firstLetterText = firstLetter; | 630 m_firstLetterText = firstLetter; |
634 } | 631 } |
635 } | 632 } |
636 m_handledFirstLetter = true; | 633 m_handledFirstLetter = true; |
637 } | 634 } |
638 | 635 |
639 bool TextIterator::handleReplacedElement() | 636 bool TextIterator::handleReplacedElement() |
640 { | 637 { |
641 if (m_fullyClippedStack.top()) | 638 if (m_fullyClippedStack.top()) |
642 return false; | 639 return false; |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 if (!matchLength) | 2661 if (!matchLength) |
2665 return collapsedToBoundary(range, !(options & Backwards)); | 2662 return collapsedToBoundary(range, !(options & Backwards)); |
2666 } | 2663 } |
2667 | 2664 |
2668 // Then, find the document position of the start and the end of the text. | 2665 // Then, find the document position of the start and the end of the text. |
2669 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); | 2666 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); |
2670 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2667 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
2671 } | 2668 } |
2672 | 2669 |
2673 } | 2670 } |
OLD | NEW |