Commit Graph

209 Commits

Author SHA1 Message Date
Florian Bruhin
6c9e23af4a eslint: Turn off max-lines-per-function 2018-06-25 08:14:02 +02:00
Florian Bruhin
a02c25dfb1 Don't escape URLs for qute://history
We only use the URL to set a 'href' attribute, which does not need escaping.

See #4011
Fixes #4012
2018-06-23 14:27:07 +02:00
Florian Bruhin
1541088e76 Use -webkit-filter on old Qt 2018-06-12 17:01:34 +02:00
Florian Bruhin
c37134861e Use ES6 template strings 2018-06-12 16:49:54 +02:00
Florian Bruhin
772654bcae Use calculated background color for newer Qt versions 2018-06-12 16:46:03 +02:00
Florian Bruhin
68a7387b6b Merge remote-tracking branch 'origin/pr/3940' 2018-06-12 16:32:05 +02:00
Slackhead
088c7b235d fix for qt 5.7.1 2018-06-12 11:22:41 +01:00
Slackhead
35a1e118f8 combine style nodes 2018-06-12 04:25:13 +01:00
Florian Bruhin
7f69920158 Merge remote-tracking branch 'origin/pr/3947' 2018-06-11 11:29:14 +02:00
Jay Kamat
de127497a2
Press enter to follow links instead of using js
This codepath may trigger a crash which was fixed by
0e75f3272d.
However, this commit does not make it more likely to happen, and this
patch was backported into arch (at least).

In the future, we may be able to use <enter> on qtwebkit with js,
without triggering this crash
2018-06-09 15:42:44 -07:00
Florian Bruhin
7fdeeb25b7 Merge remote-tracking branch 'origin/pr/3793' 2018-06-09 22:59:52 +02:00
Slackhead
c3771ca2b2 double quoted and className corrected 2018-06-09 19:45:48 +01:00
Slackhead
7858bb97d1 Change default bg colour to #000 2018-05-31 06:33:48 +01:00
Slackhead
8c1080de97 Change filter value to 85% to really darken it 2018-05-31 05:58:05 +01:00
Slackhead
d37b2713cf Change min-width to 0.2em 2018-05-31 05:45:43 +01:00
Slackhead
41a092cd80 Tweak style/animation 2018-05-31 04:50:41 +01:00
Slackhead
0fcbc209bb Add animation stopper/starter 2018-05-31 04:50:41 +01:00
Slackhead
1578a4836c Add fallback colours if inherit fails 2018-05-31 04:50:41 +01:00
Slackhead
f34d1b6ce1 Remove inherit styles 2018-05-31 04:50:41 +01:00
Slackhead
4cc2b919fa Change caret style 2018-05-31 04:50:41 +01:00
Jay Kamat
c33a887b2d
Add support for following tab selected elements to :follow-selected 2018-05-25 12:39:36 -07:00
Jimmy
47446baf29 s/obj/target/
Would a bit of consistency in variable names be too much to ask?
2018-05-21 21:23:38 +12:00
Jimmy
d162e01422 Greasemonkey: remove extra window scope IIFE
Also change the block scoped `window` declaration to be const because it
seemed like a good idea. The real window seems to just silently ignore
attempts to overwrite it.
2018-05-20 18:42:40 +12:00
Jimmy
b0d1a137da Greasemonkey: Don't attempt scope isolation on webkit
Since the JSCore used by WebKit 602.1 doesn't fully support Proxy and I
can't think of a way to provide isolation otherwise just revert to the
old behaviour in that case. I am checking for the specific WebKit
version because I'm pretty sure that version just happened to be
released when Proxy support was only partially done, any later release
will presumably have a newer JSCore where it works.

There I changed the indentation of a block in the jinja template which
will have inflated the diff.

I added mocking of `objects.backend` to the `webview` and
`webenginewebview` fixtures, I am pretty sure they are mutually
exclusive so don't expect any issues from that.

