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

Unified Diff: ui/gfx/size_base_impl.h

Issue 11410024: ui: Remove gfx::Size::ClampToNonNegative, prevent negative sizes always. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no negative sizes 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
Index: ui/gfx/size_base_impl.h
diff --git a/ui/gfx/size_base_impl.h b/ui/gfx/size_base_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e87468a9b3f13c843ea7c367dbe85257b73dc44
--- /dev/null
+++ b/ui/gfx/size_base_impl.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/size_base.h"
+
+#include "base/logging.h"
+
+// This file provides the implementation for SizeBase template and
+// used to instantiate the base class for Size and SizeF classes.
+#if !defined(UI_IMPLEMENTATION)
+#error "This file is intended for UI implementation only"
+#endif
+
+namespace gfx {
+
+template<typename Class, typename Type>
+void SizeBase<Class, Type>::set_width(Type width) {
+ DCHECK(!(width < 0));
sky 2012/11/12 04:21:46 DCHECK_GE for all of these.
danakj 2012/11/12 05:52:57 I did that at first, but then the DCHECK() fires f
+ width_ = width < 0 ? 0 : width;
+}
+
+template<typename Class, typename Type>
+void SizeBase<Class, Type>::set_height(Type height) {
+ DCHECK(!(height < 0));
+ height_ = height < 0 ? 0 : height;
+}
+
+template<typename Class, typename Type>
+SizeBase<Class, Type>::SizeBase(Type width, Type height)
+ : width_(width < 0 ? 0 : width),
+ height_(height < 0 ? 0 : height) {
+ DCHECK(!(width < 0));
+ DCHECK(!(height < 0));
+}
+
+} // namespace gfx
« ui/base/gestures/gesture_sequence.cc ('K') | « ui/gfx/size_base.h ('k') | ui/gfx/size_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698