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

Unified Diff: ios/chrome/browser/ui/util/text_region_mapper.h

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years 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 | « ios/chrome/browser/ui/util/text_frame.mm ('k') | ios/chrome/browser/ui/util/text_region_mapper.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/util/text_region_mapper.h
diff --git a/ios/chrome/browser/ui/util/text_region_mapper.h b/ios/chrome/browser/ui/util/text_region_mapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..b0bc98afd0fbd97d0010dc727c75df6e92e14b43
--- /dev/null
+++ b/ios/chrome/browser/ui/util/text_region_mapper.h
@@ -0,0 +1,46 @@
+// Copyright 2015 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.
+
+#ifndef IOS_CHROME_BROWSER_UI_UTIL_TEXT_REGION_MAPPER_H_
+#define IOS_CHROME_BROWSER_UI_UTIL_TEXT_REGION_MAPPER_H_
+
+#import <UIKit/UIKit.h>
+
+// A TextRegionMapper is a utility class that can, given an attributed string
+// and bounds that the string will be rendered in, return the regions (rects)
+// that ranges of the string occupy when rendered in the given bounds.
+
+// For testing purposes the class interface is defined as a protocol.
+
+@protocol TextRegionMapper<NSObject>
+// Create a new mapper. The mapper can be used repeatedly as long as the
+// string and its bounds do not change; if they do, another mapper must be
+// created.
+- (instancetype)initWithAttributedString:(NSAttributedString*)string
+ bounds:(CGRect)bounds;
+
+// Returns an array of (NSValue-boxed) CGRects which enclose the regions inside
+// |bounds| that the characters of |string|'s substring at |range| occupy. If
+// the string is spread across several lines, a given range might occupy several
+// disjoint rects.
+// Note that the rect encloses only the region occupied by the glyphs, not any
+// leading or other space padding.
+// If |range| is partially or wholly outside of the range of |string|, an
+// empty array is returned.
+- (NSArray*)rectsForRange:(NSRange)range;
+
+@end
+
+// The actual class implementation works by typesetting the text using CoreText.
+@interface CoreTextRegionMapper : NSObject<TextRegionMapper>
+
+- (instancetype)initWithAttributedString:(NSAttributedString*)string
+ bounds:(CGRect)bounds
+ NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_UI_UTIL_TEXT_REGION_MAPPER_H_
« no previous file with comments | « ios/chrome/browser/ui/util/text_frame.mm ('k') | ios/chrome/browser/ui/util/text_region_mapper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698