Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
index 13539b5bda7fc20fc738591c0044097ff6190ac3..15fcc2f0e3aaf15065c6170b1e2e00f8ad424af3 100644 |
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
@@ -2059,6 +2059,32 @@ bool isTextSecurityNode(const Node* node) { |
node->layoutObject()->style()->textSecurity() != TSNONE; |
} |
+// If current position is at grapheme boundary, return 0; otherwise, return the |
+// distance to its nearest left grapheme boundary. |
+size_t computeDistanceToLeftGraphemeBoundary(const Position& position) { |
+ const Position& adjustedPosition = previousPositionOf( |
+ nextPositionOf(position, PositionMoveType::GraphemeCluster), |
+ PositionMoveType::GraphemeCluster); |
+ DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); |
+ DCHECK_GE(position.computeOffsetInContainerNode(), |
+ adjustedPosition.computeOffsetInContainerNode()); |
+ return static_cast<size_t>(position.computeOffsetInContainerNode() - |
+ adjustedPosition.computeOffsetInContainerNode()); |
+} |
+ |
+// If current position is at grapheme boundary, return 0; otherwise, return the |
+// distance to its nearest right grapheme boundary. |
+size_t computeDistanceToRightGraphemeBoundary(const Position& position) { |
+ const Position& adjustedPosition = nextPositionOf( |
+ previousPositionOf(position, PositionMoveType::GraphemeCluster), |
+ PositionMoveType::GraphemeCluster); |
+ DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); |
+ DCHECK_GE(adjustedPosition.computeOffsetInContainerNode(), |
+ position.computeOffsetInContainerNode()); |
+ return static_cast<size_t>(adjustedPosition.computeOffsetInContainerNode() - |
+ position.computeOffsetInContainerNode()); |
+} |
+ |
const StaticRangeVector* targetRangesForInputEvent(const Node& node) { |
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
// needs to be audited. see http://crbug.com/590369 for more details. |