Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
index f1da75b0e408206c7b87a6ce891b67ed7c7005fc..fe032de96309f39115ce4e43b1a725368d78255d 100644 |
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
@@ -4048,4 +4048,38 @@ PositionInFlatTree skipWhitespace(const PositionInFlatTree& position) { |
return skipWhitespaceAlgorithm(position); |
} |
+template <typename Strategy> |
+static Vector<FloatQuad> textQuadAlgorithm( |
+ const EphemeralRangeTemplate<Strategy>& range) { |
+ const PositionTemplate<Strategy> startPosition = range.startPosition(); |
+ const PositionTemplate<Strategy> endPosition = range.endPosition(); |
+ Node* startContainer = startPosition.computeContainerNode(); |
+ DCHECK(startContainer); |
+ Node* endContainer = endPosition.computeContainerNode(); |
+ DCHECK(endContainer); |
+ |
+ Vector<FloatQuad> quad; |
+ for (Node& node : range.nodes()) { |
+ LayoutObject* layoutObject = node.layoutObject(); |
+ if (!layoutObject || !layoutObject->isText()) |
+ continue; |
+ LayoutText* layoutText = toLayoutText(layoutObject); |
+ unsigned startOffset = |
+ node == startContainer ? startPosition.offsetInContainerNode() : 0; |
+ unsigned endOffset = node == endContainer |
+ ? endPosition.offsetInContainerNode() |
+ : std::numeric_limits<unsigned>::max(); |
+ layoutText->absoluteQuadsForRange(quad, startOffset, endOffset); |
+ } |
+ return quad; |
+} |
+ |
+Vector<FloatQuad> textQuad(const EphemeralRange& range) { |
Xiaocheng
2017/03/30 18:46:19
nit: s/textQuad/textQuads/
|
+ return textQuadAlgorithm(range); |
+} |
+ |
+Vector<FloatQuad> textQuad(const EphemeralRangeInFlatTree& range) { |
Xiaocheng
2017/03/30 18:46:19
nit: nit: s/textQuad/textQuads/
|
+ return textQuadAlgorithm(range); |
+} |
+ |
} // namespace blink |