OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/editing/GranularityStrategy.h" | 5 #include "core/editing/GranularityStrategy.h" |
6 | 6 |
7 #include "core/editing/EditingUtilities.h" | 7 #include "core/editing/EditingUtilities.h" |
8 #include "core/editing/FrameSelection.h" | 8 #include "core/editing/FrameSelection.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Determine the word boundary, i.e. the boundary extending beyond which | 187 // Determine the word boundary, i.e. the boundary extending beyond which |
188 // should change the granularity to WordGranularity. | 188 // should change the granularity to WordGranularity. |
189 VisiblePosition wordBoundary; | 189 VisiblePosition wordBoundary; |
190 if (extentBaseOrderSwitched) { | 190 if (extentBaseOrderSwitched) { |
191 // Special case. | 191 // Special case. |
192 // If the extent-base order was switched, then the selection is now | 192 // If the extent-base order was switched, then the selection is now |
193 // expanding in a different direction than before. Therefore we | 193 // expanding in a different direction than before. Therefore we |
194 // calculate the word boundary in this new direction and based on | 194 // calculate the word boundary in this new direction and based on |
195 // the |base| position. | 195 // the |base| position. |
196 wordBoundary = nextWordBound(base, newExtentBaseOrder > 0 | 196 wordBoundary = nextWordBound(base, |
197 ? SearchDirection::SearchForward | 197 newExtentBaseOrder > 0 |
198 : SearchDirection::SearchBackwards, | 198 ? SearchDirection::SearchForward |
| 199 : SearchDirection::SearchBackwards, |
199 BoundAdjust::NextBoundIfOnBound); | 200 BoundAdjust::NextBoundIfOnBound); |
200 m_granularity = CharacterGranularity; | 201 m_granularity = CharacterGranularity; |
201 } else { | 202 } else { |
202 // Calculate the word boundary based on |oldExtentWithGranularity|. | 203 // Calculate the word boundary based on |oldExtentWithGranularity|. |
203 // If selection was shrunk in the last update and the extent is now | 204 // If selection was shrunk in the last update and the extent is now |
204 // exactly on the word boundary - we need to take the next bound as | 205 // exactly on the word boundary - we need to take the next bound as |
205 // the bound of the current word. | 206 // the bound of the current word. |
206 wordBoundary = nextWordBound(oldOffsetExtentPosition, | 207 wordBoundary = nextWordBound(oldOffsetExtentPosition, |
207 oldExtentBaseOrder > 0 | 208 oldExtentBaseOrder > 0 |
208 ? SearchDirection::SearchForward | 209 ? SearchDirection::SearchForward |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 m_diffExtentPointFromExtentPosition = | 270 m_diffExtentPointFromExtentPosition = |
270 extentPoint + IntSize(m_offset, 0) - positionLocation(newSelectionExtent); | 271 extentPoint + IntSize(m_offset, 0) - positionLocation(newSelectionExtent); |
271 return createVisibleSelection( | 272 return createVisibleSelection( |
272 SelectionInDOMTree::Builder(selection.asSelection()) | 273 SelectionInDOMTree::Builder(selection.asSelection()) |
273 .collapse(selection.base()) | 274 .collapse(selection.base()) |
274 .extend(newSelectionExtent.deepEquivalent()) | 275 .extend(newSelectionExtent.deepEquivalent()) |
275 .build()); | 276 .build()); |
276 } | 277 } |
277 | 278 |
278 } // namespace blink | 279 } // namespace blink |
OLD | NEW |