| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // should not use them. | 105 // should not use them. |
| 106 DCHECK(IsBeforeChildren() || IsAfterChildren()) << anchor_type_; | 106 DCHECK(IsBeforeChildren() || IsAfterChildren()) << anchor_type_; |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 #if DCHECK_IS_ON() | 109 #if DCHECK_IS_ON() |
| 110 DCHECK(CanBeAnchorNode<Strategy>(anchor_node_.Get())) << anchor_node_; | 110 DCHECK(CanBeAnchorNode<Strategy>(anchor_node_.Get())) << anchor_node_; |
| 111 #endif | 111 #endif |
| 112 DCHECK_NE(anchor_type_, PositionAnchorType::kOffsetInAnchor); | 112 DCHECK_NE(anchor_type_, PositionAnchorType::kOffsetInAnchor); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // TODO(editing-dev): Once we change type of |anchor_node_| to |
| 116 // |Member<const Node>|, we should get rid of |const_cast<Node*>()|. |
| 117 // See http://crbug.com/735327 |
| 115 template <typename Strategy> | 118 template <typename Strategy> |
| 116 PositionTemplate<Strategy>::PositionTemplate(Node* anchor_node, int offset) | 119 PositionTemplate<Strategy>::PositionTemplate(const Node* anchor_node, |
| 117 : anchor_node_(anchor_node), | 120 int offset) |
| 121 : anchor_node_(const_cast<Node*>(anchor_node)), |
| 118 offset_(offset), | 122 offset_(offset), |
| 119 anchor_type_(PositionAnchorType::kOffsetInAnchor) { | 123 anchor_type_(PositionAnchorType::kOffsetInAnchor) { |
| 120 if (anchor_node_) | 124 if (anchor_node_) |
| 121 DCHECK_GE(offset, 0); | 125 DCHECK_GE(offset, 0); |
| 122 else | 126 else |
| 123 DCHECK_EQ(offset, 0); | 127 DCHECK_EQ(offset, 0); |
| 124 #if DCHECK_IS_ON() | 128 #if DCHECK_IS_ON() |
| 125 DCHECK(CanBeAnchorNode<Strategy>(anchor_node_.Get())) << anchor_node_; | 129 DCHECK(CanBeAnchorNode<Strategy>(anchor_node_.Get())) << anchor_node_; |
| 126 #endif | 130 #endif |
| 127 } | 131 } |
| 128 | 132 |
| 129 template <typename Strategy> | 133 template <typename Strategy> |
| 134 PositionTemplate<Strategy>::PositionTemplate(const Node& anchor_node, |
| 135 int offset) |
| 136 : PositionTemplate(&anchor_node, offset) {} |
| 137 |
| 138 template <typename Strategy> |
| 130 PositionTemplate<Strategy>::PositionTemplate(const PositionTemplate& other) | 139 PositionTemplate<Strategy>::PositionTemplate(const PositionTemplate& other) |
| 131 : anchor_node_(other.anchor_node_), | 140 : anchor_node_(other.anchor_node_), |
| 132 offset_(other.offset_), | 141 offset_(other.offset_), |
| 133 anchor_type_(other.anchor_type_) {} | 142 anchor_type_(other.anchor_type_) {} |
| 134 | 143 |
| 135 // -- | 144 // -- |
| 136 | 145 |
| 137 template <typename Strategy> | 146 template <typename Strategy> |
| 138 Node* PositionTemplate<Strategy>::ComputeContainerNode() const { | 147 Node* PositionTemplate<Strategy>::ComputeContainerNode() const { |
| 139 if (!anchor_node_) | 148 if (!anchor_node_) |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 711 } |
| 703 | 712 |
| 704 void showTree(const blink::Position* pos) { | 713 void showTree(const blink::Position* pos) { |
| 705 if (pos) | 714 if (pos) |
| 706 pos->ShowTreeForThis(); | 715 pos->ShowTreeForThis(); |
| 707 else | 716 else |
| 708 LOG(INFO) << "Cannot showTree for <null>"; | 717 LOG(INFO) << "Cannot showTree for <null>"; |
| 709 } | 718 } |
| 710 | 719 |
| 711 #endif | 720 #endif |
| OLD | NEW |