| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // Neighbor-anchored positions are invalid DOM positions, so they need to be | 205 // Neighbor-anchored positions are invalid DOM positions, so they need to be |
| 206 // fixed up before handing them off to the Range object. | 206 // fixed up before handing them off to the Range object. |
| 207 Position Position::parentAnchoredEquivalent() const | 207 Position Position::parentAnchoredEquivalent() const |
| 208 { | 208 { |
| 209 if (!m_anchorNode) | 209 if (!m_anchorNode) |
| 210 return Position(); | 210 return Position(); |
| 211 | 211 |
| 212 // FIXME: This should only be necessary for legacy positions, but is also ne
eded for positions before and after Tables | 212 // FIXME: This should only be necessary for legacy positions, but is also ne
eded for positions before and after Tables |
| 213 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType
!= PositionIsAfterChildren)) { | 213 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType
!= PositionIsAfterChildren)) { |
| 214 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge
t()) || isTableElement(m_anchorNode.get()))) | 214 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge
t()) || isRenderedTable(m_anchorNode.get()))) |
| 215 return positionInParentBeforeNode(m_anchorNode.get()); | 215 return positionInParentBeforeNode(m_anchorNode.get()); |
| 216 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor); | 216 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor); |
| 217 } | 217 } |
| 218 if (!m_anchorNode->offsetInCharacters() | 218 if (!m_anchorNode->offsetInCharacters() |
| 219 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA
fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->childNodeCount(
)) | 219 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA
fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->childNodeCount(
)) |
| 220 && (editingIgnoresContent(m_anchorNode.get()) || isTableElement(m_anchor
Node.get())) | 220 && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_ancho
rNode.get())) |
| 221 && containerNode()) { | 221 && containerNode()) { |
| 222 return positionInParentAfterNode(m_anchorNode.get()); | 222 return positionInParentAfterNode(m_anchorNode.get()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO
ffsetInAnchor); | 225 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO
ffsetInAnchor); |
| 226 } | 226 } |
| 227 | 227 |
| 228 Node* Position::computeNodeBeforePosition() const | 228 Node* Position::computeNodeBeforePosition() const |
| 229 { | 229 { |
| 230 if (!m_anchorNode) | 230 if (!m_anchorNode) |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 // track last visible streamer position | 628 // track last visible streamer position |
| 629 if (isStreamer(currentPos)) | 629 if (isStreamer(currentPos)) |
| 630 lastVisible = currentPos; | 630 lastVisible = currentPos; |
| 631 | 631 |
| 632 // Don't move past a position that is visually distinct. We could rely
on code above to terminate and | 632 // Don't move past a position that is visually distinct. We could rely
on code above to terminate and |
| 633 // return lastVisible on the next iteration, but we terminate early to a
void doing a nodeIndex() call. | 633 // return lastVisible on the next iteration, but we terminate early to a
void doing a nodeIndex() call. |
| 634 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentPos.at
StartOfNode()) | 634 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentPos.at
StartOfNode()) |
| 635 return lastVisible; | 635 return lastVisible; |
| 636 | 636 |
| 637 // Return position after tables and nodes which have content that can be
ignored. | 637 // Return position after tables and nodes which have content that can be
ignored. |
| 638 if (editingIgnoresContent(currentNode) || isTableElement(currentNode)) { | 638 if (editingIgnoresContent(currentNode) || isRenderedTable(currentNode))
{ |
| 639 if (currentPos.atEndOfNode()) | 639 if (currentPos.atEndOfNode()) |
| 640 return positionAfterNode(currentNode); | 640 return positionAfterNode(currentNode); |
| 641 continue; | 641 continue; |
| 642 } | 642 } |
| 643 | 643 |
| 644 // return current position if it is in rendered text | 644 // return current position if it is in rendered text |
| 645 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { | 645 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { |
| 646 if (currentNode != startNode) { | 646 if (currentNode != startNode) { |
| 647 // This assertion fires in layout tests in the case-transform.ht
ml test because | 647 // This assertion fires in layout tests in the case-transform.ht
ml test because |
| 648 // of a mix-up between offsets in the text in the DOM tree with
text in the | 648 // of a mix-up between offsets in the text in the DOM tree with
text in the |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 if (rule == CanCrossEditingBoundary && boundaryCrossed) { | 756 if (rule == CanCrossEditingBoundary && boundaryCrossed) { |
| 757 lastVisible = currentPos; | 757 lastVisible = currentPos; |
| 758 break; | 758 break; |
| 759 } | 759 } |
| 760 | 760 |
| 761 // track last visible streamer position | 761 // track last visible streamer position |
| 762 if (isStreamer(currentPos)) | 762 if (isStreamer(currentPos)) |
| 763 lastVisible = currentPos; | 763 lastVisible = currentPos; |
| 764 | 764 |
| 765 // Return position before tables and nodes which have content that can b
e ignored. | 765 // Return position before tables and nodes which have content that can b
e ignored. |
| 766 if (editingIgnoresContent(currentNode) || isTableElement(currentNode)) { | 766 if (editingIgnoresContent(currentNode) || isRenderedTable(currentNode))
{ |
| 767 if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset()) | 767 if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset()) |
| 768 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); | 768 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); |
| 769 continue; | 769 continue; |
| 770 } | 770 } |
| 771 | 771 |
| 772 // return current position if it is in rendered text | 772 // return current position if it is in rendered text |
| 773 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { | 773 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { |
| 774 if (currentNode != startNode) { | 774 if (currentNode != startNode) { |
| 775 ASSERT(currentPos.atStartOfNode()); | 775 ASSERT(currentPos.atStartOfNode()); |
| 776 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); | 776 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 if (renderer->style()->visibility() != VISIBLE) | 882 if (renderer->style()->visibility() != VISIBLE) |
| 883 return false; | 883 return false; |
| 884 | 884 |
| 885 if (renderer->isBR()) | 885 if (renderer->isBR()) |
| 886 // FIXME: The condition should be m_anchorType == PositionIsBeforeAnchor
, but for now we still need to support legacy positions. | 886 // FIXME: The condition should be m_anchorType == PositionIsBeforeAnchor
, but for now we still need to support legacy positions. |
| 887 return !m_offset && m_anchorType != PositionIsAfterAnchor && !nodeIsUser
SelectNone(deprecatedNode()->parentNode()); | 887 return !m_offset && m_anchorType != PositionIsAfterAnchor && !nodeIsUser
SelectNone(deprecatedNode()->parentNode()); |
| 888 | 888 |
| 889 if (renderer->isText()) | 889 if (renderer->isText()) |
| 890 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); | 890 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); |
| 891 | 891 |
| 892 if (isTableElement(deprecatedNode()) || editingIgnoresContent(deprecatedNode
())) | 892 if (isRenderedTable(deprecatedNode()) || editingIgnoresContent(deprecatedNod
e())) |
| 893 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); | 893 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); |
| 894 | 894 |
| 895 if (isHTMLHtmlElement(m_anchorNode.get())) | 895 if (isHTMLHtmlElement(m_anchorNode.get())) |
| 896 return false; | 896 return false; |
| 897 | 897 |
| 898 if (renderer->isRenderBlockFlow()) { | 898 if (renderer->isRenderBlockFlow()) { |
| 899 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName
(bodyTag)) { | 899 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName
(bodyTag)) { |
| 900 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) | 900 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) |
| 901 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); | 901 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); |
| 902 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSe
lectNone(deprecatedNode()) && atEditingBoundary(); | 902 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSe
lectNone(deprecatedNode()) && atEditingBoundary(); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 pos.showTreeForThis(); | 1384 pos.showTreeForThis(); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 void showTree(const WebCore::Position* pos) | 1387 void showTree(const WebCore::Position* pos) |
| 1388 { | 1388 { |
| 1389 if (pos) | 1389 if (pos) |
| 1390 pos->showTreeForThis(); | 1390 pos->showTreeForThis(); |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 #endif | 1393 #endif |
| OLD | NEW |