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

Unified Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2810313003: In-place change of Range::testRects() and boundingBox() to EphemeralRange. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Range.cpp
diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
index deae19228de4b177d043485e624d0bb0a9d22e8b..d02d84ee46a30c05e3fed5964895212a87127f6f 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -1450,35 +1450,40 @@ Node* Range::PastLastNode() const {
return NodeTraversal::NextSkippingChildren(end_.Container());
}
+// TODO(hs1217.lee):: we should move this implement to VisibleUnits and then
+// this function will remove.
+static Vector<IntRect> computeTextRects(const EphemeralRange&);
+
IntRect Range::BoundingBox() const {
IntRect result;
- Vector<IntRect> rects;
- TextRects(rects);
+ 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.
for (const IntRect& rect : rects)
result.Unite(rect);
return result;
}
-void Range::TextRects(Vector<IntRect>& rects, bool use_selection_height) const {
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.
- Node* start_container = &start_.Container();
+static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
+ const Position& start_position = range.StartPosition();
+ const Position& end_position = range.EndPosition();
+ 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.
DCHECK(start_container);
- Node* end_container = &end_.Container();
+ 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.
DCHECK(end_container);
- Node* stop_node = PastLastNode();
- for (Node* node = FirstNode(); node != stop_node;
- node = NodeTraversal::Next(*node)) {
- LayoutObject* r = node->GetLayoutObject();
- if (!r || !r->IsText())
+ Vector<IntRect> rects;
+ 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.
+ 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.
+ if (!layoutObject || !layoutObject->IsText())
continue;
- LayoutText* layout_text = ToLayoutText(r);
- unsigned start_offset = node == start_container ? start_.Offset() : 0;
+ LayoutText* layout_text = ToLayoutText(layoutObject);
+ unsigned start_offset =
+ node == start_container ? start_position.OffsetInContainerNode() : 0;
unsigned end_offset = node == end_container
- ? end_.Offset()
+ ? end_position.OffsetInContainerNode()
: std::numeric_limits<unsigned>::max();
- layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset,
- use_selection_height);
+ layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset);
yosin_UTC9 2017/04/14 01:08:51 Note: |LayoutText::AbsoulteRectsForRange()| takes
}
+ return rects;
}
void Range::TextQuads(Vector<FloatQuad>& quads,
« 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