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

Unified Diff: ui/gfx/rect_base_impl.h

Issue 11293194: ui: Prefer +/- operators to apply offsets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: floats Created 8 years, 1 month 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
« .gitmodules ('K') | « ui/gfx/rect_base.h ('k') | ui/gfx/rect_f.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/rect_base_impl.h
diff --git a/ui/gfx/rect_base_impl.h b/ui/gfx/rect_base_impl.h
index 5ca9afafc41cff3ec394d447a7fb6a4c0091c203..b4cdef02661576237ad8949c65452a89d5bf8837 100644
--- a/ui/gfx/rect_base_impl.h
+++ b/ui/gfx/rect_base_impl.h
@@ -102,7 +102,7 @@ template<typename Class,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Inset(Type left, Type top, Type right, Type bottom) {
- Offset(left, top);
+ origin_ += VectorClass(left, top);
set_width(std::max(width() - left - right, static_cast<Type>(0)));
set_height(std::max(height() - top - bottom, static_cast<Type>(0)));
}
@@ -115,7 +115,29 @@ template<typename Class,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Offset(Type horizontal, Type vertical) {
- origin_.Offset(horizontal, vertical);
+ origin_ += VectorClass(horizontal, vertical);
+}
+
+template<typename Class,
+ typename PointClass,
+ typename SizeClass,
+ typename InsetsClass,
+ typename VectorClass,
+ typename Type>
+void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
+ operator+=(const VectorClass& offset) {
+ origin_ += offset;
+}
+
+template<typename Class,
+ typename PointClass,
+ typename SizeClass,
+ typename InsetsClass,
+ typename VectorClass,
+ typename Type>
+void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
+ operator-=(const VectorClass& offset) {
+ origin_ -= offset;
}
template<typename Class,
« .gitmodules ('K') | « ui/gfx/rect_base.h ('k') | ui/gfx/rect_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698