Because of the feature detection being at template compile time I had to
tweak the test setup to be done via a fixture instead of the setupClass
functionality that I was using before.
2018-05-20 18:42:40 +12:00
Jimmy
13249329f7 Greasemonkey: skip window scoping test on webkit
The implementation of Proxy in JSCore used by current QtWebkit (webkit
602.1) doesn't support the `set()` handler for whatever reason. So
instead of testing for a specific behaviour that we can't ensure on that
version let's just skip the tests and handle user complaints with
sympathy.
2018-05-20 18:42:40 +12:00
Jimmy
19242b6cb2 Greasemonkey: fix scoping function decleration.
Apparently making a function like `function foo() {};` in block scope is
illegal. It should be named via assignment.

Switched to an IIFE anyway because it doesn't need a name.
2018-05-20 18:42:40 +12:00
Jimmy
23bfe6daa2 Greasemonkey: fix window proxy for new attributes
Previously scripts were failing to find attributes that they assigned to
window and then tried to use from the global scope. Eg

    window.newthing = function() {...};
    newthing(...);  // newthing is not defined error

This wasn't the case for things that already existed in the global scope
and were just being overwritten.

This change just overrides the `Proxy.has()` function which seems to fix
it. Probably the `while` implementation was failing to pick up new
attributes because of the lack.

I also tweaked some comments and variable names and const-ness to be a
little more production ready.
2018-05-20 18:42:40 +12:00
Jimmy
ab50ad735b Greasemonkey: isolates scripts' writes to window
Since the global namespace of javascript in the browser is accessible
there where issues with scripts clobbering things that the page expected
to be attributes of window pages clobbering things that userscripts
saved to `window`. The latter was occuring with OneeChan. OneeChan was
setting `window.$` to a function that took a css selector and the 4chan
catalog script was setting `window.$` to some object. Since OneeChan was
set to run at document-start this broke OneeChan, switching it to
document-end broke scripts on 4chan.

I used OneeChan and 4chan-X on 4chan as the test case for this and
TamperMonkey as a guide for what is the correct way to handle scoping. I
didn't manage to pick apart just how TamperMonkey does what it does (I
think it might just be the environment that Chrome provides extensions
actually) but I got close to the same behaviour.

TamperMonkey provides a `window` object that appears to be what the
global window looked like before the webpage modified it. The global
scope though does have the pages modifications accessible. If the script
assigns something to an attribute `window` it can see that attribute in
the global scope. This implementation differs from that one in that, to
the scipt, `window` and the global scope always look the same, and that
is the same as the global scope looks in the environment provided by
TamperMonkey.

I am using the ES6 `Proxy` feature to allow the `window` object to look
like the actual (unsafe) one while allowing writing to it that doesn't
clobber the unsafe one. I am then using the ES4 `with` function to make
attributes of that window (proxy) object visible in the scope chain.
There may be other ways to do this without using `with` by using nested
functions and setting `this` creatively. There are notes around
alleging `with` to be various states of uncool[1].

I also ran into an issue where a userscript calling
`window.addEventListener(...)` would fail with `TypeError: Illegal
Execution` which is apparently due to `this` not being set correctly. I
looked at the functions which threw that error and those that didn't and
am using whether they have a `prototype` attribute or not to tell
whether I need to bind them with `window` as `this`. I am not sure how
correct that is but it worked for all the cases I ran into.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
2018-05-20 18:42:40 +12:00
Joakim Särehag
72c2962908 removed trailing whitespace 2018-05-09 15:52:22 +02:00
Joakim Särehag
0e756d2f68 changes to pull request 3864, window.print for webengine 2018-05-09 14:36:03 +02:00
Joakim Särehag
199eac2db8 window.print() support for WebEngine 2018-04-24 14:05:53 +02:00
Jimmy
1c0616f3ec Greasemonkey: fix early addstyle with fast sites.
nemanjan00 reported this script not having any effect da850e49cc/duckduckgo-deepdark.user.js

