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 a34467ca556c983820440502773e6e3a72ab2688..02dab3b7afe38b50bbcc8ffeb0818c43011bcc2e 100644 |
| --- a/third_party/WebKit/Source/core/dom/Range.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Range.cpp |
| @@ -1476,25 +1476,37 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
| return rects; |
| } |
| +// TODO(tanvir.rizvi): We should move this implementation to VisibleUnits and |
| +// then this function will be removed. |
| +static void ComputeTextQuads(Vector<FloatQuad>*, const EphemeralRange&, bool); |
| + |
| 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); |
| + ComputeTextQuads(&quads, EphemeralRange(this), use_selection_height); |
| +} |
| - Node* stop_node = PastLastNode(); |
| - for (Node* node = FirstNode(); node != stop_node; |
| - node = NodeTraversal::Next(*node)) { |
| - LayoutObject* r = node->GetLayoutObject(); |
| - if (!r || !r->IsText()) |
| +static void ComputeTextQuads(Vector<FloatQuad>* quads, |
| + const EphemeralRange& range, |
| + bool use_selection_height) { |
| + // start_position and end_position are offsetInAnchor. |
| + const Position& start_position = range.StartPosition(); |
| + const Position& end_position = range.EndPosition(); |
| + Node* start_container = start_position.ComputeContainerNode(); |
| + DCHECK(start_position.IsOffsetInAnchor() || start_container); |
|
Xiaocheng
2017/04/20 00:21:52
s/||/&&/
yosin_UTC9
2017/04/20 01:21:01
It is better to have two DCHECK() rather than one
tanvir
2017/04/20 05:39:17
I will create a patch to add DCHECK for computeTex
tanvir
2017/04/20 05:39:17
Done.
tanvir
2017/04/20 05:39:17
Done.
|
| + Node* end_container = end_position.ComputeContainerNode(); |
| + DCHECK(end_position.IsOffsetInAnchor() || end_container); |
|
Xiaocheng
2017/04/20 00:21:52
s/||/&&/
yosin_UTC9
2017/04/20 01:21:01
It is better to have two DCHECK() rather than one
|
| + |
| + for (Node& node : range.Nodes()) { |
| + LayoutObject* const layout_object = node.GetLayoutObject(); |
| + if (!layout_object || !layout_object->IsText()) |
| continue; |
| - LayoutText* layout_text = ToLayoutText(r); |
| - unsigned start_offset = node == start_container ? start_.Offset() : 0; |
| + LayoutText* layout_text = ToLayoutText(layout_object); |
| + unsigned start_offset = |
| + node == start_container ? start_position.OffsetInContainerNode() : 0; |
| unsigned end_offset = node == end_container |
| - ? end_.Offset() |
| + ? end_position.OffsetInContainerNode() |
| : std::numeric_limits<unsigned>::max(); |
| - layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, |
| + layout_text->AbsoluteQuadsForRange(*quads, start_offset, end_offset, |
| use_selection_height); |
| } |
| } |