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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 4087 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 } 4098 }
4099 4099
4100 Position SkipWhitespace(const Position& position) { 4100 Position SkipWhitespace(const Position& position) {
4101 return SkipWhitespaceAlgorithm(position); 4101 return SkipWhitespaceAlgorithm(position);
4102 } 4102 }
4103 4103
4104 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) { 4104 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) {
4105 return SkipWhitespaceAlgorithm(position); 4105 return SkipWhitespaceAlgorithm(position);
4106 } 4106 }
4107 4107
4108 static void CollectAbsoluteBoundsForRange(unsigned start, 4108 static Vector<FloatQuad> ComputeTextBounds(const EphemeralRange& range) {
4109 unsigned end,
4110 const LayoutText& layout_text,
4111 Vector<IntRect>& rects) {
4112 layout_text.AbsoluteRectsForRange(rects, start, end);
4113 }
4114
4115 static void CollectAbsoluteBoundsForRange(unsigned start,
4116 unsigned end,
4117 const LayoutText& layout_text,
4118 Vector<FloatQuad>& quads) {
4119 layout_text.AbsoluteQuadsForRange(quads, start, end);
4120 }
4121
4122 template <typename RectType>
4123 static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) {
4124 const Position& start_position = range.StartPosition(); 4109 const Position& start_position = range.StartPosition();
4125 const Position& end_position = range.EndPosition(); 4110 const Position& end_position = range.EndPosition();
4126 Node* const start_container = start_position.ComputeContainerNode(); 4111 Node* const start_container = start_position.ComputeContainerNode();
4127 DCHECK(start_container); 4112 DCHECK(start_container);
4128 Node* const end_container = end_position.ComputeContainerNode(); 4113 Node* const end_container = end_position.ComputeContainerNode();
4129 DCHECK(end_container); 4114 DCHECK(end_container);
4130 4115
4131 Vector<RectType> result; 4116 Vector<FloatQuad> result;
4132 for (const Node& node : range.Nodes()) { 4117 for (const Node& node : range.Nodes()) {
4133 LayoutObject* const layout_object = node.GetLayoutObject(); 4118 LayoutObject* const layout_object = node.GetLayoutObject();
4134 if (!layout_object || !layout_object->IsText()) 4119 if (!layout_object || !layout_object->IsText())
4135 continue; 4120 continue;
4136 const LayoutText* layout_text = ToLayoutText(layout_object); 4121 const LayoutText* layout_text = ToLayoutText(layout_object);
4137 unsigned start_offset = 4122 unsigned start_offset =
4138 node == start_container ? start_position.OffsetInContainerNode() : 0; 4123 node == start_container ? start_position.OffsetInContainerNode() : 0;
4139 unsigned end_offset = node == end_container 4124 unsigned end_offset = node == end_container
4140 ? end_position.OffsetInContainerNode() 4125 ? end_position.OffsetInContainerNode()
4141 : std::numeric_limits<unsigned>::max(); 4126 : std::numeric_limits<unsigned>::max();
4142 CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text, 4127 layout_text->AbsoluteQuadsForRange(result, start_offset, end_offset);
4143 result);
4144 } 4128 }
4145 return result; 4129 return result;
4146 } 4130 }
4147 4131
4148 Vector<IntRect> ComputeTextRects(const EphemeralRange& range) { 4132 IntRect ComputeTextRect(const EphemeralRange& range) {
4149 return ComputeTextBounds<IntRect>(range); 4133 IntRect result;
4134 const Vector<FloatQuad>& rects = ComputeTextBounds(range);
4135 for (const FloatQuad& rect : rects)
4136 result.Unite(rect.EnclosingBoundingBox());
4137 return result;
4150 } 4138 }
4151 4139
4152 Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) { 4140 Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) {
4153 return ComputeTextBounds<FloatQuad>(range); 4141 return ComputeTextBounds(range);
4154 } 4142 }
4155 4143
4156 } // namespace blink 4144 } // namespace blink
OLDNEW
« 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