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 return computeBoundingBox(EphemeralRange(this)); | |
1447 } | |
1448 | |
1449 template <typename Strategy> | |
1450 static Vector<IntRect> computeTextRects( | |
1451 const EphemeralRangeTemplate<Strategy>& range) { | |
1452 const PositionTemplate<Strategy> startPosition = range.startPosition(); | |
1453 const PositionTemplate<Strategy> endPosition = range.endPosition(); | |
1454 Node* startContainer = startPosition.computeContainerNode(); | |
1455 DCHECK(startContainer); | |
1456 Node* endContainer = endPosition.computeContainerNode(); | |
1457 DCHECK(endContainer); | |
1458 Vector<IntRect> rects; | |
1459 for (Node& node : range.nodes()) { | |
1460 LayoutObject* layoutObject = node.layoutObject(); | |
1461 if (!layoutObject || !layoutObject->isText()) | |
1462 continue; | |
1463 LayoutText* layoutText = toLayoutText(layoutObject); | |
1464 unsigned startOffset = | |
1465 node == startContainer ? startPosition.offsetInContainerNode() : 0; | |
1466 unsigned endOffset = node == endContainer | |
1467 ? endPosition.offsetInContainerNode() | |
1468 : std::numeric_limits<unsigned>::max(); | |
1469 layoutText->absoluteRectsForRange(rects, startOffset, endOffset); | |
1470 } | |
1471 return rects; | |
yosin_UTC9
2017/04/04 01:20:39
nit: s/rects/std::move(rects)/
This is subject to
Hwanseung Lee
2017/04/05 15:21:30
Done.
| |
1472 } | |
1473 | |
1474 IntRect Range::computeBoundingBox(const EphemeralRange& range) const { | |
yosin_UTC9
2017/04/04 01:20:39
We don't need to make |computeBoundingBox()| as me
Hwanseung Lee
2017/04/05 15:21:30
Done.
| |
1446 IntRect result; | 1475 IntRect result; |
1447 Vector<IntRect> rects; | 1476 for (const IntRect& rect : computeTextRects(range)) |
1448 textRects(rects); | |
1449 for (const IntRect& rect : rects) | |
1450 result.unite(rect); | 1477 result.unite(rect); |
1451 return result; | 1478 return result; |
1452 } | 1479 } |
1453 | 1480 |
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 } | |
1475 | |
1476 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { | 1481 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { |
1477 Node* startContainer = m_start.container(); | 1482 Node* startContainer = m_start.container(); |
1478 DCHECK(startContainer); | 1483 DCHECK(startContainer); |
1479 Node* endContainer = m_end.container(); | 1484 Node* endContainer = m_end.container(); |
1480 DCHECK(endContainer); | 1485 DCHECK(endContainer); |
1481 | 1486 |
1482 Node* stopNode = pastLastNode(); | 1487 Node* stopNode = pastLastNode(); |
1483 for (Node* node = firstNode(); node != stopNode; | 1488 for (Node* node = firstNode(); node != stopNode; |
1484 node = NodeTraversal::next(*node)) { | 1489 node = NodeTraversal::next(*node)) { |
1485 LayoutObject* r = node->layoutObject(); | 1490 LayoutObject* r = node->layoutObject(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1812 .data() | 1817 .data() |
1813 << "start offset: " << range->startOffset() | 1818 << "start offset: " << range->startOffset() |
1814 << ", end offset: " << range->endOffset(); | 1819 << ", end offset: " << range->endOffset(); |
1815 } else { | 1820 } else { |
1816 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1821 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
1817 "invalid."; | 1822 "invalid."; |
1818 } | 1823 } |
1819 } | 1824 } |
1820 | 1825 |
1821 #endif | 1826 #endif |
OLD | NEW |