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

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

Issue 2827603006: Move ComputeTextRects before Range::BoundingBox() (Closed)
Patch Set: Review Changes done. 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 void ComputeTextQuads(Vector<FloatQuad>*, 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 ComputeTextQuads(&quads, EphemeralRange(this), use_selection_height);
1482 DCHECK(start_container); 1486 }
1483 Node* end_container = &end_.Container();
1484 DCHECK(end_container);
1485 1487
1486 Node* stop_node = PastLastNode(); 1488 static void ComputeTextQuads(Vector<FloatQuad>* quads,
1487 for (Node* node = FirstNode(); node != stop_node; 1489 const EphemeralRange& range,
1488 node = NodeTraversal::Next(*node)) { 1490 bool use_selection_height) {
1489 LayoutObject* r = node->GetLayoutObject(); 1491 // start_position and end_position are offsetInAnchor.
1490 if (!r || !r->IsText()) 1492 const Position& start_position = range.StartPosition();
1493 const Position& end_position = range.EndPosition();
1494 Node* start_container = start_position.ComputeContainerNode();
1495 DCHECK(start_position.IsOffsetInAnchor() || start_container);
Xiaocheng 2017/04/20 00:21:52 s/||/&&/
yosin_UTC9 2017/04/20 01:21:01 It is better to have two DCHECK() rather than one
tanvir 2017/04/20 05:39:17 I will create a patch to add DCHECK for computeTex
tanvir 2017/04/20 05:39:17 Done.
tanvir 2017/04/20 05:39:17 Done.
1496 Node* end_container = end_position.ComputeContainerNode();
1497 DCHECK(end_position.IsOffsetInAnchor() || end_container);
Xiaocheng 2017/04/20 00:21:52 s/||/&&/
yosin_UTC9 2017/04/20 01:21:01 It is better to have two DCHECK() rather than one
1498
1499 for (Node& node : range.Nodes()) {
1500 LayoutObject* const layout_object = node.GetLayoutObject();
1501 if (!layout_object || !layout_object->IsText())
1491 continue; 1502 continue;
1492 LayoutText* layout_text = ToLayoutText(r); 1503 LayoutText* layout_text = ToLayoutText(layout_object);
1493 unsigned start_offset = node == start_container ? start_.Offset() : 0; 1504 unsigned start_offset =
1505 node == start_container ? start_position.OffsetInContainerNode() : 0;
1494 unsigned end_offset = node == end_container 1506 unsigned end_offset = node == end_container
1495 ? end_.Offset() 1507 ? end_position.OffsetInContainerNode()
1496 : std::numeric_limits<unsigned>::max(); 1508 : std::numeric_limits<unsigned>::max();
1497 layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset, 1509 layout_text->AbsoluteQuadsForRange(*quads, start_offset, end_offset,
1498 use_selection_height); 1510 use_selection_height);
1499 } 1511 }
1500 } 1512 }
1501 1513
1502 bool AreRangesEqual(const Range* a, const Range* b) { 1514 bool AreRangesEqual(const Range* a, const Range* b) {
1503 if (a == b) 1515 if (a == b)
1504 return true; 1516 return true;
1505 if (!a || !b) 1517 if (!a || !b)
1506 return false; 1518 return false;
1507 return a->StartPosition() == b->StartPosition() && 1519 return a->StartPosition() == b->StartPosition() &&
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 .Data() 1835 .Data()
1824 << "start offset: " << range->startOffset() 1836 << "start offset: " << range->startOffset()
1825 << ", end offset: " << range->endOffset(); 1837 << ", end offset: " << range->endOffset();
1826 } else { 1838 } else {
1827 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " 1839 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are "
1828 "invalid."; 1840 "invalid.";
1829 } 1841 }
1830 } 1842 }
1831 1843
1832 #endif 1844 #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