It turns out that the previous implementation of GM_addStyle was relying
on `document.onreadystatechange` when the script ran early enough that
there was no `head` element. That event wasn't getting fired for the
main frame of duckduckgo.com for whatever reason. Maybe using
`DOMContentLoaded` or something would have worked but I just copied the
fallback in the above linked script which seems to work just fine.
2018-04-01 12:38:48 +12:00
Florian Bruhin
d438aa15fa Simplify setting _qute_script_id 2018-03-30 11:48:06 +02:00
Jay Kamat
7f5a79cdfd
Escape strings with string_escape rather than tojson 2018-03-30 01:40:49 -04:00
Florian Bruhin
e50068021d Use signals to update statusbar in caret mode
This means we don't use objreg anymore to get the status bar, and also makes the
bar more accurately reflect reality.

See #3583
2018-03-19 18:44:06 +01:00
Florian Bruhin
f28a39571c Fix caret.js indent 2018-03-19 11:49:24 +01:00
Florian Bruhin
1b84bbd61d Refactor initialization of internal JavaScript
- Initialize JavaScript in webenginesettings.py instead of webenginetab.py
- Move JavaScript snippet into a .js file
- Make sure scripts can be re-run and do nothing if already run.
- Run scripts on DocumentCreation *and* DocumentReady. Closes #3717.
- Give each script an unique name for debugging.
- Also make custom stylesheets work on chrome:// pages
2018-03-19 09:14:55 +01:00
Jay Kamat
a6e94cf30c
Fix hinting in frames on qt5.9 with input ranges 2018-03-13 18:54:08 -04:00
Jimmy
60e6d28eb1 Greasemonkey: webkit: Don't use Object.entries in js.
Apparently the currently available QtWebkit's javascript engine doesn't
support Object.entries[1]. It was only using that because I had copied
it from the official gm4 polyfill (maybe I should open an issue there?).

Tested with libqt5webkit5 version 5.212.0~alpha2-5 (debian) and I was
getting the same type of failures as Travis so it looks like this is the
case in arch too.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
2018-03-03 15:02:42 +13:00
Jimmy
33d66676c9 Greasemonkey: mock the new GM4 promises based API.
Based on the gm4-polyfill.js script from the greasemonkey devs. But not
the same because that script doesn't work for us for a couple of
reasons:

* It assumes all GM_* functions are attributes of `this` which in
this case is the global window object. Which breaks it out of our iife.
It is possible to change what `this` is within the iife but then we
would have to do something weird to ensure the functions were available
with the leading `this.`. And I don't think user javascripts tend to
call GM functions like that anyway, that polyfill script is just making
weird assumptions and then claiming it'll work for "any user script
engine".

* It tries to provide implementations of GM_registerMenuCommand and
GM_getResource text which do unexpected thins or implement a circular
dependency on the new version, respectively.
2018-03-03 13:14:49 +13:00
Jay Kamat
7ecbae765d
Use baseNode over anchorNode in follow-selected
baseNode isn't documented anywhere that I can find, but it seems to be
getting us what anchorNode used to get us.
2018-02-22 16:42:58 -05:00
Florian Bruhin
35b56f2659 Remove eslint max-lines suppression
We already turn that off globally now.
2018-02-08 09:51:06 +01:00
Florian Bruhin
aa3970c83e Merge branch 'pr/3371' 2018-02-07 18:26:19 +01:00
Florian Bruhin
1f5cbf21a3 Merge remote-tracking branch 'origin/pr/3348' 2018-01-20 18:28:14 +01:00
Florian Bruhin
182bf1d688
Simplify platform handling 2018-01-20 16:43:39 +01:00
Jay Kamat
968367b042
Simplify logic for checking if an element is a frame 2018-01-19 15:25:03 -05:00
Artur Shaikhullin
1e3f11ca13 Fix eslint warnings 2018-01-19 23:17:03 +06:00
Artur Shaikhullin
22d77fadd7 Eliminate caret blinking 2018-01-19 22:40:47 +06:00
Artur Shaikhullin
2d2d71512f Add initial comment 2018-01-19 22:31:12 +06:00
Artur Shaikhullin
79766aa65b Add chromium license 2018-01-19 22:28:49 +06:00