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

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: 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 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 d30539bd95848065c192ed3f40ebd312057a3759..a34467ca556c983820440502773e6e3a72ab2688 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -1440,35 +1440,40 @@ Node* Range::PastLastNode() const {
return EndPosition().NodeAsRangePastLastNode();
}
+// 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));
for (const IntRect& rect : rects)
result.Unite(rect);
return result;
}
-void Range::TextRects(Vector<IntRect>& rects, bool use_selection_height) const {
- 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* const start_container = start_position.ComputeContainerNode();
DCHECK(start_container);
- Node* end_container = &end_.Container();
+ Node* const end_container = end_position.ComputeContainerNode();
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 (const Node& node : range.Nodes()) {
+ LayoutObject* const layoutObject = node.GetLayoutObject();
+ 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);
}
+ 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