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

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

Issue 2877463002: Move ComputeTextRects and ComputeTextQuads to VisibleUnits. (Closed)
Patch Set: updated PS 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 | « no previous file | third_party/WebKit/Source/core/editing/VisibleUnits.h » ('j') | 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 7f598f340de157985908109b614033d8150d43fd..de056bbffe1d70c4388b1d4ddd094fde4bebe475 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -1440,56 +1440,6 @@ Node* Range::PastLastNode() const {
return EndPosition().NodeAsRangePastLastNode();
}
-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) {
- const Position& start_position = range.StartPosition();
- const Position& end_position = range.EndPosition();
- Node* const start_container = start_position.ComputeContainerNode();
- DCHECK(start_container);
- Node* const end_container = end_position.ComputeContainerNode();
- DCHECK(end_container);
-
- Vector<RectType> result;
- for (const Node& node : range.Nodes()) {
- LayoutObject* const layoutObject = node.GetLayoutObject();
Xiaocheng 2017/05/11 18:28:20 Good catch! Thanks!
- if (!layoutObject || !layoutObject->IsText())
- continue;
- 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();
- CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text,
- result);
- }
- return result;
-}
-
-static Vector<IntRect> ComputeTextRects(const EphemeralRange& range) {
- return ComputeTextBounds<IntRect>(range);
-}
-
-// TODO(tanvir.rizvi): We will replace Range::TextQuads with ComputeTextQuads
-// and get rid of Range::TextQuads.
-static Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) {
- return ComputeTextBounds<FloatQuad>(range);
-}
-
IntRect Range::BoundingBox() const {
IntRect result;
const Vector<IntRect>& rects = ComputeTextRects(EphemeralRange(this));
@@ -1498,6 +1448,8 @@ IntRect Range::BoundingBox() const {
return result;
}
+// TODO(tanvir.rizvi): We will replace Range::TextQuads with
+// ComputeTextQuads(in VisibleUnits) and get rid of Range::TextQuads.
void Range::TextQuads(Vector<FloatQuad>& quads) const {
quads.AppendVector(ComputeTextQuads(EphemeralRange(this)));
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleUnits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698