From e684cfa03f2caaad765f3b11dfba1529de972ec7 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 14 Apr 2016 07:49:41 -0400 Subject: [PATCH] Trivial fixes for marks based on code review. - Fix a docstring copy-paste - Add own name/copyright date to new file - Simplify a bdd expression (no need for regex) - Scroll to a pixel position in a single operation --- qutebrowser/browser/commands.py | 7 +++---- qutebrowser/mainwindow/tabbedbrowser.py | 2 +- tests/integration/features/test_marks.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index dd80c30b0..c940e6c38 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -29,7 +29,7 @@ import xml.etree.ElementTree from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWidgets import QApplication, QTabBar -from PyQt5.QtCore import Qt, QUrl, QEvent +from PyQt5.QtCore import Qt, QUrl, QEvent, QPoint from PyQt5.QtGui import QKeyEvent from PyQt5.QtPrintSupport import QPrintDialog, QPrintPreviewDialog from PyQt5.QtWebKitWidgets import QWebPage @@ -1892,7 +1892,6 @@ class CommandDispatcher: Args: key: mark identifier; capital indicates a global mark """ - # consider urls that differ only in fragment to be identical self._tabbed_browser.set_mark(key) @cmdutils.register(instance='command-dispatcher', scope='window') @@ -1925,5 +1924,5 @@ class CommandDispatcher: def _scroll_px_absolute(self, y): """Scroll to the position y pixels from the top of the page.""" - self.scroll('top') - self.scroll_px(0, y) + frame = self._current_widget().page().currentFrame() + frame.setScrollPosition(QPoint(0, y)) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index d9efe6824..3209632d6 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -43,7 +43,7 @@ class TabDeletedError(Exception): class MarkNotSetError(Exception): - """Exception raised when _tab_index is called for a deleted tab.""" + """Exception raised when accessing a tab that is not set.""" class TabbedBrowser(tabwidget.TabWidget): diff --git a/tests/integration/features/test_marks.py b/tests/integration/features/test_marks.py index 3553ca6f3..fd61d9489 100644 --- a/tests/integration/features/test_marks.py +++ b/tests/integration/features/test_marks.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2016 Florian Bruhin (The Compiler) +# Copyright 2016 Ryan Roden-Corrent (rcorre) # # This file is part of qutebrowser. # @@ -27,7 +27,7 @@ def _get_scroll_y(quteproc): return pos['y'] -@bdd.then(bdd.parsers.re(r"the page should be scrolled to " - r"(?P\d+)")) +@bdd.then(bdd.parsers.parse("the page should be scrolled to " + "{y}")) def check_y(quteproc, y): assert int(y) == _get_scroll_y(quteproc)