Changeset 205181 in webkit
- Timestamp:
- Aug 30, 2016 8:06:19 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205180 r205181 1 2016-08-30 Antti Koivisto <antti@apple.com> 2 3 Remove StylePendingImage 4 https://bugs.webkit.org/show_bug.cgi?id=161245 5 6 Reviewed by Andreas Kling. 7 8 Instances of this confusing type are used as placeholders during style resolution. 9 We can get rid of it and make "pending" a state of StyleImage. This simplies the code and 10 will allow further improvements. 11 12 * WebCore.xcodeproj/project.pbxproj: 13 * css/CSSCrossfadeValue.cpp: 14 (WebCore::CSSCrossfadeValue::isPending): 15 (WebCore::CSSCrossfadeValue::blend): 16 * css/CSSCrossfadeValue.h: 17 * css/CSSCursorImageValue.cpp: 18 (WebCore::CSSCursorImageValue::CSSCursorImageValue): 19 (WebCore::CSSCursorImageValue::~CSSCursorImageValue): 20 21 Save the original URL since the underlying CSSImageValue may change. 22 23 (WebCore::CSSCursorImageValue::updateCursorElement): 24 (WebCore::CSSCursorImageValue::cursorElementRemoved): 25 (WebCore::CSSCursorImageValue::cursorElementChanged): 26 (WebCore::CSSCursorImageValue::loadImage): 27 (WebCore::CSSCursorImageValue::styleImage): 28 (WebCore::CSSCursorImageValue::isSVGCursor): 29 (WebCore::CSSCursorImageValue::cachedImageURL): 30 (WebCore::CSSCursorImageValue::updateCachedImage): 31 (WebCore::CSSCursorImageValue::detachPendingImage): Deleted. 32 (WebCore::CSSCursorImageValue::cachedImage): Deleted. 33 (WebCore::CSSCursorImageValue::cachedOrPendingImage): Deleted. 34 (WebCore::CSSCursorImageValue::clearCachedImage): Deleted. 35 * css/CSSCursorImageValue.h: 36 * css/CSSFilterImageValue.cpp: 37 (WebCore::CSSFilterImageValue::isPending): 38 * css/CSSFilterImageValue.h: 39 * css/CSSImageGeneratorValue.cpp: 40 (WebCore::CSSImageGeneratorValue::isPending): 41 (WebCore::CSSImageGeneratorValue::subimageIsPending): 42 (WebCore::CSSImageGeneratorValue::cachedImageForCSSValue): 43 * css/CSSImageGeneratorValue.h: 44 * css/CSSImageSetValue.cpp: 45 (WebCore::CSSImageSetValue::~CSSImageSetValue): 46 (WebCore::CSSImageSetValue::loadBestFitImage): 47 (WebCore::CSSImageSetValue::styleImage): 48 (WebCore::CSSImageSetValue::traverseSubresources): 49 (WebCore::CSSImageSetValue::detachPendingImage): Deleted. 50 (WebCore::CSSImageSetValue::bestFitImage): Deleted. 51 (WebCore::CSSImageSetValue::cachedOrPendingImageSet): Deleted. 52 * css/CSSImageSetValue.h: 53 * css/CSSImageValue.cpp: 54 (WebCore::CSSImageValue::CSSImageValue): 55 (WebCore::CSSImageValue::~CSSImageValue): 56 (WebCore::CSSImageValue::isPending): 57 (WebCore::CSSImageValue::styleImage): 58 (WebCore::CSSImageValue::loadImage): 59 (WebCore::CSSImageValue::traverseSubresources): 60 (WebCore::CSSImageValue::detachPendingImage): Deleted. 61 (WebCore::CSSImageValue::cachedOrPendingImage): Deleted. 62 (WebCore::CSSImageValue::cachedImage): Deleted. 63 * css/CSSImageValue.h: 64 (WebCore::CSSImageValue::create): 65 * css/StyleResolver.cpp: 66 (WebCore::StyleResolver::cachedOrPendingFromValue): 67 (WebCore::StyleResolver::generatedOrPendingFromValue): 68 (WebCore::StyleResolver::setOrPendingFromValue): 69 (WebCore::StyleResolver::cursorOrPendingFromValue): 70 * page/PageSerializer.cpp: 71 (WebCore::PageSerializer::retrieveResourcesForProperties): 72 * page/animation/CSSPropertyAnimation.cpp: 73 (WebCore::blendFilter): 74 (WebCore::crossfadeBlend): 75 * rendering/RenderImageResourceStyleImage.cpp: 76 (WebCore::RenderImageResourceStyleImage::image): 77 * rendering/shapes/ShapeOutsideInfo.cpp: 78 (WebCore::ShapeOutsideInfo::createShapeForImage): 79 * rendering/style/StyleCachedImage.cpp: 80 (WebCore::StyleCachedImage::StyleCachedImage): 81 (WebCore::StyleCachedImage::~StyleCachedImage): 82 (WebCore::StyleCachedImage::setCachedImage): 83 (WebCore::StyleCachedImage::cssValue): 84 (WebCore::StyleCachedImage::canRender): 85 (WebCore::StyleCachedImage::isPending): 86 (WebCore::StyleCachedImage::isLoaded): 87 (WebCore::StyleCachedImage::errorOccurred): 88 (WebCore::StyleCachedImage::imageSize): 89 (WebCore::StyleCachedImage::imageHasRelativeWidth): 90 (WebCore::StyleCachedImage::imageHasRelativeHeight): 91 (WebCore::StyleCachedImage::computeIntrinsicDimensions): 92 (WebCore::StyleCachedImage::usesImageContainerSize): 93 (WebCore::StyleCachedImage::setContainerSizeForRenderer): 94 (WebCore::StyleCachedImage::addClient): 95 (WebCore::StyleCachedImage::removeClient): 96 (WebCore::StyleCachedImage::image): 97 (WebCore::StyleCachedImage::knownToBeOpaque): 98 * rendering/style/StyleCachedImage.h: 99 * rendering/style/StyleGeneratedImage.cpp: 100 (WebCore::StyleGeneratedImage::isPending): 101 * rendering/style/StyleGeneratedImage.h: 102 * rendering/style/StyleImage.h: 103 (WebCore::StyleImage::isCachedImage): 104 (WebCore::StyleImage::StyleImage): 105 (WebCore::StyleImage::canRender): Deleted. 106 (WebCore::StyleImage::isPendingImage): Deleted. 107 * rendering/style/StylePendingImage.h: Removed. 108 * style/StylePendingResources.cpp: 109 (WebCore::Style::loadPendingImage): 110 (WebCore::Style::loadPendingImages): 111 1 112 2016-08-30 Philippe Normand <pnormand@igalia.com> 2 113 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r205161 r205181 504 504 0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; }; 505 505 0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; }; 506 0FA6F96F1BCF614A0031EE70 /* StylePendingImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */; };507 506 0FA88EBD16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FA88EBC16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm */; }; 508 507 0FB6252E18DE1B1500A07C05 /* GeometryUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB6252C18DE1B1500A07C05 /* GeometryUtilities.cpp */; }; … … 7277 7276 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; }; 7278 7277 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; }; 7279 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StylePendingImage.h; sourceTree = "<group>"; };7280 7278 0FA88EBC16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingStateFrameScrollingNodeMac.mm; sourceTree = "<group>"; }; 7281 7279 0FB6252C18DE1B1500A07C05 /* GeometryUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeometryUtilities.cpp; sourceTree = "<group>"; }; … … 21193 21191 BC5EB74B0E81E06700B25965 /* StyleMultiColData.cpp */, 21194 21192 BC5EB74C0E81E06700B25965 /* StyleMultiColData.h */, 21195 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */,21196 21193 BC2272E10E82EE9B00E7F975 /* StyleRareInheritedData.cpp */, 21197 21194 BC2272E20E82EE9B00E7F975 /* StyleRareInheritedData.h */, … … 26362 26359 0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */, 26363 26360 BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */, 26364 0FA6F96F1BCF614A0031EE70 /* StylePendingImage.h in Headers */,26365 26361 E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */, 26366 26362 A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */, -
trunk/Source/WebCore/css/CSSCrossfadeValue.cpp
r201290 r205181 111 111 } 112 112 113 bool CSSCrossfadeValue::isPending() 113 bool CSSCrossfadeValue::isPending() const 114 114 { 115 115 return CSSImageGeneratorValue::subimageIsPending(m_fromValue) … … 200 200 if (!m_cachedToImage || !m_cachedFromImage) 201 201 return nullptr; 202 RefPtr<StyleCachedImage> toStyledImage = StyleCachedImage::create(m_cachedToImage.get()); 203 RefPtr<StyleCachedImage> fromStyledImage = StyleCachedImage::create(m_cachedFromImage.get()); 204 205 auto fromImageValue = CSSImageValue::create(m_cachedFromImage->url(), fromStyledImage.get()); 206 auto toImageValue = CSSImageValue::create(m_cachedToImage->url(), toStyledImage.get()); 202 auto fromImageValue = CSSImageValue::create(*m_cachedFromImage); 203 auto toImageValue = CSSImageValue::create(*m_cachedToImage); 207 204 208 205 double fromPercentage = from.m_percentageValue->getDoubleValue(); -
trunk/Source/WebCore/css/CSSCrossfadeValue.h
r205093 r205181 58 58 59 59 bool isPrefixed() const { return m_isPrefixed; } 60 bool isPending() ;60 bool isPending() const; 61 61 bool knownToBeOpaque(const RenderElement*) const; 62 62 -
trunk/Source/WebCore/css/CSSCursorImageValue.cpp
r204566 r205181 29 29 #include "StyleCachedImage.h" 30 30 #include "StyleImage.h" 31 #include "StylePendingImage.h"32 31 #include "SVGCursorElement.h" 33 32 #include "SVGLengthContext.h" … … 47 46 , m_hotSpot(hotSpot) 48 47 { 49 } 50 51 inline void CSSCursorImageValue::detachPendingImage() 52 { 53 if (is<StylePendingImage>(m_image.get())) 54 downcast<StylePendingImage>(*m_image).detachFromCSSValue(); 48 if (is<CSSImageValue>(m_imageValue.get())) 49 m_originalURL = { ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url() }; 55 50 } 56 51 57 52 CSSCursorImageValue::~CSSCursorImageValue() 58 53 { 59 detachPendingImage();60 61 54 for (auto* element : m_cursorElements) 62 55 element->removeClient(*this); … … 78 71 SVGCursorElement* CSSCursorImageValue::updateCursorElement(const Document& document) 79 72 { 80 if (! isSVGCursor())73 if (!m_originalURL.hasFragmentIdentifier()) 81 74 return nullptr; 82 75 83 auto* element = SVGURIReference::targetElementFromIRIString( downcast<CSSImageValue>(m_imageValue.get()).url(), document);76 auto* element = SVGURIReference::targetElementFromIRIString(m_originalURL, document); 84 77 if (!is<SVGCursorElement>(element)) 85 78 return nullptr; … … 96 89 { 97 90 m_cursorElements.remove(&cursorElement); 98 clearCachedImage();99 91 } 100 92 101 93 void CSSCursorImageValue::cursorElementChanged(SVGCursorElement& cursorElement) 102 94 { 103 clearCachedImage();104 105 95 // FIXME: This will override hot spot specified in CSS, which is probably incorrect. 106 96 SVGLengthContext lengthContext(nullptr); … … 113 103 } 114 104 115 StyleImage* CSSCursorImageValue::cachedImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)105 void CSSCursorImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options) 116 106 { 117 if (is<CSSImageSetValue>(m_imageValue.get())) 118 return downcast<CSSImageSetValue>(m_imageValue.get()).bestFitImage(loader, options); 119 120 auto* cursorElement = loader.document() ? updateCursorElement(*loader.document()) : nullptr; 121 122 if (!m_isImageValid) { 123 m_isImageValid = true; 124 // For SVG images we need to lazily substitute in the correct URL. Rather than attempt 125 // to change the URL of the CSSImageValue (which would then change behavior like cssText), 126 // we create an alternate CSSImageValue to use. 127 if (cursorElement) { 128 detachPendingImage(); 129 Ref<CSSImageValue> svgImageValue(CSSImageValue::create(cursorElement->href())); 130 StyleCachedImage* cachedImage = svgImageValue->cachedImage(loader, options); 131 m_image = cachedImage; 132 return cachedImage; 133 } 134 135 if (is<CSSImageValue>(m_imageValue.get())) { 136 detachPendingImage(); 137 m_image = downcast<CSSImageValue>(m_imageValue.get()).cachedImage(loader, options); 138 } 107 if (is<CSSImageSetValue>(m_imageValue.get())) { 108 downcast<CSSImageSetValue>(m_imageValue.get()).loadBestFitImage(loader, options); 109 return; 139 110 } 140 111 141 if (is<StyleCachedImage>(m_image.get())) 142 return downcast<StyleCachedImage>(m_image.get()); 143 144 return nullptr; 112 downcast<CSSImageValue>(m_imageValue.get()).loadImage(loader, options); 145 113 } 146 114 147 Style Image* CSSCursorImageValue::cachedOrPendingImage(const Document& document)115 StyleCachedImage& CSSCursorImageValue::styleImage(const Document& document) 148 116 { 149 117 // Need to delegate completely so that changes in device scale factor can be handled appropriately. 118 StyleCachedImage* styleImage; 150 119 if (is<CSSImageSetValue>(m_imageValue.get())) 151 return downcast<CSSImageSetValue>(m_imageValue.get()).cachedOrPendingImageSet(document); 120 styleImage = &downcast<CSSImageSetValue>(m_imageValue.get()).styleImage(document); 121 else { 122 if (auto* cursorElement = updateCursorElement(document)) { 123 if (cursorElement->href() != downcast<CSSImageValue>(m_imageValue.get()).url()) 124 m_imageValue = CSSImageValue::create(cursorElement->href()); 125 } 126 styleImage = &downcast<CSSImageValue>(m_imageValue.get()).styleImage(); 127 } 128 styleImage->setCSSValue(*this); 152 129 153 if (!m_image) 154 m_image = StylePendingImage::create(this); 155 156 return m_image.get(); 157 } 158 159 bool CSSCursorImageValue::isSVGCursor() const 160 { 161 if (is<CSSImageValue>(m_imageValue.get())) { 162 URL kurl(ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url()); 163 return kurl.hasFragmentIdentifier(); 164 } 165 return false; 166 } 167 168 String CSSCursorImageValue::cachedImageURL() 169 { 170 if (!is<StyleCachedImage>(m_image.get())) 171 return String(); 172 return downcast<StyleCachedImage>(*m_image).cachedImage()->url(); 173 } 174 175 void CSSCursorImageValue::clearCachedImage() 176 { 177 detachPendingImage(); 178 m_image = nullptr; 179 m_isImageValid = false; 130 return *styleImage; 180 131 } 181 132 -
trunk/Source/WebCore/css/CSSCursorImageValue.h
r205093 r205181 32 32 class SVGCursorElement; 33 33 class SVGElement; 34 class StyleCachedImage; 34 35 35 36 class CSSCursorImageValue final : public CSSValue { … … 53 54 String customCSSText() const; 54 55 55 SVGCursorElement* updateCursorElement(const Document&); 56 StyleImage* cachedImage(CachedResourceLoader&, const ResourceLoaderOptions&); 57 StyleImage* cachedOrPendingImage(const Document&); 56 void loadImage(CachedResourceLoader&, const ResourceLoaderOptions&); 57 StyleCachedImage& styleImage(const Document&); 58 58 59 59 void removeReferencedElement(SVGElement*); … … 67 67 CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot); 68 68 69 void detachPendingImage();69 SVGCursorElement* updateCursorElement(const Document&); 70 70 71 bool isSVGCursor() const; 72 String cachedImageURL(); 73 void clearCachedImage(); 74 71 URL m_originalURL; 75 72 Ref<CSSValue> m_imageValue; 76 73 77 74 bool m_hasHotSpot; 78 75 IntPoint m_hotSpot; 79 RefPtr<StyleImage> m_image;80 bool m_isImageValid { false };81 76 HashSet<SVGCursorElement*> m_cursorElements; 82 77 }; -
trunk/Source/WebCore/css/CSSFilterImageValue.cpp
r201290 r205181 74 74 } 75 75 76 bool CSSFilterImageValue::isPending() 76 bool CSSFilterImageValue::isPending() const 77 77 { 78 78 return CSSImageGeneratorValue::subimageIsPending(m_imageValue); -
trunk/Source/WebCore/css/CSSFilterImageValue.h
r205093 r205181 60 60 FloatSize fixedSize(const RenderElement*); 61 61 62 bool isPending() ;62 bool isPending() const; 63 63 bool knownToBeOpaque(const RenderElement*) const; 64 64 -
trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp
r201290 r205181 168 168 } 169 169 170 bool CSSImageGeneratorValue::isPending() 170 bool CSSImageGeneratorValue::isPending() const 171 171 { 172 172 switch (classType()) { … … 233 233 } 234 234 235 bool CSSImageGeneratorValue::subimageIsPending( CSSValue& value)235 bool CSSImageGeneratorValue::subimageIsPending(const CSSValue& value) 236 236 { 237 237 if (is<CSSImageValue>(value)) 238 return downcast<CSSImageValue>(value). cachedOrPendingImage().isPendingImage();238 return downcast<CSSImageValue>(value).isPending(); 239 239 240 240 if (is<CSSImageGeneratorValue>(value)) … … 252 252 { 253 253 if (is<CSSImageValue>(value)) { 254 StyleCachedImage* styleCachedImage = downcast<CSSImageValue>(value).cachedImage(cachedResourceLoader, options); 255 if (!styleCachedImage) 256 return nullptr; 257 258 return styleCachedImage->cachedImage(); 254 auto& imageValue = downcast<CSSImageValue>(value); 255 imageValue.loadImage(cachedResourceLoader, options); 256 return imageValue.styleImage().cachedImage(); 259 257 } 260 258 -
trunk/Source/WebCore/css/CSSImageGeneratorValue.h
r201290 r205181 55 55 FloatSize fixedSize(const RenderElement*); 56 56 57 bool isPending() ;57 bool isPending() const; 58 58 bool knownToBeOpaque(const RenderElement*) const; 59 59 … … 69 69 // Helper functions for Crossfade and Filter. 70 70 static CachedImage* cachedImageForCSSValue(CSSValue&, CachedResourceLoader&, const ResourceLoaderOptions&); 71 static bool subimageIsPending( CSSValue&);71 static bool subimageIsPending(const CSSValue&); 72 72 73 73 private: -
trunk/Source/WebCore/css/CSSImageSetValue.cpp
r204566 r205181 37 37 #include "Page.h" 38 38 #include "StyleCachedImage.h" 39 #include "StylePendingImage.h"40 39 #include <wtf/text/StringBuilder.h> 41 40 … … 49 48 } 50 49 51 inline void CSSImageSetValue::detachPendingImage()52 {53 if (is<StylePendingImage>(m_image.get()))54 downcast<StylePendingImage>(*m_image).detachFromCSSValue();55 }56 57 50 CSSImageSetValue::~CSSImageSetValue() 58 51 { 59 detachPendingImage(); 60 61 if (is<StyleCachedImage>(m_image.get())) 62 downcast<StyleCachedImage>(*m_image).detachFromCSSValue(); 52 if (m_image) 53 m_image->detachFromCSSValue(); 63 54 } 64 55 … … 99 90 } 100 91 101 StyleCachedImage* CSSImageSetValue::bestFitImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)92 void CSSImageSetValue::loadBestFitImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options) 102 93 { 103 94 Document* document = loader.document(); … … 110 101 fillImageSet(); 111 102 112 if (!m_accessedBestFitImage) { 113 // FIXME: In the future, we want to take much more than deviceScaleFactor into acount here. 114 // All forms of scale should be included: Page::pageScaleFactor(), Frame::pageZoomFactor(), 115 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 116 ImageWithScale image = bestImageForScaleFactor(); 117 CachedResourceRequest request(ResourceRequest(document->completeURL(image.imageURL)), options); 118 request.setInitiator(cachedResourceRequestInitiators().css); 119 if (options.mode == FetchOptions::Mode::Cors) { 120 ASSERT(document->securityOrigin()); 121 updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials); 122 } 123 if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) { 124 detachPendingImage(); 125 m_image = StyleCachedImage::createForImageSet(cachedImage.get(), image.scaleFactor, *this); 126 m_accessedBestFitImage = true; 127 } 103 if (m_accessedBestFitImage) 104 return; 105 // FIXME: In the future, we want to take much more than deviceScaleFactor into acount here. 106 // All forms of scale should be included: Page::pageScaleFactor(), Frame::pageZoomFactor(), 107 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 108 ImageWithScale image = bestImageForScaleFactor(); 109 CachedResourceRequest request(ResourceRequest(document->completeURL(image.imageURL)), options); 110 request.setInitiator(cachedResourceRequestInitiators().css); 111 if (options.mode == FetchOptions::Mode::Cors) { 112 ASSERT(document->securityOrigin()); 113 updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials); 128 114 } 129 130 return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr; 115 if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) { 116 styleImage(*document).setCachedImage(*cachedImage, image.scaleFactor); 117 m_accessedBestFitImage = true; 118 } 131 119 } 132 120 133 Style Image* CSSImageSetValue::cachedOrPendingImageSet(const Document& document)121 StyleCachedImage& CSSImageSetValue::styleImage(const Document& document) 134 122 { 135 123 if (!m_image) 136 m_image = Style PendingImage::create(this);137 else if (!m_image->isPending Image()) {124 m_image = StyleCachedImage::create(*this); 125 else if (!m_image->isPending()) { 138 126 float deviceScaleFactor = 1; 139 127 if (Page* page = document.page()) … … 143 131 if (deviceScaleFactor != m_scaleFactor) { 144 132 m_accessedBestFitImage = false; 145 m_image = StylePendingImage::create(this); 133 m_image->detachFromCSSValue(); 134 m_image = StyleCachedImage::create(*this); 146 135 } 147 136 } 148 137 149 return m_image.get();138 return *m_image; 150 139 } 151 140 … … 182 171 bool CSSImageSetValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const 183 172 { 184 if (! is<StyleCachedImage>(m_image.get()))173 if (!m_image) 185 174 return false; 186 CachedImage* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage(); 187 ASSERT(cachedResource); 175 CachedImage* cachedResource = m_image->cachedImage(); 176 if (!cachedResource) 177 return false; 188 178 return handler(*cachedResource); 189 179 } -
trunk/Source/WebCore/css/CSSImageSetValue.h
r205093 r205181 46 46 ~CSSImageSetValue(); 47 47 48 StyleCachedImage* bestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&); 49 50 // Returns a StyleCachedImage if the best fit image has been cached already, otherwise a StylePendingImage. 51 StyleImage* cachedOrPendingImageSet(const Document&); 48 void loadBestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&); 49 StyleCachedImage& styleImage(const Document&); 52 50 53 51 String customCSSText() const; … … 71 69 CSSImageSetValue(const CSSImageSetValue& cloneFrom); 72 70 73 void detachPendingImage();74 71 void fillImageSet(); 75 72 static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale second) { return first.scaleFactor < second.scaleFactor; } 76 73 77 RefPtr<Style Image> m_image;74 RefPtr<StyleCachedImage> m_image; 78 75 bool m_accessedBestFitImage; 79 76 -
trunk/Source/WebCore/css/CSSImageValue.cpp
r204014 r205181 34 34 #include "MemoryCache.h" 35 35 #include "StyleCachedImage.h" 36 #include "StylePendingImage.h"37 36 38 37 namespace WebCore { … … 45 44 } 46 45 47 CSSImageValue::CSSImageValue( const String& url, StyleImage*image)46 CSSImageValue::CSSImageValue(CachedImage& image) 48 47 : CSSValue(ImageClass) 49 , m_url( url)50 , m_image( image)48 , m_url(image.url()) 49 , m_image(StyleCachedImage::create(*this)) 51 50 , m_accessedImage(true) 52 51 { 52 m_image->setCachedImage(image); 53 53 } 54 54 55 inline void CSSImageValue::detachPendingImage()56 {57 if (is<StylePendingImage>(m_image.get()))58 downcast<StylePendingImage>(*m_image).detachFromCSSValue();59 }60 55 61 56 CSSImageValue::~CSSImageValue() 62 57 { 63 detachPendingImage(); 58 if (m_image) 59 m_image->detachFromCSSValue(); 64 60 } 65 61 66 StyleImage& CSSImageValue::cachedOrPendingImage() 62 bool CSSImageValue::isPending() const 63 { 64 return !m_image || !m_image->cachedImage(); 65 } 66 67 StyleCachedImage& CSSImageValue::styleImage() 67 68 { 68 69 if (!m_image) 69 m_image = Style PendingImage::create(this);70 m_image = StyleCachedImage::create(*this); 70 71 71 72 return *m_image; 72 73 } 73 74 74 StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)75 void CSSImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options) 75 76 { 76 if (!m_accessedImage) { 77 m_accessedImage = true; 77 if (m_accessedImage) 78 return; 79 m_accessedImage = true; 78 80 79 80 81 82 83 81 CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)), options); 82 if (m_initiatorName.isEmpty()) 83 request.setInitiator(cachedResourceRequestInitiators().css); 84 else 85 request.setInitiator(m_initiatorName); 84 86 85 if (options.mode == FetchOptions::Mode::Cors) { 86 ASSERT(loader.document()->securityOrigin()); 87 updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials); 88 } 89 if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) { 90 detachPendingImage(); 91 m_image = StyleCachedImage::create(cachedImage.get()); 92 } 87 if (options.mode == FetchOptions::Mode::Cors) { 88 ASSERT(loader.document()->securityOrigin()); 89 updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials); 93 90 } 94 95 return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr;91 if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) 92 styleImage().setCachedImage(*cachedImage); 96 93 } 97 94 98 95 bool CSSImageValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const 99 96 { 100 if (! is<StyleCachedImage>(m_image.get()))97 if (!m_image) 101 98 return false; 102 CachedResource* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage(); 103 ASSERT(cachedResource); 99 CachedResource* cachedResource = m_image->cachedImage(); 100 if (!cachedResource) 101 return false; 104 102 return handler(*cachedResource); 105 103 } -
trunk/Source/WebCore/css/CSSImageValue.h
r205093 r205181 27 27 namespace WebCore { 28 28 29 class CachedImage; 29 30 class CachedResourceLoader; 30 31 class Element; 31 32 class StyleCachedImage; 32 class StyleImage;33 33 class RenderElement; 34 34 struct ResourceLoaderOptions; … … 37 37 public: 38 38 static Ref<CSSImageValue> create(const String& url) { return adoptRef(*new CSSImageValue(url)); } 39 static Ref<CSSImageValue> create( const String& url, StyleImage* image) { return adoptRef(*new CSSImageValue(url,image)); }39 static Ref<CSSImageValue> create(CachedImage& image) { return adoptRef(*new CSSImageValue(image)); } 40 40 ~CSSImageValue(); 41 41 42 StyleCachedImage* cachedImage(CachedResourceLoader&, const ResourceLoaderOptions&);43 // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.44 Style Image& cachedOrPendingImage();42 bool isPending() const; 43 void loadImage(CachedResourceLoader&, const ResourceLoaderOptions&); 44 StyleCachedImage& styleImage(); 45 45 46 46 const String& url() const { return m_url; } … … 60 60 private: 61 61 explicit CSSImageValue(const String& url); 62 CSSImageValue(const String& url, StyleImage*); 63 void detachPendingImage(); 62 explicit CSSImageValue(CachedImage&); 64 63 65 64 String m_url; 66 RefPtr<Style Image> m_image;65 RefPtr<StyleCachedImage> m_image; 67 66 bool m_accessedImage; 68 67 AtomicString m_initiatorName; -
trunk/Source/WebCore/css/StyleResolver.cpp
r204566 r205181 124 124 #include "StyleFontSizeFunctions.h" 125 125 #include "StyleGeneratedImage.h" 126 #include "StylePendingImage.h"127 126 #include "StyleProperties.h" 128 127 #include "StylePropertyShorthand.h" … … 1724 1723 Ref<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID property, CSSImageValue& value) 1725 1724 { 1726 Ref<StyleImage> image = value. cachedOrPendingImage();1727 if (image->isPending Image())1725 Ref<StyleImage> image = value.styleImage(); 1726 if (image->isPending()) 1728 1727 m_state.ensurePendingResources().pendingImages.set(property, &value); 1729 1728 return image; … … 1736 1735 downcast<CSSFilterImageValue>(value).createFilterOperations(this); 1737 1736 } 1738 1739 if (value.isPending()) { 1737 if (value.isPending()) 1740 1738 m_state.ensurePendingResources().pendingImages.set(property, &value); 1741 return StylePendingImage::create(&value); 1742 } 1739 1743 1740 return StyleGeneratedImage::create(value); 1744 1741 } … … 1746 1743 RefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID property, CSSImageSetValue& value) 1747 1744 { 1748 RefPtr<StyleImage> image = value.cachedOrPendingImageSet(document());1749 if (image && image->isPendingImage())1745 auto& image = value.styleImage(document()); 1746 if (image.isPending()) 1750 1747 m_state.ensurePendingResources().pendingImages.set(property, &value); 1751 return image;1748 return ℑ 1752 1749 } 1753 1750 1754 1751 RefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(CSSPropertyID property, CSSCursorImageValue& value) 1755 1752 { 1756 RefPtr<StyleImage> image = value.cachedOrPendingImage(document());1757 if (image && image->isPendingImage())1753 auto& image = value.styleImage(document()); 1754 if (image.isPending()) 1758 1755 m_state.ensurePendingResources().pendingImages.set(property, &value); 1759 return image;1756 return ℑ 1760 1757 } 1761 1758 -
trunk/Source/WebCore/page/PageSerializer.cpp
r203324 r205181 332 332 continue; 333 333 334 auto& styleImage = downcast<CSSImageValue>(*cssValue).cachedOrPendingImage(); 335 // Non cached-images are just place-holders and do not contain data. 336 if (!is<StyleCachedImage>(styleImage)) 334 auto& styleImage = downcast<CSSImageValue>(*cssValue).styleImage(); 335 336 auto* image = styleImage.cachedImage(); 337 if (!image) 337 338 continue; 338 339 CachedImage* image = downcast<StyleCachedImage>(styleImage).cachedImage();340 339 341 340 URL url = document->completeURL(image->url()); -
trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp
r201290 r205181 226 226 FilterOperations filterResult = blendFilterOperations(anim, from, to, progress); 227 227 228 RefPtr<StyleCachedImage> styledImage = StyleCachedImage::create(image); 229 auto imageValue = CSSImageValue::create(image->url(), styledImage.get()); 228 auto imageValue = CSSImageValue::create(*image); 230 229 auto filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer()->style(), filterResult, DoNotAdjustPixelValues); 231 230 … … 291 290 return toStyleImage; 292 291 293 auto fromImageValue = CSSImageValue::create( fromStyleImage->cachedImage()->url(), fromStyleImage);294 auto toImageValue = CSSImageValue::create( toStyleImage->cachedImage()->url(), toStyleImage);292 auto fromImageValue = CSSImageValue::create(*fromStyleImage->cachedImage()); 293 auto toImageValue = CSSImageValue::create(*toStyleImage->cachedImage()); 295 294 auto percentageValue = CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER); 296 295 -
trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp
r191083 r205181 64 64 { 65 65 // Generated content may trigger calls to image() while we're still pending, don't assert but gracefully exit. 66 if (m_styleImage->isPending Image())66 if (m_styleImage->isPending()) 67 67 return nullptr; 68 68 return m_styleImage->image(m_renderer, IntSize(width, height)); -
trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp
r191234 r205181 157 157 : LayoutRect(LayoutPoint(), imageSize); 158 158 159 ASSERT(!styleImage->isPending Image());159 ASSERT(!styleImage->isPending()); 160 160 RefPtr<Image> image = styleImage->image(const_cast<RenderBox*>(&m_renderer), imageSize); 161 161 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin); -
trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp
r204566 r205181 31 31 namespace WebCore { 32 32 33 StyleCachedImage::StyleCachedImage(CachedImage* image, float scaleFactor, CSSImageSetValue* cssValue) 34 : m_image(image) 35 , m_scaleFactor(scaleFactor) 36 , m_cssImageSetValue(cssValue) 33 StyleCachedImage::StyleCachedImage(CSSValue& cssValue) 34 : m_cssValue(&cssValue) 37 35 { 38 36 m_isCachedImage = true; 39 m_image->addClient(this);40 37 } 41 38 42 39 StyleCachedImage::~StyleCachedImage() 43 40 { 44 m_image->removeClient(this); 41 if (m_image) 42 m_image->removeClient(this); 43 } 44 45 void StyleCachedImage::setCachedImage(CachedImage& image, float scaleFactor) 46 { 47 ASSERT(!m_image); 48 m_image = ℑ 49 m_image->addClient(this); 50 m_scaleFactor = scaleFactor; 45 51 } 46 52 47 53 PassRefPtr<CSSValue> StyleCachedImage::cssValue() const 48 54 { 49 if (m_css ImageSetValue)50 return const_cast<CSSImageSetValue*>(m_cssImageSetValue);55 if (m_cssValue) 56 return m_cssValue; 51 57 return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI); 52 58 } … … 54 60 bool StyleCachedImage::canRender(const RenderObject* renderer, float multiplier) const 55 61 { 62 if (!m_image) 63 return false; 56 64 return m_image->canRender(renderer, multiplier); 65 } 66 67 bool StyleCachedImage::isPending() const 68 { 69 return !m_image; 57 70 } 58 71 59 72 bool StyleCachedImage::isLoaded() const 60 73 { 74 if (!m_image) 75 return false; 61 76 return m_image->isLoaded(); 62 77 } … … 64 79 bool StyleCachedImage::errorOccurred() const 65 80 { 81 if (!m_image) 82 return false; 66 83 return m_image->errorOccurred(); 67 84 } … … 69 86 FloatSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const 70 87 { 88 if (!m_image) 89 return { }; 71 90 FloatSize size = m_image->imageSizeForRenderer(renderer, multiplier); 72 91 size.scale(1 / m_scaleFactor); … … 76 95 bool StyleCachedImage::imageHasRelativeWidth() const 77 96 { 97 if (!m_image) 98 return false; 78 99 return m_image->imageHasRelativeWidth(); 79 100 } … … 81 102 bool StyleCachedImage::imageHasRelativeHeight() const 82 103 { 104 if (!m_image) 105 return false; 83 106 return m_image->imageHasRelativeHeight(); 84 107 } … … 86 109 void StyleCachedImage::computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) 87 110 { 111 if (!m_image) 112 return; 88 113 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio); 89 114 } … … 91 116 bool StyleCachedImage::usesImageContainerSize() const 92 117 { 118 if (!m_image) 119 return false; 93 120 return m_image->usesImageContainerSize(); 94 121 } … … 96 123 void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor) 97 124 { 125 if (!m_image) 126 return; 98 127 m_image->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor); 99 128 } … … 101 130 void StyleCachedImage::addClient(RenderElement* renderer) 102 131 { 132 if (!m_image) 133 return; 103 134 m_image->addClient(renderer); 104 135 } … … 106 137 void StyleCachedImage::removeClient(RenderElement* renderer) 107 138 { 139 if (!m_image) 140 return; 108 141 m_image->removeClient(renderer); 109 142 } … … 111 144 RefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const FloatSize&) const 112 145 { 146 if (!m_image) 147 return nullptr; 113 148 return m_image->imageForRenderer(renderer); 114 149 } … … 121 156 bool StyleCachedImage::knownToBeOpaque(const RenderElement* renderer) const 122 157 { 158 if (!m_image) 159 return false; 123 160 return m_image->currentFrameKnownToBeOpaque(renderer); 124 161 } -
trunk/Source/WebCore/rendering/style/StyleCachedImage.h
r204560 r205181 31 31 namespace WebCore { 32 32 33 class CSS ImageSetValue;33 class CSSValue; 34 34 class CachedImage; 35 35 … … 37 37 WTF_MAKE_FAST_ALLOCATED; 38 38 public: 39 static Ref<StyleCachedImage> create(CachedImage* image) { return adoptRef(*new StyleCachedImage(image, 1, nullptr)); } 40 static Ref<StyleCachedImage> createForImageSet(CachedImage* image, float scaleFactor, CSSImageSetValue& cssValue) { return adoptRef(*new StyleCachedImage(image, scaleFactor, &cssValue)); } 39 static Ref<StyleCachedImage> create(CSSValue& cssValue) { return adoptRef(*new StyleCachedImage(cssValue)); } 41 40 virtual ~StyleCachedImage(); 42 41 43 42 CachedImage* cachedImage() const override { return m_image.get(); } 44 43 45 void detachFromCSSValue() { m_cssImageSetValue = nullptr; } 44 void detachFromCSSValue() { m_cssValue = nullptr; } 45 void setCSSValue(CSSValue& value) { m_cssValue = &value; } 46 46 47 private: 47 void setCachedImage(CachedImage&, float scaleFactor = 1); 48 48 49 WrappedImagePtr data() const override { return m_image.get(); } 49 50 … … 51 52 52 53 bool canRender(const RenderObject*, float multiplier) const override; 54 bool isPending() const override; 53 55 bool isLoaded() const override; 54 56 bool errorOccurred() const override; … … 65 67 bool knownToBeOpaque(const RenderElement*) const override; 66 68 67 StyleCachedImage(CachedImage*, float scaleFactor, CSSImageSetValue*); 69 private: 70 StyleCachedImage(CSSValue&); 68 71 72 CSSValue* m_cssValue; 73 float m_scaleFactor { 1 }; 69 74 CachedResourceHandle<CachedImage> m_image; 70 float m_scaleFactor;71 CSSImageSetValue* m_cssImageSetValue; // Not retained; it owns us.72 75 }; 73 76 -
trunk/Source/WebCore/rendering/style/StyleGeneratedImage.cpp
r194496 r205181 41 41 { 42 42 return const_cast<CSSImageGeneratorValue*>(m_imageGeneratorValue.ptr()); 43 } 44 45 bool StyleGeneratedImage::isPending() const 46 { 47 return m_imageGeneratorValue->isPending(); 43 48 } 44 49 -
trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h
r197563 r205181 46 46 PassRefPtr<CSSValue> cssValue() const override; 47 47 48 bool isPending() const override; 48 49 FloatSize imageSize(const RenderElement*, float multiplier) const override; 49 50 bool imageHasRelativeWidth() const override { return !m_fixedSize; } -
trunk/Source/WebCore/rendering/style/StyleImage.h
r204560 r205181 48 48 bool operator==(const StyleImage& other) const 49 49 { 50 return data() == other.data();50 return &other == this || (data() && data() == other.data()); 51 51 } 52 52 … … 54 54 55 55 virtual bool canRender(const RenderObject*, float /*multiplier*/) const { return true; } 56 virtual bool isPending() const = 0; 56 57 virtual bool isLoaded() const { return true; } 57 58 virtual bool errorOccurred() const { return false; } … … 71 72 72 73 ALWAYS_INLINE bool isCachedImage() const { return m_isCachedImage; } 73 ALWAYS_INLINE bool isPendingImage() const { return m_isPendingImage; }74 74 ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; } 75 75 … … 77 77 StyleImage() 78 78 : m_isCachedImage(false) 79 , m_isPendingImage(false)80 79 , m_isGeneratedImage(false) 81 80 { 82 81 } 83 82 bool m_isCachedImage : 1; 84 bool m_isPendingImage : 1;85 83 bool m_isGeneratedImage : 1; 86 84 }; -
trunk/Source/WebCore/style/StylePendingResources.cpp
r204566 r205181 27 27 #include "StylePendingResources.h" 28 28 29 #include "CSSCursorImageValue.h" 30 #include "CSSImageGeneratorValue.h" 31 #include "CSSImageSetValue.h" 32 #include "CSSImageValue.h" 29 33 #include "CachedResourceLoader.h" 30 34 #include "CachedSVGDocumentReference.h" … … 37 41 #include "StyleCachedImage.h" 38 42 #include "StyleGeneratedImage.h" 39 #include "StylePendingImage.h"40 43 #include "TransformFunctions.h" 41 44 … … 44 47 45 48 enum class LoadPolicy { Normal, ShapeOutside }; 46 static RefPtr<StyleImage> loadPendingImage(Document& document, const StyleImage& image, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal)49 static void loadPendingImage(Document& document, const StyleImage* styleImage, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal) 47 50 { 48 auto& pendingImage = downcast<StylePendingImage>(image); 51 if (!styleImage || !styleImage->isPending()) 52 return; 53 49 54 ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions(); 50 55 options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck; … … 56 61 } 57 62 58 if (auto imageValue = pendingImage.cssImageValue()) 59 return imageValue->cachedImage(document.cachedResourceLoader(), options); 63 auto cssValue = const_cast<StyleImage*>(styleImage)->cssValue(); 64 if (is<CSSImageValue>(cssValue.get())) { 65 downcast<CSSImageValue>(*cssValue).loadImage(document.cachedResourceLoader(), options); 66 return; 67 }; 60 68 61 if ( auto imageGeneratorValue = pendingImage.cssImageGeneratorValue()) {62 imageGeneratorValue->loadSubimages(document.cachedResourceLoader(), options);63 return StyleGeneratedImage::create(*imageGeneratorValue);64 } 69 if (is<CSSImageSetValue>(cssValue.get())) { 70 downcast<CSSImageSetValue>(*cssValue).loadBestFitImage(document.cachedResourceLoader(), options); 71 return; 72 }; 65 73 66 if (auto cursorImageValue = pendingImage.cssCursorImageValue()) 67 return cursorImageValue->cachedImage(document.cachedResourceLoader(), options); 74 if (is<CSSImageGeneratorValue>(cssValue.get())) { 75 downcast<CSSImageGeneratorValue>(*cssValue).loadSubimages(document.cachedResourceLoader(), options); 76 return; 77 }; 68 78 69 if ( auto imageSetValue = pendingImage.cssImageSetValue())70 return imageSetValue->bestFitImage(document.cachedResourceLoader(), options);71 72 return nullptr;79 if (is<CSSCursorImageValue>(cssValue.get())) { 80 downcast<CSSCursorImageValue>(*cssValue).loadImage(document.cachedResourceLoader(), options); 81 return; 82 }; 73 83 } 74 84 … … 78 88 switch (currentProperty) { 79 89 case CSSPropertyBackgroundImage: { 80 for (FillLayer* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { 81 auto* styleImage = backgroundLayer->image(); 82 if (is<StylePendingImage>(styleImage)) 83 backgroundLayer->setImage(loadPendingImage(document, *styleImage, element)); 84 } 90 for (auto* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) 91 loadPendingImage(document, backgroundLayer->image(), element); 85 92 break; 86 93 } 87 94 case CSSPropertyContent: { 88 for ( ContentData* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) {95 for (auto* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) { 89 96 if (is<ImageContentData>(*contentData)) { 90 97 auto& styleImage = downcast<ImageContentData>(*contentData).image(); 91 if (is<StylePendingImage>(styleImage)) { 92 if (auto loadedImage = loadPendingImage(document, styleImage, element)) 93 downcast<ImageContentData>(*contentData).setImage(WTFMove(loadedImage)); 94 } 98 loadPendingImage(document, &styleImage, element); 95 99 } 96 100 } … … 98 102 } 99 103 case CSSPropertyCursor: { 100 if (CursorList* cursorList = style.cursors()) { 101 for (size_t i = 0; i < cursorList->size(); ++i) { 102 CursorData& currentCursor = cursorList->at(i); 103 auto* styleImage = currentCursor.image(); 104 if (is<StylePendingImage>(styleImage)) 105 currentCursor.setImage(loadPendingImage(document, *styleImage, element)); 106 } 104 if (auto* cursorList = style.cursors()) { 105 for (size_t i = 0; i < cursorList->size(); ++i) 106 loadPendingImage(document, cursorList->at(i).image(), element); 107 107 } 108 108 break; 109 109 } 110 110 case CSSPropertyListStyleImage: { 111 auto* styleImage = style.listStyleImage(); 112 if (is<StylePendingImage>(styleImage)) 113 style.setListStyleImage(loadPendingImage(document, *styleImage, element)); 111 loadPendingImage(document, style.listStyleImage(), element); 114 112 break; 115 113 } 116 114 case CSSPropertyBorderImageSource: { 117 auto* styleImage = style.borderImageSource(); 118 if (is<StylePendingImage>(styleImage)) 119 style.setBorderImageSource(loadPendingImage(document, *styleImage, element)); 115 loadPendingImage(document, style.borderImageSource(), element); 120 116 break; 121 117 } 122 118 case CSSPropertyWebkitBoxReflect: { 123 if (StyleReflection* reflection = style.boxReflect()) { 124 const NinePieceImage& maskImage = reflection->mask(); 125 auto* styleImage = maskImage.image(); 126 if (is<StylePendingImage>(styleImage)) { 127 auto loadedImage = loadPendingImage(document, *styleImage, element); 128 reflection->setMask(NinePieceImage(WTFMove(loadedImage), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule())); 129 } 130 } 119 if (auto* reflection = style.boxReflect()) 120 loadPendingImage(document, reflection->mask().image(), element); 131 121 break; 132 122 } 133 123 case CSSPropertyWebkitMaskBoxImageSource: { 134 auto* styleImage = style.maskBoxImageSource(); 135 if (is<StylePendingImage>(styleImage)) 136 style.setMaskBoxImageSource(loadPendingImage(document, *styleImage, element)); 124 loadPendingImage(document, style.maskBoxImageSource(), element); 137 125 break; 138 126 } 139 127 case CSSPropertyWebkitMaskImage: { 140 for (FillLayer* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { 141 auto* styleImage = maskLayer->image(); 142 if (is<StylePendingImage>(styleImage)) 143 maskLayer->setImage(loadPendingImage(document, *styleImage, element)); 144 } 128 for (auto* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) 129 loadPendingImage(document, maskLayer->image(), element); 145 130 break; 146 131 } 147 132 #if ENABLE(CSS_SHAPES) 148 133 case CSSPropertyWebkitShapeOutside: { 149 if (!style.shapeOutside()) 150 return; 151 152 StyleImage* image = style.shapeOutside()->image(); 153 if (is<StylePendingImage>(image)) 154 style.shapeOutside()->setImage(loadPendingImage(document, *image, element, LoadPolicy::ShapeOutside)); 155 134 if (style.shapeOutside()) 135 loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::ShapeOutside); 156 136 break; 157 137 }
Note: See TracChangeset
for help on using the changeset viewer.