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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (!m_anchorNode) | 86 if (!m_anchorNode) |
87 return; | 87 return; |
88 | 88 |
89 if (m_nodeAfterPositionInAnchor) { | 89 if (m_nodeAfterPositionInAnchor) { |
90 m_anchorNode = m_nodeAfterPositionInAnchor; | 90 m_anchorNode = m_nodeAfterPositionInAnchor; |
91 m_nodeAfterPositionInAnchor = Strategy::firstChild(*m_anchorNode); | 91 m_nodeAfterPositionInAnchor = Strategy::firstChild(*m_anchorNode); |
92 m_offsetInAnchor = 0; | 92 m_offsetInAnchor = 0; |
93 return; | 93 return; |
94 } | 94 } |
95 | 95 |
96 if (!Strategy::hasChildren(*m_anchorNode) && m_offsetInAnchor < Strategy::la
stOffsetForEditing(m_anchorNode)) { | 96 if (m_anchorNode->layoutObject() && !Strategy::hasChildren(*m_anchorNode) &&
m_offsetInAnchor < Strategy::lastOffsetForEditing(m_anchorNode)) { |
97 m_offsetInAnchor = PositionAlgorithm<Strategy>::uncheckedNextOffset(m_an
chorNode, m_offsetInAnchor); | 97 m_offsetInAnchor = PositionAlgorithm<Strategy>::uncheckedNextOffset(m_an
chorNode, m_offsetInAnchor); |
98 } else { | 98 } else { |
99 m_nodeAfterPositionInAnchor = m_anchorNode; | 99 m_nodeAfterPositionInAnchor = m_anchorNode; |
100 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); | 100 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); |
101 m_nodeAfterPositionInAnchor = Strategy::nextSibling(*m_nodeAfterPosition
InAnchor); | 101 m_nodeAfterPositionInAnchor = Strategy::nextSibling(*m_nodeAfterPosition
InAnchor); |
102 m_offsetInAnchor = 0; | 102 m_offsetInAnchor = 0; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 template <typename Strategy> | 106 template <typename Strategy> |
(...skipping 12 matching lines...) Expand all Loading... |
119 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); | 119 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); |
120 m_offsetInAnchor = 0; | 120 m_offsetInAnchor = 0; |
121 } | 121 } |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 if (Strategy::hasChildren(*m_anchorNode)) { | 125 if (Strategy::hasChildren(*m_anchorNode)) { |
126 m_anchorNode = Strategy::lastChild(*m_anchorNode); | 126 m_anchorNode = Strategy::lastChild(*m_anchorNode); |
127 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode)? 0 : Strategy::l
astOffsetForEditing(m_anchorNode); | 127 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode)? 0 : Strategy::l
astOffsetForEditing(m_anchorNode); |
128 } else { | 128 } else { |
129 if (m_offsetInAnchor) { | 129 if (m_offsetInAnchor && m_anchorNode->layoutObject()) { |
130 m_offsetInAnchor = PositionAlgorithm<Strategy>::uncheckedPreviousOff
set(m_anchorNode, m_offsetInAnchor); | 130 m_offsetInAnchor = PositionAlgorithm<Strategy>::uncheckedPreviousOff
set(m_anchorNode, m_offsetInAnchor); |
131 } else { | 131 } else { |
132 m_nodeAfterPositionInAnchor = m_anchorNode; | 132 m_nodeAfterPositionInAnchor = m_anchorNode; |
133 m_anchorNode = Strategy::parent(*m_anchorNode); | 133 m_anchorNode = Strategy::parent(*m_anchorNode); |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 template <typename Strategy> | 138 template <typename Strategy> |
139 bool PositionIteratorAlgorithm<Strategy>::atStart() const | 139 bool PositionIteratorAlgorithm<Strategy>::atStart() const |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return true; | 172 return true; |
173 if (m_nodeAfterPositionInAnchor) | 173 if (m_nodeAfterPositionInAnchor) |
174 return false; | 174 return false; |
175 return Strategy::hasChildren(*m_anchorNode) || m_offsetInAnchor >= Strategy:
:lastOffsetForEditing(m_anchorNode); | 175 return Strategy::hasChildren(*m_anchorNode) || m_offsetInAnchor >= Strategy:
:lastOffsetForEditing(m_anchorNode); |
176 } | 176 } |
177 | 177 |
178 template class PositionIteratorAlgorithm<EditingStrategy>; | 178 template class PositionIteratorAlgorithm<EditingStrategy>; |
179 template class PositionIteratorAlgorithm<EditingInComposedTreeStrategy>; | 179 template class PositionIteratorAlgorithm<EditingInComposedTreeStrategy>; |
180 | 180 |
181 } // namespace blink | 181 } // namespace blink |
OLD | NEW |