Chromium Code Reviews| 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 a234656ab5f420fdfc89510245cc750322b15ce5..3cb4283eff7f68b404a726a8bfea2a0f243e95ff 100644 |
| --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| @@ -4078,4 +4078,52 @@ PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) { |
| return SkipWhitespaceAlgorithm(position); |
| } |
| +static void CollectAbsoluteBoundsForRange(unsigned start, |
| + unsigned end, |
| + const LayoutText& layout_text, |
| + Vector<IntRect>& rects) { |
| + layout_text.AbsoluteRectsForRange(rects, start, end); |
| +} |
| + |
| +static void CollectAbsoluteBoundsForRange(unsigned start, |
| + unsigned end, |
| + const LayoutText& layout_text, |
| + Vector<FloatQuad>& quads) { |
| + layout_text.AbsoluteQuadsForRange(quads, start, end); |
| +} |
| + |
| +template <typename RectType> |
| +static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) { |
| + const Position& start_position = range.StartPosition(); |
| + const Position& end_position = range.EndPosition(); |
| + Node* const start_container = start_position.ComputeContainerNode(); |
| + DCHECK(start_container); |
| + Node* const end_container = end_position.ComputeContainerNode(); |
| + DCHECK(end_container); |
| + |
| + Vector<RectType> result; |
| + for (const Node& node : range.Nodes()) { |
| + LayoutObject* const layoutObject = node.GetLayoutObject(); |
|
Srirama
2017/05/11 04:41:41
s/layoutObject/layout_object
tanvir
2017/05/11 05:31:28
Done.
|
| + if (!layoutObject || !layoutObject->IsText()) |
| + continue; |
| + const LayoutText* layout_text = ToLayoutText(layoutObject); |
| + unsigned start_offset = |
| + node == start_container ? start_position.OffsetInContainerNode() : 0; |
| + unsigned end_offset = node == end_container |
| + ? end_position.OffsetInContainerNode() |
| + : std::numeric_limits<unsigned>::max(); |
| + CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text, |
| + result); |
| + } |
| + return result; |
| +} |
| + |
| +Vector<IntRect> ComputeTextRects(const EphemeralRange& range) { |
| + return ComputeTextBounds<IntRect>(range); |
| +} |
| + |
| +Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) { |
| + return ComputeTextBounds<FloatQuad>(range); |
| +} |
| + |
| } // namespace blink |