Store both x and y position for marks.
Previously only stored/used y.
This commit is contained in:
parent
f4b9573744
commit
be6308534f
@ -651,15 +651,14 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
"""
|
||||
# strip the fragment as it may interfere with scrolling
|
||||
url = self.current_url().adjusted(QUrl.RemoveFragment)
|
||||
frame = self.currentWidget().page().currentFrame()
|
||||
y = frame.scrollPosition().y()
|
||||
point = self.currentWidget().page().currentFrame().scrollPosition()
|
||||
|
||||
if key.isupper():
|
||||
self._global_marks[key] = y, url
|
||||
self._global_marks[key] = point, url
|
||||
else:
|
||||
if url not in self._local_marks:
|
||||
self._local_marks[url] = {}
|
||||
self._local_marks[url][key] = y
|
||||
self._local_marks[url][key] = point
|
||||
|
||||
def jump_mark(self, key):
|
||||
"""Jump to the mark named by `key`.
|
||||
@ -672,23 +671,23 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
frame = self.currentWidget().page().currentFrame()
|
||||
|
||||
if key.isupper() and key in self._global_marks:
|
||||
y, url = self._global_marks[key]
|
||||
point, url = self._global_marks[key]
|
||||
|
||||
def callback(ok):
|
||||
if ok:
|
||||
self.cur_load_finished.disconnect(callback)
|
||||
frame.setScrollPosition(QPoint(0, y))
|
||||
frame.setScrollPosition(point)
|
||||
|
||||
self.openurl(url, newtab=False)
|
||||
self.cur_load_finished.connect(callback)
|
||||
elif urlkey in self._local_marks and key in self._local_marks[urlkey]:
|
||||
y = self._local_marks[urlkey][key]
|
||||
point = self._local_marks[urlkey][key]
|
||||
|
||||
# save the pre-jump position in the special ' mark
|
||||
# this has to happen after we read the mark, otherwise jump_mark
|
||||
# "'" would just jump to the current position every time
|
||||
self.set_mark("'")
|
||||
|
||||
frame.setScrollPosition(QPoint(0, y))
|
||||
frame.setScrollPosition(point)
|
||||
else:
|
||||
message.error(self._win_id, "Mark {} is not set".format(key))
|
||||
|
@ -7,43 +7,43 @@ Feature: Setting positional marks
|
||||
## :set-mark, :jump-mark
|
||||
|
||||
Scenario: Setting and jumping to a local mark
|
||||
When I run :scroll-px 0 10
|
||||
When I run :scroll-px 5 10
|
||||
And I run :set-mark 'a'
|
||||
And I run :scroll-px 0 20
|
||||
And I run :jump-mark 'a'
|
||||
Then the page should be scrolled to 10
|
||||
Then the page should be scrolled to 5 10
|
||||
|
||||
Scenario: Jumping back jumping to a particular percentage
|
||||
When I run :scroll-px 0 20
|
||||
When I run :scroll-px 10 20
|
||||
And I run :scroll-perc 100
|
||||
And I run :jump-mark "'"
|
||||
Then the page should be scrolled to 20
|
||||
Then the page should be scrolled to 10 20
|
||||
|
||||
Scenario: Setting the same local mark on another page
|
||||
When I run :scroll-px 0 10
|
||||
When I run :scroll-px 5 10
|
||||
And I run :set-mark 'a'
|
||||
And I open data/marks.html
|
||||
And I run :scroll-px 0 20
|
||||
And I run :set-mark 'a'
|
||||
And I run :jump-mark 'a'
|
||||
Then the page should be scrolled to 20
|
||||
Then the page should be scrolled to 0 20
|
||||
|
||||
Scenario: Jumping to a local mark after returning to a page
|
||||
When I run :scroll-px 0 10
|
||||
When I run :scroll-px 5 10
|
||||
And I run :set-mark 'a'
|
||||
And I open data/numbers/1.txt
|
||||
And I run :set-mark 'a'
|
||||
And I open data/marks.html
|
||||
And I run :jump-mark 'a'
|
||||
Then the page should be scrolled to 10
|
||||
Then the page should be scrolled to 5 10
|
||||
|
||||
Scenario: Setting and jumping to a global mark
|
||||
When I run :scroll-px 0 20
|
||||
When I run :scroll-px 5 20
|
||||
And I run :set-mark 'A'
|
||||
And I open data/numbers/1.txt
|
||||
And I run :jump-mark 'A'
|
||||
Then data/marks.html should be loaded
|
||||
And the page should be scrolled to 20
|
||||
And the page should be scrolled to 5 20
|
||||
|
||||
Scenario: Jumping to an unset mark
|
||||
When I run :jump-mark 'b'
|
||||
@ -58,14 +58,14 @@ Feature: Setting positional marks
|
||||
Scenario: Jumping to a local mark after changing fragments
|
||||
When I open data/marks.html#top
|
||||
And I run :scroll 'top'
|
||||
And I run :scroll-px 0 10
|
||||
And I run :scroll-px 10 10
|
||||
And I run :set-mark 'a'
|
||||
When I open data/marks.html#bottom
|
||||
And I run :jump-mark 'a'
|
||||
Then the page should be scrolled to 10
|
||||
Then the page should be scrolled to 10 10
|
||||
|
||||
Scenario: Jumping back after following a link
|
||||
When I run :hint links normal
|
||||
And I run :follow-hint s
|
||||
And I run :jump-mark "'"
|
||||
Then the page should be scrolled to 0
|
||||
Then the page should be scrolled to 0 0
|
||||
|
@ -21,13 +21,9 @@ import pytest_bdd as bdd
|
||||
bdd.scenarios('marks.feature')
|
||||
|
||||
|
||||
def _get_scroll_y(quteproc):
|
||||
@bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}"))
|
||||
def check_y(quteproc, x, y):
|
||||
data = quteproc.get_session()
|
||||
pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos']
|
||||
return pos['y']
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse("the page should be scrolled to "
|
||||
"{y}"))
|
||||
def check_y(quteproc, y):
|
||||
assert int(y) == _get_scroll_y(quteproc)
|
||||
assert int(x) == pos['x']
|
||||
assert int(y) == pos['y']
|
||||
|
Loading…
Reference in New Issue
Block a user