Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/Range.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp |
| index 76e18fa4a989b4c8e263194cc052a329fa79348e..7b12539b2843c9eb45e927bbd83b41599a116440 100644 |
| --- a/third_party/WebKit/Source/core/dom/Range.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Range.cpp |
| @@ -1440,7 +1440,15 @@ Node* Range::PastLastNode() const { |
| return EndPosition().NodeAsRangePastLastNode(); |
| } |
| -static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
| +static void CollectAbsoluteBoundsForRange(Vector<IntRect>& rects, |
| + unsigned start, |
| + unsigned end, |
| + LayoutText* layout_text) { |
|
yosin_UTC9
2017/04/25 06:54:34
nit: s/LayoutText*/const LayoutText&/
Please wait
tanvir
2017/04/26 09:36:30
Done.
|
| + layout_text->AbsoluteRectsForRange(rects, start, end); |
| +} |
| + |
| +template <typename ElementType> |
| +static Vector<ElementType> ComputeTextBounds(const EphemeralRange& range) { |
| const Position& start_position = range.StartPosition(); |
| const Position& end_position = range.EndPosition(); |
| Node* const start_container = start_position.ComputeContainerNode(); |
| @@ -1448,7 +1456,7 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
| Node* const end_container = end_position.ComputeContainerNode(); |
| DCHECK(end_container); |
| - Vector<IntRect> rects; |
| + Vector<ElementType> result; |
| for (const Node& node : range.Nodes()) { |
| LayoutObject* const layoutObject = node.GetLayoutObject(); |
| if (!layoutObject || !layoutObject->IsText()) |
| @@ -1459,9 +1467,14 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
| unsigned end_offset = node == end_container |
| ? end_position.OffsetInContainerNode() |
| : std::numeric_limits<unsigned>::max(); |
| - layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); |
| + CollectAbsoluteBoundsForRange(result, start_offset, end_offset, |
| + layout_text); |
| } |
| - return rects; |
| + return result; |
| +} |
| + |
| +static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
| + return ComputeTextBounds<IntRect>(range); |
| } |
| IntRect Range::BoundingBox() const { |