WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
99677
When using SVG as an image, we should load datauri images when these images are not in the image cache.
https://bugs.webkit.org/show_bug.cgi?id=99677
Summary
When using SVG as an image, we should load datauri images when these images a...
Philip Rogers
Reported
2012-10-17 21:08:28 PDT
Consider an html page with: <img src="leaves.svg"></img> where leaves.svg is: <svg xmlns="
http://www.w3.org/2000/svg
" xmlns:xlink="
http://www.w3.org/1999/xlink
"> <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,[a bunch of base64 data here]"/> </svg> We currently do not support this (likely for security reasons for linking to external files from the embedded SVG) but we should support this usecase.
Attachments
Test file 1 / 2
(227 bytes, text/html)
2012-10-17 21:08 PDT
,
Philip Rogers
no flags
Details
Test file 2 / 2
(401 bytes, image/svg+xml)
2012-10-17 21:09 PDT
,
Philip Rogers
no flags
Details
Patch
(4.24 KB, patch)
2014-06-26 01:59 PDT
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
Patch
(4.22 KB, patch)
2014-08-07 03:07 PDT
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
as requested by Dirk Schulze
(5.09 KB, application/zip)
2014-08-07 09:12 PDT
,
Steven Vachon
no flags
Details
as requested by Dirk Schulze
(5.08 KB, application/zip)
2014-08-07 12:00 PDT
,
Steven Vachon
no flags
Details
Patch
(15.67 KB, patch)
2014-08-08 05:14 PDT
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
Patch
(20.61 KB, patch)
2014-08-08 08:57 PDT
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion
(781.53 KB, application/zip)
2014-08-08 10:17 PDT
,
Build Bot
no flags
Details
as requested by Dirk Schulze
(15.33 KB, application/zip)
2014-08-08 10:27 PDT
,
Steven Vachon
no flags
Details
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion
(780.71 KB, application/zip)
2014-08-08 11:18 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2
(763.55 KB, application/zip)
2014-08-08 13:05 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from webkit-ews-13 for mac-mountainlion-wk2
(766.90 KB, application/zip)
2014-08-08 14:03 PDT
,
Build Bot
no flags
Details
Patch
(29.11 KB, patch)
2014-12-18 15:04 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews105 for mac-mountainlion-wk2
(646.36 KB, application/zip)
2014-12-18 15:43 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from ews100 for mac-mountainlion
(650.13 KB, application/zip)
2014-12-18 16:00 PST
,
Build Bot
no flags
Details
Patch
(121.53 KB, patch)
2014-12-19 19:07 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews105 for mac-mountainlion-wk2
(642.52 KB, application/zip)
2014-12-19 19:46 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from ews101 for mac-mountainlion
(699.63 KB, application/zip)
2014-12-19 19:56 PST
,
Build Bot
no flags
Details
Patch
(126.13 KB, patch)
2014-12-19 21:55 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(134.96 KB, patch)
2015-01-05 15:20 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(129.98 KB, patch)
2015-01-05 20:21 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews105 for mac-mountainlion-wk2
(635.16 KB, application/zip)
2015-01-05 21:07 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from ews100 for mac-mountainlion
(638.57 KB, application/zip)
2015-01-05 21:28 PST
,
Build Bot
no flags
Details
Patch
(134.61 KB, patch)
2015-01-06 15:35 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(135.16 KB, patch)
2015-01-06 16:41 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews101 for mac-mountainlion
(614.16 KB, application/zip)
2015-01-06 18:42 PST
,
Build Bot
no flags
Details
Patch
(42.08 KB, patch)
2015-02-02 15:13 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(41.88 KB, patch)
2015-02-02 19:57 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(41.78 KB, patch)
2015-02-03 14:17 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(41.65 KB, patch)
2015-02-04 11:25 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(16)
View All
Add attachment
proposed patch, testcase, etc.
Philip Rogers
Comment 1
2012-10-17 21:08:58 PDT
Created
attachment 169333
[details]
Test file 1 / 2
Philip Rogers
Comment 2
2012-10-17 21:09:21 PDT
Created
attachment 169334
[details]
Test file 2 / 2
danya.postfactum
Comment 3
2013-05-11 06:00:35 PDT
If you open in the window an svg image first, then load a document, containing this image in the same window, the image will display data:uri picture.
Allan Sandfeld Jensen
Comment 4
2014-06-26 01:59:44 PDT
Created
attachment 233895
[details]
Patch
Dirk Schulze
Comment 5
2014-06-26 02:20:32 PDT
(In reply to
comment #4
)
> Created an attachment (id=233895) [details] > Patch
Does the patch respect the fact that no further resources are allowed to be fetched from the dataURI in SVG images? No CSS, no scripts, no images, no <use> reference to external document, <iframe>, -webkit-mask, -webkit-filter and so on?
Dirk Schulze
Comment 6
2014-06-26 02:25:13 PDT
Comment on
attachment 233895
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=233895&action=review
r- to make sure that this does not just get landed as is.
> Source/WebCore/ChangeLog:7 > + in a SVG images was not loaded in most cases.
On purpose!
> Source/WebCore/ChangeLog:11 > + This patch enables auto-loading of images. This only affects data > + URLs since the dummy chrome and page of SVG images still do not > + have a NetworkingContext.
Again, on purpose! No network requests at all from content of SVG images... dataURLs should be interpreted but the same restrictions apply here as well of course.
> Source/WebCore/svg/graphics/SVGImage.cpp:367 > + m_page->settings()->setLoadsImagesAutomatically(true);
Hm, in theory this allows loading further resources. Is that blocked at a different place? Could you point out where? Please also add a comment that we need to be very careful that this does not do any network requests.
> LayoutTests/svg/in-html/resources/embedded.svg:3 > + <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/>
Please add examples with an SVG that loads another image decoded with dataURL.
Allan Sandfeld Jensen
Comment 7
2014-06-26 03:21:38 PDT
(In reply to
comment #6
)
> (From update of
attachment 233895
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=233895&action=review
> > r- to make sure that this does not just get landed as is. > > > Source/WebCore/ChangeLog:7 > > + in a SVG images was not loaded in most cases. > > On purpose! >
On purpose that they CAN be loaded but just happens not to be unless something else triggers them to load? Currently the SVGImage allows images, but just doesn't trigger the load on its own. If the same SVG or something else with the same resource loads the URL, then the SVGImage will also show the image. We should either autoload the images that are allowed by canRequest and canDisplay logic, or we should disallow images completely.
> > Source/WebCore/ChangeLog:11 > > + This patch enables auto-loading of images. This only affects data > > + URLs since the dummy chrome and page of SVG images still do not > > + have a NetworkingContext. > > Again, on purpose! No network requests at all from content of SVG images... dataURLs should be interpreted but the same restrictions apply here as well of course.
I know, I wasn't complaining about that. This is just why the patch is safe, there are not NetworkingContext which means no network resources can be loaded.
> > > Source/WebCore/svg/graphics/SVGImage.cpp:367 > > + m_page->settings()->setLoadsImagesAutomatically(true); > > Hm, in theory this allows loading further resources. Is that blocked at a different place? Could you point out where? Please also add a comment that we need to be very careful that this does not do any network requests.
It is blocked because a) there is no networking context and b) canRequest/canDisplay would not allow it.
> > > LayoutTests/svg/in-html/resources/embedded.svg:3 > > + <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/> > > Please add examples with an SVG that loads another image decoded with dataURL.
I am not sure I follow.
Dirk Schulze
Comment 8
2014-06-26 04:07:44 PDT
(In reply to
comment #6
)
> > LayoutTests/svg/in-html/resources/embedded.svg:3 > > + <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/> > > Please add examples with an SVG that loads another image decoded with dataURL.
<img src="image.svg"> Where image.svg has an element <image xlink:href="data:image/svg+xml;utf8,<svg xmlns='
http://www.w3.org/2000/svg
' width='10' height='10'><image xlink:href='image.png' width='10' height='10'/></svg>"/>
Steven Vachon
Comment 9
2014-07-21 03:47:40 PDT
http://www.svachon.com/webframes/examples.html
The non-vector examples do not work in WebKit/Safari, but they work everywhere else. Please fix this in time for Safari 8's release.
Steven Vachon
Comment 10
2014-08-06 09:56:21 PDT
Hello? Does anyone give a fuck?
Allan Sandfeld Jensen
Comment 11
2014-08-07 02:47:16 PDT
(In reply to
comment #8
)
> (In reply to
comment #6
) > > > LayoutTests/svg/in-html/resources/embedded.svg:3 > > > + <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/> > > > > Please add examples with an SVG that loads another image decoded with dataURL. > > <img src="image.svg"> > > Where image.svg has an element <image xlink:href="data:image/svg+xml;utf8,<svg xmlns='
http://www.w3.org/2000/svg
' width='10' height='10'><image xlink:href='image.png' width='10' height='10'/></svg>"/>
That wouldn't work. It can only load dataurl images.
Allan Sandfeld Jensen
Comment 12
2014-08-07 03:07:59 PDT
Created
attachment 236182
[details]
Patch
Dirk Schulze
Comment 13
2014-08-07 05:59:24 PDT
Comment on
attachment 236182
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=236182&action=review
> Source/WebCore/ChangeLog:7 > + in a SVG images was not loaded in most cases.
What does "most cases" mean? When did it work?
> Source/WebCore/ChangeLog:11 > + URLs since the dummy chrome and page of SVG images still do not > + have a NetworkingContext.
I would like to have that phrased differently. Otherwise someone believes that we will allow SVGImage to fetch further image resources... which we don't.
> Source/WebCore/svg/graphics/SVGImage.cpp:367 > + m_page->settings().setLoadsImagesAutomatically(true);
Hm, I would like to see a safety mechanism that ALWAYS disallows real image fetches. We should never ever process URLs that are something different than dataURLs. This would probably include a mechanism that actively avoids the dataURL document (assuming it is an SVG image itself) to ever load further resources. We might have that in the loader, but I am not sure. Could you check if we have this in place? And if yes, if it is strong enough? Please add a comment of your finding to the bug report. I fear that some one "fixes" NetworkingContext "issue" and suddenly fetching of further resources is possible. SVGImage must not fetch resources.
> LayoutTests/ChangeLog:17 > + * svg/in-html/resources/embedded.svg: Added.
I would like to see more tests 1) HTML document that loads an SVG image (like nested-data-url.html). The SVG image's <image> element references a *red* PNG. 2) HTML document that loads an SVG image (like nested-data-url.html). The SVG image's <image> element has a dataURL of an SVG image with a green square. 3) HTML document that loads an SVG image (like nested-data-url.html). The SVG image's <image> element has a dataURL of an SVG image which itself contains an <image> element that references a *red* PNG.
Dirk Schulze
Comment 14
2014-08-07 06:06:55 PDT
(In reply to
comment #7
)
> (In reply to
comment #6
) > > (From update of
attachment 233895
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=233895&action=review
> > > > r- to make sure that this does not just get landed as is. > > > > > Source/WebCore/ChangeLog:7 > > > + in a SVG images was not loaded in most cases. > > > > On purpose! > > > > On purpose that they CAN be loaded but just happens not to be unless something else triggers them to load? Currently the SVGImage allows images, but just doesn't trigger the load on its own. If the same SVG or something else with the same resource loads the URL, then the SVGImage will also show the image.
Wow! That should not happen at all! SVGImage should not display the image and definitely not load the image from an SVGImage. Both cases are security concerns.
> > We should either autoload the images that are allowed by canRequest and canDisplay logic, or we should disallow images completely.
With the exceptions of Blobs and dataURLs they should be disabled completely. dataURLs are not allowed to trigger resource fetching and are not allowed to draw images that required resource fetching.
> > > > Source/WebCore/ChangeLog:11 > > > + This patch enables auto-loading of images. This only affects data > > > + URLs since the dummy chrome and page of SVG images still do not > > > + have a NetworkingContext. > > > > Again, on purpose! No network requests at all from content of SVG images... dataURLs should be interpreted but the same restrictions apply here as well of course. > > I know, I wasn't complaining about that. This is just why the patch is safe, there are not NetworkingContext which means no network resources can be loaded.
See review from patch above. What makes sure that we still won't fetch an image if someone fixes the NetworkingContext "issue"?
> > > > > > Source/WebCore/svg/graphics/SVGImage.cpp:367 > > > + m_page->settings()->setLoadsImagesAutomatically(true); > > > > Hm, in theory this allows loading further resources. Is that blocked at a different place? Could you point out where? Please also add a comment that we need to be very careful that this does not do any network requests. > > It is blocked because a) there is no networking context and b) canRequest/canDisplay would not allow it.
The first part would satisfy my fetching concerns. Didn't you say that we still display resources when they were fetched by something else? So canDisplay doesn't seem to work?
> > > > > > LayoutTests/svg/in-html/resources/embedded.svg:3 > > > + <image x="20" y="20" width="30px" height="30px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/> > > > > Please add examples with an SVG that loads another image decoded with dataURL. > > I am not sure I follow.
I hope it gets clear with the review.
Allan Sandfeld Jensen
Comment 15
2014-08-07 06:53:03 PDT
(In reply to
comment #13
)
> (From update of
attachment 236182
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=236182&action=review
> > > Source/WebCore/ChangeLog:7 > > + in a SVG images was not loaded in most cases. > > What does "most cases" mean? When did it work? >
The data-url images are allowed, but not loaded. If something else loads the same data-url the SVG will show it.
> > Source/WebCore/ChangeLog:11 > > + URLs since the dummy chrome and page of SVG images still do not > > + have a NetworkingContext. > > I would like to have that phrased differently. Otherwise someone believes that we will allow SVGImage to fetch further image resources... which we don't. >
Okay.
> > Source/WebCore/svg/graphics/SVGImage.cpp:367 > > + m_page->settings().setLoadsImagesAutomatically(true); > > Hm, I would like to see a safety mechanism that ALWAYS disallows real image fetches. We should never ever process URLs that are something different than dataURLs. This would probably include a mechanism that actively avoids the dataURL document (assuming it is an SVG image itself) to ever load further resources. We might have that in the loader, but I am not sure. Could you check if we have this in place? And if yes, if it is strong enough? Please add a comment of your finding to the bug report.
We already have mechanisms for that that check our policies and enforce them. This patch only deals with the case of images that our policy checked allowed but just wasn't loaded. It is a few months since I digged through this, but as remember it there are two important checks in SecurityOrigin canRequest and canDisplay. In this case of data-urls canDisplay allows it, but with blob-urls it delegates to canRequest(). Data URLs are for the checking policy also considered unique origins, so they are not allowed to load anything else.
Steven Vachon
Comment 16
2014-08-07 09:12:57 PDT
Created
attachment 236188
[details]
as requested by Dirk Schulze nested-data-url.html green-embedded-embedded.svg green-embedded.svg green-referenced-embedded.svg green-referenced.svg green.svg red-embedded-embedded.svg red-embedded.svg red-referenced-embedded.svg red-referenced.svg red.png
Dirk Schulze
Comment 17
2014-08-07 09:45:20 PDT
https://bugs.webkit.org/attachment.cgi?id=236188&action=edit(In
reply to
comment #16
)
> Created an attachment (id=236188) [details] > as requested by Dirk Schulze > > nested-data-url.html > > green-embedded-embedded.svg > green-embedded.svg > green-referenced-embedded.svg > green-referenced.svg > green.svg > red-embedded-embedded.svg > red-embedded.svg > red-referenced-embedded.svg > red-referenced.svg > red.png
Oh, not two colors per test case... the colors should be an indicator... if you see red, the test doesn't pass. That is why the SVGImage with external references should all embed red pictures.... in cases where it is ok (dataURL without references) it should be green. So green-referenced-embedded.svg is not correct for instance. Please add the tests to the patch. They look good to me.
Steven Vachon
Comment 18
2014-08-07 09:53:41 PDT
I'd thought you wanted green to distinguish vector from raster. Would you like the tests updated?
Dirk Schulze
Comment 19
2014-08-07 10:21:51 PDT
(In reply to
comment #18
)
> I'd thought you wanted green to distinguish vector from raster. Would you like the tests updated?
The color red is used as an indicator: If you see red it means something went wrong. So the tests where the image should NOT load and/or display, the referenced image should be red. Where you DO want to see the image (because it is a datURL without further resource fetches) it should be green or at least not red.
Steven Vachon
Comment 20
2014-08-07 12:00:54 PDT
Created
attachment 236204
[details]
as requested by Dirk Schulze (In reply to
comment #19
)
> The color red is used as an indicator: If you see red it means something went wrong. So the tests where the image should NOT load and/or display, the referenced image should be red. Where you DO want to see the image (because it is a datURL without further resource fetches) it should be green or at least not red.
Updated. You guys will have to add it to the patch, though, as I do not write C.
Allan Sandfeld Jensen
Comment 21
2014-08-08 05:14:53 PDT
Created
attachment 236278
[details]
Patch
Dirk Schulze
Comment 22
2014-08-08 06:18:22 PDT
Comment on
attachment 236278
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=236278&action=review
Nearly there. Just some more updates to the tests.
> LayoutTests/ChangeLog:21 > + * svg/in-html/nested-data-url.html: Added.
I didn't see a reference file so that we run reference tests. Could you please add one?
> LayoutTests/svg/in-html/resources/raster-referenced-embedded.svg:3 > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJyYXN0ZXIucG5nIi8+Cgo8L3N2Zz4="/>
This should be an red image that is referenced.
> LayoutTests/svg/in-html/resources/raster-referenced.svg:3 > +<image width="100" height="100" xlink:href="raster.png"/>
This should reference a red image. Loading would be an error.
> LayoutTests/svg/in-html/resources/vector-referenced-embedded.svg:3 > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJ2ZWN0b3Iuc3ZnIi8+Cgo8L3N2Zz4="/>
This should be a reference to a red image. Because it would be an error if it is displayed.
> LayoutTests/svg/in-html/resources/vector-referenced.svg:3 > +<image width="100" height="100" xlink:href="vector.svg"/>
vector.svg should be a red image. If it loads, then this is a bug.
Allan Sandfeld Jensen
Comment 23
2014-08-08 06:58:03 PDT
(In reply to
comment #22
)
> (From update of
attachment 236278
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=236278&action=review
> > Nearly there. Just some more updates to the tests. > > > LayoutTests/ChangeLog:21 > > + * svg/in-html/nested-data-url.html: Added. > > I didn't see a reference file so that we run reference tests. Could you please add one? > > > LayoutTests/svg/in-html/resources/raster-referenced-embedded.svg:3 > > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJyYXN0ZXIucG5nIi8+Cgo8L3N2Zz4="/> > > This should be an red image that is referenced. > > > LayoutTests/svg/in-html/resources/raster-referenced.svg:3 > > +<image width="100" height="100" xlink:href="raster.png"/> > > This should reference a red image. Loading would be an error. > > > LayoutTests/svg/in-html/resources/vector-referenced-embedded.svg:3 > > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJ2ZWN0b3Iuc3ZnIi8+Cgo8L3N2Zz4="/> > > This should be a reference to a red image. Because it would be an error if it is displayed. > > > LayoutTests/svg/in-html/resources/vector-referenced.svg:3 > > +<image width="100" height="100" xlink:href="vector.svg"/> > > vector.svg should be a red image. If it loads, then this is a bug.
Yes, half them should be red. I left them in so that are also testing that they can't load further images. I will see what I can do about the reference.
Dirk Schulze
Comment 24
2014-08-08 08:13:50 PDT
(In reply to
comment #23
)
> (In reply to
comment #22
) > > (From update of
attachment 236278
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=236278&action=review
> > > > Nearly there. Just some more updates to the tests. > > > > > LayoutTests/ChangeLog:21 > > > + * svg/in-html/nested-data-url.html: Added. > > > > I didn't see a reference file so that we run reference tests. Could you please add one? > > > > > LayoutTests/svg/in-html/resources/raster-referenced-embedded.svg:3 > > > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJyYXN0ZXIucG5nIi8+Cgo8L3N2Zz4="/> > > > > This should be an red image that is referenced. > > > > > LayoutTests/svg/in-html/resources/raster-referenced.svg:3 > > > +<image width="100" height="100" xlink:href="raster.png"/> > > > > This should reference a red image. Loading would be an error. > > > > > LayoutTests/svg/in-html/resources/vector-referenced-embedded.svg:3 > > > +<image width="100" height="100" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgoKPGltYWdlIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB4bGluazpocmVmPSJ2ZWN0b3Iuc3ZnIi8+Cgo8L3N2Zz4="/> > > > > This should be a reference to a red image. Because it would be an error if it is displayed. > > > > > LayoutTests/svg/in-html/resources/vector-referenced.svg:3 > > > +<image width="100" height="100" xlink:href="vector.svg"/> > > > > vector.svg should be a red image. If it loads, then this is a bug. > > Yes, half them should be red. I left them in so that are also testing that they can't load further images.
Pleases let the tests in! They are great. There should just be red images for the cases where we do not expect image loading.
> > I will see what I can do about the reference.
Thanks!
Allan Sandfeld Jensen
Comment 25
2014-08-08 08:56:33 PDT
(In reply to
comment #24
)
> Pleases let the tests in! They are great. There should just be red images for the cases where we do not expect image loading. >
I think the red background-color showing where an image is lacking is enough. I just have to make sure it doesn't show the 'missing image' image.
Allan Sandfeld Jensen
Comment 26
2014-08-08 08:57:32 PDT
Created
attachment 236281
[details]
Patch
Steven Vachon
Comment 27
2014-08-08 09:00:58 PDT
I'm updating the tests. They'll be ready soon. Also adding "direct" tests involving iframes.
Build Bot
Comment 28
2014-08-08 10:17:32 PDT
Comment on
attachment 236281
[details]
Patch
Attachment 236281
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/6110123193794560
New failing tests: svg/in-html/nested-data-url.html
Build Bot
Comment 29
2014-08-08 10:17:38 PDT
Created
attachment 236285
[details]
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-05 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Steven Vachon
Comment 30
2014-08-08 10:27:07 PDT
Created
attachment 236286
[details]
as requested by Dirk Schulze iframe-svg-image-dataurl/ iframe-svg-image-reference/ img-svg-image-dataurl/ img-svg-image-reference/ stylesheet.css
Build Bot
Comment 31
2014-08-08 11:18:48 PDT
Comment on
attachment 236281
[details]
Patch
Attachment 236281
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/6345089848705024
New failing tests: svg/in-html/nested-data-url.html
Build Bot
Comment 32
2014-08-08 11:18:56 PDT
Created
attachment 236290
[details]
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-04 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 33
2014-08-08 13:05:19 PDT
Comment on
attachment 236281
[details]
Patch
Attachment 236281
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/5092397138575360
New failing tests: svg/in-html/nested-data-url.html
Build Bot
Comment 34
2014-08-08 13:05:36 PDT
Created
attachment 236300
[details]
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-09 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Steven Vachon
Comment 35
2014-08-08 13:27:33 PDT
Please add (id=236286)[#236286] to the patch.
Build Bot
Comment 36
2014-08-08 14:03:16 PDT
Comment on
attachment 236281
[details]
Patch
Attachment 236281
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/5712084683718656
New failing tests: svg/in-html/nested-data-url.html
Build Bot
Comment 37
2014-08-08 14:03:24 PDT
Created
attachment 236303
[details]
Archive of layout-test-results from webkit-ews-13 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-13 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Darin Adler
Comment 38
2014-08-11 22:52:14 PDT
Comment on
attachment 236281
[details]
Patch svg/in-html/nested-data-url.html is failing on the two Mac EWS bots
Allan Sandfeld Jensen
Comment 39
2014-08-11 23:21:03 PDT
(In reply to
comment #38
)
> (From update of
attachment 236281
[details]
) > svg/in-html/nested-data-url.html is failing on the two Mac EWS bots
Yes I noticed, and the failure looks like the data-url image is not loaded at all, but my original reference test in the 7th of August patch did pass on the bots.
Steven Vachon
Comment 40
2014-08-13 08:30:47 PDT
Add the latest tests to the patch, please. They're in
https://bugs.webkit.org/attachment.cgi?id=236286
Steven Vachon
Comment 41
2014-09-06 06:19:29 PDT
I guess that no one cares about this bug.
Alexey Proskuryakov
Comment 42
2014-10-22 20:03:20 PDT
***
Bug 137941
has been marked as a duplicate of this bug. ***
Alexey Proskuryakov
Comment 43
2014-10-22 20:03:31 PDT
***
Bug 118068
has been marked as a duplicate of this bug. ***
Said Abou-Hallawa
Comment 44
2014-11-03 14:47:25 PST
The bug is not repro anymore. We explicitly disallow loading external resources loaded by an SVG referenced in an <img> tag expect for data uri. Please see
https://bugs.webkit.org/show_bug.cgi?id=137762
.
Steven Vachon
Comment 45
2014-11-03 15:18:18 PST
"You are not authorized to access
bug #137762
." ?
Said Abou-Hallawa
Comment 46
2014-11-03 16:16:38 PST
I was wrong. The bug is still repro but the image should not be in the cache. I loaded the svg first which puts in the cache. Then when I loaded the page, the image was in the cache so it was displaying fine. So I am reopening the bug.
Said Abou-Hallawa
Comment 47
2014-11-03 17:24:26 PST
(In reply to
comment #45
)
> "You are not authorized to access
bug #137762
." > ?
Because this a security bug. You have to ask some one from the security team to give you access to it.
Said Abou-Hallawa
Comment 48
2014-12-18 15:04:30 PST
Created
attachment 243522
[details]
Patch
Said Abou-Hallawa
Comment 49
2014-12-18 15:15:56 PST
I think the original patch was incorrect. I think there was also a confusion about whether this patch fixed the bug or not. If the svg image was loaded as a standalone file before loading the the html, the bug does not happen. And this might explains why the test in the patch was not passing in Bot.
Build Bot
Comment 50
2014-12-18 15:43:21 PST
Comment on
attachment 243522
[details]
Patch
Attachment 243522
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/4606574513356800
New failing tests: fast/forms/basic-buttons.html compositing/tiling/huge-layer-img.html
Build Bot
Comment 51
2014-12-18 15:43:26 PST
Created
attachment 243525
[details]
Archive of layout-test-results from ews105 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Build Bot
Comment 52
2014-12-18 16:00:16 PST
Comment on
attachment 243522
[details]
Patch
Attachment 243522
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/6210498911535104
New failing tests: fast/forms/basic-buttons.html compositing/tiling/huge-layer-img.html
Build Bot
Comment 53
2014-12-18 16:00:22 PST
Created
attachment 243527
[details]
Archive of layout-test-results from ews100 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Said Abou-Hallawa
Comment 54
2014-12-18 20:13:56 PST
Comment on
attachment 243522
[details]
Patch Looking at the failures.
Said Abou-Hallawa
Comment 55
2014-12-19 19:07:09 PST
Created
attachment 243601
[details]
Patch
Build Bot
Comment 56
2014-12-19 19:46:00 PST
Comment on
attachment 243601
[details]
Patch
Attachment 243601
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/4527628182618112
New failing tests: fast/forms/basic-buttons.html
Build Bot
Comment 57
2014-12-19 19:46:06 PST
Created
attachment 243602
[details]
Archive of layout-test-results from ews105 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Build Bot
Comment 58
2014-12-19 19:56:09 PST
Comment on
attachment 243601
[details]
Patch
Attachment 243601
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/6128451614408704
New failing tests: fast/forms/basic-buttons.html
Build Bot
Comment 59
2014-12-19 19:56:15 PST
Created
attachment 243603
[details]
Archive of layout-test-results from ews101 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Said Abou-Hallawa
Comment 60
2014-12-19 21:55:32 PST
Created
attachment 243605
[details]
Patch
Daniel Bates
Comment 61
2014-12-23 15:51:51 PST
Comment on
attachment 243605
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=243605&action=review
> Source/WebCore/ChangeLog:8 > + Loading data URI SVG resources should bypass the security checks and should happen
The phrase "bypass the security checks" doesn't sounds good. Can you elaborate on the security checks that prevented the load of a data URL in an SVG document embedded in an HTML document? How does making data URL loading synchronous fix this SVG issue?
> Source/WebCore/ChangeLog:10 > + synchronously. The workflow of loading external resources is not suitable for loading > + data URI resources. Once the data URI is set to the resource link attribute, the data
Can you elaborate on why the "workflow of loading external resources is not suitable for loading data URI resources"?
> Source/WebCore/ChangeLog:11 > + of the resource is parsed form the URI and set to the resource. The resource is marked
Nit: form => from
> Source/WebCore/ChangeLog:26 > + This is a debug code for checking recursive calls to loadPendingResources(). The code
Nit: "is a" => is
> Source/WebCore/css/StyleResolver.cpp:3654 > + static Vector<Document*>* vector = new Vector<Document*>();
Nit: We should use NeverDestroyed<> (*) here and have this function return a reference instead of heap allocating Vector(), as a means to prevent its destructor from being called, and returning a pointer. See the documentation at the top of Source/WTF/wtf/NeverDestroyed.h for more details, including a usage example: <
http://trac.webkit.org/browser/trunk/Source/WTF/wtf/NeverDestroyed.h?rev=169518#L34
>.
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:135 > + // Data URI images can be processed synchronously and avoid using the resource loader. > + if (type == CachedResource::ImageResource && request.url().protocolIsData()) { > + String mimeType, charset; > + RefPtr<SharedBuffer> buffer = parseDataURL(request.url().string(), mimeType, charset); > + > + if (buffer) { > + ResourceResponse response(request.url(), mimeType, buffer->size(), charset); > + resource->responseReceived(response); > + > + // finialize the loading will set the resouce actual data > + resource->finishLoading(buffer.get()); > + resource->finish(); > + } > + }
Can you elaborate on the necessity of this code given that we don't seem to have similar parsing/loading logic in WebCore for loading a data URL with respect to a HTML Image element?
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:520 > + if (((policy != Use && resource->status() != CachedResource::Cached) || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) {
This is incorrect for non-data URLs because a server may request that a resource not be cached (via the HTTP Cache-Control header(*)) among other cache policy options. (*) "Cache Control Extensions", Hypertext Transfer Protocol -- HTTP 1.1 (RFC2616), <
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.6
>
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:555 > + CachedResourceHandle<CachedResource> newResource = createAndLoadResource(resource->type(), resource->resourceRequest(), resource->encoding(), resource->sessionID());
Can you elaborate on this change? Specifically, when does a data URL need to be revalidated?
> Source/WebCore/platform/URL.cpp:1967 > + return extractMIMETypeFromMediaType(mediaType);
This doesn't seem correct. While we may be able to get away with using extractMIMETypeFromMediaType() to extract the MIME type, its parsing rules are with respect to parsing HTTP headers, in particular the HTTP Content Type header.
> Source/WebCore/platform/URL.cpp:2011 > +PassRefPtr<SharedBuffer> parseDataURL(const String& url, String& mimeType, String& charset) > +{ > + String mediaType = mediaTypeFromDataURL(url); > + if (mediaType.isEmpty()) > + return nullptr; > + > + // Skip "data:", mediaType and the seprator ",|;" at the end > + String data = url.substring(5 + mediaType.length() + 1); > + > + bool base64 = mediaType.endsWith(";base64", false); > + if (base64) > + mediaType = mediaType.left(mediaType.length() - 7); > + > + if (mediaType.isEmpty()) > + mediaType = "text/plain,"; > + > + mimeType = extractMIMETypeFromMediaType(mediaType); > + charset = extractCharsetFromMediaType(mediaType); > + > + if (charset.isEmpty()) > + charset = "US-ASCII"; > + > + if (base64) { > + data = decodeURLEscapeSequences(data); > + Vector<char> result; > + base64Decode(data, result, Base64IgnoreWhitespace); > + return SharedBuffer::create(result.data(), result.size()); > + } > + > + TextEncoding encoding(charset); > + data = decodeURLEscapeSequences(data, encoding); > + return SharedBuffer::create(data.characters8(), data.length()); > +}
I haven't looked over this code in detail. I'll wait for your reply with regards to whether we need such logic in WebCore. If so, then I'll review this code.
Said Abou-Hallawa
Comment 62
2015-01-05 15:20:21 PST
Created
attachment 244011
[details]
Patch
Said Abou-Hallawa
Comment 63
2015-01-05 16:01:26 PST
(In reply to
comment #61
)
> Comment on
attachment 243605
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=243605&action=review
> > > Source/WebCore/ChangeLog:8 > > + Loading data URI SVG resources should bypass the security checks and should happen > > The phrase "bypass the security checks" doesn't sounds good. Can you > elaborate on the security checks that prevented the load of a data URL in an > SVG document embedded in an HTML document? How does making data URL loading > synchronous fix this SVG issue? >
Fixed. Loading resources expect for top-level documents is prevented. For example, an SVG document, which is created from an <img> tag, can't load any sub-resource. For data uri, the image is already loaded. All we need to do is to decoded the text and create the resource data object.
> > Source/WebCore/ChangeLog:10 > > + synchronously. The workflow of loading external resources is not suitable for loading > > + data URI resources. Once the data URI is set to the resource link attribute, the data > > Can you elaborate on why the "workflow of loading external resources is not > suitable for loading data URI resources"? >
Answered above.
> > Source/WebCore/ChangeLog:11 > > + of the resource is parsed form the URI and set to the resource. The resource is marked > > Nit: form => from >
Done.
> > Source/WebCore/ChangeLog:26 > > + This is a debug code for checking recursive calls to loadPendingResources(). The code > > Nit: "is a" => is >
Done.
> > Source/WebCore/css/StyleResolver.cpp:3654 > > + static Vector<Document*>* vector = new Vector<Document*>(); > > Nit: We should use NeverDestroyed<> (*) here and have this function return a > reference instead of heap allocating Vector(), as a means to prevent its > destructor from being called, and returning a pointer. See the documentation > at the top of Source/WTF/wtf/NeverDestroyed.h for more details, including a > usage example: > <
http://trac.webkit.org/browser/trunk/Source/WTF/wtf/NeverDestroyed
. > h?rev=169518#L34>. >
Done.
> > Source/WebCore/loader/cache/CachedResourceLoader.cpp:135 > > + // Data URI images can be processed synchronously and avoid using the resource loader. > > + if (type == CachedResource::ImageResource && request.url().protocolIsData()) { > > + String mimeType, charset; > > + RefPtr<SharedBuffer> buffer = parseDataURL(request.url().string(), mimeType, charset); > > + > > + if (buffer) { > > + ResourceResponse response(request.url(), mimeType, buffer->size(), charset); > > + resource->responseReceived(response); > > + > > + // finialize the loading will set the resouce actual data > > + resource->finishLoading(buffer.get()); > > + resource->finish(); > > + } > > + } > > Can you elaborate on the necessity of this code given that we don't seem to > have similar parsing/loading logic in WebCore for loading a data URL with > respect to a HTML Image element? >
I believe loading the data uri synchronously is the right way because, actually we do not load any data. All we need to do is decoding the text and creating the resource data object. To me, it does not make sense to change all the sub-resource loading workflow and security checks and go though a different thread and wait for the resource-loaded notification just because we do not want to do the decoding. If the data uri image is an SVG, extra steps will take place synchronously, like creating an SVG document and resolving its css before finishing loading the top-level document. But this scenario seems to work fine. Also the image onload() event fires only after loading the main document.
> > Source/WebCore/loader/cache/CachedResourceLoader.cpp:520 > > + if (((policy != Use && resource->status() != CachedResource::Cached) || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) { > > This is incorrect for non-data URLs because a server may request that a > resource not be cached (via the HTTP Cache-Control header(*)) among other > cache policy options. > > (*) "Cache Control Extensions", Hypertext Transfer Protocol -- HTTP 1.1 > (RFC2616), <
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.6
>
> Fixed. I wanted something to tell me if the image data resource object is created or not. I changed the code to handle this case more robustly.
> > Source/WebCore/loader/cache/CachedResourceLoader.cpp:555 > > + CachedResourceHandle<CachedResource> newResource = createAndLoadResource(resource->type(), resource->resourceRequest(), resource->encoding(), resource->sessionID()); > > Can you elaborate on this change? Specifically, when does a data URL need to > be revalidated? >
This change is now reverted back. And yes you are right, revalidateResource() should not be called for data uri images.
> > Source/WebCore/platform/URL.cpp:1967 > > + return extractMIMETypeFromMediaType(mediaType); > > This doesn't seem correct. While we may be able to get away with using > extractMIMETypeFromMediaType() to extract the MIME type, its parsing rules > are with respect to parsing HTTP headers, in particular the HTTP Content > Type header. >
The data uri scheme is the following: data:[<MIME-type>][;charset=<encoding>][;base64],<data> The mime-type is the sub-string following the "data:" and before the first sime-colon. If no-sime-colon exists, we get the sub-string before the first comma. And this what extractMIMETypeFromMediaType() does.
> > Source/WebCore/platform/URL.cpp:2011 > > +PassRefPtr<SharedBuffer> parseDataURL(const String& url, String& mimeType, String& charset) > > +{ > > + String mediaType = mediaTypeFromDataURL(url); > > + if (mediaType.isEmpty()) > > + return nullptr; > > + > > + // Skip "data:", mediaType and the seprator ",|;" at the end > > + String data = url.substring(5 + mediaType.length() + 1); > > + > > + bool base64 = mediaType.endsWith(";base64", false); > > + if (base64) > > + mediaType = mediaType.left(mediaType.length() - 7); > > + > > + if (mediaType.isEmpty()) > > + mediaType = "text/plain,"; > > + > > + mimeType = extractMIMETypeFromMediaType(mediaType); > > + charset = extractCharsetFromMediaType(mediaType); > > + > > + if (charset.isEmpty()) > > + charset = "US-ASCII"; > > + > > + if (base64) { > > + data = decodeURLEscapeSequences(data); > > + Vector<char> result; > > + base64Decode(data, result, Base64IgnoreWhitespace); > > + return SharedBuffer::create(result.data(), result.size()); > > + } > > + > > + TextEncoding encoding(charset); > > + data = decodeURLEscapeSequences(data, encoding); > > + return SharedBuffer::create(data.characters8(), data.length()); > > +} > > I haven't looked over this code in detail. I'll wait for your reply with > regards to whether we need such logic in WebCore. If so, then I'll review > this code.
I changed this function a little since the URL precent decoding was not working correctly.
Said Abou-Hallawa
Comment 64
2015-01-05 20:21:54 PST
Created
attachment 244030
[details]
Patch
Build Bot
Comment 65
2015-01-05 21:07:28 PST
Comment on
attachment 244030
[details]
Patch
Attachment 244030
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/6621323807686656
New failing tests: fast/forms/basic-buttons.html
Build Bot
Comment 66
2015-01-05 21:07:44 PST
Created
attachment 244032
[details]
Archive of layout-test-results from ews105 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Build Bot
Comment 67
2015-01-05 21:28:41 PST
Comment on
attachment 244030
[details]
Patch
Attachment 244030
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/4848738728148992
New failing tests: fast/forms/basic-buttons.html
Build Bot
Comment 68
2015-01-05 21:28:46 PST
Created
attachment 244034
[details]
Archive of layout-test-results from ews100 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Alexey Proskuryakov
Comment 69
2015-01-06 13:17:44 PST
Comment on
attachment 244030
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=244030&action=review
> Source/WebCore/ChangeLog:8 > + Loading data URI SVG resources should happen synchronously. The workflow of
Synchronous loading is a change that is observable from JavaScript in many ways (e.g. load events). What do other browsers do? In addition to the compatibility concern, doing synchronous event dispatch is generally bad for security, because an event handler can change the DOM in ways that parser is not prepared to handle.
> Source/WebCore/ChangeLog:51 > + Implement a data URI parser. It was mostly taken from platform/network/DataURL.cpp.
Should DataURL use the code in URL.cpp now? I don't think that we want two copies of the code.
> Source/WebCore/ChangeLog:55 > + * platform/text/TextCodecLatin1.cpp: > + (WebCore::TextCodecLatin1::decode): > + This function has a bug when it goes through the fast decoding path. After copying one or
I think that it should be landed as a separate fix with a regression test of its own.
> Source/WebCore/css/StyleResolver.cpp:3423 > // Re-entering this function will probably mean trouble. Catch it in debug builds.
It is surprising if we now have a code path that can cause re-entering this function from a different document, but not from the same one. I don't think that this can be the case. For example, if you have a load event handler on an element, and the handler is synchronously called while parsing, then the handler can insert another element with a data url source, which will be loaded synchronously too.
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:533 > + // Check if the resource can be loaded synchronously instead of using the resource loader > + if (!synchronousLoadResource(resource->resourceRequest(), request.defer(), resource.get()))
The resource loader doesn't just load resources - it also implements a number of policy checks. What comes to mind immediately is that it can be in a "defersLoading" state, and that there are client calls to inform the application (and WebInspector) about the loading. There is also (theoretically) some scheduling to prioritize more important resources, although I'm not sure if that matters for data: URLs. It might matter.
> Source/WebCore/platform/URL.cpp:1953 > + index = url.find(';');
Is data:text/plain;content a valid data URL? When I load '<iframe src="data:text/plain;content"></iframe>' in shipping Safari, nothing loads, which suggests to me that it's not.
> Source/WebCore/platform/URL.cpp:1958 > + if (index < 5)
I don't think that this can happen. The first 4 characters are "data:", there is no comma or semicolon here.
> Source/WebCore/platform/URL.cpp:1959 > + return "text/plain,"; // Data URLs with no MIME type are considered text/plain.
This needs to be ASCIILiteral(). Also, is this even true? When I do '<iframe src="data:aaaabbb"></iframe>' in shipping Safari, there is nothing rendered, so apparently the URL is not parsed as described here.
> Source/WebCore/platform/URL.cpp:1983 > + if (mediaType.isEmpty()) > + return nullptr;
I didn't find a test for this special case. Does this change behavior compared to CFNetwork data URL loading?
> Source/WebCore/platform/URL.cpp:1985 > + // Skip "data:", mediaType and the seprator ",|;" at the end
Typo: seprator.
> Source/WebCore/platform/URL.cpp:1988 > + bool base64 = mediaType.endsWith(";base64", false);
Is data:text/plain;base64;charset=utf-8,... valid? If so, endsWith is not the right check.
> Source/WebCore/platform/URL.cpp:2010 > + CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables);
This seems quite wasteful - we don't need the data encoded just to be decoded once again.
> LayoutTests/ChangeLog:27 > + * platform/mac/fast/forms/basic-buttons-expected.png: > + * platform/mac/fast/forms/basic-buttons-expected.txt: > + * platform/mac-mavericks/fast/forms/basic-buttons-expected.txt:
EWS fails because this patch also needs to update mac-mountainlion results. You can take them from the uploaded EWS archive.
> LayoutTests/compositing/tiling/huge-layer-img.html:33 > + setTimeout(doDumpTree, 100);
This is not right - a 100 ms timeout will likely be insufficient when running under GuardMalloc, ASan or leaks tool. Even on release builds, we use hyper-threading, which means that some tests run on very slow virtual cores.
Said Abou-Hallawa
Comment 70
2015-01-06 15:35:00 PST
Created
attachment 244103
[details]
Patch
Said Abou-Hallawa
Comment 71
2015-01-06 16:41:26 PST
Created
attachment 244110
[details]
Patch
Said Abou-Hallawa
Comment 72
2015-01-06 16:42:30 PST
(In reply to
comment #69
)
> Comment on
attachment 244030
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=244030&action=review
> > > Source/WebCore/ChangeLog:8 > > + Loading data URI SVG resources should happen synchronously. The workflow of > > Synchronous loading is a change that is observable from JavaScript in many > ways (e.g. load events). What do other browsers do? > > In addition to the compatibility concern, doing synchronous event dispatch > is generally bad for security, because an event handler can change the DOM > in ways that parser is not prepared to handle. >
I do not think this is a concern. All the image onload events are sent only after loading the main document. I included the test svg/as-image/svg-image-with-data-uri-load-event.html to confirm that. The order of completing the resources in a page is random. It depends on the servers' response time and how big the resources are. Since the data uri images are loaded with the main document, it is expected that they should receive their onload events first.
> > Source/WebCore/ChangeLog:51 > > + Implement a data URI parser. It was mostly taken from platform/network/DataURL.cpp. > > Should DataURL use the code in URL.cpp now? I don't think that we want two > copies of the code. >
This file platform/network/DataURL.cpp is not included in the WebKit project
> > Source/WebCore/ChangeLog:55 > > + * platform/text/TextCodecLatin1.cpp: > > + (WebCore::TextCodecLatin1::decode): > > + This function has a bug when it goes through the fast decoding path. After copying one or > > I think that it should be landed as a separate fix with a regression test of > its own. >
I will sort this out once we agree on the approach to fix this bug.
> > Source/WebCore/css/StyleResolver.cpp:3423 > > // Re-entering this function will probably mean trouble. Catch it in debug builds. > > It is surprising if we now have a code path that can cause re-entering this > function from a different document, but not from the same one. I don't think > that this can be the case. > > For example, if you have a load event handler on an element, and the handler > is synchronously called while parsing, then the handler can insert another > element with a data url source, which will be loaded synchronously too. >
This case happen if the css section of a document has a data uri SVG image. To load this image an SVG document has to be created and its css has to be resolved while resolving the css of the main has not finished yet. I included the test svg/as-image/svg-image-with-data-uri-background.html to test this case.
> > Source/WebCore/loader/cache/CachedResourceLoader.cpp:533 > > + // Check if the resource can be loaded synchronously instead of using the resource loader > > + if (!synchronousLoadResource(resource->resourceRequest(), request.defer(), resource.get())) > > The resource loader doesn't just load resources - it also implements a > number of policy checks. What comes to mind immediately is that it can be in > a "defersLoading" state, and that there are client calls to inform the > application (and WebInspector) about the loading. > > There is also (theoretically) some scheduling to prioritize more important > resources, although I'm not sure if that matters for data: URLs. It might > matter. >
I think synchronousLoadResource() might be a misleading name since we do not load anything. The image is already loaded with the main document. I can change the name if this make the fix cleaner. The case for turning imagesEnabled off is covered by the checking defer != CachedResourceRequest::DeferredByClient. I added the test svg/as-image/svg-image-with-data-uri-images-disabled.html to cover this case.
> > Source/WebCore/platform/URL.cpp:1953 > > + index = url.find(';'); > > Is data:text/plain;content a valid data URL? When I load '<iframe > src="data:text/plain;content"></iframe>' in shipping Safari, nothing loads, > which suggests to me that it's not. >
Fixed. The data uri scheme is the following: data:[<MIME-type>][;charset=<encoding>][;base64],<data> This means it has to start with a "data:" and end with ','.
> > Source/WebCore/platform/URL.cpp:1958 > > + if (index < 5) > > I don't think that this can happen. The first 4 characters are "data:", > there is no comma or semicolon here. >
"data:" is 5 characters string :)
> > Source/WebCore/platform/URL.cpp:1959 > > + return "text/plain,"; // Data URLs with no MIME type are considered text/plain. > > This needs to be ASCIILiteral().
Done.
> > Also, is this even true? When I do '<iframe src="data:aaaabbb"></iframe>' in > shipping Safari, there is nothing rendered, so apparently the URL is not > parsed as described here. >
Your data uri is wrong. It has to be <iframe src="data,:aaaabbb"></iframe>'. (I added a comma after "data:").
> > Source/WebCore/platform/URL.cpp:1983 > > + if (mediaType.isEmpty()) > > + return nullptr; > > I didn't find a test for this special case. Does this change behavior > compared to CFNetwork data URL loading? >
I will add a test for this.
> > Source/WebCore/platform/URL.cpp:1985 > > + // Skip "data:", mediaType and the seprator ",|;" at the end > > Typo: seprator. >
Fixed.
> > Source/WebCore/platform/URL.cpp:1988 > > + bool base64 = mediaType.endsWith(";base64", false); > > Is data:text/plain;base64;charset=utf-8,... valid? If so, endsWith is not > the right check. >
The scheme is data:[<MIME-type>][;charset=<encoding>][;base64],<data>. So ";base64" has to come at the end of the media type.
> > Source/WebCore/platform/URL.cpp:2010 > > + CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables); > > This seems quite wasteful - we don't need the data encoded just to be > decoded once again. >
Actually it is needed. decodeURLEscapeSequences(data, encoding) decodes the URL percent text to US-ASCII. If a character is greater than 127, we encode it a double byte character. For example a string "%80" is converted to 0x20ac. And the string has to be converted to 16 bit characters. To convert the string back to single byte string encoding.encode(data, URLEncodedEntitiesForUnencodables) is used.
> > LayoutTests/ChangeLog:27 > > + * platform/mac/fast/forms/basic-buttons-expected.png: > > + * platform/mac/fast/forms/basic-buttons-expected.txt: > > + * platform/mac-mavericks/fast/forms/basic-buttons-expected.txt: > > EWS fails because this patch also needs to update mac-mountainlion results. > You can take them from the uploaded EWS archive. >
Done.
> > LayoutTests/compositing/tiling/huge-layer-img.html:33 > > + setTimeout(doDumpTree, 100); > > This is not right - a 100 ms timeout will likely be insufficient when > running under GuardMalloc, ASan or leaks tool. Even on release builds, we > use hyper-threading, which means that some tests run on very slow virtual > cores.
Done. I increased the time to be 500 ms. However with this patch, this time will not be needed since the image size will be available immediately and the decision for making the tilting will be made faster.
Build Bot
Comment 73
2015-01-06 18:42:27 PST
Comment on
attachment 244110
[details]
Patch
Attachment 244110
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/6479911472594944
New failing tests: fast/css/direct-adjacent-style-update-optimization.html
Build Bot
Comment 74
2015-01-06 18:42:33 PST
Created
attachment 244119
[details]
Archive of layout-test-results from ews101 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Simon Fraser (smfr)
Comment 75
2015-01-06 19:02:21 PST
Comment on
attachment 244110
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=244110&action=review
> Source/WebCore/ChangeLog:62 > + * platform/text/TextCodecLatin1.cpp: > + (WebCore::TextCodecLatin1::decode): > + This function has a bug when it goes through the fast decoding path. After copying one or > + more all ASCII MachineWords from source to the destination, the following byte is copied > + as is from the source to the destination even if it is non ASCII byte. This causes the decoded > + bytes to be incorrect. The fix is to use the mapping table always since it returns the same > + value if the byte is ASCII. An alternative solution is to check isASCII(*source) is true > + before setting *destination = *source. But the function call seems to be more expensive > + than the array indexing. The test imported/mozilla/svg/filters/feSpecularLighting-1.svg was > + failing after applying my patch because of this bug. The expected result is an SVG which > + contains a data uri image.
Can this part of the patch be tested and landed separately?
Alexey Proskuryakov
Comment 76
2015-01-06 19:50:38 PST
> All the image onload events are sent only after loading the main document.
Is this the correct behavior? Why?
> This file platform/network/DataURL.cpp is not included in the WebKit project
You are saying that we don't build it on Mac or iOS, but this is not a good reason to copy/paste code within WebCore, especially for something as important as data URL parsing.
> The data uri scheme is the following:
>
> data:[<MIME-type>][;charset=<encoding>][;base64],<data>
This is what an RFC says, but is this how it works? How did you confirm that?
> Done. I increased the time to be 500 ms. However with this patch, this time will not be needed since the image size will be available immediately and the decision for making the tilting will be made faster.
If the timeout is not needed, then you shouldn't add it. Nothing guarantees that 500 ms is enough either, we should never use any timeouts in layout tests other than 0 ms.
> To convert the string back to single byte string encoding.encode(data, URLEncodedEntitiesForUnencodables) is used.
This still appears wasteful, and we need to structure the code differently.
> > > Source/WebCore/platform/URL.cpp:1958 >> > + if (index < 5) > > > > I don't think that this can happen. The first 4 characters are "data:", > > there is no comma or semicolon here.
>
> "data:" is 5 characters string :)
My comment stands, this is dead code.
Alexey Proskuryakov
Comment 77
2015-01-06 19:53:48 PST
Comment on
attachment 244110
[details]
Patch We should probably talk through the approach in person, but this doesn't address most of my smaller comments on the previous patch, which need to be addressed. Also, please split the decoder fix into a separate bug, it needs to be discussed separately, so keeping it here doesn't help.
Said Abou-Hallawa
Comment 78
2015-01-06 21:27:11 PST
(In reply to
comment #75
)
> Comment on
attachment 244110
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=244110&action=review
> > > Source/WebCore/ChangeLog:62 > > + * platform/text/TextCodecLatin1.cpp: > > + (WebCore::TextCodecLatin1::decode): > > + This function has a bug when it goes through the fast decoding path. After copying one or > > + more all ASCII MachineWords from source to the destination, the following byte is copied > > + as is from the source to the destination even if it is non ASCII byte. This causes the decoded > > + bytes to be incorrect. The fix is to use the mapping table always since it returns the same > > + value if the byte is ASCII. An alternative solution is to check isASCII(*source) is true > > + before setting *destination = *source. But the function call seems to be more expensive > > + than the array indexing. The test imported/mozilla/svg/filters/feSpecularLighting-1.svg was > > + failing after applying my patch because of this bug. The expected result is an SVG which > > + contains a data uri image. > > Can this part of the patch be tested and landed separately?
Done.
https://bugs.webkit.org/show_bug.cgi?id=140173
Philip Rogers
Comment 79
2015-01-06 22:41:14 PST
(In reply to
comment #72
)
> (In reply to
comment #69
) > > Synchronous loading is a change that is observable from JavaScript in many > > ways (e.g. load events). What do other browsers do? > > > > In addition to the compatibility concern, doing synchronous event dispatch > > is generally bad for security, because an event handler can change the DOM > > in ways that parser is not prepared to handle. > > > > I do not think this is a concern. All the image onload events are sent only > after loading the main document. I included the test > svg/as-image/svg-image-with-data-uri-load-event.html to confirm that. The > order of completing the resources in a page is random. It depends on the > servers' response time and how big the resources are. Since the data uri > images are loaded with the main document, it is expected that they should > receive their onload events first.
In Chromium we took the approach of synchronously sending load events for data uri images and I think you're on a good path here in terms of web compatibility. I can warn you about an edge case that did bite us: global image event handlers. These are a kludge and should be removed entirely but synchronously firing them at inopportune times can be dangerous (e.g., from elements that themselves load images). It may be useful to check out the following patches and possibly include their tests (if only as a safeguard):
https://src.chromium.org/viewvc/blink?revision=153029&view=revision
https://src.chromium.org/viewvc/blink?view=rev&revision=153969
Said Abou-Hallawa
Comment 80
2015-02-02 15:13:30 PST
Created
attachment 245904
[details]
Patch
Said Abou-Hallawa
Comment 81
2015-02-02 15:15:59 PST
I changed the solution to be asynchronous loading as expected for all resources and sub-resources. The solution depends on using the NetworkingContext of the main FrameLoader when loading a data URI resource.
Chris Dumez
Comment 82
2015-02-02 19:34:48 PST
Comment on
attachment 245904
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=245904&action=review
Just a few drive-by comments.
> Source/WebCore/svg/graphics/SVGImageClients.h:36 > +class SVGImageChromeClient : public EmptyChromeClient {
Is this ever subclassed? if no, we should make it final.
> Source/WebCore/svg/graphics/SVGImageClients.h:50 > + m_image = 0;
nullptr
> Source/WebCore/svg/graphics/SVGImageClients.h:63 > +inline SVGImageChromeClient* toSVGImageChromeClient(ChromeClient* client)
We use downcast<>() instead of those toXXX() in WebKit nowadays. You would use need to use SPECIALIZE_TYPE_TRAITS_*() to provide the right Traits specialization and then downcast<>() would work for SVGImageChromeClient as well.
> Source/WebCore/svg/graphics/SVGImageClients.h:76 > + virtual FrameLoader* dataProtocolLoader() const { return m_dataProtocolLoader; }
missing override?
Said Abou-Hallawa
Comment 83
2015-02-02 19:57:19 PST
Created
attachment 245921
[details]
Patch
Said Abou-Hallawa
Comment 84
2015-02-02 19:59:55 PST
(In reply to
comment #82
)
> Comment on
attachment 245904
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=245904&action=review
> > Just a few drive-by comments. > > > Source/WebCore/svg/graphics/SVGImageClients.h:36 > > +class SVGImageChromeClient : public EmptyChromeClient { > > Is this ever subclassed? if no, we should make it final. >
Done.
> > Source/WebCore/svg/graphics/SVGImageClients.h:50 > > + m_image = 0; > > nullptr >
Done.
> > Source/WebCore/svg/graphics/SVGImageClients.h:63 > > +inline SVGImageChromeClient* toSVGImageChromeClient(ChromeClient* client) > > We use downcast<>() instead of those toXXX() in WebKit nowadays. You would > use need to use SPECIALIZE_TYPE_TRAITS_*() to provide the right Traits > specialization and then downcast<>() would work for SVGImageChromeClient as > well. >
toSVGImageChromeClient() is deleted because it is never referenced in the code.
> > Source/WebCore/svg/graphics/SVGImageClients.h:76 > > + virtual FrameLoader* dataProtocolLoader() const { return m_dataProtocolLoader; } > > missing override?
Done.
Darin Adler
Comment 85
2015-02-03 08:45:01 PST
Comment on
attachment 245921
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=245921&action=review
I think the approach here is wrong. We should find a way to connect the SVGImage with the loader that does not involve adding the FrameLoader concept to the Image class. Unfortunately, it looks like the entire SVGImage mechanism itself has a similar layering violation, but I don’t think it needs to. I think the main thing would be to move the SVGImage object out of the platform directory, since it’s a much higher level concept.
> Source/WebCore/loader/ResourceLoader.cpp:176 > + FrameLoader* loader = m_request.url().protocolIsData() ? dataProtocolFrameLoader() : frameLoader();
Since we rely on this never being null, I suggest making this local variable be a reference rather than a pointer.
> Source/WebCore/loader/ResourceLoader.cpp:205 > + FrameLoader* loader = frameLoader(); > + return loader && loader->client().dataProtocolLoader() ? loader->client().dataProtocolLoader() : loader;
It’s not good that this calls loader->client().dataProtocolLoader() twice. It should be rewritten to not do that. I suggest changing this to return FrameLoader& and to assert that frameLoader() is non-null. We only call this when we need it to be non-null, so it’s not good to have the null checking and to have a pointer at the call site.
> Source/WebCore/loader/cache/CachedImage.cpp:112 > + if (cachedResourceLoader.autoLoadImages() || resourceRequest().url().protocolIsData())
Can we find a way to put this logic into CachedResourceLoader rather than repeating the logic twice? It’s not good that both this function and CachedResourceLoader::shouldDeferImageLoad encode the same rule.
> Source/WebCore/platform/graphics/Image.h:114 > + virtual void setDataProtocolLoader(FrameLoader*) { }
This is not the right way to design this; it’s a layering violation. The Image class is a lower level graphics abstraction from the platform directory and must not know anything about frame loaders. Even though it’s uglier, at the very least we should use isSVGImage and put this function on the SVG image class only. But we should also look for opportunities to fix this. We do not want our graphics level Image class depend on the design of the frame loader!
Darin Adler
Comment 86
2015-02-03 08:52:32 PST
I think that long term we need some kind of ImageLoadingContext that the graphics layer uses to abstract what it needs from the higher levels. That’s where NetworkingContext came from; at one time code was working directly with Frame and Page, but then we decided to abstract that for the loader. But a problem here is that SVGImage is not really part of the graphics layer. We need to figure out a factoring where SVGImage can be part of the higher level of SVG, not of the graphics layer, and SVGImage can get the data it needs without the Image class having to have an isSVGImage function in it or having knowledge of loaders. In any case, we should not take any more steps in the direction of building knowledge of the loader into the graphics layer.
Said Abou-Hallawa
Comment 87
2015-02-03 14:17:16 PST
Created
attachment 245968
[details]
Patch
Said Abou-Hallawa
Comment 88
2015-02-03 14:24:11 PST
(In reply to
comment #85
)
> Comment on
attachment 245921
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=245921&action=review
> > I think the approach here is wrong. We should find a way to connect the > SVGImage with the loader that does not involve adding the FrameLoader > concept to the Image class. Unfortunately, it looks like the entire SVGImage > mechanism itself has a similar layering violation, but I don’t think it > needs to. I think the main thing would be to move the SVGImage object out of > the platform directory, since it’s a much higher level concept. > > > Source/WebCore/loader/ResourceLoader.cpp:176 > > + FrameLoader* loader = m_request.url().protocolIsData() ? dataProtocolFrameLoader() : frameLoader(); > > Since we rely on this never being null, I suggest making this local variable > be a reference rather than a pointer. >
Done. And I added an assertion that frameLoader() is not null.
> > Source/WebCore/loader/ResourceLoader.cpp:205 > > + FrameLoader* loader = frameLoader(); > > + return loader && loader->client().dataProtocolLoader() ? loader->client().dataProtocolLoader() : loader; > > It’s not good that this calls loader->client().dataProtocolLoader() twice. > It should be rewritten to not do that. > > I suggest changing this to return FrameLoader& and to assert that > frameLoader() is non-null. We only call this when we need it to be non-null, > so it’s not good to have the null checking and to have a pointer at the call > site. >
Done.
> > Source/WebCore/loader/cache/CachedImage.cpp:112 > > + if (cachedResourceLoader.autoLoadImages() || resourceRequest().url().protocolIsData()) > > Can we find a way to put this logic into CachedResourceLoader rather than > repeating the logic twice? It’s not good that both this function and > CachedResourceLoader::shouldDeferImageLoad encode the same rule. >
Done. A new function called shouldPerformImageLoad() is added to CachedResourceLoader. If the name is not clear enough, please let me know.
> > Source/WebCore/platform/graphics/Image.h:114 > > + virtual void setDataProtocolLoader(FrameLoader*) { } > > This is not the right way to design this; it’s a layering violation. The > Image class is a lower level graphics abstraction from the platform > directory and must not know anything about frame loaders. Even though it’s > uglier, at the very least we should use isSVGImage and put this function on > the SVG image class only. But we should also look for opportunities to fix > this. We do not want our graphics level Image class depend on the design of > the frame loader!
Done. setDataProtocolLoader() is now a specific function to the SVGImage. It is called from CachedImage::finishedLoading() only when m_image->isSVGImage(). The same condition is repeated in couple places in CachedImage.cpp.
Darin Adler
Comment 89
2015-02-04 08:55:22 PST
Comment on
attachment 245968
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=245968&action=review
> Source/WebCore/svg/graphics/SVGImage.h:109 > + FrameLoader* m_dataProtocolLoader;
If we initialized this to null here we would not need to in the constructor: FrameLoader* m_dataProtocolLoader { nullptr };
Radar WebKit Bug Importer
Comment 90
2015-02-04 11:11:49 PST
<
rdar://problem/19717682
>
Said Abou-Hallawa
Comment 91
2015-02-04 11:25:11 PST
Created
attachment 246039
[details]
Patch
WebKit Commit Bot
Comment 92
2015-02-04 12:55:26 PST
Comment on
attachment 246039
[details]
Patch Clearing flags on attachment: 246039 Committed
r179626
: <
http://trac.webkit.org/changeset/179626
>
WebKit Commit Bot
Comment 93
2015-02-04 12:55:38 PST
All reviewed patches have been landed. Closing bug.
Steven Vachon
Comment 94
2015-02-04 18:02:25 PST
Holy knights of columbus! It's been fixed!!!
Said Abou-Hallawa
Comment 95
2015-05-11 10:40:26 PDT
***
Bug 127441
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug