(chunk, h)
| 7584 | // Find the line at the given vertical position, using the height |
| 7585 | // information in the document tree. |
| 7586 | function lineAtHeight(chunk, h) { |
| 7587 | var n = chunk.first; |
| 7588 | outer: do { |
| 7589 | for (var i = 0; i < chunk.children.length; ++i) { |
| 7590 | var child = chunk.children[i], ch = child.height; |
| 7591 | if (h < ch) { chunk = child; continue outer; } |
| 7592 | h -= ch; |
| 7593 | n += child.chunkSize(); |
| 7594 | } |
| 7595 | return n; |
| 7596 | } while (!chunk.lines); |
| 7597 | for (var i = 0; i < chunk.lines.length; ++i) { |
| 7598 | var line = chunk.lines[i], lh = line.height; |
| 7599 | if (h < lh) break; |
| 7600 | h -= lh; |
| 7601 | } |
| 7602 | return n + i; |
| 7603 | } |
| 7604 | |
| 7605 | |
| 7606 | // Find the height above the given line. |
no outgoing calls
no test coverage detected