Commit Graph

107 Commits

Author SHA1 Message Date
tophf
e3e1ecf2d3 don't precompile regexps in storage.js (no gain) 2017-06-25 13:39:22 +03:00
tophf
ac5e9b965a saveStyle's codeIsUpdated can be true or false, not undefined 2017-06-06 04:40:08 +03:00
tophf
d3d3a1f9b5 only global sections are skipped if empty/comment/namespace 2017-05-05 17:21:17 +03:00
tophf
71f4a53b41 fixup! 2017-05-03 19:06:14 +03:00
tophf
5f0b57bebf embed digest in DB as style.originalDigest 2017-05-03 18:58:09 +03:00
tophf
6d65d2a2b6 Expose iframes via HTML[stylus-iframe]
* convert actions to buttons
2017-04-29 03:27:47 +03:00
tophf
33fa5693ed make sure style.id is not 0 in saveStyle 2017-04-28 15:28:52 +03:00
tophf
a22874a898 write/read styleDigest in the backup file 2017-04-28 15:28:50 +03:00
tophf
acc4d83b9d promisify DB access 2017-04-26 01:36:08 +03:00
tophf
7677f0dece updater: add 'ignoreDigest' to force-update on manage page
* saveStyle: retain only known properties in sections[] and normalize their order
* remove styleDigest on import
* shorten detailed status names in updater
* don't autohide update status message
2017-04-26 01:35:14 +03:00
tophf
32ae088c03 Detect and don't update locally edited styles 2017-04-26 01:34:57 +03:00
tophf
3a8ac2d9dc inline reportError() 2017-04-19 19:22:13 +03:00
tophf
4fd1a3db62 remove fixBoolean() 2017-04-19 19:13:11 +03:00
tophf
f5da135e81 invalidateCache: minor refactor & fix deletedId case 2017-04-19 19:03:00 +03:00
tophf
fa46a2c336 split filterStyles()
js engines don't like big functions (V8 often deoptimized the original filterStyles), it also makes sense to extract the less frequently executed code
2017-04-18 12:46:37 +03:00
tophf
dcfb8ad356 simplify/modularize styleSectionsEqual
+ 1.5x speedup thanks to checkedInB memoization
+ more strict type comparison
+ two-way array comparison (more correct, even if there's no practical difference)
2017-04-18 12:46:37 +03:00
tophf
db1dc0df7b simplify/modularize getApplicableSections 2017-04-18 12:46:37 +03:00
tophf
8f784a19d4 simplify saveStyle, invalidateCache 2017-04-18 12:46:37 +03:00
tophf
1749057b91 Explainer for stylusUnavailableForURL message
We don't mention the G+ iframe on CWS stylable only when "Out of process iframes" feature is enabled which can be set manually via chrome://flags/#enable-site-per-process. It's still in development and is known to break some sites, which is why it's not enabled by default.
2017-04-18 12:46:35 +03:00
tophf
5c8d1950a7 Isolate storage.js in background context
To prevent cross-page leaks we need to create/copy prefs and cachedStyles inside the background page context.

* storage.js is now used only in the background page

* messaging.js now contains less bg-specific methods and more common methods. Added saveStyleSafe, deleteStyleSafe which automatically invoke onRuntimeMessage of the current page or just handleUpdate/handleDelete when notify:false

* prefs.js with 'prefs' for background and UI pages: separate objects because a UI page may load before the background page and it can read prefs from localStorage/sync/defaults
2017-04-18 12:46:34 +03:00
tophf
2bb7d31042 fixups for Opera/Vivaldi/Firefox-compatibility 2017-04-18 12:46:32 +03:00
tophf
fcb149ae21 limit broadcast area of prefChanged in notifyAllTabs 2017-04-18 12:46:31 +03:00
tophf
e3b461a9e8 manage: add new UI option
* align svg icons to pixel grid
* globalize enforceInputRange() and use it in manage
* 1 installed.onclick instead of 1000+ local ones
2017-04-18 12:46:31 +03:00
tophf
efd3e9ef6c options: use live prefs + reset button 2017-04-18 12:46:30 +03:00
tophf
c32e968f63 Restore sync for popupWidth; mirror all prefs in localStorage; 2017-04-18 12:46:28 +03:00
tophf
26802e36df Optimize startup: coalesce & debounce prefs.set
Previously prefs.set broadcast many messages per each changed pref value to all open tabs, background page, popups. This lead to repeated and needless updates of various things like the toolbar icon, reapplying of styles, and whatnot. It could easily take more than 100ms on an average computer with many tabs open.

Now we debounce the broadcast & sync.set and coalesce all values in one object which is then sent just once per destination.
2017-04-18 12:46:28 +03:00
tophf
f8d13d8dec Remove code:false mode; show sloppy regexps in popup
* Now that our own pages retrieve the styles directly via getStylesSafe the only 0.001% of cases where code:false would be needed (the browser is starting up with some of the tabs showing our built-in pages like editor or manage) is not worth optimizing for.

* According to CSS4 @document specification the entire URL must match. Stylish-for-Chrome implemented it incorrectly since the very beginning. We detect styles that abuse the bug by finding the sections that would have been applied by Stylish but not by us as we follow the spec. Additionally we'll check for invalid regexps.
2017-04-18 12:46:28 +03:00
tophf
e384657668 Use our beautify-css-mod.js with more options 2017-04-18 12:46:27 +03:00
tophf
6be903e2ad Add UI for 'editor.matchHighlight' option 2017-04-18 12:46:27 +03:00
tophf
1c2c14d231 Correctly omit @namespace-only code in popup + speed up 2017-04-18 12:46:26 +03:00
tophf
4a642f77a5 Cache last 100 getDomains for filterStyles 2017-04-18 12:46:24 +03:00
tophf
78c56352cb Cache compiled regexps 2017-04-18 12:46:24 +03:00
tophf
2ef87e003d Remove webSqlStorage cruft as Stylus never used it 2017-04-18 12:46:23 +03:00
tophf
ac4a420e2b ESLint: customize the rules; fix the issues 2017-04-18 12:46:23 +03:00
tophf
8bcd7f60c5 Restore implicit handleUpdate in saveStyle 2017-04-18 12:46:22 +03:00
tophf
b1c19bdf3d Import styles: show report with Undo button 2017-04-18 12:46:22 +03:00
tophf
d53db2d45c Refactor & speed up styleSectionsEqual 2017-04-18 12:43:30 +03:00
tophf
80130797ce Refactor contextMenus and commands 2017-04-18 12:43:30 +03:00
tophf
95e2263c10 Autocleanup cached filters when over 10k items (a few MB)
Precaution for the [rare but possible] case of users running Stylus for a very long time without restarting the browser.
2017-04-18 12:43:30 +03:00
tophf
2f4da37fdb Refactor and speed up popup & manager
Popup:
* Enforce 200-800px range for the popup width option

Manage:
* faster search via cachedStyles.byId
* faster restoration of search results on history nav
* style name is clickable and opens the editor
* animated highlight of style element on update/add/save
* expandable extra applies-to targets
* remember scroll position on normal history navigation
* boz-sizing in #header, also in editor
* applies-to targets use structured markup
* get*Tab*, enableStyle and deleteStyle are promisified
2017-04-18 12:43:29 +03:00
tophf
9fd067c6e3 Switch editor to add style mode when id=nonexistentstyle 2017-04-18 12:43:29 +03:00
tophf
8c7f7b81f8 Don't recreate editors after save 2017-04-18 12:43:29 +03:00
tophf
f256f558dc IndexedDB getAll to read all styles in one op
Available since Chrome 48, FF44 (or FF27+ using dom.indexedDB.experimental flag)
2017-04-18 12:43:28 +03:00
tophf
f4e689721a Improve style caching, cache requests too, add code:false mode
Previously, when a cache was invalidated and every tab/iframe issued a getStyles request, we previous needlessly accessed IndexedDB for each of these requests. It happened because 1) the global cachedStyles was created only at the end of the async DB-reading, 2) and each style record is retrieved asynchronously so the single threaded JS engine interleaved all these operations. It could easily span a few seconds when many tabs are open and you have like 100 styles.

Now, in getStyles: all requests issued while cachedStyles is being populated are queued and invoked at the end.

Now, in filterStyles: all requests are cached using the request's options combined in a string as a key. It also helps on each navigation because we monitor page loading process at different stages: before, when committed, history traversal, requesting applicable styles by a content script. Icon badge update also may issue a copy of the just issued request by one of the navigation listeners.

Now, the caches are invalidated smartly: style add/update/delete/toggle only purges filtering cache, and modifies style cache in-place without re-reading the entire IndexedDB.

Now, code:false mode for manage page that only needs style meta. It reduces the transferred message size 10-100 times thus reducing the overhead caused by to internal JSON-fication in the extensions API.

Also fast&direct getStylesSafe for own pages; code cosmetics
2017-04-18 12:43:28 +03:00
tophf
764cd1b6de Use the synced show-badge preference on startup 2017-03-19 01:57:19 +03:00
tophf
34cd025487 Use Object.assign instead of shallowMerge 2017-03-16 13:32:12 +03:00
tophf
913df00f35 Don't notify normal tabs if style contents hasn't changed 2017-03-16 13:32:12 +03:00
tophf
e807d41eb7 Refactor manage::codeIsEqual -> storage::styleSectionsEqual 2017-03-16 13:32:12 +03:00
tophf
38006847f7 Don't apply styles until import is finished 2017-03-16 13:32:12 +03:00
Jeremy Schomery
4f83aa1239 possible fix for https://github.com/schomery/stylish-chrome/issues/43#issuecomment-286142529 2017-03-13 19:18:00 +03:30