Changeset View
Changeset View
Standalone View
Standalone View
webengineviewer/src/webenginescript.cpp
Show All 12 Lines | 1 | /* | |||
---|---|---|---|---|---|
13 | 13 | | |||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | #include "webenginescript.h" | 19 | #include "webenginescript.h" | ||
20 | #include <QDebug> | 20 | #include <QDebug> | ||
21 | #include <QtWebEngine/QtWebEngineVersion> | ||||
21 | using namespace WebEngineViewer; | 22 | using namespace WebEngineViewer; | ||
22 | 23 | | |||
23 | QString WebEngineScript::findAllImages() | 24 | QString WebEngineScript::findAllImages() | ||
24 | { | 25 | { | ||
25 | const QString source = QStringLiteral("(function() {" | 26 | const QString source = QStringLiteral("(function() {" | ||
26 | "var out = [];" | 27 | "var out = [];" | ||
27 | "var imgs = document.getElementsByTagName('img');" | 28 | "var imgs = document.getElementsByTagName('img');" | ||
28 | "for (var i = 0; i < imgs.length; ++i) {" | 29 | "for (var i = 0; i < imgs.length; ++i) {" | ||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 120 | const QString source = QStringLiteral("var element = document.getElementById('%1'); " | |||
121 | " var geometry = element.getBoundingClientRect(); " | 122 | " var geometry = element.getBoundingClientRect(); " | ||
122 | " [(geometry.left + window.scrollX), (geometry.top + window.scrollY)]; " | 123 | " [(geometry.left + window.scrollX), (geometry.top + window.scrollY)]; " | ||
123 | "}").arg(elementStr); | 124 | "}").arg(elementStr); | ||
124 | return source; | 125 | return source; | ||
125 | } | 126 | } | ||
126 | 127 | | |||
127 | static QString scrollTop() | 128 | static QString scrollTop() | ||
128 | { | 129 | { | ||
129 | #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) | 130 | #if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 10, 0) | ||
130 | return QStringLiteral("document.documentElement.scrollTop"); | 131 | return QStringLiteral("document.documentElement.scrollTop"); | ||
131 | #else | 132 | #else | ||
132 | return QStringLiteral("document.body.scrollTop"); | 133 | return QStringLiteral("document.body.scrollTop"); | ||
133 | #endif | 134 | #endif | ||
134 | } | 135 | } | ||
135 | 136 | | |||
136 | QString WebEngineScript::scrollPercentage(int percent) | 137 | QString WebEngineScript::scrollPercentage(int percent) | ||
137 | { | 138 | { | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |