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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 399 } |
400 | 400 |
401 // Handle the current node according to its type. | 401 // Handle the current node according to its type. |
402 if (m_iterationProgress < HandledNode) { | 402 if (m_iterationProgress < HandledNode) { |
403 bool handledNode = false; | 403 bool handledNode = false; |
404 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE)
{ // FIXME: What about CDATA_SECTION_NODE? | 404 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE)
{ // FIXME: What about CDATA_SECTION_NODE? |
405 handledNode = handleTextNode(); | 405 handledNode = handleTextNode(); |
406 } else if (renderer && (renderer->isImage() || renderer->isWidge
t() | 406 } else if (renderer && (renderer->isImage() || renderer->isWidge
t() |
407 || (m_node && m_node->isElementNode() | 407 || (m_node && m_node->isElementNode() |
408 && (toElement(m_node)->isFormControlElement() | 408 && (toElement(m_node)->isFormControlElement() |
409 || toElement(m_node)->hasTagName(legendTag) | 409 || isHTMLLegendElement(toElement(*m_node)) |
410 || toElement(m_node)->hasTagName(meterTag) | 410 || isHTMLMeterElement(toElement(*m_node)) |
411 || toElement(m_node)->hasTagName(progressTag))))) { | 411 || isHTMLProgressElement(toElement(*m_node)))))) { |
412 handledNode = handleReplacedElement(); | 412 handledNode = handleReplacedElement(); |
413 } else { | 413 } else { |
414 handledNode = handleNonTextNode(); | 414 handledNode = handleNonTextNode(); |
415 } | 415 } |
416 if (handledNode) | 416 if (handledNode) |
417 m_iterationProgress = HandledNode; | 417 m_iterationProgress = HandledNode; |
418 if (m_positionNode) | 418 if (m_positionNode) |
419 return; | 419 return; |
420 } | 420 } |
421 } | 421 } |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 // Want a tab before every cell other than the first one | 801 // Want a tab before every cell other than the first one |
802 RenderTableCell* rc = toRenderTableCell(r); | 802 RenderTableCell* rc = toRenderTableCell(r); |
803 RenderTable* t = rc->table(); | 803 RenderTable* t = rc->table(); |
804 return t && (t->cellBefore(rc) || t->cellAbove(rc)); | 804 return t && (t->cellBefore(rc) || t->cellAbove(rc)); |
805 } | 805 } |
806 | 806 |
807 static bool shouldEmitNewlineForNode(Node* node, bool emitsOriginalText) | 807 static bool shouldEmitNewlineForNode(Node* node, bool emitsOriginalText) |
808 { | 808 { |
809 RenderObject* renderer = node->renderer(); | 809 RenderObject* renderer = node->renderer(); |
810 | 810 |
811 if (renderer ? !renderer->isBR() : !node->hasTagName(brTag)) | 811 if (renderer ? !renderer->isBR() : !isHTMLBRElement(node)) |
812 return false; | 812 return false; |
813 return emitsOriginalText || !(node->isInShadowTree() && node->shadowHost()->
hasTagName(inputTag)); | 813 return emitsOriginalText || !(node->isInShadowTree() && isHTMLInputElement(*
node->shadowHost())); |
814 } | 814 } |
815 | 815 |
816 static bool shouldEmitNewlinesBeforeAndAfterNode(Node& node) | 816 static bool shouldEmitNewlinesBeforeAndAfterNode(Node& node) |
817 { | 817 { |
818 // Block flow (versus inline flow) is represented by having | 818 // Block flow (versus inline flow) is represented by having |
819 // a newline both before and after the element. | 819 // a newline both before and after the element. |
820 RenderObject* r = node.renderer(); | 820 RenderObject* r = node.renderer(); |
821 if (!r) { | 821 if (!r) { |
822 return (node.hasTagName(blockquoteTag) | 822 return (node.hasTagName(blockquoteTag) |
823 || node.hasTagName(ddTag) | 823 || node.hasTagName(ddTag) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 // so don't second guess that now. | 968 // so don't second guess that now. |
969 // NOTE: Is this really correct when m_node is not a leftmost descendant? Pr
obably | 969 // NOTE: Is this really correct when m_node is not a leftmost descendant? Pr
obably |
970 // immaterial since we likely would have already emitted something by now. | 970 // immaterial since we likely would have already emitted something by now. |
971 if (!m_startOffset) | 971 if (!m_startOffset) |
972 return false; | 972 return false; |
973 | 973 |
974 // If this node is unrendered or invisible the VisiblePosition checks below
won't have much meaning. | 974 // If this node is unrendered or invisible the VisiblePosition checks below
won't have much meaning. |
975 // Additionally, if the range we are iterating over contains huge sections o
f unrendered content, | 975 // Additionally, if the range we are iterating over contains huge sections o
f unrendered content, |
976 // we would create VisiblePositions on every call to this function without t
his check. | 976 // we would create VisiblePositions on every call to this function without t
his check. |
977 if (!m_node->renderer() || m_node->renderer()->style()->visibility() != VISI
BLE | 977 if (!m_node->renderer() || m_node->renderer()->style()->visibility() != VISI
BLE |
978 || (m_node->renderer()->isRenderBlockFlow() && !toRenderBlock(m_node->re
nderer())->height() && !m_node->hasTagName(bodyTag))) | 978 || (m_node->renderer()->isRenderBlockFlow() && !toRenderBlock(m_node->re
nderer())->height() && !isHTMLBodyElement(*m_node))) |
979 return false; | 979 return false; |
980 | 980 |
981 // The startPos.isNotNull() check is needed because the start could be befor
e the body, | 981 // The startPos.isNotNull() check is needed because the start could be befor
e the body, |
982 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. | 982 // and in that case we'll get null. We don't want to put in newlines at the
start in that case. |
983 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent | 983 // The currPos.isNotNull() check is needed because positions in non-HTML con
tent |
984 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. | 984 // (like SVG) do not have visible positions, and we don't want to emit for t
hem either. |
985 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); | 985 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star
tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); |
986 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); | 986 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST
REAM); |
987 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); | 987 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos,
currPos); |
988 } | 988 } |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 if (!matchLength) | 2081 if (!matchLength) |
2082 return collapsedToBoundary(range, !(options & Backwards)); | 2082 return collapsedToBoundary(range, !(options & Backwards)); |
2083 } | 2083 } |
2084 | 2084 |
2085 // Then, find the document position of the start and the end of the text. | 2085 // Then, find the document position of the start and the end of the text. |
2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); | 2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); |
2087 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2087 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
2088 } | 2088 } |
2089 | 2089 |
2090 } | 2090 } |
OLD | NEW |