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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2891313002: Use FloatQuad instead of intrect in visibleunit (Closed)
Patch Set: Created 3 years, 7 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/editing/VisibleUnits.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/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index f953a2630b0faab92dc3a4259336e58aded96745..afe553a213561b28d48b0aaab111e716ddc20792 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -4105,22 +4105,7 @@ PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) {
return SkipWhitespaceAlgorithm(position);
}
-static void CollectAbsoluteBoundsForRange(unsigned start,
- unsigned end,
- const LayoutText& layout_text,
- Vector<IntRect>& rects) {
- layout_text.AbsoluteRectsForRange(rects, start, end);
-}
-
-static void CollectAbsoluteBoundsForRange(unsigned start,
- unsigned end,
- const LayoutText& layout_text,
- Vector<FloatQuad>& quads) {
- layout_text.AbsoluteQuadsForRange(quads, start, end);
-}
-
-template <typename RectType>
-static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) {
+static Vector<FloatQuad> ComputeTextBounds(const EphemeralRange& range) {
const Position& start_position = range.StartPosition();
const Position& end_position = range.EndPosition();
Node* const start_container = start_position.ComputeContainerNode();
@@ -4128,7 +4113,7 @@ static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) {
Node* const end_container = end_position.ComputeContainerNode();
DCHECK(end_container);
- Vector<RectType> result;
+ Vector<FloatQuad> result;
for (const Node& node : range.Nodes()) {
LayoutObject* const layout_object = node.GetLayoutObject();
if (!layout_object || !layout_object->IsText())
@@ -4139,18 +4124,21 @@ static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) {
unsigned end_offset = node == end_container
? end_position.OffsetInContainerNode()
: std::numeric_limits<unsigned>::max();
- CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text,
- result);
+ layout_text->AbsoluteQuadsForRange(result, start_offset, end_offset);
}
return result;
}
-Vector<IntRect> ComputeTextRects(const EphemeralRange& range) {
- return ComputeTextBounds<IntRect>(range);
+IntRect ComputeTextRect(const EphemeralRange& range) {
+ IntRect result;
+ const Vector<FloatQuad>& rects = ComputeTextBounds(range);
+ for (const FloatQuad& rect : rects)
+ result.Unite(rect.EnclosingBoundingBox());
+ return result;
}
Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) {
- return ComputeTextBounds<FloatQuad>(range);
+ return ComputeTextBounds(range);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698