Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/core/editing/GranularityStrategy.cpp

Issue 1308323004: Introduce absoluteCaretBoundsOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T19:12:35 Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/GranularityStrategyTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/editing/GranularityStrategy.h" 6 #include "core/editing/GranularityStrategy.h"
7 7
8 #include "core/editing/EditingUtilities.h" 8 #include "core/editing/EditingUtilities.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 enum class BoundAdjust {CurrentPosIfOnBound, NextBoundIfOnBound}; 13 enum class BoundAdjust {CurrentPosIfOnBound, NextBoundIfOnBound};
14 enum class SearchDirection {SearchBackwards, SearchForward}; 14 enum class SearchDirection {SearchBackwards, SearchForward};
15 15
16 // We use the bottom-left corner of the caret rect to represent the 16 // We use the bottom-left corner of the caret rect to represent the
17 // location of a VisiblePosition. This way locations corresponding to 17 // location of a VisiblePosition. This way locations corresponding to
18 // VisiblePositions on the same line will all have the same y coordinate 18 // VisiblePositions on the same line will all have the same y coordinate
19 // unless the text is transformed. 19 // unless the text is transformed.
20 static IntPoint positionLocation(const VisiblePosition& vp) 20 static IntPoint positionLocation(const VisiblePosition& vp)
21 { 21 {
22 return vp.absoluteCaretBounds().minXMaxYCorner(); 22 return absoluteCaretBoundsOf(vp).minXMaxYCorner();
23 } 23 }
24 24
25 // Order is specified using the same contract as comparePositions. 25 // Order is specified using the same contract as comparePositions.
26 static bool arePositionsInSpecifiedOrder( 26 static bool arePositionsInSpecifiedOrder(
27 const VisiblePosition& vp1, 27 const VisiblePosition& vp1,
28 const VisiblePosition& vp2, 28 const VisiblePosition& vp2,
29 int specifiedOrder) 29 int specifiedOrder)
30 { 30 {
31 int positionOrder = comparePositions(vp1, vp2); 31 int positionOrder = comparePositions(vp1, vp2);
32 if (specifiedOrder == 0) 32 if (specifiedOrder == 0)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (newSelectionExtent.deepEquivalent() != selection.visibleExtent().deepEqu ivalent()) 230 if (newSelectionExtent.deepEquivalent() != selection.visibleExtent().deepEqu ivalent())
231 m_state = thisMoveShrunkSelection ? StrategyState::Shrinking : StrategyS tate::Expanding; 231 m_state = thisMoveShrunkSelection ? StrategyState::Shrinking : StrategyS tate::Expanding;
232 232
233 m_diffExtentPointFromExtentPosition = extentPoint + IntSize(m_offset, 0) - p ositionLocation(newSelectionExtent); 233 m_diffExtentPointFromExtentPosition = extentPoint + IntSize(m_offset, 0) - p ositionLocation(newSelectionExtent);
234 VisibleSelection newSelection = selection; 234 VisibleSelection newSelection = selection;
235 newSelection.setExtent(newSelectionExtent); 235 newSelection.setExtent(newSelectionExtent);
236 return newSelection; 236 return newSelection;
237 } 237 }
238 238
239 } // namespace blink 239 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/GranularityStrategyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698