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

Side by Side Diff: ios/chrome/browser/ui/util/text_frame.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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/util/snapshot_util.mm ('k') | ios/chrome/browser/ui/util/text_frame.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_UI_UTIL_TEXT_FRAME_H_
6 #define IOS_CHROME_BROWSER_UI_UTIL_TEXT_FRAME_H_
7
8 #import <CoreText/CoreText.h>
9 #import <UIKit/UIKit.h>
10
11 // An object encapsulating a line of text that has been framed within a bounding
12 // rect.
13 @interface FramedLine : NSObject
14
15 // Designated initializer.
16 - (instancetype)initWithLine:(CTLineRef)line
17 stringRange:(NSRange)stringRange
18 origin:(CGPoint)origin NS_DESIGNATED_INITIALIZER;
19 - (instancetype)init NS_UNAVAILABLE;
20
21 // The CTLine that was framed.
22 @property(nonatomic, readonly) CTLineRef line;
23 // The range within the original string that corresponds with |line|. CTLines
24 // created by ManualTextFramers report string ranges with 0 for their locations,
25 // so the actual range is stored here separately.
26 @property(nonatomic, readonly) NSRange stringRange;
27 // The baseline origin (in Quartz coordinates) of the line within its bounds.
28 @property(nonatomic, readonly) CGPoint origin;
29
30 // Returns the offset into |line| of the glyph corresponding with the character
31 // in the original string at |stringLocation|. Returns kCFNotFound if
32 // |stringLocation| is outside of |stringRange|.
33 - (CFIndex)lineOffsetForStringLocation:(NSUInteger)stringLocation;
34
35 @end
36
37 // Protocol for objects that contain NSAttributedStrings laid out within a
38 // bounding rect.
39 @protocol TextFrame<NSObject>
40
41 // The string that was framed within |bounds|.
42 @property(nonatomic, readonly) NSAttributedString* string;
43 // The range of |string| that was successfully framed.
44 @property(nonatomic, readonly) NSRange framedRange;
45 // An NSArray of FramedLines corresponding to |string| as laid out in |bounds|.
46 @property(nonatomic, readonly) NSArray* lines;
47 // The bounds in which |string| is laid out.
48 @property(nonatomic, readonly) CGRect bounds;
49
50 @end
51
52 // A TextFrame implementation that is backed by a CTFrameRef.
53 @interface CoreTextTextFrame : NSObject<TextFrame>
54
55 // Designated initializer.
56 - (instancetype)initWithString:(NSAttributedString*)string
57 bounds:(CGRect)bounds
58 frame:(CTFrameRef)frame NS_DESIGNATED_INITIALIZER;
59 - (instancetype)init NS_UNAVAILABLE;
60
61 @end
62
63 #endif // IOS_CHROME_BROWSER_UI_UTIL_TEXT_FRAME_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/util/snapshot_util.mm ('k') | ios/chrome/browser/ui/util/text_frame.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698