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

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

Issue 2839633002: Introduce ComputeTextBounds template in Range.cpp (Closed)
Patch Set: Updated PS 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 76e18fa4a989b4c8e263194cc052a329fa79348e..6796ae823b30866a90a190c8262b904048007a0e 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -1440,7 +1440,15 @@ Node* Range::PastLastNode() const {
return EndPosition().NodeAsRangePastLastNode();
}
-static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
+static void CollectAbsoluteBoundsForRange(Vector<IntRect>& rects,
tkent 2017/04/27 06:40:37 Please make |rects| the last argument. https://go
tanvir 2017/04/27 14:26:29 Done.
+ unsigned start,
+ unsigned end,
+ const LayoutText& layout_text) {
+ layout_text.AbsoluteRectsForRange(rects, start, end);
+}
+
+template <typename ElementType>
tkent 2017/04/27 06:40:37 |ElementType| is confusing with DOM Element. Can
tanvir 2017/04/27 14:26:29 Done.
+static Vector<ElementType> ComputeTextBounds(const EphemeralRange& range) {
const Position& start_position = range.StartPosition();
const Position& end_position = range.EndPosition();
Node* const start_container = start_position.ComputeContainerNode();
@@ -1448,20 +1456,25 @@ static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
Node* const end_container = end_position.ComputeContainerNode();
DCHECK(end_container);
- Vector<IntRect> rects;
+ Vector<ElementType> result;
for (const Node& node : range.Nodes()) {
LayoutObject* const layoutObject = node.GetLayoutObject();
if (!layoutObject || !layoutObject->IsText())
continue;
- LayoutText* layout_text = ToLayoutText(layoutObject);
+ const LayoutText* layout_text = ToLayoutText(layoutObject);
unsigned start_offset =
node == start_container ? start_position.OffsetInContainerNode() : 0;
unsigned end_offset = node == end_container
? end_position.OffsetInContainerNode()
: std::numeric_limits<unsigned>::max();
- layout_text->AbsoluteRectsForRange(rects, start_offset, end_offset);
+ CollectAbsoluteBoundsForRange(result, start_offset, end_offset,
+ *layout_text);
}
- return rects;
+ return result;
+}
+
+static Vector<IntRect> computeTextRects(const EphemeralRange& range) {
+ return ComputeTextBounds<IntRect>(range);
}
IntRect Range::BoundingBox() const {
« 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