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 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 Node* Range::FirstNode() const { | 1435 Node* Range::FirstNode() const { |
| 1436 return StartPosition().NodeAsRangeFirstNode(); | 1436 return StartPosition().NodeAsRangeFirstNode(); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 Node* Range::PastLastNode() const { | 1439 Node* Range::PastLastNode() const { |
| 1440 return EndPosition().NodeAsRangePastLastNode(); | 1440 return EndPosition().NodeAsRangePastLastNode(); |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 static Vector<IntRect> computeTextRects(const EphemeralRange& range) { | 1443 static void CollectAbsoluteBoundsForRange(Vector<IntRect>& rects, |
| 1444 unsigned start, | |
| 1445 unsigned end, | |
| 1446 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.
| |
| 1447 layout_text->AbsoluteRectsForRange(rects, start, end); | |
| 1448 } | |
| 1449 | |
| 1450 template <typename ElementType> | |
| 1451 static Vector<ElementType> ComputeTextBounds(const EphemeralRange& range) { | |
| 1444 const Position& start_position = range.StartPosition(); | 1452 const Position& start_position = range.StartPosition(); |
| 1445 const Position& end_position = range.EndPosition(); | 1453 const Position& end_position = range.EndPosition(); |
| 1446 Node* const start_container = start_position.ComputeContainerNode(); | 1454 Node* const start_container = start_position.ComputeContainerNode(); |
| 1447 DCHECK(start_container); | 1455 DCHECK(start_container); |
| 1448 Node* const end_container = end_position.ComputeContainerNode(); | 1456 Node* const end_container = end_position.ComputeContainerNode(); |
| 1449 DCHECK(end_container); | 1457 DCHECK(end_container); |
| 1450 | 1458 |
| 1451 Vector<IntRect> rects; | 1459 Vector<ElementType> result; |
| 1452 for (const Node& node : range.Nodes()) { | 1460 for (const Node& node : range.Nodes()) { |
| 1453 LayoutObject* const layoutObject = node.GetLayoutObject(); | 1461 LayoutObject* const layoutObject = node.GetLayoutObject(); |
| 1454 if (!layoutObject || !layoutObject->IsText()) | 1462 if (!layoutObject || !layoutObject->IsText()) |
| 1455 continue; | 1463 continue; |
| 1456 LayoutText* layout_text = ToLayoutText(layoutObject); | 1464 LayoutText* layout_text = ToLayoutText(layoutObject); |
| 1457 unsigned start_offset = | 1465 unsigned start_offset = |
| 1458 node == start_container ? start_position.OffsetInContainerNode() : 0; | 1466 node == start_container ? start_position.OffsetInContainerNode() : 0; |
| 1459 unsigned end_offset = node == end_container | 1467 unsigned end_offset = node == end_container |
| 1460 ? end_position.OffsetInContainerNode() | 1468 ? end_position.OffsetInContainerNode() |
| 1461 : std::numeric_limits<unsigned>::max(); | 1469 : std::numeric_limits<unsigned>::max(); |
| 1462 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); | 1470 CollectAbsoluteBoundsForRange(result, start_offset, end_offset, |
| 1471 layout_text); | |
| 1463 } | 1472 } |
| 1464 return rects; | 1473 return result; |
| 1474 } | |
| 1475 | |
| 1476 static Vector<IntRect> computeTextRects(const EphemeralRange& range) { | |
| 1477 return ComputeTextBounds<IntRect>(range); | |
| 1465 } | 1478 } |
| 1466 | 1479 |
| 1467 IntRect Range::BoundingBox() const { | 1480 IntRect Range::BoundingBox() const { |
| 1468 IntRect result; | 1481 IntRect result; |
| 1469 const Vector<IntRect>& rects = computeTextRects(EphemeralRange(this)); | 1482 const Vector<IntRect>& rects = computeTextRects(EphemeralRange(this)); |
| 1470 for (const IntRect& rect : rects) | 1483 for (const IntRect& rect : rects) |
| 1471 result.Unite(rect); | 1484 result.Unite(rect); |
| 1472 return result; | 1485 return result; |
| 1473 } | 1486 } |
| 1474 | 1487 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1821 .data() | 1834 .data() |
| 1822 << "start offset: " << range->startOffset() | 1835 << "start offset: " << range->startOffset() |
| 1823 << ", end offset: " << range->endOffset(); | 1836 << ", end offset: " << range->endOffset(); |
| 1824 } else { | 1837 } else { |
| 1825 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1838 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1826 "invalid."; | 1839 "invalid."; |
| 1827 } | 1840 } |
| 1828 } | 1841 } |
| 1829 | 1842 |
| 1830 #endif | 1843 #endif |
| OLD | NEW |