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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 854 |
855 if (node->renderer() && node->renderer()->isText()) | 855 if (node->renderer() && node->renderer()->isText()) |
856 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset); | 856 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset); |
857 | 857 |
858 return offset; | 858 return offset; |
859 } | 859 } |
860 | 860 |
861 // Whether or not we should emit a character as we enter m_node (if it's a conta
iner) or as we hit it (if it's atomic). | 861 // Whether or not we should emit a character as we enter m_node (if it's a conta
iner) or as we hit it (if it's atomic). |
862 bool TextIterator::shouldRepresentNodeOffsetZero() | 862 bool TextIterator::shouldRepresentNodeOffsetZero() |
863 { | 863 { |
864 if (m_emitsCharactersBetweenAllVisiblePositions && m_node->renderer() && m_n
ode->renderer()->isTable()) | 864 if (m_emitsCharactersBetweenAllVisiblePositions && isRenderedTable(m_node)) |
865 return true; | 865 return true; |
866 | 866 |
867 // Leave element positioned flush with start of a paragraph | 867 // Leave element positioned flush with start of a paragraph |
868 // (e.g. do not insert tab before a table cell at the start of a paragraph) | 868 // (e.g. do not insert tab before a table cell at the start of a paragraph) |
869 if (m_lastCharacter == '\n') | 869 if (m_lastCharacter == '\n') |
870 return false; | 870 return false; |
871 | 871 |
872 // Otherwise, show the position if we have emitted any characters | 872 // Otherwise, show the position if we have emitted any characters |
873 if (m_hasEmitted) | 873 if (m_hasEmitted) |
874 return true; | 874 return true; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. | 910 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. |
911 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent | 911 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent |
912 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. | 912 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. |
913 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); | 913 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); |
914 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); | 914 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); |
915 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); | 915 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); |
916 } | 916 } |
917 | 917 |
918 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node) | 918 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node) |
919 { | 919 { |
920 return node->renderer() && node->renderer()->isTable() && (node->renderer()-
>isInline() || m_emitsCharactersBetweenAllVisiblePositions); | 920 return isRenderedTable(node) && (node->renderer()->isInline() || m_emitsChar
actersBetweenAllVisiblePositions); |
921 } | 921 } |
922 | 922 |
923 void TextIterator::representNodeOffsetZero() | 923 void TextIterator::representNodeOffsetZero() |
924 { | 924 { |
925 // Emit a character to show the positioning of m_node. | 925 // Emit a character to show the positioning of m_node. |
926 | 926 |
927 // When we haven't been emitting any characters, shouldRepresentNodeOffsetZe
ro() can | 927 // When we haven't been emitting any characters, shouldRepresentNodeOffsetZe
ro() can |
928 // create VisiblePositions, which is expensive. So, we perform the inexpensi
ve checks | 928 // create VisiblePositions, which is expensive. So, we perform the inexpensi
ve checks |
929 // on m_node to see if it necessitates emitting a character first and will e
arly return | 929 // on m_node to see if it necessitates emitting a character first and will e
arly return |
930 // before encountering shouldRepresentNodeOffsetZero()s worse case behavior. | 930 // before encountering shouldRepresentNodeOffsetZero()s worse case behavior. |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 if (!matchLength) | 2320 if (!matchLength) |
2321 return collapsedToBoundary(range, !(options & Backwards)); | 2321 return collapsedToBoundary(range, !(options & Backwards)); |
2322 } | 2322 } |
2323 | 2323 |
2324 // Then, find the document position of the start and the end of the text. | 2324 // Then, find the document position of the start and the end of the text. |
2325 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); | 2325 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
); |
2326 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2326 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
2327 } | 2327 } |
2328 | 2328 |
2329 } | 2329 } |
OLD | NEW |