Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1469 unsigned start_offset = | 1469 unsigned start_offset = |
| 1470 node == start_container ? start_position.OffsetInContainerNode() : 0; | 1470 node == start_container ? start_position.OffsetInContainerNode() : 0; |
| 1471 unsigned end_offset = node == end_container | 1471 unsigned end_offset = node == end_container |
| 1472 ? end_position.OffsetInContainerNode() | 1472 ? end_position.OffsetInContainerNode() |
| 1473 : std::numeric_limits<unsigned>::max(); | 1473 : std::numeric_limits<unsigned>::max(); |
| 1474 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); | 1474 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); |
| 1475 } | 1475 } |
| 1476 return rects; | 1476 return rects; |
| 1477 } | 1477 } |
| 1478 | 1478 |
| 1479 // TODO(tanvir.rizvi): We should move this implementation to VisibleUnits and | |
| 1480 // then this function will be removed. | |
| 1481 static void ComputeTextQuads(Vector<FloatQuad>*, const EphemeralRange&, bool); | |
| 1482 | |
| 1479 void Range::TextQuads(Vector<FloatQuad>& quads, | 1483 void Range::TextQuads(Vector<FloatQuad>& quads, |
| 1480 bool use_selection_height) const { | 1484 bool use_selection_height) const { |
| 1481 Node* start_container = &start_.Container(); | 1485 ComputeTextQuads(&quads, EphemeralRange(this), use_selection_height); |
| 1486 } | |
| 1487 | |
| 1488 static void ComputeTextQuads(Vector<FloatQuad>* quads, | |
|
yosin_UTC9
2017/04/20 06:59:54
Could you returnVector<FloatQuad> instead of void
| |
| 1489 const EphemeralRange& range, | |
| 1490 bool use_selection_height) { | |
| 1491 // start_position and end_position are offsetInAnchor. | |
| 1492 const Position& start_position = range.StartPosition(); | |
| 1493 DCHECK(start_position.IsOffsetInAnchor()); | |
| 1494 const Position& end_position = range.EndPosition(); | |
| 1495 DCHECK(end_position.IsOffsetInAnchor()); | |
| 1496 Node* start_container = start_position.ComputeContainerNode(); | |
| 1482 DCHECK(start_container); | 1497 DCHECK(start_container); |
| 1483 Node* end_container = &end_.Container(); | 1498 Node* end_container = end_position.ComputeContainerNode(); |
| 1484 DCHECK(end_container); | 1499 DCHECK(end_container); |
| 1485 | 1500 |
| 1486 Node* stop_node = PastLastNode(); | 1501 for (Node& node : range.Nodes()) { |
| 1487 for (Node* node = FirstNode(); node != stop_node; | 1502 LayoutObject* const layout_object = node.GetLayoutObject(); |
| 1488 node = NodeTraversal::Next(*node)) { | 1503 if (!layout_object || !layout_object->IsText()) |
| 1489 LayoutObject* r = node->GetLayoutObject(); | |
| 1490 if (!r || !r->IsText()) | |
| 1491 continue; | 1504 continue; |
| 1492 LayoutText* layout_text = ToLayoutText(r); | 1505 LayoutText* layout_text = ToLayoutText(layout_object); |
| 1493 unsigned start_offset = node == start_container ? start_.Offset() : 0; | 1506 unsigned start_offset = |
| 1507 node == start_container ? start_position.OffsetInContainerNode() : 0; | |
| 1494 unsigned end_offset = node == end_container | 1508 unsigned end_offset = node == end_container |
| 1495 ? end_.Offset() | 1509 ? end_position.OffsetInContainerNode() |
| 1496 : std::numeric_limits<unsigned>::max(); | 1510 : std::numeric_limits<unsigned>::max(); |
| 1497 layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, | 1511 layout_text->AbsoluteQuadsForRange(*quads, start_offset, end_offset, |
| 1498 use_selection_height); | 1512 use_selection_height); |
| 1499 } | 1513 } |
| 1500 } | 1514 } |
| 1501 | 1515 |
| 1502 bool AreRangesEqual(const Range* a, const Range* b) { | 1516 bool AreRangesEqual(const Range* a, const Range* b) { |
| 1503 if (a == b) | 1517 if (a == b) |
| 1504 return true; | 1518 return true; |
| 1505 if (!a || !b) | 1519 if (!a || !b) |
| 1506 return false; | 1520 return false; |
| 1507 return a->StartPosition() == b->StartPosition() && | 1521 return a->StartPosition() == b->StartPosition() && |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1823 .Data() | 1837 .Data() |
| 1824 << "start offset: " << range->startOffset() | 1838 << "start offset: " << range->startOffset() |
| 1825 << ", end offset: " << range->endOffset(); | 1839 << ", end offset: " << range->endOffset(); |
| 1826 } else { | 1840 } else { |
| 1827 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1841 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1828 "invalid."; | 1842 "invalid."; |
| 1829 } | 1843 } |
| 1830 } | 1844 } |
| 1831 | 1845 |
| 1832 #endif | 1846 #endif |
| OLD | NEW |