Firefox modifies the "color" property for <a> elements in SVG
Categories
(Core :: SVG, defect)
Tracking
()
People
(Reporter: dholbert, Assigned: longsonr, NeedInfo)
References
()
Details
Attachments
(3 files)
| Reporter | ||
Updated•15 years ago
|
| Reporter | ||
Comment 1•15 years ago
|
||
| Comment hidden (obsolete) |
Comment 3•15 years ago
|
||
| Comment hidden (obsolete) |
| Reporter | ||
Comment 5•15 years ago
|
||
Comment 6•15 years ago
|
||
| Assignee | ||
Comment 7•15 years ago
|
||
| Assignee | ||
Comment 8•5 years ago
|
||
Updated•5 years ago
|
Please be careful of performance numbers with a patch like that. (I'm not sure the servo-based style system has the same performance characteristics, but in the old style system those would have been the most perf-sensitive selectors in the UA sheet.)
Also, does this change match the relevant specs? If not, are there issues on file to update them?
| Assignee | ||
Comment 10•5 years ago
|
||
The SVG specification has never said that <a> elements should have this, I guess specs don't normally say what doesn't happen, they say what does.
Also Safari doesn't do this either.
| Assignee | ||
Comment 11•5 years ago
|
||
Are there perf tests I can run on try that would reveal any impact?
I think it's worth checking whether either the HTML or CSS specifications say this should happen.
For tests, at a minimum I'd look at our existing perf-reftests and talos tests, but heycam or emilio might have more specific suggestions.
| Reporter | ||
Comment 13•5 years ago
|
||
Also FWIW, it seems Chrome/Chromium's behavior has changed on this in the time since this bug was filed -- though their behavior makes no sense & is probably a bug. I'll go ahead and file one. (They render the top line of my testcase as black, for no clear reason.)
| Reporter | ||
Comment 14•5 years ago
|
||
| Reporter | ||
Comment 15•5 years ago
|
||
FWIW, I filed https://bugs.chromium.org/p/chromium/issues/detail?id=1103536 on Chrome's somewhat-odd current behavior (rendering visited SVG links with black as the computed color, overriding the color that the element otherwise would've had/inherited).
Comment 16•5 years ago
|
||
Regarding the performance of these selectors, I think (and Emilio can correct me once he's back from PTO next week if I'm wrong) that we handle :not() efficiently enough now that this shouldn't be a problem.
If it is a problem, then we can work around that pretty easily -- the only elements that can match the link pseudo-classes are HTML a and area, SVG a, and (if you can believe it) any MathML element with an href="" attribute on it. So if you need to you could rewrite these rules as:
html|*:link, math|*:link { color: ... }
...
and probably the change in specificity here wouldn't cause a problem.
For a perf test, you could try something like this, dropped into the perf-reftest-singletons directory (though I wouldn't bother committing this test):
<!DOCTYPE html>
<script src="util.js"></script>
<style id="s"></style>
<script>
window.onload = function() {
let styles = '.x a {}';
let root = document.createElement("div");
for (let i = 0; i < 100000; i++) {
let link = document.createElement("a");
link.className = `y${i}`;
link.href = "x";
root.append(link);
styles += `.y${i} {}`;
}
s.textContent = styles;
document.body.appendChild(root);
flush_style(root);
root.className = "x";
perf_start();
flush_style(root);
perf_finish();
};
</script>
(Open the document and it'll alert the time spent under the second flush_style call, which should re-do selector matching on all of the a elements.)
It's a little noisy on my machine, but if you record the results of say 10 runs of this with and without your patch, it should tell you whether the time spent evaluating the :not(svg|*) is noticeable.
As for specs, the HTML spec has rules in the suggested UA sheets that match only HTML elements, and there are no rules in the SVG 2 spec that set the color on links, though there are rules that set the cursor.
| Reporter | ||
Comment 17•5 years ago
|
||
Worth noting: in Chrome's related bug on this ( https://bugs.chromium.org/p/chromium/issues/detail?id=352912 , which my bug was duped to), there are suggestions from Blink developers that Chrome should align SVG with HTML (i.e. matching Firefox's current behavior).
In particular, this comment:
https://bugs.chromium.org/p/chromium/issues/detail?id=352912#c12
pdr suggests that they align with HTML (which I think would mean visitedness would have an effect). He says this is pretty much resolved at the spec level, but he links to https://github.com/w3c/svgwg/issues/47 which heycam filed & which, by my reading, resolved on saying we should not align with HTML (i.e. visitedness should have no effect).
The spec bug seems most authoritative here & leans in favor of taking this patch. And if we do take this patch, we should weigh in on the Chromium bug to make sure they don't change to match our current (maybe-soon "old") behavior. :)
| Reporter | ||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•3 years ago
|
Comment 18•3 years ago
|
||
There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:longsonr, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Description
•