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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 // Neighbor-anchored positions are invalid DOM positions, so they need to be | 204 // Neighbor-anchored positions are invalid DOM positions, so they need to be |
205 // fixed up before handing them off to the Range object. | 205 // fixed up before handing them off to the Range object. |
206 Position Position::parentAnchoredEquivalent() const | 206 Position Position::parentAnchoredEquivalent() const |
207 { | 207 { |
208 if (!m_anchorNode) | 208 if (!m_anchorNode) |
209 return Position(); | 209 return Position(); |
210 | 210 |
211 // FIXME: This should only be necessary for legacy positions, but is also ne
eded for positions before and after Tables | 211 // FIXME: This should only be necessary for legacy positions, but is also ne
eded for positions before and after Tables |
212 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType
!= PositionIsAfterChildren)) { | 212 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType
!= PositionIsAfterChildren)) { |
213 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge
t()) || isRenderedTableElement(m_anchorNode.get()))) | 213 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge
t()) || isRenderedHTMLTableElement(m_anchorNode.get()))) |
214 return positionInParentBeforeNode(*m_anchorNode); | 214 return positionInParentBeforeNode(*m_anchorNode); |
215 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor); | 215 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor); |
216 } | 216 } |
217 if (!m_anchorNode->offsetInCharacters() | 217 if (!m_anchorNode->offsetInCharacters() |
218 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA
fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->countChildren()
) | 218 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA
fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->countChildren()
) |
219 && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTableElement(
m_anchorNode.get())) | 219 && (editingIgnoresContent(m_anchorNode.get()) || isRenderedHTMLTableElem
ent(m_anchorNode.get())) |
220 && containerNode()) { | 220 && containerNode()) { |
221 return positionInParentAfterNode(*m_anchorNode); | 221 return positionInParentAfterNode(*m_anchorNode); |
222 } | 222 } |
223 | 223 |
224 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO
ffsetInAnchor); | 224 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO
ffsetInAnchor); |
225 } | 225 } |
226 | 226 |
227 Node* Position::computeNodeBeforePosition() const | 227 Node* Position::computeNodeBeforePosition() const |
228 { | 228 { |
229 if (!m_anchorNode) | 229 if (!m_anchorNode) |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 // track last visible streamer position | 575 // track last visible streamer position |
576 if (isStreamer(currentPos)) | 576 if (isStreamer(currentPos)) |
577 lastVisible = currentPos; | 577 lastVisible = currentPos; |
578 | 578 |
579 // Don't move past a position that is visually distinct. We could rely
on code above to terminate and | 579 // Don't move past a position that is visually distinct. We could rely
on code above to terminate and |
580 // return lastVisible on the next iteration, but we terminate early to a
void doing a nodeIndex() call. | 580 // return lastVisible on the next iteration, but we terminate early to a
void doing a nodeIndex() call. |
581 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentPos.at
StartOfNode()) | 581 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentPos.at
StartOfNode()) |
582 return lastVisible; | 582 return lastVisible; |
583 | 583 |
584 // Return position after tables and nodes which have content that can be
ignored. | 584 // Return position after tables and nodes which have content that can be
ignored. |
585 if (editingIgnoresContent(currentNode) || isRenderedTableElement(current
Node)) { | 585 if (editingIgnoresContent(currentNode) || isRenderedHTMLTableElement(cur
rentNode)) { |
586 if (currentPos.atEndOfNode()) | 586 if (currentPos.atEndOfNode()) |
587 return positionAfterNode(currentNode); | 587 return positionAfterNode(currentNode); |
588 continue; | 588 continue; |
589 } | 589 } |
590 | 590 |
591 // return current position if it is in rendered text | 591 // return current position if it is in rendered text |
592 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { | 592 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { |
593 if (currentNode != startNode) { | 593 if (currentNode != startNode) { |
594 // This assertion fires in layout tests in the case-transform.ht
ml test because | 594 // This assertion fires in layout tests in the case-transform.ht
ml test because |
595 // of a mix-up between offsets in the text in the DOM tree with
text in the | 595 // 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... |
703 if (rule == CanCrossEditingBoundary && boundaryCrossed) { | 703 if (rule == CanCrossEditingBoundary && boundaryCrossed) { |
704 lastVisible = currentPos; | 704 lastVisible = currentPos; |
705 break; | 705 break; |
706 } | 706 } |
707 | 707 |
708 // track last visible streamer position | 708 // track last visible streamer position |
709 if (isStreamer(currentPos)) | 709 if (isStreamer(currentPos)) |
710 lastVisible = currentPos; | 710 lastVisible = currentPos; |
711 | 711 |
712 // Return position before tables and nodes which have content that can b
e ignored. | 712 // Return position before tables and nodes which have content that can b
e ignored. |
713 if (editingIgnoresContent(currentNode) || isRenderedTableElement(current
Node)) { | 713 if (editingIgnoresContent(currentNode) || isRenderedHTMLTableElement(cur
rentNode)) { |
714 if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset()) | 714 if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset()) |
715 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); | 715 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); |
716 continue; | 716 continue; |
717 } | 717 } |
718 | 718 |
719 // return current position if it is in rendered text | 719 // return current position if it is in rendered text |
720 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { | 720 if (renderer->isText() && toRenderText(renderer)->firstTextBox()) { |
721 if (currentNode != startNode) { | 721 if (currentNode != startNode) { |
722 ASSERT(currentPos.atStartOfNode()); | 722 ASSERT(currentPos.atStartOfNode()); |
723 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); | 723 return createLegacyEditingPosition(currentNode, renderer->caretM
inOffset()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 835 |
836 if (renderer->isText()) | 836 if (renderer->isText()) |
837 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); | 837 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); |
838 | 838 |
839 if (renderer->isSVG()) { | 839 if (renderer->isSVG()) { |
840 // We don't consider SVG elements are contenteditable except for | 840 // We don't consider SVG elements are contenteditable except for |
841 // associated renderer returns isText() true, e.g. RenderSVGInlineText. | 841 // associated renderer returns isText() true, e.g. RenderSVGInlineText. |
842 return false; | 842 return false; |
843 } | 843 } |
844 | 844 |
845 if (isRenderedTableElement(deprecatedNode()) || editingIgnoresContent(deprec
atedNode())) | 845 if (isRenderedHTMLTableElement(deprecatedNode()) || editingIgnoresContent(de
precatedNode())) |
846 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); | 846 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); |
847 | 847 |
848 if (isHTMLHtmlElement(*m_anchorNode)) | 848 if (isHTMLHtmlElement(*m_anchorNode)) |
849 return false; | 849 return false; |
850 | 850 |
851 if (renderer->isRenderBlockFlow()) { | 851 if (renderer->isRenderBlockFlow()) { |
852 if (toRenderBlock(renderer)->logicalHeight() || isHTMLBodyElement(*m_anc
horNode)) { | 852 if (toRenderBlock(renderer)->logicalHeight() || isHTMLBodyElement(*m_anc
horNode)) { |
853 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) | 853 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) |
854 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); | 854 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); |
855 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); | 855 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 pos.showTreeForThis(); | 1304 pos.showTreeForThis(); |
1305 } | 1305 } |
1306 | 1306 |
1307 void showTree(const blink::Position* pos) | 1307 void showTree(const blink::Position* pos) |
1308 { | 1308 { |
1309 if (pos) | 1309 if (pos) |
1310 pos->showTreeForThis(); | 1310 pos->showTreeForThis(); |
1311 } | 1311 } |
1312 | 1312 |
1313 #endif | 1313 #endif |
OLD | NEW |