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

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

Issue 2827603006: Move ComputeTextRects before Range::BoundingBox() (Closed)
Patch Set: For Review 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 | « no previous file | 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 a34467ca556c983820440502773e6e3a72ab2688..4dcfe02d513f4a48267ff970a4950959be121fe8 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -1476,27 +1476,38 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
return rects;
}
+// TODO(tanvir.rizvi): We should move this implementation to VisibleUnits and
+// then this function will be removed.
+static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange&, bool);
+
void Range::TextQuads(Vector<FloatQuad>& quads,
bool use_selection_height) const {
- Node* start_container = &start_.Container();
+ quads = ComputeTextQuads(EphemeralRange(this), use_selection_height);
+}
+
+static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range,
+ bool use_selection_height) {
+ const Position& start_position = range.StartPosition();
+ const Position& end_position = range.EndPosition();
+ Node* start_container = start_position.ComputeContainerNode();
DCHECK(start_container);
- Node* end_container = &end_.Container();
+ Node* 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<FloatQuad> quads;
+ for (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;
- unsigned end_offset = node == end_container
- ? end_.Offset()
- : std::numeric_limits<unsigned>::max();
- layout_text->AbsoluteQuadsForRange(quads, start_offset, end_offset,
- use_selection_height);
+ LayoutText* layoutText = ToLayoutText(layoutObject);
Srirama 2017/04/19 06:43:41 Align with new coding guidelines. s/layoutText/lay
tanvir 2017/04/19 07:23:09 Done.
+ unsigned startOffset =
Srirama 2017/04/19 06:43:41 s/startOffset/start_offset and everywhere else
tanvir 2017/04/19 07:23:09 Done.
+ node == start_container ? start_position.OffsetInContainerNode() : 0;
+ unsigned endOffset = node == end_container
+ ? end_position.OffsetInContainerNode()
+ : std::numeric_limits<unsigned>::max();
+ layoutText->AbsoluteQuadsForRange(quads, startOffset, endOffset);
}
+ return quads;
}
bool AreRangesEqual(const Range* a, const Range* b) {
« 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