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

Unified Diff: ui/ios/NSString+CrStringDrawing.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: use WARN_UNUSED_RESULT 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
« no previous file with comments | « no previous file | ui/ios/ui_ios.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ios/NSString+CrStringDrawing.mm
diff --git a/ui/ios/NSString+CrStringDrawing.mm b/ui/ios/NSString+CrStringDrawing.mm
index 9f7d88b2684f221dd054f86844a44e5b3a6cedd8..214b0c19102cc65d4f822ba4762fe00dac936aaf 100644
--- a/ui/ios/NSString+CrStringDrawing.mm
+++ b/ui/ios/NSString+CrStringDrawing.mm
@@ -5,25 +5,14 @@
#import "ui/ios/NSString+CrStringDrawing.h"
#include "base/logging.h"
-
-namespace {
-// Returns the closest pixel-aligned value higher than |value|, taking the scale
-// factor into account. At a scale of 1, equivalent to ceil().
-// TODO(lliabraa): Move this method to a common util file (crbug.com/409823).
-CGFloat alignValueToUpperPixel(CGFloat value) {
- CGFloat scale = [[UIScreen mainScreen] scale];
- return ceil(value * scale) / scale;
-}
-} // namespace
+#include "ui/ios/uikit_util.h"
@implementation NSString (CrStringDrawing)
- (CGSize)cr_pixelAlignedSizeWithFont:(UIFont*)font {
DCHECK(font) << "|font| can not be nil; it is used as a NSDictionary value";
NSDictionary* attributes = @{ NSFontAttributeName : font };
- CGSize size = [self sizeWithAttributes:attributes];
- return CGSizeMake(alignValueToUpperPixel(size.width),
- alignValueToUpperPixel(size.height));
+ return ui::AlignSizeToUpperPixel([self sizeWithAttributes:attributes]);
}
- (CGSize)cr_sizeWithFont:(UIFont*)font {
« no previous file with comments | « no previous file | ui/ios/ui_ios.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698