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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2877463002: Move ComputeTextRects and ComputeTextQuads to VisibleUnits. (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 4060 matching lines...) Expand 10 before | Expand all | Expand 10 after
4071 } 4071 }
4072 4072
4073 Position SkipWhitespace(const Position& position) { 4073 Position SkipWhitespace(const Position& position) {
4074 return SkipWhitespaceAlgorithm(position); 4074 return SkipWhitespaceAlgorithm(position);
4075 } 4075 }
4076 4076
4077 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) { 4077 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) {
4078 return SkipWhitespaceAlgorithm(position); 4078 return SkipWhitespaceAlgorithm(position);
4079 } 4079 }
4080 4080
4081 static void CollectAbsoluteBoundsForRange(unsigned start,
4082 unsigned end,
4083 const LayoutText& layout_text,
4084 Vector<IntRect>& rects) {
4085 layout_text.AbsoluteRectsForRange(rects, start, end);
4086 }
4087
4088 static void CollectAbsoluteBoundsForRange(unsigned start,
4089 unsigned end,
4090 const LayoutText& layout_text,
4091 Vector<FloatQuad>& quads) {
4092 layout_text.AbsoluteQuadsForRange(quads, start, end);
4093 }
4094
4095 template <typename RectType>
4096 static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) {
4097 const Position& start_position = range.StartPosition();
4098 const Position& end_position = range.EndPosition();
4099 Node* const start_container = start_position.ComputeContainerNode();
4100 DCHECK(start_container);
4101 Node* const end_container = end_position.ComputeContainerNode();
4102 DCHECK(end_container);
4103
4104 Vector<RectType> result;
4105 for (const Node& node : range.Nodes()) {
4106 LayoutObject* const layoutObject = node.GetLayoutObject();
Srirama 2017/05/11 04:41:41 s/layoutObject/layout_object
tanvir 2017/05/11 05:31:28 Done.
4107 if (!layoutObject || !layoutObject->IsText())
4108 continue;
4109 const LayoutText* layout_text = ToLayoutText(layoutObject);
4110 unsigned start_offset =
4111 node == start_container ? start_position.OffsetInContainerNode() : 0;
4112 unsigned end_offset = node == end_container
4113 ? end_position.OffsetInContainerNode()
4114 : std::numeric_limits<unsigned>::max();
4115 CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text,
4116 result);
4117 }
4118 return result;
4119 }
4120
4121 Vector<IntRect> ComputeTextRects(const EphemeralRange& range) {
4122 return ComputeTextBounds<IntRect>(range);
4123 }
4124
4125 Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) {
4126 return ComputeTextBounds<FloatQuad>(range);
4127 }
4128
4081 } // namespace blink 4129 } // 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