Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2810313003: In-place change of Range::testRects() and boundingBox() to EphemeralRange. (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 } 1433 }
1434 1434
1435 Node* Range::FirstNode() const { 1435 Node* Range::FirstNode() const {
1436 return StartPosition().NodeAsRangeFirstNode(); 1436 return StartPosition().NodeAsRangeFirstNode();
1437 } 1437 }
1438 1438
1439 Node* Range::PastLastNode() const { 1439 Node* Range::PastLastNode() const {
1440 return EndPosition().NodeAsRangePastLastNode(); 1440 return EndPosition().NodeAsRangePastLastNode();
1441 } 1441 }
1442 1442
1443 // TODO(hs1217.lee):: we should move this implement to VisibleUnits and then
1444 // this function will remove.
1445 static Vector<IntRect> computeTextRects(const EphemeralRange&);
1446
1443 IntRect Range::BoundingBox() const { 1447 IntRect Range::BoundingBox() const {
1444 IntRect result; 1448 IntRect result;
1445 Vector<IntRect> rects; 1449 const Vector<IntRect>& rects = computeTextRects(EphemeralRange(this));
1446 TextRects(rects);
1447 for (const IntRect& rect : rects) 1450 for (const IntRect& rect : rects)
1448 result.Unite(rect); 1451 result.Unite(rect);
1449 return result; 1452 return result;
1450 } 1453 }
1451 1454
1452 void Range::TextRects(Vector<IntRect>& rects, bool use_selection_height) const { 1455 static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
1453 Node* start_container = &start_.Container(); 1456 const Position& start_position = range.StartPosition();
1457 const Position& end_position = range.EndPosition();
1458 Node* const start_container = start_position.ComputeContainerNode();
1454 DCHECK(start_container); 1459 DCHECK(start_container);
1455 Node* end_container = &end_.Container(); 1460 Node* const end_container = end_position.ComputeContainerNode();
1456 DCHECK(end_container); 1461 DCHECK(end_container);
1457 1462
1458 Node* stop_node = PastLastNode(); 1463 Vector<IntRect> rects;
1459 for (Node* node = FirstNode(); node != stop_node; 1464 for (const Node& node : range.Nodes()) {
1460 node = NodeTraversal::Next(*node)) { 1465 LayoutObject* const layoutObject = node.GetLayoutObject();
1461 LayoutObject* r = node->GetLayoutObject(); 1466 if (!layoutObject || !layoutObject->IsText())
1462 if (!r || !r->IsText())
1463 continue; 1467 continue;
1464 LayoutText* layout_text = ToLayoutText(r); 1468 LayoutText* layout_text = ToLayoutText(layoutObject);
1465 unsigned start_offset = node == start_container ? start_.Offset() : 0; 1469 unsigned start_offset =
1470 node == start_container ? start_position.OffsetInContainerNode() : 0;
1466 unsigned end_offset = node == end_container 1471 unsigned end_offset = node == end_container
1467 ? end_.Offset() 1472 ? end_position.OffsetInContainerNode()
1468 : std::numeric_limits<unsigned>::max(); 1473 : std::numeric_limits<unsigned>::max();
1469 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset, 1474 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset);
1470 use_selection_height);
1471 } 1475 }
1476 return rects;
1472 } 1477 }
1473 1478
1474 void Range::TextQuads(Vector<FloatQuad>& quads, 1479 void Range::TextQuads(Vector<FloatQuad>& quads,
1475 bool use_selection_height) const { 1480 bool use_selection_height) const {
1476 Node* start_container = &start_.Container(); 1481 Node* start_container = &start_.Container();
1477 DCHECK(start_container); 1482 DCHECK(start_container);
1478 Node* end_container = &end_.Container(); 1483 Node* end_container = &end_.Container();
1479 DCHECK(end_container); 1484 DCHECK(end_container);
1480 1485
1481 Node* stop_node = PastLastNode(); 1486 Node* stop_node = PastLastNode();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698