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..6796ae823b30866a90a190c8262b904048007a0e 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, |
|
tkent
2017/04/27 06:40:37
Please make |rects| the last argument.
https://go
tanvir
2017/04/27 14:26:29
Done.
|
| + unsigned start, |
| + unsigned end, |
| + const LayoutText& layout_text) { |
| + layout_text.AbsoluteRectsForRange(rects, start, end); |
| +} |
| + |
| +template <typename ElementType> |
|
tkent
2017/04/27 06:40:37
|ElementType| is confusing with DOM Element. Can
tanvir
2017/04/27 14:26:29
Done.
|
| +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,20 +1456,25 @@ 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()) |
| continue; |
| - LayoutText* layout_text = ToLayoutText(layoutObject); |
| + 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(); |
| - 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 { |