| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 m_domTreeVersion(0) {} | 64 m_domTreeVersion(0) {} |
| 65 | 65 |
| 66 template <typename Strategy> | 66 template <typename Strategy> |
| 67 PositionTemplate<Strategy> | 67 PositionTemplate<Strategy> |
| 68 PositionIteratorAlgorithm<Strategy>::deprecatedComputePosition() const { | 68 PositionIteratorAlgorithm<Strategy>::deprecatedComputePosition() const { |
| 69 // TODO(yoichio): Share code to check domTreeVersion with EphemeralRange. | 69 // TODO(yoichio): Share code to check domTreeVersion with EphemeralRange. |
| 70 DCHECK(isValid()); | 70 DCHECK(isValid()); |
| 71 if (m_nodeAfterPositionInAnchor) { | 71 if (m_nodeAfterPositionInAnchor) { |
| 72 DCHECK_EQ(Strategy::parent(*m_nodeAfterPositionInAnchor), m_anchorNode); | 72 DCHECK_EQ(Strategy::parent(*m_nodeAfterPositionInAnchor), m_anchorNode); |
| 73 DCHECK_NE(m_offsetsInAnchorNode[m_depthToAnchorNode], kInvalidOffset); | 73 DCHECK_NE(m_offsetsInAnchorNode[m_depthToAnchorNode], kInvalidOffset); |
| 74 // FIXME: This check is inadaquete because any ancestor could be ignored by
editing | 74 // FIXME: This check is inadaquete because any ancestor could be ignored by |
| 75 // editing |
| 75 if (Strategy::editingIgnoresContent( | 76 if (Strategy::editingIgnoresContent( |
| 76 Strategy::parent(*m_nodeAfterPositionInAnchor))) | 77 Strategy::parent(*m_nodeAfterPositionInAnchor))) |
| 77 return PositionTemplate<Strategy>::beforeNode(m_anchorNode); | 78 return PositionTemplate<Strategy>::beforeNode(m_anchorNode); |
| 78 return PositionTemplate<Strategy>( | 79 return PositionTemplate<Strategy>( |
| 79 m_anchorNode, m_offsetsInAnchorNode[m_depthToAnchorNode]); | 80 m_anchorNode, m_offsetsInAnchorNode[m_depthToAnchorNode]); |
| 80 } | 81 } |
| 81 if (Strategy::hasChildren(*m_anchorNode)) | 82 if (Strategy::hasChildren(*m_anchorNode)) |
| 82 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNode); | 83 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNode); |
| 83 return PositionTemplate<Strategy>::editingPositionOf(m_anchorNode, | 84 return PositionTemplate<Strategy>::editingPositionOf(m_anchorNode, |
| 84 m_offsetInAnchor); | 85 m_offsetInAnchor); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 // | | 97 // | |
| 97 // |-C | 98 // |-C |
| 98 // +-D | 99 // +-D |
| 99 // |-G | 100 // |-G |
| 100 // +-H | 101 // +-H |
| 101 if (m_nodeAfterPositionInAnchor) { | 102 if (m_nodeAfterPositionInAnchor) { |
| 102 // For example, position is before E, F. | 103 // For example, position is before E, F. |
| 103 DCHECK_EQ(Strategy::parent(*m_nodeAfterPositionInAnchor), m_anchorNode); | 104 DCHECK_EQ(Strategy::parent(*m_nodeAfterPositionInAnchor), m_anchorNode); |
| 104 DCHECK_NE(m_offsetsInAnchorNode[m_depthToAnchorNode], kInvalidOffset); | 105 DCHECK_NE(m_offsetsInAnchorNode[m_depthToAnchorNode], kInvalidOffset); |
| 105 // TODO(yoichio): This should be equivalent to | 106 // TODO(yoichio): This should be equivalent to |
| 106 // PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::BeforeAnchor
); | 107 // PositionTemplate<Strategy>(m_anchorNode, |
| 108 // PositionAnchorType::BeforeAnchor); |
| 107 return PositionTemplate<Strategy>( | 109 return PositionTemplate<Strategy>( |
| 108 m_anchorNode, m_offsetsInAnchorNode[m_depthToAnchorNode]); | 110 m_anchorNode, m_offsetsInAnchorNode[m_depthToAnchorNode]); |
| 109 } | 111 } |
| 110 if (Strategy::hasChildren(*m_anchorNode)) | 112 if (Strategy::hasChildren(*m_anchorNode)) |
| 111 // For example, position is the end of B. | 113 // For example, position is the end of B. |
| 112 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNode); | 114 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNode); |
| 113 if (m_anchorNode->isTextNode()) | 115 if (m_anchorNode->isTextNode()) |
| 114 return PositionTemplate<Strategy>(m_anchorNode, m_offsetInAnchor); | 116 return PositionTemplate<Strategy>(m_anchorNode, m_offsetInAnchor); |
| 115 if (m_offsetInAnchor) | 117 if (m_offsetInAnchor) |
| 116 // For example, position is after G. | 118 // For example, position is after G. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 if (m_nodeAfterPositionInAnchor) | 344 if (m_nodeAfterPositionInAnchor) |
| 343 return false; | 345 return false; |
| 344 return Strategy::hasChildren(*m_anchorNode) || | 346 return Strategy::hasChildren(*m_anchorNode) || |
| 345 m_offsetInAnchor >= Strategy::lastOffsetForEditing(m_anchorNode); | 347 m_offsetInAnchor >= Strategy::lastOffsetForEditing(m_anchorNode); |
| 346 } | 348 } |
| 347 | 349 |
| 348 template class PositionIteratorAlgorithm<EditingStrategy>; | 350 template class PositionIteratorAlgorithm<EditingStrategy>; |
| 349 template class PositionIteratorAlgorithm<EditingInFlatTreeStrategy>; | 351 template class PositionIteratorAlgorithm<EditingInFlatTreeStrategy>; |
| 350 | 352 |
| 351 } // namespace blink | 353 } // namespace blink |
| OLD | NEW |