| 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 | 1436 |
| 1437 Node* Range::pastLastNode() const { | 1437 Node* Range::pastLastNode() const { |
| 1438 if (m_end.container()->isCharacterDataNode()) | 1438 if (m_end.container()->isCharacterDataNode()) |
| 1439 return NodeTraversal::nextSkippingChildren(*m_end.container()); | 1439 return NodeTraversal::nextSkippingChildren(*m_end.container()); |
| 1440 if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset())) | 1440 if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset())) |
| 1441 return child; | 1441 return child; |
| 1442 return NodeTraversal::nextSkippingChildren(*m_end.container()); | 1442 return NodeTraversal::nextSkippingChildren(*m_end.container()); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 IntRect Range::boundingBox() const { | 1445 IntRect Range::boundingBox() const { |
| 1446 IntRect result; | 1446 return computeBoundingBox(EphemeralRange(this)); |
| 1447 Vector<IntRect> rects; | |
| 1448 textRects(rects); | |
| 1449 for (const IntRect& rect : rects) | |
| 1450 result.unite(rect); | |
| 1451 return result; | |
| 1452 } | |
| 1453 | |
| 1454 void Range::textRects(Vector<IntRect>& rects, bool useSelectionHeight) const { | |
| 1455 Node* startContainer = m_start.container(); | |
| 1456 DCHECK(startContainer); | |
| 1457 Node* endContainer = m_end.container(); | |
| 1458 DCHECK(endContainer); | |
| 1459 | |
| 1460 Node* stopNode = pastLastNode(); | |
| 1461 for (Node* node = firstNode(); node != stopNode; | |
| 1462 node = NodeTraversal::next(*node)) { | |
| 1463 LayoutObject* r = node->layoutObject(); | |
| 1464 if (!r || !r->isText()) | |
| 1465 continue; | |
| 1466 LayoutText* layoutText = toLayoutText(r); | |
| 1467 unsigned startOffset = node == startContainer ? m_start.offset() : 0; | |
| 1468 unsigned endOffset = node == endContainer | |
| 1469 ? m_end.offset() | |
| 1470 : std::numeric_limits<unsigned>::max(); | |
| 1471 layoutText->absoluteRectsForRange(rects, startOffset, endOffset, | |
| 1472 useSelectionHeight); | |
| 1473 } | |
| 1474 } | 1447 } |
| 1475 | 1448 |
| 1476 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { | 1449 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { |
| 1477 Node* startContainer = m_start.container(); | 1450 Node* startContainer = m_start.container(); |
| 1478 DCHECK(startContainer); | 1451 DCHECK(startContainer); |
| 1479 Node* endContainer = m_end.container(); | 1452 Node* endContainer = m_end.container(); |
| 1480 DCHECK(endContainer); | 1453 DCHECK(endContainer); |
| 1481 | 1454 |
| 1482 Node* stopNode = pastLastNode(); | 1455 Node* stopNode = pastLastNode(); |
| 1483 for (Node* node = firstNode(); node != stopNode; | 1456 for (Node* node = firstNode(); node != stopNode; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 .data() | 1785 .data() |
| 1813 << "start offset: " << range->startOffset() | 1786 << "start offset: " << range->startOffset() |
| 1814 << ", end offset: " << range->endOffset(); | 1787 << ", end offset: " << range->endOffset(); |
| 1815 } else { | 1788 } else { |
| 1816 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1789 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1817 "invalid."; | 1790 "invalid."; |
| 1818 } | 1791 } |
| 1819 } | 1792 } |
| 1820 | 1793 |
| 1821 #endif | 1794 #endif |
| OLD | NEW |