| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 Position adjustPositionForEnd(const Position& currentPosition, Node* startContai
nerNode) | 100 Position adjustPositionForEnd(const Position& currentPosition, Node* startContai
nerNode) |
| 101 { | 101 { |
| 102 TreeScope& treeScope = startContainerNode->treeScope(); | 102 TreeScope& treeScope = startContainerNode->treeScope(); |
| 103 | 103 |
| 104 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); | 104 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); |
| 105 | 105 |
| 106 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo
ntainerNode())) { | 106 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo
ntainerNode())) { |
| 107 if (ancestor->contains(startContainerNode)) | 107 if (ancestor->contains(startContainerNode)) |
| 108 return Position::afterNode(ancestor); | 108 return Position::afterNode(ancestor); |
| 109 return positionBeforeNode(ancestor); | 109 return Position::beforeNode(ancestor); |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (Node* lastChild = treeScope.rootNode().lastChild()) | 112 if (Node* lastChild = treeScope.rootNode().lastChild()) |
| 113 return Position::afterNode(lastChild); | 113 return Position::afterNode(lastChild); |
| 114 | 114 |
| 115 return Position(); | 115 return Position(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 PositionInFlatTree adjustPositionInFlatTreeForEnd(const PositionInFlatTree& posi
tion, Node* shadowHost) | 118 PositionInFlatTree adjustPositionInFlatTreeForEnd(const PositionInFlatTree& posi
tion, Node* shadowHost) |
| 119 { | 119 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 Position adjustPositionForStart(const Position& currentPosition, Node* endContai
nerNode) | 134 Position adjustPositionForStart(const Position& currentPosition, Node* endContai
nerNode) |
| 135 { | 135 { |
| 136 TreeScope& treeScope = endContainerNode->treeScope(); | 136 TreeScope& treeScope = endContainerNode->treeScope(); |
| 137 | 137 |
| 138 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); | 138 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); |
| 139 | 139 |
| 140 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo
ntainerNode())) { | 140 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo
ntainerNode())) { |
| 141 if (ancestor->contains(endContainerNode)) | 141 if (ancestor->contains(endContainerNode)) |
| 142 return positionBeforeNode(ancestor); | 142 return Position::beforeNode(ancestor); |
| 143 return Position::afterNode(ancestor); | 143 return Position::afterNode(ancestor); |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (Node* firstChild = treeScope.rootNode().firstChild()) | 146 if (Node* firstChild = treeScope.rootNode().firstChild()) |
| 147 return positionBeforeNode(firstChild); | 147 return Position::beforeNode(firstChild); |
| 148 | 148 |
| 149 return Position(); | 149 return Position(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 // Updates |selectionInFlatTree| to match with |selection|. | 154 // Updates |selectionInFlatTree| to match with |selection|. |
| 155 void SelectionAdjuster::adjustSelectionInFlatTree(VisibleSelectionInFlatTree* se
lectionInFlatTree, const VisibleSelection& selection) | 155 void SelectionAdjuster::adjustSelectionInFlatTree(VisibleSelectionInFlatTree* se
lectionInFlatTree, const VisibleSelection& selection) |
| 156 { | 156 { |
| 157 if (selection.isNone()) { | 157 if (selection.isNone()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 selection->m_end = newEnd; | 270 selection->m_end = newEnd; |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart; | 273 Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart; |
| 274 const PositionInFlatTree& newStart = adjustPositionInFlatTreeForStart(select
ion->start(), shadowHost); | 274 const PositionInFlatTree& newStart = adjustPositionInFlatTreeForStart(select
ion->start(), shadowHost); |
| 275 selection->m_extent = newStart; | 275 selection->m_extent = newStart; |
| 276 selection->m_start = newStart; | 276 selection->m_start = newStart; |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace blink | 279 } // namespace blink |
| OLD | NEW |