Changeset 205421 in webkit
- Timestamp:
- Sep 4, 2016 11:50:21 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205419 r205421 1 2016-09-04 Antti Koivisto <antti@apple.com> 2 3 Remove Style::PendingResources 4 https://bugs.webkit.org/show_bug.cgi?id=161574 5 6 Reviewed by Andreas Kling. 7 8 RenderStyle contains all the information needed to initialize resource loads. There is no need for this side structure. 9 10 * css/CSSFilterImageValue.cpp: 11 (WebCore::CSSFilterImageValue::loadSubimages): 12 13 Load external SVG resources along with any image resources. 14 15 * css/CSSToStyleMap.cpp: 16 (WebCore::CSSToStyleMap::styleImage): 17 (WebCore::CSSToStyleMap::mapFillImage): 18 (WebCore::CSSToStyleMap::mapNinePieceImage): 19 * css/CSSToStyleMap.h: 20 * css/StyleBuilderConverter.h: 21 (WebCore::StyleBuilderConverter::convertStyleImage): 22 (WebCore::StyleBuilderConverter::convertShapeValue): 23 * css/StyleBuilderCustom.h: 24 (WebCore::StyleBuilderCustom::applyValueCursor): 25 (WebCore::StyleBuilderCustom::applyValueContent): 26 * css/StyleResolver.cpp: 27 (WebCore::StyleResolver::State::clear): 28 (WebCore::StyleResolver::styleImage): 29 (WebCore::StyleResolver::createFilterOperations): 30 (WebCore::StyleResolver::loadPendingResources): 31 (WebCore::StyleResolver::State::ensurePendingResources): Deleted. 32 (WebCore::StyleResolver::styleCachedImageFromValue): Deleted. 33 (WebCore::StyleResolver::styleGeneratedImageFromValue): Deleted. 34 * css/StyleResolver.h: 35 (WebCore::StyleResolver::State::takePendingResources): Deleted. 36 * platform/graphics/filters/FilterOperation.cpp: 37 (WebCore::ReferenceFilterOperation::loadExternalDocumentIfNeeded): 38 (WebCore::ReferenceFilterOperation::getOrCreateCachedSVGDocumentReference): Deleted. 39 * platform/graphics/filters/FilterOperation.h: 40 (WebCore::ReferenceFilterOperation::cachedSVGDocumentReference): 41 * rendering/style/StyleCachedImage.cpp: 42 (WebCore::StyleCachedImage::StyleCachedImage): 43 * style/StylePendingResources.cpp: 44 (WebCore::Style::loadPendingResources): 45 46 Trigger resource loads by checking pending resources in RenderStyle unconditionally. Keeping track of them 47 separately wasn't necessary or a meaningful optimization. 48 49 (WebCore::Style::loadPendingImages): Deleted. 50 (WebCore::Style::loadPendingSVGFilters): Deleted. 51 * style/StylePendingResources.h: 52 1 53 2016-09-04 Antti Koivisto <antti@apple.com> 2 54 -
trunk/Source/WebCore/css/CSSFilterImageValue.cpp
r205181 r205421 31 31 #include "CachedImage.h" 32 32 #include "CachedResourceLoader.h" 33 #include "CachedSVGDocumentReference.h" 33 34 #include "CrossfadeGeneratedImage.h" 34 35 #include "FilterEffectRenderer.h" … … 95 96 if (m_cachedImage) 96 97 m_cachedImage->addClient(&m_filterSubimageObserver); 98 } 99 100 for (auto& filterOperation : m_filterOperations.operations()) { 101 if (!is<ReferenceFilterOperation>(filterOperation.get())) 102 continue; 103 auto& referenceFilterOperation = downcast<ReferenceFilterOperation>(*filterOperation); 104 referenceFilterOperation.loadExternalDocumentIfNeeded(cachedResourceLoader, options); 97 105 } 98 106 -
trunk/Source/WebCore/css/CSSToStyleMap.cpp
r204566 r205421 67 67 } 68 68 69 RefPtr<StyleImage> CSSToStyleMap::styleImage(CSS PropertyID propertyId, CSSValue& value)70 { 71 return m_resolver->styleImage( propertyId,value);69 RefPtr<StyleImage> CSSToStyleMap::styleImage(CSSValue& value) 70 { 71 return m_resolver->styleImage(value); 72 72 } 73 73 … … 156 156 } 157 157 158 layer.setImage(styleImage( propertyID,value));158 layer.setImage(styleImage(value)); 159 159 } 160 160 … … 558 558 CSSValueList& borderImage = downcast<CSSValueList>(*value); 559 559 560 // Set the image (this kicks off the load).561 CSSPropertyID imageProperty;562 if (property == CSSPropertyWebkitBorderImage)563 imageProperty = CSSPropertyBorderImageSource;564 else if (property == CSSPropertyWebkitMaskBoxImage)565 imageProperty = CSSPropertyWebkitMaskBoxImageSource;566 else567 imageProperty = property;568 569 560 for (auto& current : borderImage) { 570 561 if (is<CSSImageValue>(current.get()) || is<CSSImageGeneratorValue>(current.get()) || is<CSSImageSetValue>(current.get())) 571 image.setImage(styleImage( imageProperty,current.get()));562 image.setImage(styleImage(current.get())); 572 563 else if (is<CSSBorderImageSliceValue>(current.get())) 573 564 mapNinePieceImageSlice(current, image); -
trunk/Source/WebCore/css/CSSToStyleMap.h
r200098 r205421 88 88 // is held by the StyleResolver, and likely provided to this object 89 89 // during the resolve. 90 RefPtr<StyleImage> styleImage(CSS PropertyID, CSSValue&);90 RefPtr<StyleImage> styleImage(CSSValue&); 91 91 92 92 StyleResolver* m_resolver; -
trunk/Source/WebCore/css/StyleBuilderConverter.h
r204566 r205421 409 409 inline PassRefPtr<StyleImage> StyleBuilderConverter::convertStyleImage(StyleResolver& styleResolver, CSSValue& value) 410 410 { 411 return styleResolver.styleImage( property,value);411 return styleResolver.styleImage(value); 412 412 } 413 413 … … 742 742 743 743 if (isImageShape(value)) 744 return ShapeValue::createImageValue(styleResolver.styleImage( CSSPropertyWebkitShapeOutside,value));744 return ShapeValue::createImageValue(styleResolver.styleImage(value)); 745 745 746 746 RefPtr<BasicShape> shape; -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r205419 r205421 1148 1148 if (is<CSSCursorImageValue>(item.get())) { 1149 1149 auto& image = downcast<CSSCursorImageValue>(item.get()); 1150 styleResolver.style()->addCursor(styleResolver.styleImage( CSSPropertyCursor,image), image.hotSpot());1150 styleResolver.style()->addCursor(styleResolver.styleImage(image), image.hotSpot()); 1151 1151 continue; 1152 1152 } … … 1315 1315 didSet = true; 1316 1316 } else if (is<CSSImageSetValue>(item.get())) { 1317 styleResolver.style()->setContent( styleResolver.styleCachedImageFromValue(CSSPropertyContent,item), didSet);1317 styleResolver.style()->setContent(StyleCachedImage::create(item), didSet); 1318 1318 didSet = true; 1319 1319 } 1320 1320 1321 1321 if (is<CSSImageValue>(item.get())) { 1322 styleResolver.style()->setContent( styleResolver.styleCachedImageFromValue(CSSPropertyContent,item), didSet);1322 styleResolver.style()->setContent(StyleCachedImage::create(item), didSet); 1323 1323 didSet = true; 1324 1324 continue; -
trunk/Source/WebCore/css/StyleResolver.cpp
r205419 r205421 190 190 m_ownedParentStyle = nullptr; 191 191 m_regionForStyling = nullptr; 192 m_pendingResources = nullptr;193 192 m_cssToLengthConversionData = CSSToLengthConversionData(); 194 193 } … … 377 376 m_ownedParentStyle = WTFMove(parentStyle); 378 377 m_parentStyle = m_ownedParentStyle.get(); 379 }380 381 Style::PendingResources& StyleResolver::State::ensurePendingResources()382 {383 if (!m_pendingResources)384 m_pendingResources = std::make_unique<Style::PendingResources>();385 return *m_pendingResources;386 378 } 387 379 … … 1701 1693 } 1702 1694 1703 RefPtr<StyleImage> StyleResolver::styleImage(CSS PropertyID property, CSSValue& value)1695 RefPtr<StyleImage> StyleResolver::styleImage(CSSValue& value) 1704 1696 { 1705 1697 if (is<CSSImageGeneratorValue>(value)) { 1706 1698 if (is<CSSGradientValue>(value)) 1707 return styleGeneratedImageFromValue(property, *downcast<CSSGradientValue>(value).gradientWithStylesResolved(this)); 1708 return styleGeneratedImageFromValue(property, downcast<CSSImageGeneratorValue>(value)); 1699 return StyleGeneratedImage::create(*downcast<CSSGradientValue>(value).gradientWithStylesResolved(this)); 1700 1701 if (is<CSSFilterImageValue>(value)) { 1702 // FilterImage needs to calculate FilterOperations. 1703 downcast<CSSFilterImageValue>(value).createFilterOperations(this); 1704 } 1705 return StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(value)); 1709 1706 } 1710 1707 1711 1708 if (is<CSSImageValue>(value) || is<CSSImageSetValue>(value) || is<CSSCursorImageValue>(value)) 1712 return styleCachedImageFromValue(property,value);1709 return StyleCachedImage::create(value); 1713 1710 1714 1711 return nullptr; 1715 }1716 1717 Ref<StyleCachedImage> StyleResolver::styleCachedImageFromValue(CSSPropertyID property, CSSValue& value)1718 {1719 auto image = StyleCachedImage::create(value);1720 if (image->isPending())1721 m_state.ensurePendingResources().pendingImages.set(property, &value);1722 return image;1723 }1724 1725 Ref<StyleGeneratedImage> StyleResolver::styleGeneratedImageFromValue(CSSPropertyID property, CSSImageGeneratorValue& value)1726 {1727 if (is<CSSFilterImageValue>(value)) {1728 // FilterImage needs to calculate FilterOperations.1729 downcast<CSSFilterImageValue>(value).createFilterOperations(this);1730 }1731 if (value.isPending())1732 m_state.ensurePendingResources().pendingImages.set(property, &value);1733 1734 return StyleGeneratedImage::create(value);1735 1712 } 1736 1713 … … 1969 1946 1970 1947 RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(cssUrl, url.fragmentIdentifier()); 1971 if (SVGURIReference::isExternalURIReference(cssUrl, m_state.document()))1972 state.ensurePendingResources().pendingSVGFilters.append(operation);1973 1974 1948 operations.operations().append(operation); 1975 1949 continue; … … 2079 2053 TemporaryChange<bool> changeInLoadPendingImages(m_inLoadPendingImages, true); 2080 2054 2081 if (auto pendingResources = state().takePendingResources()) 2082 Style::loadPendingResources(*pendingResources, document(), *style(), m_state.element()); 2055 Style::loadPendingResources(*style(), document(), m_state.element()); 2083 2056 } 2084 2057 -
trunk/Source/WebCore/css/StyleResolver.h
r205419 r205421 77 77 class StyleImage; 78 78 class StyleKeyframe; 79 class StylePendingImage;80 79 class StyleProperties; 81 80 class StyleRule; … … 408 407 bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); } 409 408 410 Style::PendingResources& ensurePendingResources();411 std::unique_ptr<Style::PendingResources> takePendingResources() { return WTFMove(m_pendingResources); }412 413 409 const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; } 414 410 … … 447 443 Color m_backgroundColor; 448 444 449 std::unique_ptr<Style::PendingResources> m_pendingResources;450 445 CSSToLengthConversionData m_cssToLengthConversionData; 451 446 … … 460 455 const State& state() const { return m_state; } 461 456 462 RefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue&); 463 Ref<StyleCachedImage> styleCachedImageFromValue(CSSPropertyID, CSSValue&); 464 Ref<StyleGeneratedImage> styleGeneratedImageFromValue(CSSPropertyID, CSSImageGeneratorValue&); 457 RefPtr<StyleImage> styleImage(CSSValue&); 465 458 466 459 bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); } -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
r200343 r205421 28 28 29 29 #include "AnimationUtilities.h" 30 #include "CachedResourceLoader.h" 30 31 #include "CachedSVGDocumentReference.h" 31 32 #include "FilterEffect.h" 33 #include "SVGURIReference.h" 32 34 #include "TextStream.h" 33 35 … … 60 62 return m_url == downcast<ReferenceFilterOperation>(operation).m_url; 61 63 } 62 63 CachedSVGDocumentReference* ReferenceFilterOperation::getOrCreateCachedSVGDocumentReference() 64 { 65 if (!m_cachedSVGDocumentReference) 66 m_cachedSVGDocumentReference = std::make_unique<CachedSVGDocumentReference>(m_url); 67 return m_cachedSVGDocumentReference.get(); 64 65 void ReferenceFilterOperation::loadExternalDocumentIfNeeded(CachedResourceLoader& cachedResourceLoader, const ResourceLoaderOptions& options) 66 { 67 if (m_cachedSVGDocumentReference) 68 return; 69 if (!SVGURIReference::isExternalURIReference(m_url, *cachedResourceLoader.document())) 70 return; 71 m_cachedSVGDocumentReference = std::make_unique<CachedSVGDocumentReference>(m_url); 72 m_cachedSVGDocumentReference->load(cachedResourceLoader, options); 68 73 } 69 74 -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h
r197563 r205421 43 43 // CSS Filters 44 44 45 class CachedResourceLoader; 45 46 class CachedSVGDocumentReference; 46 47 class FilterEffect; 48 struct ResourceLoaderOptions; 47 49 48 50 class FilterOperation : public RefCounted<FilterOperation> { … … 185 187 const String& fragment() const { return m_fragment; } 186 188 189 void loadExternalDocumentIfNeeded(CachedResourceLoader&, const ResourceLoaderOptions&); 190 187 191 CachedSVGDocumentReference* cachedSVGDocumentReference() const { return m_cachedSVGDocumentReference.get(); } 188 CachedSVGDocumentReference* getOrCreateCachedSVGDocumentReference();189 192 190 193 FilterEffect* filterEffect() const { return m_filterEffect.get(); } -
trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp
r205419 r205421 39 39 40 40 m_isCachedImage = true; 41 42 // CSSImageValue doesn't get invalidated so we can grab the CachedImage immediately if it exists. 43 if (is<CSSImageValue>(m_cssValue)) 44 m_cachedImage = downcast<CSSImageValue>(m_cssValue.get()).cachedImage(); 41 45 } 42 46 -
trunk/Source/WebCore/style/StylePendingResources.cpp
r205419 r205421 29 29 #include "CSSCursorImageValue.h" 30 30 #include "CachedResourceLoader.h" 31 #include "CachedSVGDocumentReference.h"32 31 #include "ContentData.h" 33 32 #include "CursorData.h" … … 61 60 } 62 61 63 static void loadPendingImages(const PendingResources& pendingResources, Document& document, RenderStyle& style, const Element* element)62 void loadPendingResources(RenderStyle& style, Document& document, const Element* element) 64 63 { 65 for (auto currentProperty : pendingResources.pendingImages.keys()) { 66 switch (currentProperty) { 67 case CSSPropertyBackgroundImage: { 68 for (auto* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) 69 loadPendingImage(document, backgroundLayer->image(), element); 70 break; 71 } 72 case CSSPropertyContent: { 73 for (auto* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) { 74 if (is<ImageContentData>(*contentData)) { 75 auto& styleImage = downcast<ImageContentData>(*contentData).image(); 76 loadPendingImage(document, &styleImage, element); 77 } 78 } 79 break; 80 } 81 case CSSPropertyCursor: { 82 if (auto* cursorList = style.cursors()) { 83 for (size_t i = 0; i < cursorList->size(); ++i) 84 loadPendingImage(document, cursorList->at(i).image(), element); 85 } 86 break; 87 } 88 case CSSPropertyListStyleImage: { 89 loadPendingImage(document, style.listStyleImage(), element); 90 break; 91 } 92 case CSSPropertyBorderImageSource: { 93 loadPendingImage(document, style.borderImageSource(), element); 94 break; 95 } 96 case CSSPropertyWebkitBoxReflect: { 97 if (auto* reflection = style.boxReflect()) 98 loadPendingImage(document, reflection->mask().image(), element); 99 break; 100 } 101 case CSSPropertyWebkitMaskBoxImageSource: { 102 loadPendingImage(document, style.maskBoxImageSource(), element); 103 break; 104 } 105 case CSSPropertyWebkitMaskImage: { 106 for (auto* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) 107 loadPendingImage(document, maskLayer->image(), element); 108 break; 109 } 110 #if ENABLE(CSS_SHAPES) 111 case CSSPropertyWebkitShapeOutside: { 112 if (style.shapeOutside()) 113 loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::ShapeOutside); 114 break; 115 } 116 #endif 117 default: 118 ASSERT_NOT_REACHED(); 64 for (auto* backgroundLayer = style.backgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) 65 loadPendingImage(document, backgroundLayer->image(), element); 66 67 for (auto* contentData = style.contentData(); contentData; contentData = contentData->next()) { 68 if (is<ImageContentData>(*contentData)) { 69 auto& styleImage = downcast<ImageContentData>(*contentData).image(); 70 loadPendingImage(document, &styleImage, element); 119 71 } 120 72 } 121 }122 73 123 static void loadPendingSVGFilters(const PendingResources& pendingResources, Document& document, const Element* element) 124 { 125 if (pendingResources.pendingSVGFilters.isEmpty())126 return;74 if (auto* cursorList = style.cursors()) { 75 for (size_t i = 0; i < cursorList->size(); ++i) 76 loadPendingImage(document, cursorList->at(i).image(), element); 77 } 127 78 128 ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions(); 129 options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck; 79 loadPendingImage(document, style.listStyleImage(), element); 80 loadPendingImage(document, style.borderImageSource(), element); 81 loadPendingImage(document, style.maskBoxImageSource(), element); 130 82 131 for (auto& filterOperation : pendingResources.pendingSVGFilters) 132 filterOperation->getOrCreateCachedSVGDocumentReference()->load(document.cachedResourceLoader(), options); 133 } 83 if (auto* reflection = style.boxReflect()) 84 loadPendingImage(document, reflection->mask().image(), element); 134 85 135 void loadPendingResources(const PendingResources& pendingResources, Document& document, RenderStyle& style, const Element* element) 136 { 137 loadPendingImages(pendingResources, document, style, element); 138 loadPendingSVGFilters(pendingResources, document, element); 86 for (auto* maskLayer = style.maskLayers(); maskLayer; maskLayer = maskLayer->next()) 87 loadPendingImage(document, maskLayer->image(), element); 88 89 #if ENABLE(CSS_SHAPES) 90 if (style.shapeOutside()) 91 loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::ShapeOutside); 92 #endif 139 93 } 140 94 -
trunk/Source/WebCore/style/StylePendingResources.h
r202656 r205421 26 26 #pragma once 27 27 28 #include "CSSPropertyNames.h"29 #include "FilterOperations.h"30 #include <wtf/HashMap.h>31 32 28 namespace WebCore { 33 29 34 class CSSValue;35 30 class Document; 36 31 class Element; … … 39 34 namespace Style { 40 35 41 struct PendingResources { 42 WTF_MAKE_FAST_ALLOCATED; 43 public: 44 HashMap<CSSPropertyID, RefPtr<CSSValue>> pendingImages; 45 Vector<RefPtr<ReferenceFilterOperation>> pendingSVGFilters; 46 }; 47 48 void loadPendingResources(const PendingResources&, Document&, RenderStyle&, const Element*); 36 void loadPendingResources(RenderStyle&, Document&, const Element*); 49 37 50 38 }
Note: See TracChangeset
for help on using the changeset viewer.