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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } | 613 } |
614 if (!m_textBox && m_remainingTextBox) { | 614 if (!m_textBox && m_remainingTextBox) { |
615 m_textBox = m_remainingTextBox; | 615 m_textBox = m_remainingTextBox; |
616 m_remainingTextBox = 0; | 616 m_remainingTextBox = 0; |
617 m_firstLetterText = 0; | 617 m_firstLetterText = 0; |
618 m_offset = 0; | 618 m_offset = 0; |
619 handleTextBox(); | 619 handleTextBox(); |
620 } | 620 } |
621 } | 621 } |
622 | 622 |
623 static inline RenderText* firstRenderTextInFirstLetter(RenderObject* firstLetter
) | |
624 { | |
625 if (!firstLetter) | |
626 return 0; | |
627 | |
628 // FIXME: Should this check descendent objects? | |
629 for (RenderObject* current = firstLetter->firstChild(); current; current = c
urrent->nextSibling()) { | |
630 if (current->isText()) | |
631 return toRenderText(current); | |
632 } | |
633 return 0; | |
634 } | |
635 | |
636 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer) | 623 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer) |
637 { | 624 { |
638 if (renderer->firstLetter()) { | 625 if (renderer->firstLetter()) { |
639 RenderObject* r = renderer->firstLetter(); | 626 RenderObject* r = renderer->firstLetter(); |
640 if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility) | 627 if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility) |
641 return; | 628 return; |
642 if (RenderText* firstLetter = firstRenderTextInFirstLetter(r)) { | 629 if (RenderText* firstLetter = renderer->firstRenderTextInFirstLetter())
{ |
643 m_handledFirstLetter = true; | 630 m_handledFirstLetter = true; |
644 m_remainingTextBox = m_textBox; | 631 m_remainingTextBox = m_textBox; |
645 m_textBox = firstLetter->firstTextBox(); | 632 m_textBox = firstLetter->firstTextBox(); |
646 m_sortedTextBoxes.clear(); | 633 m_sortedTextBoxes.clear(); |
647 m_firstLetterText = firstLetter; | 634 m_firstLetterText = firstLetter; |
648 } | 635 } |
649 } | 636 } |
650 m_handledFirstLetter = true; | 637 m_handledFirstLetter = true; |
651 } | 638 } |
652 | 639 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 } | 1269 } |
1283 | 1270 |
1284 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) { | 1271 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) { |
1285 m_shouldHandleFirstLetter = true; | 1272 m_shouldHandleFirstLetter = true; |
1286 offsetInNode = offsetAfterFirstLetter; | 1273 offsetInNode = offsetAfterFirstLetter; |
1287 return renderer; | 1274 return renderer; |
1288 } | 1275 } |
1289 | 1276 |
1290 m_shouldHandleFirstLetter = false; | 1277 m_shouldHandleFirstLetter = false; |
1291 offsetInNode = 0; | 1278 offsetInNode = 0; |
1292 return firstRenderTextInFirstLetter(fragment->firstLetter()); | 1279 return fragment->firstRenderTextInFirstLetter(); |
1293 } | 1280 } |
1294 | 1281 |
1295 bool SimplifiedBackwardsTextIterator::handleReplacedElement() | 1282 bool SimplifiedBackwardsTextIterator::handleReplacedElement() |
1296 { | 1283 { |
1297 unsigned index = m_node->nodeIndex(); | 1284 unsigned index = m_node->nodeIndex(); |
1298 // We want replaced elements to behave like punctuation for boundary | 1285 // We want replaced elements to behave like punctuation for boundary |
1299 // finding, and to simply take up space for the selection preservation | 1286 // finding, and to simply take up space for the selection preservation |
1300 // code in moveParagraphs, so we use a comma. Unconditionally emit | 1287 // code in moveParagraphs, so we use a comma. Unconditionally emit |
1301 // here because this iterator is only used for boundary finding. | 1288 // here because this iterator is only used for boundary finding. |
1302 emitCharacter(',', m_node->parentNode(), index, index + 1); | 1289 emitCharacter(',', m_node->parentNode(), index, index + 1); |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 if (!matchLength) | 2430 if (!matchLength) |
2444 return collapsedToBoundary(range, !(options & Backwards)); | 2431 return collapsedToBoundary(range, !(options & Backwards)); |
2445 } | 2432 } |
2446 | 2433 |
2447 // Then, find the document position of the start and the end of the text. | 2434 // Then, find the document position of the start and the end of the text. |
2448 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); | 2435 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); |
2449 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2436 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
2450 } | 2437 } |
2451 | 2438 |
2452 } | 2439 } |
OLD | NEW |