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 Vector<FloatQuad> ComputeTextQuads(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 quads = ComputeTextQuads(EphemeralRange(this), use_selection_height); |
1486 } | |
1487 | |
1488 static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range, | |
1489 bool use_selection_height) { | |
1490 const Position& start_position = range.StartPosition(); | |
1491 const Position& end_position = range.EndPosition(); | |
1492 Node* start_container = start_position.ComputeContainerNode(); | |
1482 DCHECK(start_container); | 1493 DCHECK(start_container); |
1483 Node* end_container = &end_.Container(); | 1494 Node* end_container = end_position.ComputeContainerNode(); |
1484 DCHECK(end_container); | 1495 DCHECK(end_container); |
1485 | 1496 |
1486 Node* stop_node = PastLastNode(); | 1497 Vector<FloatQuad> quads; |
1487 for (Node* node = FirstNode(); node != stop_node; | 1498 for (Node& node : range.Nodes()) { |
1488 node = NodeTraversal::Next(*node)) { | 1499 LayoutObject* const layoutObject = node.GetLayoutObject(); |
1489 LayoutObject* r = node->GetLayoutObject(); | 1500 if (!layoutObject || !layoutObject->IsText()) |
1490 if (!r || !r->IsText()) | |
1491 continue; | 1501 continue; |
1492 LayoutText* layout_text = ToLayoutText(r); | 1502 LayoutText* layoutText = ToLayoutText(layoutObject); |
Srirama
2017/04/19 06:43:41
Align with new coding guidelines.
s/layoutText/lay
tanvir
2017/04/19 07:23:09
Done.
| |
1493 unsigned start_offset = node == start_container ? start_.Offset() : 0; | 1503 unsigned startOffset = |
Srirama
2017/04/19 06:43:41
s/startOffset/start_offset and everywhere else
tanvir
2017/04/19 07:23:09
Done.
| |
1494 unsigned end_offset = node == end_container | 1504 node == start_container ? start_position.OffsetInContainerNode() : 0; |
1495 ? end_.Offset() | 1505 unsigned endOffset = node == end_container |
1496 : std::numeric_limits<unsigned>::max(); | 1506 ? end_position.OffsetInContainerNode() |
1497 layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, | 1507 : std::numeric_limits<unsigned>::max(); |
1498 use_selection_height); | 1508 layoutText->AbsoluteQuadsForRange(quads, startOffset, endOffset); |
1499 } | 1509 } |
1510 return quads; | |
1500 } | 1511 } |
1501 | 1512 |
1502 bool AreRangesEqual(const Range* a, const Range* b) { | 1513 bool AreRangesEqual(const Range* a, const Range* b) { |
1503 if (a == b) | 1514 if (a == b) |
1504 return true; | 1515 return true; |
1505 if (!a || !b) | 1516 if (!a || !b) |
1506 return false; | 1517 return false; |
1507 return a->StartPosition() == b->StartPosition() && | 1518 return a->StartPosition() == b->StartPosition() && |
1508 a->EndPosition() == b->EndPosition(); | 1519 a->EndPosition() == b->EndPosition(); |
1509 } | 1520 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1823 .Data() | 1834 .Data() |
1824 << "start offset: " << range->startOffset() | 1835 << "start offset: " << range->startOffset() |
1825 << ", end offset: " << range->endOffset(); | 1836 << ", end offset: " << range->endOffset(); |
1826 } else { | 1837 } else { |
1827 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 " |
1828 "invalid."; | 1839 "invalid."; |
1829 } | 1840 } |
1830 } | 1841 } |
1831 | 1842 |
1832 #endif | 1843 #endif |
OLD | NEW |