pull fixes for viewport-related code from base

Needs https://github.com/koreader/koreader-base/pull/280