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

Unified Diff: ui/ios/uikit_util.mm

Issue 539253002: Add a couple UIKit util functions in src/ui/ios/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
Index: ui/ios/uikit_util.mm
diff --git a/ui/ios/uikit_util.mm b/ui/ios/uikit_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..a997c9e378fbae05252dc7f749e0a725fc955979
--- /dev/null
+++ b/ui/ios/uikit_util.mm
@@ -0,0 +1,21 @@
+// Copyright 2014 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/ios/uikit_util.h"
+
+#import <UIKit/UIKit.h>
+
+namespace ui {
+
+CGFloat alignValueToUpperPixel(CGFloat value) {
+ CGFloat scale = [[UIScreen mainScreen] scale];
+ return ceil(value * scale) / scale;
stuartmorgan 2014/09/04 22:16:11 std::ceil so it does the right thing with 64-bit?
lliabraa 2014/09/05 16:53:44 Done.
+}
+
+CGSize alignSizeToUpperPixel(CGSize size) {
+ return CGSizeMake(alignValueToUpperPixel(size.width),
+ alignValueToUpperPixel(size.height));
stuartmorgan 2014/09/04 22:16:11 Should align inside the (
lliabraa 2014/09/05 16:53:45 Done.
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698