Fix :scroll-page with --bottom-navigate on QtWebEngine

There were two issues here:

- The comparison was backwards, causing scroller.at_bottom() to always return
  true.
- When zoomed in, jsret['px']['y'] can be a float, which means we can be
  slightly off when checking the difference - math.ceil() fixes that.
This commit is contained in:
Florian Bruhin 2017-06-29 22:39:48 +02:00
parent f136f78802
commit d132b6ed71
3 changed files with 10 additions and 1 deletions

View File

@ -137,6 +137,7 @@ Fixed
fixed.
- Scrolling to an anchor in a background tab now works correctly, and javascript
gets the correct window size for background tabs.
- `:scroll-page` with `--bottom-navigate` now works correctly on QtWebEngine
v0.10.1
-------

View File

@ -20,6 +20,7 @@
"""Wrapper over a QWebEngineView."""
import os
import math
import functools
import sip
@ -342,7 +343,7 @@ class WebEngineScroller(browsertab.AbstractScroller):
else:
perc_y = min(100, round(100 / dy * jsret['px']['y']))
self._at_bottom = dy >= jsret['px']['y']
self._at_bottom = math.ceil(jsret['px']['y']) >= dy
self._pos_perc = perc_x, perc_y
self.perc_changed.emit(*self._pos_perc)

View File

@ -292,6 +292,13 @@ Feature: Scrolling
And I run :scroll-page --bottom-navigate next 0 1
Then data/hello2.txt should be loaded
Scenario: :scroll-page with --bottom-navigate when not at the bottom
When I run :scroll-px 0 10
And I wait until the scroll position changed
And I run :scroll-page --bottom-navigate next 0 1
Then the following tabs should be open:
- data/scroll/simple.html
Scenario: :scroll-page with --top-navigate
When I run :scroll-page --top-navigate prev 0 -1
Then data/hello3.txt should be loaded