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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/LayoutRect.cpp

Issue 2191233002: Add platform/geometry pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fewer redundant spaces, more toString tests Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 m_location.scale(s, s); 135 m_location.scale(s, s);
136 m_size.scale(s); 136 m_size.scale(s);
137 } 137 }
138 138
139 void LayoutRect::scale(float xAxisScale, float yAxisScale) 139 void LayoutRect::scale(float xAxisScale, float yAxisScale)
140 { 140 {
141 m_location.scale(xAxisScale, yAxisScale); 141 m_location.scale(xAxisScale, yAxisScale);
142 m_size.scale(xAxisScale, yAxisScale); 142 m_size.scale(xAxisScale, yAxisScale);
143 } 143 }
144 144
145 #ifndef NDEBUG
146 void LayoutRect::show(bool showRawValue) const
147 {
148 if (showRawValue)
149 printf("Rect (in raw layout units): [x=%d y=%d maxX=%d maxY=%d]\n", x(). rawValue(), y().rawValue(), maxX().rawValue(), maxY().rawValue());
150 else
151 printf("Rect (in pixels): [x=%lf y=%lf maxX=%lf maxY=%lf]\n", x().toDoub le(), y().toDouble(), maxX().toDouble(), maxY().toDouble());
152 }
153
154 String LayoutRect::toString() const
155 {
156 return String::format("%s %s", location().toString().ascii().data(), size(). toString().ascii().data());
157 }
158 #endif
159
160 LayoutRect unionRect(const Vector<LayoutRect>& rects) 145 LayoutRect unionRect(const Vector<LayoutRect>& rects)
161 { 146 {
162 LayoutRect result; 147 LayoutRect result;
163 148
164 size_t count = rects.size(); 149 size_t count = rects.size();
165 for (size_t i = 0; i < count; ++i) 150 for (size_t i = 0; i < count; ++i)
166 result.unite(rects[i]); 151 result.unite(rects[i]);
167 152
168 return result; 153 return result;
169 } 154 }
(...skipping 19 matching lines...) Expand all
189 return IntRect(location, maxPoint - location); 174 return IntRect(location, maxPoint - location);
190 } 175 }
191 176
192 LayoutRect enclosingLayoutRect(const FloatRect& rect) 177 LayoutRect enclosingLayoutRect(const FloatRect& rect)
193 { 178 {
194 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner()); 179 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner());
195 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner()); 180 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner());
196 return LayoutRect(location, maxPoint - location); 181 return LayoutRect(location, maxPoint - location);
197 } 182 }
198 183
184 String LayoutRect::toString() const
185 {
186 return String::format("%s %s",
187 location().toString().ascii().data(),
188 size().toString().ascii().data());
189 }
190
199 } // namespace blink 191 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698