QtWebEngine: Implement WebEngineScroller.at_bottom

This commit is contained in:
Florian Bruhin 2016-09-07 09:32:51 +02:00
parent cf6cffeb08
commit 919196714b
3 changed files with 12 additions and 2 deletions

View File

@ -189,6 +189,7 @@ class WebEngineScroller(browsertab.AbstractScroller):
super().__init__(tab, parent)
self._pos_perc = (0, 0)
self._pos_px = QPoint()
self._at_bottom = False
def _init_widget(self, widget):
super()._init_widget(widget)
@ -219,6 +220,7 @@ class WebEngineScroller(browsertab.AbstractScroller):
assert isinstance(jsret, dict), jsret
self._pos_perc = (jsret['perc']['x'], jsret['perc']['y'])
self._pos_px = QPoint(jsret['px']['x'], jsret['px']['y'])
self._at_bottom = jsret['at_bottom']
self.perc_changed.emit(*self._pos_perc)
js_code = javascript.assemble('scroll', 'pos')
@ -273,7 +275,7 @@ class WebEngineScroller(browsertab.AbstractScroller):
return self.pos_px().y() == 0
def at_bottom(self):
log.stub()
return self._at_bottom
class WebEngineHistory(browsertab.AbstractHistory):

View File

@ -80,6 +80,7 @@ window._qutebrowser.scroll = (function() {
var pos = {
"perc": {"x": perc_x, "y": perc_y},
"px": {"x": window.scrollX, "y": window.scrollY},
"at_bottom": dy === window.scrollY,
};
// console.log(JSON.stringify(pos));

View File

@ -279,13 +279,20 @@ Feature: Scrolling
And I wait until the scroll position changed to 0/0
Then the page should not be scrolled
@qtwebengine_todo: at_bottom is not implemented yet
Scenario: :scroll-page with --bottom-navigate
When I run :scroll-perc 100
And I wait until the scroll position changed
And I run :scroll-page --bottom-navigate next 0 1
Then data/hello2.txt should be loaded
Scenario: :scroll-page with --bottom-navigate and zoom
When I run :zoom 200
And I wait until the scroll position changed
And I run :scroll-perc 100
And I wait until the scroll position changed
And I run :scroll-page --bottom-navigate next 0 1
Then data/hello2.txt should be loaded
Scenario: :scroll-page with --top-navigate
When I run :scroll-page --top-navigate prev 0 -1
Then data/hello3.txt should be loaded