Changeset 179626 in webkit
- Timestamp:
- Feb 4, 2015 12:55:21 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 12 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r179625 r179626 1 2015-02-04 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 When using SVG as an image, we should load datauri images when these images are not in the image cache. 4 https://bugs.webkit.org/show_bug.cgi?id=99677. 5 6 Reviewed by Darin Adler. 7 8 * svg/as-image/resources/image-with-nested-data-uri-images.svg: Added. 9 This SVG has a tree of depth = 5 of nested data URI images. All the data URI images are 10 SVG images expect the innermost one which is a png data URI image. 11 12 * svg/as-image/resources/image-with-nested-rects.svg: Added. 13 This SVG produces the same drawing as image-with-nested-data-uri-images.svg does but 14 it uses <rect> SVG elements instead. 15 16 * svg/as-image/svg-image-with-data-uri-background-expected.html: Added. 17 * svg/as-image/svg-image-with-data-uri-background.html: Added. 18 Test the data URI SVG as a css background image. 19 20 * svg/as-image/svg-image-with-data-uri-from-canvas-expected.html: Added. 21 * svg/as-image/svg-image-with-data-uri-from-canvas.html: Added. 22 Test the data URI image when it is the result of drawing an SVG image on a canvas object. 23 24 * svg/as-image/svg-image-with-data-uri-images-disabled-expected.html: Added. 25 * svg/as-image/svg-image-with-data-uri-images-disabled.html: Added. 26 Ensure the data uri images are not loaded if imagesEnabled is turned off. 27 28 * svg/as-image/svg-image-with-data-uri-reloading-expected.html: Added. 29 * svg/as-image/svg-image-with-data-uri-reloading.html: Added. 30 Test the data URI SVG when reloading the page. 31 32 * svg/as-image/svg-image-with-data-uri-use-data-uri-expected.svg: Added. 33 * svg/as-image/svg-image-with-data-uri-use-data-uri.svg: Added. 34 Test the data URI image when it is referenced from an SVG <use> tag. 35 36 * svg/as-image/svg-image-with-svg-data-uri-expected.html: Added. 37 * svg/as-image/svg-image-with-svg-data-uri.html: Added. 38 Test the data URI image when it is referenced from an HTML <img> tag. 39 1 40 2015-02-04 Zalan Bujtas <zalan@apple.com> 2 41 -
trunk/Source/WebCore/ChangeLog
r179624 r179626 1 2015-02-04 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 When using SVG as an image, we should load datauri images when these images are not in the image cache. 4 https://bugs.webkit.org/show_bug.cgi?id=99677. 5 6 Reviewed by Darin Adler. 7 8 Data URI sub-resources are not loaded because the networking context of FrameLoader 9 attached to the SubResourceLoader is set to null. This is done intentionally to 10 disallow any resource from loading external sub-resources. For example if an <img> 11 tag has its 'src' attribute points to an svg file, this svg is not allowed to load 12 an external image through the 'xlink' attribute of an <image> element. This restriction 13 is not valid if the value of the 'xlink' attribute is a data URI. In this case the image 14 should be loaded into memory since there is no network traffic involved. All we need 15 to do is to decode the data part of the URI. 16 17 The fix is to pass the root FrameLoader, which has a valid NetworkingContext, through 18 the FrameLoaderClient, to the ResourceHandle::create() which uses the NetworkingContext 19 to decode the data and fire the load events of the data URI resources. 20 21 Tests: svg/as-image/svg-image-with-data-uri-background.html 22 svg/as-image/svg-image-with-data-uri-from-canvas.html 23 svg/as-image/svg-image-with-data-uri-images-disabled.html 24 svg/as-image/svg-image-with-data-uri-reloading.html 25 svg/as-image/svg-image-with-data-uri-use-data-uri.svg 26 svg/as-image/svg-image-with-svg-data-uri.html 27 28 * accessibility/AccessibilityRenderObject.cpp: 29 Remove unreferenced header file. 30 31 * loader/FrameLoaderClient.h: 32 Define the null virtual function dataProtocolLoader() which should return the FrameLoader 33 for loading data URI resources. 34 35 * loader/ResourceLoader.cpp: 36 (WebCore::ResourceLoader::start): 37 (WebCore::ResourceLoader::dataProtocolFrameLoader): 38 * loader/ResourceLoader.h: 39 Add ResourceLoader::dataProtocolFrameLoader() which returns the root FrameLoader. The 40 root FrameLoader is used to get a valid NetworkingContext which can be passed to 41 ResourceHandle::create() when url().protocolIsData(). 42 43 * loader/cache/CachedImage.cpp: 44 (WebCore::CachedImage::load): 45 (WebCore::CachedImage::finishLoading): 46 * loader/cache/CachedResourceLoader.cpp: 47 (WebCore::CachedResourceLoader::shouldPerformImageLoad): 48 (WebCore::CachedResourceLoader::shouldDeferImageLoad): 49 * loader/cache/CachedResourceLoader.h: 50 Allow loading data URI sub-resources as long as loading images is not disabled. Also we 51 need to call setDataProtocolLoader() before calling setData() for the isSVGImage case, 52 setData() will create a page by calling Page::createPageFromBuffer() via SVGImage::dataChanged(), 53 and we need to pass the correct FrameLoaderClient to the created FrameLoader of the main 54 frame of this page. 55 56 * svg/graphics/SVGImage.cpp: 57 (WebCore::SVGImage::SVGImage): 58 (WebCore::SVGImage::dataChanged): 59 * svg/graphics/SVGImage.h: 60 Create a new FrameLoaderClient of type SVGFrameLoaderClient and set it in pageConfiguration 61 which is used when creating the page from the SVG data URI. 62 63 * WebCore.xcodeproj/project.pbxproj: 64 * svg/graphics/SVGImageChromeClient.h: Removed. 65 * svg/graphics/SVGImageClients.h: Added. 66 Add a new class SVGImageChromeClient which overrides the function dataProtocolLoader(). 67 Rename the header file SVGImageChromeClient.h to be SVGImageClients.h since it now 68 includes the classes SVGImageChromeClient and SVGFrameLoaderClient. 69 1 70 2015-02-04 Timothy Horton <timothy_horton@apple.com> 2 71 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r179534 r179626 4337 4337 AAA728F816D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA728F216D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm */; }; 4338 4338 AAA728F916D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA728F316D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm */; }; 4339 AAC08CEF15F933D600F1E188 /* SVGImageChromeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC08CED15F933D600F1E188 /* SVGImageChromeClient.h */; };4340 4339 AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC08CF115F941FC00F1E188 /* AccessibilitySVGRoot.h */; }; 4341 4340 AAF5B7B71524B6C50004CB49 /* WebSocketFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAF5B7B11524B4BD0004CB49 /* WebSocketFrame.cpp */; }; … … 9222 9221 550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 9223 9222 550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 9223 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; }; 9224 9224 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentDistributor.cpp; sourceTree = "<group>"; }; 9225 9225 57B791A014C6A62900F202D1 /* ContentDistributor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentDistributor.h; sourceTree = "<group>"; }; … … 11588 11588 AAA728F216D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAccessibilityObjectWrapperIOS.mm; sourceTree = "<group>"; }; 11589 11589 AAA728F316D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheIOS.mm; sourceTree = "<group>"; }; 11590 AAC08CED15F933D600F1E188 /* SVGImageChromeClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageChromeClient.h; sourceTree = "<group>"; };11591 11590 AAC08CF015F941FC00F1E188 /* AccessibilitySVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGRoot.cpp; sourceTree = "<group>"; }; 11592 11591 AAC08CF115F941FC00F1E188 /* AccessibilitySVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGRoot.h; sourceTree = "<group>"; }; … … 20377 20376 08F859D21463F9CD0067D933 /* SVGImageCache.cpp */, 20378 20377 08F859D31463F9CD0067D933 /* SVGImageCache.h */, 20379 AAC08CED15F933D600F1E188 /* SVGImageChromeClient.h */,20378 55D408F71A7C631800C78450 /* SVGImageClients.h */, 20380 20379 08F859D21463F9CD0067D934 /* SVGImageForContainer.cpp */, 20381 20380 08F859D31463F9CD0067D934 /* SVGImageForContainer.h */, … … 26344 26343 B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */, 26345 26344 08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */, 26346 AAC08CEF15F933D600F1E188 /* SVGImageChromeClient.h in Headers */,26347 26345 B2227A2D0D00BF220071B782 /* SVGImageElement.h in Headers */, 26348 26346 08F859D51463F9CD0067D934 /* SVGImageForContainer.h in Headers */, -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r179253 r179626 97 97 #include "SVGDocument.h" 98 98 #include "SVGImage.h" 99 #include "SVGImageChromeClient.h"100 99 #include "SVGNames.h" 101 100 #include "SVGSVGElement.h" -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r177941 r179626 333 333 virtual bool isEmptyFrameLoaderClient() { return false; } 334 334 335 virtual FrameLoader* dataProtocolLoader() const { return nullptr; } 336 335 337 #if USE(QUICK_LOOK) 336 338 virtual void didCreateQuickLookHandle(QuickLookHandle&) { } -
trunk/Source/WebCore/loader/ResourceLoader.cpp
r179533 r179626 162 162 ASSERT(!m_request.isNull()); 163 163 ASSERT(m_deferredRequest.isNull()); 164 ASSERT(frameLoader()); 164 165 165 166 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) … … 176 177 } 177 178 178 if (!m_reachedTerminalState) 179 m_handle = ResourceHandle::create(m_frame->loader().networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent() == SniffContent); 179 if (!m_reachedTerminalState) { 180 FrameLoader& loader = m_request.url().protocolIsData() ? dataProtocolFrameLoader() : *frameLoader(); 181 m_handle = ResourceHandle::create(loader.networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent() == SniffContent); 182 } 180 183 } 181 184 … … 199 202 return 0; 200 203 return &m_frame->loader(); 204 } 205 206 // This function should only be called when frameLoader() is non-null. 207 FrameLoader& ResourceLoader::dataProtocolFrameLoader() const 208 { 209 FrameLoader* loader = frameLoader(); 210 ASSERT(loader); 211 FrameLoader* dataProtocolLoader = loader->client().dataProtocolLoader(); 212 return *(dataProtocolLoader ? dataProtocolLoader : loader); 201 213 } 202 214 -
trunk/Source/WebCore/loader/ResourceLoader.h
r176626 r179626 72 72 73 73 WEBCORE_EXPORT FrameLoader* frameLoader() const; 74 FrameLoader& dataProtocolFrameLoader() const; 74 75 DocumentLoader* documentLoader() const { return m_documentLoader.get(); } 75 76 WEBCORE_EXPORT const ResourceRequest& originalRequest() const { return m_originalRequest; } -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r179489 r179626 110 110 void CachedImage::load(CachedResourceLoader& cachedResourceLoader, const ResourceLoaderOptions& options) 111 111 { 112 if (cachedResourceLoader. autoLoadImages())112 if (cachedResourceLoader.shouldPerformImageLoad(resourceRequest().url())) 113 113 CachedResource::load(cachedResourceLoader, options); 114 114 else … … 416 416 createImage(); 417 417 418 if (m_image) 418 if (m_image) { 419 if (m_loader && m_image->isSVGImage()) 420 downcast<SVGImage>(*m_image).setDataProtocolLoader(&m_loader->dataProtocolFrameLoader()); 419 421 m_image->setData(data, true); 422 } 420 423 421 424 if (!m_image || m_image->isNull()) { -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r179584 r179626 755 755 } 756 756 757 bool CachedResourceLoader::shouldPerformImageLoad(const URL& url) const 758 { 759 return m_autoLoadImages || url.protocolIsData(); 760 } 761 757 762 bool CachedResourceLoader::shouldDeferImageLoad(const URL& url) const 758 763 { 759 return clientDefersImage(url) || ! m_autoLoadImages;764 return clientDefersImage(url) || !shouldPerformImageLoad(url); 760 765 } 761 766 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r179421 r179626 105 105 106 106 bool shouldDeferImageLoad(const URL&) const; 107 bool shouldPerformImageLoad(const URL&) const; 107 108 108 109 CachePolicy cachePolicy(CachedResource::Type) const; -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r179335 r179626 32 32 #include "DocumentLoader.h" 33 33 #include "ElementIterator.h" 34 #include "FrameLoader.h" 34 35 #include "FrameView.h" 35 36 #include "ImageBuffer.h" … … 42 43 #include "SVGDocument.h" 43 44 #include "SVGForeignObjectElement.h" 44 #include "SVGImageC hromeClient.h"45 #include "SVGImageClients.h" 45 46 #include "SVGSVGElement.h" 46 47 #include "Settings.h" … … 345 346 m_chromeClient = std::make_unique<SVGImageChromeClient>(this); 346 347 pageConfiguration.chromeClient = m_chromeClient.get(); 348 m_loaderClient = std::make_unique<SVGFrameLoaderClient>(m_dataProtocolLoader); 349 pageConfiguration.loaderClientForMainFrame = m_loaderClient.get(); 350 347 351 bool canHaveScrollbars = false; // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars. 348 352 bool transparent = true; // SVG Images are transparent. -
trunk/Source/WebCore/svg/graphics/SVGImage.h
r174623 r179626 34 34 35 35 class Element; 36 class FrameLoader; 36 37 class FrameView; 37 38 class ImageBuffer; … … 39 40 class RenderBox; 40 41 class SVGSVGElement; 42 class SVGFrameLoaderClient; 41 43 class SVGImageChromeClient; 42 44 class SVGImageForContainer; … … 56 58 57 59 void setURL(const URL& url) { m_url = url; } 60 void setDataProtocolLoader(FrameLoader* dataProtocolLoader) { m_dataProtocolLoader = dataProtocolLoader; } 58 61 59 62 virtual bool hasSingleSecurityOrigin() const override; … … 99 102 SVGSVGElement* rootElement() const; 100 103 104 std::unique_ptr<SVGFrameLoaderClient> m_loaderClient; 101 105 std::unique_ptr<SVGImageChromeClient> m_chromeClient; 102 106 std::unique_ptr<Page> m_page; 103 107 FloatSize m_intrinsicSize; 104 108 URL m_url; 109 FrameLoader* m_dataProtocolLoader { nullptr }; 105 110 }; 106 111 -
trunk/Source/WebCore/svg/graphics/SVGImageClients.h
r179625 r179626 1 1 /* 2 * Copyright (C) 201 2Apple Inc. All rights reserved.2 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 */ 28 28 29 #ifndef SVGImageC hromeClient_h30 #define SVGImageC hromeClient_h29 #ifndef SVGImageClients_h 30 #define SVGImageClients_h 31 31 32 32 #include "EmptyClients.h" … … 34 34 namespace WebCore { 35 35 36 class SVGImageChromeClient : public EmptyChromeClient {36 class SVGImageChromeClient final : public EmptyChromeClient { 37 37 WTF_MAKE_NONCOPYABLE(SVGImageChromeClient); WTF_MAKE_FAST_ALLOCATED; 38 38 public: … … 48 48 virtual void chromeDestroyed() override 49 49 { 50 m_image = 0;50 m_image = nullptr; 51 51 } 52 52 … … 61 61 }; 62 62 63 inline SVGImageChromeClient* toSVGImageChromeClient(ChromeClient* client) 64 { 65 ASSERT_WITH_SECURITY_IMPLICATION(!client || client->isSVGImageChromeClient()); 66 return static_cast<SVGImageChromeClient*>(client); 67 } 68 63 class SVGFrameLoaderClient final : public EmptyFrameLoaderClient { 64 public: 65 SVGFrameLoaderClient(FrameLoader* dataProtocolLoader) 66 : m_dataProtocolLoader(dataProtocolLoader) 67 { 68 } 69 70 virtual FrameLoader* dataProtocolLoader() const override { return m_dataProtocolLoader; } 71 private: 72 FrameLoader* m_dataProtocolLoader; 73 }; 74 69 75 } 70 76 71 #endif // SVGImageC hromeClient_h77 #endif // SVGImageClients_h
Note: See TracChangeset
for help on using the changeset viewer.