| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Neighbor-anchored positions are invalid DOM positions, so they need to be | 170 // Neighbor-anchored positions are invalid DOM positions, so they need to be |
| 171 // fixed up before handing them off to the Range object. | 171 // fixed up before handing them off to the Range object. |
| 172 template <typename Strategy> | 172 template <typename Strategy> |
| 173 PositionTemplate<Strategy> | 173 PositionTemplate<Strategy> |
| 174 PositionTemplate<Strategy>::parentAnchoredEquivalent() const { | 174 PositionTemplate<Strategy>::parentAnchoredEquivalent() const { |
| 175 if (!m_anchorNode) | 175 if (!m_anchorNode) |
| 176 return PositionTemplate<Strategy>(); | 176 return PositionTemplate<Strategy>(); |
| 177 | 177 |
| 178 // FIXME: This should only be necessary for legacy positions, but is also need
ed for positions before and after Tables | 178 // FIXME: This should only be necessary for legacy positions, but is also |
| 179 // needed for positions before and after Tables |
| 179 if (m_offset == 0 && !isAfterAnchorOrAfterChildren()) { | 180 if (m_offset == 0 && !isAfterAnchorOrAfterChildren()) { |
| 180 if (Strategy::parent(*m_anchorNode) && | 181 if (Strategy::parent(*m_anchorNode) && |
| 181 (Strategy::editingIgnoresContent(m_anchorNode.get()) || | 182 (Strategy::editingIgnoresContent(m_anchorNode.get()) || |
| 182 isDisplayInsideTable(m_anchorNode.get()))) | 183 isDisplayInsideTable(m_anchorNode.get()))) |
| 183 return inParentBeforeNode(*m_anchorNode); | 184 return inParentBeforeNode(*m_anchorNode); |
| 184 return PositionTemplate<Strategy>(m_anchorNode.get(), 0); | 185 return PositionTemplate<Strategy>(m_anchorNode.get(), 0); |
| 185 } | 186 } |
| 186 if (!m_anchorNode->isCharacterDataNode() && | 187 if (!m_anchorNode->isCharacterDataNode() && |
| 187 (isAfterAnchorOrAfterChildren() || | 188 (isAfterAnchorOrAfterChildren() || |
| 188 static_cast<unsigned>(m_offset) == m_anchorNode->countChildren()) && | 189 static_cast<unsigned>(m_offset) == m_anchorNode->countChildren()) && |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 template <typename Strategy> | 342 template <typename Strategy> |
| 342 bool PositionTemplate<Strategy>::operator>=( | 343 bool PositionTemplate<Strategy>::operator>=( |
| 343 const PositionTemplate<Strategy>& other) const { | 344 const PositionTemplate<Strategy>& other) const { |
| 344 return comparePositions(*this, other) >= 0; | 345 return comparePositions(*this, other) >= 0; |
| 345 } | 346 } |
| 346 | 347 |
| 347 template <typename Strategy> | 348 template <typename Strategy> |
| 348 bool PositionTemplate<Strategy>::atFirstEditingPositionForNode() const { | 349 bool PositionTemplate<Strategy>::atFirstEditingPositionForNode() const { |
| 349 if (isNull()) | 350 if (isNull()) |
| 350 return true; | 351 return true; |
| 351 // FIXME: Position before anchor shouldn't be considered as at the first editi
ng position for node | 352 // FIXME: Position before anchor shouldn't be considered as at the first |
| 352 // since that position resides outside of the node. | 353 // editing position for node since that position resides outside of the node. |
| 353 switch (m_anchorType) { | 354 switch (m_anchorType) { |
| 354 case PositionAnchorType::OffsetInAnchor: | 355 case PositionAnchorType::OffsetInAnchor: |
| 355 return m_offset == 0; | 356 return m_offset == 0; |
| 356 case PositionAnchorType::BeforeChildren: | 357 case PositionAnchorType::BeforeChildren: |
| 357 case PositionAnchorType::BeforeAnchor: | 358 case PositionAnchorType::BeforeAnchor: |
| 358 return true; | 359 return true; |
| 359 case PositionAnchorType::AfterChildren: | 360 case PositionAnchorType::AfterChildren: |
| 360 case PositionAnchorType::AfterAnchor: | 361 case PositionAnchorType::AfterAnchor: |
| 361 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead | 362 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead |
| 362 // of DOM tree version. | 363 // of DOM tree version. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 393 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead of | 394 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead of |
| 394 // DOM tree version. | 395 // DOM tree version. |
| 395 return !Strategy::parent(*anchorNode()) && | 396 return !Strategy::parent(*anchorNode()) && |
| 396 m_offset >= EditingStrategy::lastOffsetForEditing(anchorNode()); | 397 m_offset >= EditingStrategy::lastOffsetForEditing(anchorNode()); |
| 397 } | 398 } |
| 398 | 399 |
| 399 // static | 400 // static |
| 400 template <typename Strategy> | 401 template <typename Strategy> |
| 401 PositionTemplate<Strategy> PositionTemplate<Strategy>::inParentBeforeNode( | 402 PositionTemplate<Strategy> PositionTemplate<Strategy>::inParentBeforeNode( |
| 402 const Node& node) { | 403 const Node& node) { |
| 403 // FIXME: This should DCHECK(node.parentNode()) | 404 // FIXME: This should DCHECK(node.parentNode()). At least one caller currently |
| 404 // At least one caller currently hits this ASSERT though, which indicates | 405 // hits this DCHECK though, which indicates that the caller is trying to make |
| 405 // that the caller is trying to make a position relative to a disconnected nod
e (which is likely an error) | 406 // a position relative to a disconnected node (which is likely an error) |
| 406 // Specifically, editing/deleting/delete-ligature-001.html crashes with DCHECK
(node->parentNode()) | 407 // Specifically, editing/deleting/delete-ligature-001.html crashes with |
| 408 // DCHECK(node->parentNode()) |
| 407 return PositionTemplate<Strategy>(Strategy::parent(node), | 409 return PositionTemplate<Strategy>(Strategy::parent(node), |
| 408 Strategy::index(node)); | 410 Strategy::index(node)); |
| 409 } | 411 } |
| 410 | 412 |
| 411 // static | 413 // static |
| 412 template <typename Strategy> | 414 template <typename Strategy> |
| 413 PositionTemplate<Strategy> PositionTemplate<Strategy>::inParentAfterNode( | 415 PositionTemplate<Strategy> PositionTemplate<Strategy>::inParentAfterNode( |
| 414 const Node& node) { | 416 const Node& node) { |
| 415 DCHECK(node.parentNode()) << node; | 417 DCHECK(node.parentNode()) << node; |
| 416 return PositionTemplate<Strategy>(Strategy::parent(node), | 418 return PositionTemplate<Strategy>(Strategy::parent(node), |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 672 } |
| 671 | 673 |
| 672 void showTree(const blink::Position* pos) { | 674 void showTree(const blink::Position* pos) { |
| 673 if (pos) | 675 if (pos) |
| 674 pos->showTreeForThis(); | 676 pos->showTreeForThis(); |
| 675 else | 677 else |
| 676 LOG(INFO) << "Cannot showTree for <null>"; | 678 LOG(INFO) << "Cannot showTree for <null>"; |
| 677 } | 679 } |
| 678 | 680 |
| 679 #endif | 681 #endif |
| OLD | NEW |