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