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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 | 997 |
998 if (node->renderer() && node->renderer()->isText()) | 998 if (node->renderer() && node->renderer()->isText()) |
999 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset); | 999 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset); |
1000 | 1000 |
1001 return offset; | 1001 return offset; |
1002 } | 1002 } |
1003 | 1003 |
1004 // 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). | 1004 // 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). |
1005 bool TextIterator::shouldRepresentNodeOffsetZero() | 1005 bool TextIterator::shouldRepresentNodeOffsetZero() |
1006 { | 1006 { |
1007 if (m_emitsCharactersBetweenAllVisiblePositions && isRenderedTable(m_node)) | 1007 if (m_emitsCharactersBetweenAllVisiblePositions && isRenderedTableElement(m_
node)) |
1008 return true; | 1008 return true; |
1009 | 1009 |
1010 // Leave element positioned flush with start of a paragraph | 1010 // Leave element positioned flush with start of a paragraph |
1011 // (e.g. do not insert tab before a table cell at the start of a paragraph) | 1011 // (e.g. do not insert tab before a table cell at the start of a paragraph) |
1012 if (m_lastCharacter == '\n') | 1012 if (m_lastCharacter == '\n') |
1013 return false; | 1013 return false; |
1014 | 1014 |
1015 // Otherwise, show the position if we have emitted any characters | 1015 // Otherwise, show the position if we have emitted any characters |
1016 if (m_hasEmitted) | 1016 if (m_hasEmitted) |
1017 return true; | 1017 return true; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. | 1053 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. |
1054 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent | 1054 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent |
1055 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. | 1055 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. |
1056 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); | 1056 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); |
1057 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); | 1057 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); |
1058 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); | 1058 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); |
1059 } | 1059 } |
1060 | 1060 |
1061 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node) | 1061 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node) |
1062 { | 1062 { |
1063 return isRenderedTable(node) && (node->renderer()->isInline() || m_emitsChar
actersBetweenAllVisiblePositions); | 1063 return isRenderedTableElement(node) && (node->renderer()->isInline() || m_em
itsCharactersBetweenAllVisiblePositions); |
1064 } | 1064 } |
1065 | 1065 |
1066 void TextIterator::representNodeOffsetZero() | 1066 void TextIterator::representNodeOffsetZero() |
1067 { | 1067 { |
1068 // Emit a character to show the positioning of m_node. | 1068 // Emit a character to show the positioning of m_node. |
1069 | 1069 |
1070 // When we haven't been emitting any characters, shouldRepresentNodeOffsetZe
ro() can | 1070 // When we haven't been emitting any characters, shouldRepresentNodeOffsetZe
ro() can |
1071 // create VisiblePositions, which is expensive. So, we perform the inexpensi
ve checks | 1071 // create VisiblePositions, which is expensive. So, we perform the inexpensi
ve checks |
1072 // on m_node to see if it necessitates emitting a character first and will e
arly return | 1072 // on m_node to see if it necessitates emitting a character first and will e
arly return |
1073 // before encountering shouldRepresentNodeOffsetZero()s worse case behavior. | 1073 // before encountering shouldRepresentNodeOffsetZero()s worse case behavior. |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 resultEnd = collapseTo; | 2220 resultEnd = collapseTo; |
2221 return; | 2221 return; |
2222 } | 2222 } |
2223 } | 2223 } |
2224 | 2224 |
2225 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); | 2225 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); |
2226 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); | 2226 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); |
2227 } | 2227 } |
2228 | 2228 |
2229 } | 2229 } |
OLD | NEW |