Merge branch 'Spreadyy-patch-1'

This commit is contained in:
Florian Bruhin 2016-10-03 07:03:19 +02:00
commit 4801352254
4 changed files with 41 additions and 14 deletions

View File

@ -207,6 +207,7 @@ Contributors, sorted by the number of commits in descending order:
* jnphilipp
* Tobias Patzl
* Stefan Tatschner
* Spreadyy
* Samuel Loury
* Peter Michely
* Panashe M. Fundira

View File

@ -258,11 +258,18 @@ class WebEngineScroller(browsertab.AbstractScroller):
self._pos_px = QPoint(jsret['px']['x'], jsret['px']['y'])
dx = jsret['scroll']['width'] - jsret['inner']['width']
perc_x = 0 if dx == 0 else round(100 / dx * jsret['px']['x'])
dy = jsret['scroll']['height'] - jsret['inner']['height']
perc_y = 0 if dy == 0 else round(100 / dy * jsret['px']['y'])
if dx == 0:
perc_x = 0
else:
perc_x = min(100, round(100 / dx * jsret['px']['x']))
self._at_bottom = dy == jsret['px']['y']
dy = jsret['scroll']['height'] - jsret['inner']['height']
if dy == 0:
perc_y = 0
else:
perc_y = min(100, round(100 / dy * jsret['px']['y']))
self._at_bottom = dy >= jsret['px']['y']
self._pos_perc = perc_x, perc_y
self.perc_changed.emit(*self._pos_perc)

View File

@ -23,16 +23,28 @@ window._qutebrowser.scroll = (function() {
var funcs = {};
funcs.to_perc = function(x, y) {
var elem = document.documentElement;
var x_px = window.scrollX;
var y_px = window.scrollY;
var width = Math.max(
document.body.scrollWidth,
document.body.offsetWidth,
document.documentElement.scrollWidth,
document.documentElement.offsetWidth
);
var height = Math.max(
document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight
);
if (x !== undefined) {
x_px = (elem.scrollWidth - window.innerWidth) / 100 * x;
x_px = (width - window.innerWidth) / 100 * x;
}
if (y !== undefined) {
y_px = (elem.scrollHeight - window.innerHeight) / 100 * y;
y_px = (height - window.innerHeight) / 100 * y;
}
/*
@ -40,12 +52,12 @@ window._qutebrowser.scroll = (function() {
"x": x,
"window.scrollX": window.scrollX,
"window.innerWidth": window.innerWidth,
"elem.scrollWidth": elem.scrollWidth,
"elem.scrollWidth": document.documentElement.scrollWidth,
"x_px": x_px,
"y": y,
"window.scrollY": window.scrollY,
"window.innerHeight": window.innerHeight,
"elem.scrollHeight": elem.scrollHeight,
"elem.scrollHeight": document.documentElement.scrollHeight,
"y_px": y_px,
}));
*/
@ -60,13 +72,21 @@ window._qutebrowser.scroll = (function() {
};
funcs.pos = function() {
var elem = document.documentElement;
var pos = {
"px": {"x": window.scrollX, "y": window.scrollY},
"scroll": {
"width": elem.scrollWidth,
"height": elem.scrollHeight,
"width": Math.max(
document.body.scrollWidth,
document.body.offsetWidth,
document.documentElement.scrollWidth,
document.documentElement.offsetWidth
),
"height": Math.max(
document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight
),
},
"inner": {
"width": window.innerWidth,

View File

@ -307,7 +307,6 @@ Feature: Scrolling
## issues
@qtwebengine_todo: #1945
Scenario: Relative scroll position with a position:absolute page
When I open data/scroll/position_absolute.html
And I run :scroll-perc 100