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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1443 } | 1443 } |
1444 | 1444 |
1445 Node* Range::PastLastNode() const { | 1445 Node* Range::PastLastNode() const { |
1446 if (end_.Container().IsCharacterDataNode()) | 1446 if (end_.Container().IsCharacterDataNode()) |
1447 return NodeTraversal::NextSkippingChildren(end_.Container()); | 1447 return NodeTraversal::NextSkippingChildren(end_.Container()); |
1448 if (Node* child = NodeTraversal::ChildAt(end_.Container(), end_.Offset())) | 1448 if (Node* child = NodeTraversal::ChildAt(end_.Container(), end_.Offset())) |
1449 return child; | 1449 return child; |
1450 return NodeTraversal::NextSkippingChildren(end_.Container()); | 1450 return NodeTraversal::NextSkippingChildren(end_.Container()); |
1451 } | 1451 } |
1452 | 1452 |
1453 // TODO(hs1217.lee):: we should move this implement to VisibleUnits and then | |
1454 // this function will remove. | |
1455 static Vector<IntRect> computeTextRects(const EphemeralRange&); | |
1456 | |
1453 IntRect Range::BoundingBox() const { | 1457 IntRect Range::BoundingBox() const { |
1454 IntRect result; | 1458 IntRect result; |
1455 Vector<IntRect> rects; | 1459 const Vector<IntRect> rects = computeTextRects(EphemeralRange(this)); |
yosin_UTC9
2017/04/14 01:08:50
nit: s/Vector<IntRect>/Vector<IntRect>&/
Hwanseung Lee
2017/04/15 02:54:33
Done.
| |
1456 TextRects(rects); | |
1457 for (const IntRect& rect : rects) | 1460 for (const IntRect& rect : rects) |
1458 result.Unite(rect); | 1461 result.Unite(rect); |
1459 return result; | 1462 return result; |
1460 } | 1463 } |
1461 | 1464 |
1462 void Range::TextRects(Vector<IntRect>& rects, bool use_selection_height) const { | 1465 static Vector<IntRect> computeTextRects(const EphemeralRange& range) { |
yosin_UTC9
2017/04/14 01:08:51
Note: |use_selection_height| is default to false a
Hwanseung Lee
2017/04/15 02:54:33
right. this line was removed.
| |
1463 Node* start_container = &start_.Container(); | 1466 const Position& start_position = range.StartPosition(); |
1467 const Position& end_position = range.EndPosition(); | |
1468 Node* start_container = start_position.ComputeContainerNode(); | |
yosin_UTC9
2017/04/14 01:08:51
nit: s/Node*/Node* const/
Hwanseung Lee
2017/04/15 02:54:33
Done.
| |
1464 DCHECK(start_container); | 1469 DCHECK(start_container); |
1465 Node* end_container = &end_.Container(); | 1470 Node* end_container = end_position.ComputeContainerNode(); |
yosin_UTC9
2017/04/14 01:08:51
nit: s/Node*/Node* const/
Hwanseung Lee
2017/04/15 02:54:33
Done.
| |
1466 DCHECK(end_container); | 1471 DCHECK(end_container); |
1467 | 1472 |
1468 Node* stop_node = PastLastNode(); | 1473 Vector<IntRect> rects; |
1469 for (Node* node = FirstNode(); node != stop_node; | 1474 for (Node& node : range.Nodes()) { |
yosin_UTC9
2017/04/14 01:08:51
nit: s/Node&/const Node&/
It is nice to use range
Hwanseung Lee
2017/04/15 02:54:33
Done.
| |
1470 node = NodeTraversal::Next(*node)) { | 1475 LayoutObject* layoutObject = node.GetLayoutObject(); |
yosin_UTC9
2017/04/14 01:08:51
nit: s/LayoutObject*/LayoutObject* const/
Hwanseung Lee
2017/04/15 02:54:33
Done.
| |
1471 LayoutObject* r = node->GetLayoutObject(); | 1476 if (!layoutObject || !layoutObject->IsText()) |
1472 if (!r || !r->IsText()) | |
1473 continue; | 1477 continue; |
1474 LayoutText* layout_text = ToLayoutText(r); | 1478 LayoutText* layout_text = ToLayoutText(layoutObject); |
1475 unsigned start_offset = node == start_container ? start_.Offset() : 0; | 1479 unsigned start_offset = |
1480 node == start_container ? start_position.OffsetInContainerNode() : 0; | |
1476 unsigned end_offset = node == end_container | 1481 unsigned end_offset = node == end_container |
1477 ? end_.Offset() | 1482 ? end_position.OffsetInContainerNode() |
1478 : std::numeric_limits<unsigned>::max(); | 1483 : std::numeric_limits<unsigned>::max(); |
1479 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset, | 1484 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); |
yosin_UTC9
2017/04/14 01:08:51
Note: |LayoutText::AbsoulteRectsForRange()| takes
| |
1480 use_selection_height); | |
1481 } | 1485 } |
1486 return rects; | |
1482 } | 1487 } |
1483 | 1488 |
1484 void Range::TextQuads(Vector<FloatQuad>& quads, | 1489 void Range::TextQuads(Vector<FloatQuad>& quads, |
1485 bool use_selection_height) const { | 1490 bool use_selection_height) const { |
1486 Node* start_container = &start_.Container(); | 1491 Node* start_container = &start_.Container(); |
1487 DCHECK(start_container); | 1492 DCHECK(start_container); |
1488 Node* end_container = &end_.Container(); | 1493 Node* end_container = &end_.Container(); |
1489 DCHECK(end_container); | 1494 DCHECK(end_container); |
1490 | 1495 |
1491 Node* stop_node = PastLastNode(); | 1496 Node* stop_node = PastLastNode(); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1828 .Data() | 1833 .Data() |
1829 << "start offset: " << range->startOffset() | 1834 << "start offset: " << range->startOffset() |
1830 << ", end offset: " << range->endOffset(); | 1835 << ", end offset: " << range->endOffset(); |
1831 } else { | 1836 } else { |
1832 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1837 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
1833 "invalid."; | 1838 "invalid."; |
1834 } | 1839 } |
1835 } | 1840 } |
1836 | 1841 |
1837 #endif | 1842 #endif |
OLD | NEW |