Skip to content

Commit e58a836

Browse files
committed
Remove Methods Destroying Layout Information
1 parent 9296067 commit e58a836

File tree

2 files changed

+0
-60
lines changed

2 files changed

+0
-60
lines changed

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager+Layout.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -250,28 +250,4 @@ extension TextLayoutManager {
250250
layoutView?.addSubview(view)
251251
view.needsDisplay = true
252252
}
253-
254-
/// Invalidates and prepares a line position for display.
255-
/// - Parameter position: The line position to prepare.
256-
/// - Returns: The height of the newly laid out line and all it's fragments.
257-
func preparePositionForDisplay(_ position: TextLineStorage<TextLine>.TextLinePosition) -> CGFloat {
258-
guard let textStorage else { return 0 }
259-
let displayData = TextLine.DisplayData(
260-
maxWidth: maxLineLayoutWidth,
261-
lineHeightMultiplier: lineHeightMultiplier,
262-
estimatedLineHeight: estimateLineHeight()
263-
)
264-
position.data.prepareForDisplay(
265-
displayData: displayData,
266-
range: position.range,
267-
stringRef: textStorage,
268-
markedRanges: markedTextManager.markedRanges(in: position.range),
269-
breakStrategy: lineBreakStrategy
270-
)
271-
var height: CGFloat = 0
272-
for fragmentPosition in position.data.lineFragments {
273-
height += fragmentPosition.data.scaledHeight
274-
}
275-
return height
276-
}
277253
}

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager+Public.swift

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)