Port totalHeight() to v3 branch

@njx I can't quite remember the process for merging to v3. This pull request points to upstream-master. I didn't see any older pull requests in github's history that does this, so I'm guessing I'm doing something wrong.