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 938e7c2acac291ee8ab4a70f35508cae5947b084..264119f38ef77169ad2220e3c885119dbe112c6d 100644 |
--- a/third_party/WebKit/Source/core/dom/Range.cpp |
+++ b/third_party/WebKit/Source/core/dom/Range.cpp |
@@ -1447,6 +1447,13 @@ static void CollectAbsoluteBoundsForRange(unsigned start, |
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(); |
@@ -1477,6 +1484,10 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
return ComputeTextBounds<IntRect>(range); |
} |
+static Vector<FloatQuad> computeTextQuads(const EphemeralRange& range) { |
+ return ComputeTextBounds<FloatQuad>(range); |
+} |
+ |
IntRect Range::BoundingBox() const { |
IntRect result; |
const Vector<IntRect>& rects = computeTextRects(EphemeralRange(this)); |
@@ -1487,25 +1498,8 @@ IntRect Range::BoundingBox() const { |
void Range::TextQuads(Vector<FloatQuad>& quads, |
bool use_selection_height) const { |
- Node* start_container = &start_.Container(); |
- DCHECK(start_container); |
- Node* end_container = &end_.Container(); |
- DCHECK(end_container); |
- |
- Node* stop_node = PastLastNode(); |
- for (Node* node = FirstNode(); node != stop_node; |
- node = NodeTraversal::Next(*node)) { |
- LayoutObject* r = node->GetLayoutObject(); |
- if (!r || !r->IsText()) |
- continue; |
- LayoutText* layout_text = ToLayoutText(r); |
- unsigned start_offset = node == start_container ? start_.Offset() : 0; |
- unsigned end_offset = node == end_container |
- ? end_.Offset() |
- : std::numeric_limits<unsigned>::max(); |
- layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, |
- use_selection_height); |
Xiaocheng
2017/05/02 21:15:03
Could you first remove |use_selection_height| from
|
- } |
+ const Vector<FloatQuad>& result = computeTextQuads(EphemeralRange(this)); |
+ quads.insert(quads.size(), result); |
} |
bool AreRangesEqual(const Range* a, const Range* b) { |