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

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

Issue 2827603006: Move ComputeTextRects before Range::BoundingBox() (Closed)
Patch Set: Review Comments Fixed 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 | « no previous file | 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 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 unsigned start_offset = 1469 unsigned start_offset =
1470 node == start_container ? start_position.OffsetInContainerNode() : 0; 1470 node == start_container ? start_position.OffsetInContainerNode() : 0;
1471 unsigned end_offset = node == end_container 1471 unsigned end_offset = node == end_container
1472 ? end_position.OffsetInContainerNode() 1472 ? end_position.OffsetInContainerNode()
1473 : std::numeric_limits<unsigned>::max(); 1473 : std::numeric_limits<unsigned>::max();
1474 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset); 1474 layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset);
1475 } 1475 }
1476 return rects; 1476 return rects;
1477 } 1477 }
1478 1478
1479 // TODO(tanvir.rizvi): We should move this implementation to VisibleUnits and
1480 // then this function will be removed.
1481 static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange&, bool);
1482
1479 void Range::TextQuads(Vector<FloatQuad>& quads, 1483 void Range::TextQuads(Vector<FloatQuad>& quads,
1480 bool use_selection_height) const { 1484 bool use_selection_height) const {
1481 Node* start_container = &start_.Container(); 1485 quads = ComputeTextQuads(EphemeralRange(this), use_selection_height);
Xiaocheng 2017/04/19 07:54:56 Could you verify if this is copy assignment or mov
tanvir 2017/04/19 14:05:59 As discussed in https://codereview.chromium.org/27
1486 }
1487
1488 static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range,
Xiaocheng 2017/04/19 07:54:56 Do we want to templatize this function for flat tr
tanvir 2017/04/19 14:05:59 Yes , i will template the function in the further
1489 bool use_selection_height) {
1490 const Position& start_position = range.StartPosition();
1491 const Position& end_position = range.EndPosition();
1492 Node* start_container = start_position.ComputeContainerNode();
1482 DCHECK(start_container); 1493 DCHECK(start_container);
1483 Node* end_container = &end_.Container(); 1494 Node* end_container = end_position.ComputeContainerNode();
1484 DCHECK(end_container); 1495 DCHECK(end_container);
1485 1496
1486 Node* stop_node = PastLastNode(); 1497 Vector<FloatQuad> quads;
1487 for (Node* node = FirstNode(); node != stop_node; 1498 for (Node& node : range.Nodes()) {
1488 node = NodeTraversal::Next(*node)) { 1499 LayoutObject* const layout_object = node.GetLayoutObject();
1489 LayoutObject* r = node->GetLayoutObject(); 1500 if (!layout_object || !layout_object->IsText())
1490 if (!r || !r->IsText())
1491 continue; 1501 continue;
1492 LayoutText* layout_text = ToLayoutText(r); 1502 LayoutText* layout_text = ToLayoutText(layout_object);
1493 unsigned start_offset = node == start_container ? start_.Offset() : 0; 1503 unsigned start_offset =
1504 node == start_container ? start_position.OffsetInContainerNode() : 0;
Xiaocheng 2017/04/19 07:54:56 |OffsetInContainerNode()| only works for OffsetInA
tanvir 2017/04/19 14:05:59 Followed Approach 1. Thanks for explanation.
1494 unsigned end_offset = node == end_container 1505 unsigned end_offset = node == end_container
1495 ? end_.Offset() 1506 ? end_position.OffsetInContainerNode()
1496 : std::numeric_limits<unsigned>::max(); 1507 : std::numeric_limits<unsigned>::max();
1497 layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, 1508 layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset);
Xiaocheng 2017/04/19 07:54:56 |use_selection_height| shouldn't be dropped. It'
tanvir 2017/04/19 14:05:59 Done.
1498 use_selection_height);
1499 } 1509 }
1510 return quads;
1500 } 1511 }
1501 1512
1502 bool AreRangesEqual(const Range* a, const Range* b) { 1513 bool AreRangesEqual(const Range* a, const Range* b) {
1503 if (a == b) 1514 if (a == b)
1504 return true; 1515 return true;
1505 if (!a || !b) 1516 if (!a || !b)
1506 return false; 1517 return false;
1507 return a->StartPosition() == b->StartPosition() && 1518 return a->StartPosition() == b->StartPosition() &&
1508 a->EndPosition() == b->EndPosition(); 1519 a->EndPosition() == b->EndPosition();
1509 } 1520 }
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 .Data() 1834 .Data()
1824 << "start offset: " << range->startOffset() 1835 << "start offset: " << range->startOffset()
1825 << ", end offset: " << range->endOffset(); 1836 << ", end offset: " << range->endOffset();
1826 } else { 1837 } else {
1827 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " 1838 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are "
1828 "invalid."; 1839 "invalid.";
1829 } 1840 }
1830 } 1841 }
1831 1842
1832 #endif 1843 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698