(chunk, h)
| 7847 | // Find the line at the given vertical position, using the height |
| 7848 | // information in the document tree. |
| 7849 | function lineAtHeight(chunk, h) { |
| 7850 | var n = chunk.first; |
| 7851 | outer: do { |
| 7852 | for (var i = 0; i < chunk.children.length; ++i) { |
| 7853 | var child = chunk.children[i], ch = child.height; |
| 7854 | if (h < ch) { chunk = child; continue outer; } |
| 7855 | h -= ch; |
| 7856 | n += child.chunkSize(); |
| 7857 | } |
| 7858 | return n; |
| 7859 | } while (!chunk.lines); |
| 7860 | for (var i = 0; i < chunk.lines.length; ++i) { |
| 7861 | var line = chunk.lines[i], lh = line.height; |
| 7862 | if (h < lh) break; |
| 7863 | h -= lh; |
| 7864 | } |
| 7865 | return n + i; |
| 7866 | } |
| 7867 | |
| 7868 | |
| 7869 | // Find the height above the given line. |
no outgoing calls
no test coverage detected