Discussion:
[chromium-dev] Re: Best way to load an svg into a webui page
Joe Mason
2018-11-21 20:26:24 UTC
Permalink
Hmm, I thought I had subscribed to this group from my @google.com address,
but this mail didn't show up. Trying again...
I have an svg file to display on a subpage of chrome://settings. Since
it's part of the Google branding, the svg file is checked into the internal
src tree. Currently this is stored in the binary as an IDR_FOO and mapped
to chrome://settings/name-of-file.svg (using
WebUIDataSource::AddResourcePath), then displayed on the page with <img
src="chrome://settings/name-of-file.svg">.
The problem is that the .svg contains <title> and <aria-labelled-by>
attributes to tell screen readers what to substitute for the image, and
those are being ignored. As far as I can tell, the screen reader I'm
testing with (JAWS on windows) only sees these attributes in <svg> elements
in the page. So what I'd like to do is replace that <img> node with the
contents of the .svg file (which is an <svg> doc itself).
I tried replacing the <img> with a <span> and using fetch() to load
chrome://settings/name-of-file.svg and set the span's innerHTML to the
result. But this fails because chrome:// is not a recognized scheme for
fetch. I assume this would be true of XHR too, but I haven't tried it yet.
I've got this working by replacing the <img> with <embed
src="chrome://settings/name-of-file.svg">. But that requires me to weaken
the content security policy on chrome://settings to allow embedding, which
+ html_source->OverrideContentSecurityPolicyObjectSrc("object-src
chrome:;");
+ html_source->OverrideContentSecurityPolicyChildSrc("child-src
chrome:;");
+ html_source->DisableDenyXFrameOptions();
(I think I can add a new entry point to WebUIDataSource to override
X-Frame-Options to allow only chrome:, rather than disabling it entirely,
but still. Pretty invasive.)
Is there an easier way to do this that I'm missing?
Thanks,
Joe
--
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAH%3DT95QxR4YdEN%2B_DUbZcfPrt5GeWrQNkjdR4sT22wn1UQSWJw%40mail.gmail.com.
Loading...