| 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 { |
| 11 | 11 |
| 12 enum class BoundAdjust { CurrentPosIfOnBound, NextBoundIfOnBound }; | 12 enum class BoundAdjust { CurrentPosIfOnBound, NextBoundIfOnBound }; |
| 13 enum class SearchDirection { SearchBackwards, SearchForward }; | 13 enum class SearchDirection { SearchBackwards, SearchForward }; |
| 14 | 14 |
| 15 // We use the bottom-left corner of the caret rect to represent the | 15 // We use the bottom-left corner of the selection rect to represent the |
| 16 // location of a VisiblePosition. This way locations corresponding to | 16 // location of a VisiblePosition. This way locations corresponding to |
| 17 // VisiblePositions on the same line will all have the same y coordinate | 17 // VisiblePositions on the same line will all have the same y coordinate |
| 18 // unless the text is transformed. | 18 // unless the text is transformed. |
| 19 static IntPoint positionLocation(const VisiblePosition& vp) { | 19 static IntPoint positionLocation(const VisiblePosition& vp) { |
| 20 return absoluteCaretBoundsOf(vp).minXMaxYCorner(); | 20 return absoluteSelectionBoundsOf(vp).minXMaxYCorner(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Order is specified using the same contract as comparePositions. | 23 // Order is specified using the same contract as comparePositions. |
| 24 static bool arePositionsInSpecifiedOrder(const VisiblePosition& vp1, | 24 static bool arePositionsInSpecifiedOrder(const VisiblePosition& vp1, |
| 25 const VisiblePosition& vp2, | 25 const VisiblePosition& vp2, |
| 26 int specifiedOrder) { | 26 int specifiedOrder) { |
| 27 int positionOrder = comparePositions(vp1, vp2); | 27 int positionOrder = comparePositions(vp1, vp2); |
| 28 if (specifiedOrder == 0) | 28 if (specifiedOrder == 0) |
| 29 return positionOrder == 0; | 29 return positionOrder == 0; |
| 30 return specifiedOrder > 0 ? positionOrder > 0 : positionOrder < 0; | 30 return specifiedOrder > 0 ? positionOrder > 0 : positionOrder < 0; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 m_diffExtentPointFromExtentPosition = | 269 m_diffExtentPointFromExtentPosition = |
| 270 extentPoint + IntSize(m_offset, 0) - positionLocation(newSelectionExtent); | 270 extentPoint + IntSize(m_offset, 0) - positionLocation(newSelectionExtent); |
| 271 return createVisibleSelection( | 271 return createVisibleSelection( |
| 272 SelectionInDOMTree::Builder(selection.asSelection()) | 272 SelectionInDOMTree::Builder(selection.asSelection()) |
| 273 .collapse(selection.base()) | 273 .collapse(selection.base()) |
| 274 .extend(newSelectionExtent.deepEquivalent()) | 274 .extend(newSelectionExtent.deepEquivalent()) |
| 275 .build()); | 275 .build()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |