Primary eng (and PM) emails
Summary
Deprecate getMatchedCSSRules().
Motivation
It's WebKit-only.
There's an open WebKit bug to remove it with interesting comments:
https://bugs.webkit.org/show_bug.cgi?id=79653
Compatibility Risk
This API was introduced in WebKit in 2005:
http://trac.webkit.org/changeset/11233
"Add support for getMatchedCSSRules, an API that can be used to inspect the set of rules that match on an element. From Obj-C you see all rules (user agent, author, user). From JS you just see author rules."
Removing the API will cause exceptions to be thrown where it's used unconditionally.
Alternative implementation suggestion for web developers
http://stackoverflow.com/questions/2952667/find-all-css-rules-that-apply-to-an-element
While I haven't tried it, this looks promising:
http://www.brothercake.com/site/resources/scripts/cssutilities/
Usage information from UseCounter
https://www.chromestatus.com/metrics/feature/timeline/popularity/155
In July, usage came down from ~0.5% and is currently ~0.01%.
Entry on chromestatus.com, crbug.com, or MDN
https://code.google.com/p/chromium/issues/detail?id=437569
Requesting approval to remove too?
No. Usage isn't zero and maybe the deprecation message will shake out some developer feedback on why they need the API.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Can you describe in some more detail what conditions you're trying to
use for filtering? You say "applied CSS properties", but that's
accessible getComputedStyle()
... Are you thinking of hiding stuff
that's styled by a particular stylesheet, using the knowledge that
certain stylesheets are included only to style ads?
How would you do the same thing in Firefox and IE
If there is some use case that makes sense generally, then maybe
something should be standardized. Maybe getMatchedCSSRules() is
exactly the API you need, but I'd like to learn more.
Hi Philip,
On Friday, January 9, 2015 at 4:11:50 PM UTC+1, Philip Jägenstedt wrote:Can you describe in some more detail what conditions you're trying to
use for filtering? You say "applied CSS properties", but that's
accessible getComputedStyle()
...
If there is some use case that makes sense generally, then maybe
something should be standardized. Maybe getMatchedCSSRules() is
exactly the API you need, but I'd like to learn more.While getMatchedCSSRules() in combination with TreeWalker and MutationObserver, seems to work good enough for our purpose, an API that lets us select elements by applied properties and listen to new matching elements added would be nicer:var nodeList = document.getElementsByCSSProperties({margin: 0; color: "red"})nodeList.onadded = function() {}
Or even better, a CSS selector syntax that lets us match elements by applied styles, so all we need to do is injecting a stylesheet:*:prop(margin: 0):prop(color: "red") {display: none;}
On Fri, Jan 9, 2015 at 8:33 AM, <seba...@adblockplus.org> wrote:While getMatchedCSSRules() in combination with TreeWalker and MutationObserver, seems to work good enough for our purpose, an API that lets us select elements by applied properties and listen to new matching elements added would be nicer:var nodeList = document.getElementsByCSSProperties({margin: 0; color: "red"})nodeList.onadded = function() {}This also is going to be very expensive, we'd have to walk the entire page running all the CSS rules a second time since which rules matched are lost after style recalc.I'd suggest instead using your own CSS parser and just calling querySelector on the rules you parsed from it. (You could also use CSSOM).
Or even better, a CSS selector syntax that lets us match elements by applied styles, so all we need to do is injecting a stylesheet:*:prop(margin: 0):prop(color: "red") {display: none;}This is cyclical, you can't implement it because you don't know what properties match until you run the body. Implementing this would also be very expensive, and in general I think we should stop adding expensive selectors and focus on making the ones we have already fast.
On Friday, January 9, 2015 at 10:35:07 PM UTC+1, Elliott Sprehn wrote:On Fri, Jan 9, 2015 at 8:33 AM, <seba...@adblockplus.org> wrote:While getMatchedCSSRules() in combination with TreeWalker and MutationObserver, seems to work good enough for our purpose,
an API that lets us select elements by applied properties and listen to new matching elements added would be nicer:var nodeList = document.getElementsByCSSProperties({margin: 0; color: "red"})nodeList.onadded = function() {}This also is going to be very expensive, we'd have to walk the entire page running all the CSS rules a second time since which rules matched are lost after style recalc.I'd suggest instead using your own CSS parser and just calling querySelector on the rules you parsed from it. (You could also use CSSOM).I don't see how doing that ourselves with JavaScript on (every DOM change!) is any more efficient than having the browser do it for us.
Or even better, a CSS selector syntax that lets us match elements by applied styles, so all we need to do is injecting a stylesheet:*:prop(margin: 0):prop(color: "red") {display: none;}This is cyclical, you can't implement it because you don't know what properties match until you run the body. Implementing this would also be very expensive, and in general I think we should stop adding expensive selectors and focus on making the ones we have already fast.I don't see how this would be different from the :dir() selector.
[side note] Computed CSS-based adblocking is not practical in my opinion.
but also because it can easily be circumvented. E.g. by randomizing properties of values ("red", "RED", "rgb(255,0,0)", "rgb(254,0,0)", "rgba(255,0,0,1)").
2015-01-09 22:47 GMT+01:00 <seba...@adblockplus.org>:On Friday, January 9, 2015 at 10:35:07 PM UTC+1, Elliott Sprehn wrote:On Fri, Jan 9, 2015 at 8:33 AM, <seba...@adblockplus.org> wrote:While getMatchedCSSRules() in combination with TreeWalker and MutationObserver, seems to work good enough for our purpose,
A few months ago, I profiled the use of MutationObservers in an extension for matching specific elements-attribute combinations. On huge pages, the load time increased by 25 - 35% (3-8% with perceivable throttling). In a DOM benchmark with the throttled implementation, the (peek) memory usage tripled.As a popular browser extension vendor, you have to be considerate and not add features that significantly degrade the performance.
an API that lets us select elements by applied properties and listen to new matching elements added would be nicer:var nodeList = document.getElementsByCSSProperties({margin: 0; color: "red"})nodeList.onadded = function() {}This also is going to be very expensive, we'd have to walk the entire page running all the CSS rules a second time since which rules matched are lost after style recalc.I'd suggest instead using your own CSS parser and just calling querySelector on the rules you parsed from it. (You could also use CSSOM).I don't see how doing that ourselves with JavaScript on (every DOM change!) is any more efficient than having the browser do it for us.Implementing this feature is also expensive for browser engines. Your JS code could outperform the browser if there are assumptions that your code can make. E.g. assumptions like "there is no need to process child nodes if an element is matched".
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
--
You received this message because you are subscribed to a topic in the Google Groups "blink-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/blink-dev/fd-QLCiLESQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blink-dev+...@chromium.org.
... } else if (typeof view.getMatchedCSSRules == 'function') { style = new Evernote.ClipStyle(view.getMatchedCSSRules(node), filter); } else { try { if (typeof CSSStyleDeclaration != 'undefined' && node.style instanceof CSSStyleDeclaration && node.style.length > 0) { style = new Evernote.ClipStyle(node.style, filter); } } catch (e) {} }
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
I understand that getMatchedCSSRules is Webkit only and for general consumption deprecation makes sense, however it provides functionality that is extremely useful for developer tools (extensions) and at the moment there is no good alternative. Removing this feature effectively locks away declared user styles leaving only computed styles accessible. Can this not be moved somewhere appropriate to extensions so that these values are not hidden away forever?
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/e751fe36-0edc-4e38-ae73-cfe477c9a082%40chromium.org.