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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1442 | 1442 |
1443 Node* Range::pastLastNode() const { | 1443 Node* Range::pastLastNode() const { |
1444 if (m_end.container()->isCharacterDataNode()) | 1444 if (m_end.container()->isCharacterDataNode()) |
1445 return NodeTraversal::nextSkippingChildren(*m_end.container()); | 1445 return NodeTraversal::nextSkippingChildren(*m_end.container()); |
1446 if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset())) | 1446 if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset())) |
1447 return child; | 1447 return child; |
1448 return NodeTraversal::nextSkippingChildren(*m_end.container()); | 1448 return NodeTraversal::nextSkippingChildren(*m_end.container()); |
1449 } | 1449 } |
1450 | 1450 |
1451 IntRect Range::boundingBox() const { | 1451 IntRect Range::boundingBox() const { |
1452 return computeBoundingBox(EphemeralRange(this)); | |
1453 } | |
1454 | |
1455 template <typename Strategy> | |
yosin_UTC9
2017/04/07 04:48:10
We don't need to use |template <Strategy>|, |compu
Hwanseung Lee
2017/04/07 17:55:53
Done.
| |
1456 static Vector<IntRect> computeTextRects( | |
yosin_UTC9
2017/04/07 04:48:10
It is OK to adding forward declaration before |Ran
Hwanseung Lee
2017/04/07 17:55:53
Done.
| |
1457 const EphemeralRangeTemplate<Strategy>& range) { | |
yosin_UTC9
2017/04/07 04:48:10
nit: const EphemeralRange&
Hwanseung Lee
2017/04/07 17:55:53
Done.
| |
1458 const PositionTemplate<Strategy> startPosition = range.startPosition(); | |
yosin_UTC9
2017/04/07 04:48:10
nit const Position&
Hwanseung Lee
2017/04/07 17:55:53
Done.
| |
1459 const PositionTemplate<Strategy> endPosition = range.endPosition(); | |
1460 Node* startContainer = startPosition.computeContainerNode(); | |
1461 DCHECK(startContainer); | |
1462 Node* endContainer = endPosition.computeContainerNode(); | |
1463 DCHECK(endContainer); | |
1464 Vector<IntRect> rects; | |
1465 for (Node& node : range.nodes()) { | |
1466 LayoutObject* layoutObject = node.layoutObject(); | |
1467 if (!layoutObject || !layoutObject->isText()) | |
1468 continue; | |
1469 LayoutText* layoutText = toLayoutText(layoutObject); | |
1470 unsigned startOffset = | |
1471 node == startContainer ? startPosition.offsetInContainerNode() : 0; | |
1472 unsigned endOffset = node == endContainer | |
1473 ? endPosition.offsetInContainerNode() | |
1474 : std::numeric_limits<unsigned>::max(); | |
1475 layoutText->absoluteRectsForRange(rects, startOffset, endOffset); | |
1476 } | |
1477 return rects; | |
1478 } | |
1479 | |
1480 IntRect Range::computeBoundingBox(const EphemeralRange& range) const { | |
1452 IntRect result; | 1481 IntRect result; |
1453 Vector<IntRect> rects; | 1482 for (const IntRect& rect : computeTextRects(range)) |
yosin_UTC9
2017/04/07 04:48:10
Just change these two lines:
const Vector<IntRect
| |
1454 textRects(rects); | |
1455 for (const IntRect& rect : rects) | |
1456 result.unite(rect); | 1483 result.unite(rect); |
1457 return result; | 1484 return result; |
1458 } | 1485 } |
1459 | 1486 |
1460 void Range::textRects(Vector<IntRect>& rects, bool useSelectionHeight) const { | |
1461 Node* startContainer = m_start.container(); | |
1462 DCHECK(startContainer); | |
1463 Node* endContainer = m_end.container(); | |
1464 DCHECK(endContainer); | |
1465 | |
1466 Node* stopNode = pastLastNode(); | |
1467 for (Node* node = firstNode(); node != stopNode; | |
1468 node = NodeTraversal::next(*node)) { | |
1469 LayoutObject* r = node->layoutObject(); | |
1470 if (!r || !r->isText()) | |
1471 continue; | |
1472 LayoutText* layoutText = toLayoutText(r); | |
1473 unsigned startOffset = node == startContainer ? m_start.offset() : 0; | |
1474 unsigned endOffset = node == endContainer | |
1475 ? m_end.offset() | |
1476 : std::numeric_limits<unsigned>::max(); | |
1477 layoutText->absoluteRectsForRange(rects, startOffset, endOffset, | |
1478 useSelectionHeight); | |
1479 } | |
1480 } | |
1481 | |
1482 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { | 1487 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight) const { |
1483 Node* startContainer = m_start.container(); | 1488 Node* startContainer = m_start.container(); |
1484 DCHECK(startContainer); | 1489 DCHECK(startContainer); |
1485 Node* endContainer = m_end.container(); | 1490 Node* endContainer = m_end.container(); |
1486 DCHECK(endContainer); | 1491 DCHECK(endContainer); |
1487 | 1492 |
1488 Node* stopNode = pastLastNode(); | 1493 Node* stopNode = pastLastNode(); |
1489 for (Node* node = firstNode(); node != stopNode; | 1494 for (Node* node = firstNode(); node != stopNode; |
1490 node = NodeTraversal::next(*node)) { | 1495 node = NodeTraversal::next(*node)) { |
1491 LayoutObject* r = node->layoutObject(); | 1496 LayoutObject* r = node->layoutObject(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 .data() | 1823 .data() |
1819 << "start offset: " << range->startOffset() | 1824 << "start offset: " << range->startOffset() |
1820 << ", end offset: " << range->endOffset(); | 1825 << ", end offset: " << range->endOffset(); |
1821 } else { | 1826 } else { |
1822 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1827 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
1823 "invalid."; | 1828 "invalid."; |
1824 } | 1829 } |
1825 } | 1830 } |
1826 | 1831 |
1827 #endif | 1832 #endif |
OLD | NEW |