@@ -120,9 +120,6 @@ extension TextLayoutManager {
120120 guard let linePosition = lineStorage. getLine ( atOffset: offset) else {
121121 return nil
122122 }
123- if linePosition. data. lineFragments. isEmpty {
124- ensureLayoutUntil ( offset)
125- }
126123
127124 guard let fragmentPosition = linePosition. data. typesetter. lineFragments. getLine (
128125 atOffset: offset - linePosition. range. location
@@ -160,7 +157,6 @@ extension TextLayoutManager {
160157 /// - line: The line to calculate rects for.
161158 /// - Returns: Multiple bounding rects. Will return one rect for each line fragment that overlaps the given range.
162159 public func rectsFor( range: NSRange ) -> [ CGRect ] {
163- ensureLayoutUntil ( range. max)
164160 return lineStorage. linesInRange ( range) . flatMap { self . rectsFor ( range: range, in: $0) }
165161 }
166162
@@ -289,36 +285,4 @@ extension TextLayoutManager {
289285 height: lineFragment. scaledHeight
290286 ) . pixelAligned
291287 }
292-
293- // MARK: - Ensure Layout
294-
295- /// Forces layout calculation for all lines up to and including the given offset.
296- /// - Parameter offset: The offset to ensure layout until.
297- public func ensureLayoutUntil( _ offset: Int ) {
298- guard let linePosition = lineStorage. getLine ( atOffset: offset) ,
299- let visibleRect = delegate? . visibleRect,
300- visibleRect. maxY < linePosition. yPos + linePosition. height,
301- let startingLinePosition = lineStorage. getLine ( atPosition: visibleRect. minY)
302- else {
303- return
304- }
305- let originalHeight = lineStorage. height
306-
307- for linePosition in lineStorage. linesInRange (
308- NSRange ( start: startingLinePosition. range. location, end: linePosition. range. max)
309- ) {
310- let height = preparePositionForDisplay ( linePosition)
311- if height != linePosition. height {
312- lineStorage. update (
313- atOffset: linePosition. range. location,
314- delta: 0 ,
315- deltaHeight: height - linePosition. height
316- )
317- }
318- }
319-
320- if originalHeight != lineStorage. height || layoutView? . frame. size. height != lineStorage. height {
321- delegate? . layoutManagerHeightDidUpdate ( newHeight: lineStorage. height)
322- }
323- }
324288}
0 commit comments