(chunk, h)
| 6482 | // Find the line at the given vertical position, using the height |
| 6483 | // information in the document tree. |
| 6484 | function lineAtHeight(chunk, h) { |
| 6485 | var n = chunk.first; |
| 6486 | outer: do { |
| 6487 | for (var i = 0; i < chunk.children.length; ++i) { |
| 6488 | var child = chunk.children[i], ch = child.height; |
| 6489 | if (h < ch) { chunk = child; continue outer; } |
| 6490 | h -= ch; |
| 6491 | n += child.chunkSize(); |
| 6492 | } |
| 6493 | return n; |
| 6494 | } while (!chunk.lines); |
| 6495 | for (var i = 0; i < chunk.lines.length; ++i) { |
| 6496 | var line = chunk.lines[i], lh = line.height; |
| 6497 | if (h < lh) break; |
| 6498 | h -= lh; |
| 6499 | } |
| 6500 | return n + i; |
| 6501 | } |
| 6502 | |
| 6503 | |
| 6504 | // Find the height above the given line. |
no outgoing calls
no test coverage detected