OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/css/resolver/StyleResourceLoader.h" | 24 #include "core/css/resolver/StyleResourceLoader.h" |
25 | 25 |
26 #include "core/CSSPropertyNames.h" | 26 #include "core/CSSPropertyNames.h" |
27 #include "core/css/CSSCursorImageValue.h" | 27 #include "core/css/CSSCursorImageValue.h" |
28 #include "core/css/CSSImageValue.h" | 28 #include "core/css/CSSImageValue.h" |
29 #include "core/css/CSSSVGDocumentValue.h" | 29 #include "core/css/CSSSVGDocumentValue.h" |
30 #include "core/css/resolver/ElementStyleResources.h" | 30 #include "core/css/resolver/ElementStyleResources.h" |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/fetch/ResourceFetcher.h" | 32 #include "core/fetch/ResourceFetcher.h" |
| 33 #include "core/layout/svg/ReferenceFilterBuilder.h" |
| 34 #include "core/style/ComputedStyle.h" |
33 #include "core/style/ContentData.h" | 35 #include "core/style/ContentData.h" |
34 #include "core/style/FillLayer.h" | 36 #include "core/style/FillLayer.h" |
35 #include "core/style/ComputedStyle.h" | |
36 #include "core/style/StyleFetchedImage.h" | 37 #include "core/style/StyleFetchedImage.h" |
37 #include "core/style/StyleFetchedImageSet.h" | 38 #include "core/style/StyleFetchedImageSet.h" |
38 #include "core/style/StyleGeneratedImage.h" | 39 #include "core/style/StyleGeneratedImage.h" |
39 #include "core/style/StylePendingImage.h" | 40 #include "core/style/StylePendingImage.h" |
40 #include "core/layout/svg/ReferenceFilterBuilder.h" | |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 StyleResourceLoader::StyleResourceLoader(Document* document) | 44 StyleResourceLoader::StyleResourceLoader(Document* document) |
45 : m_document(document) | 45 : m_document(document) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 DEFINE_TRACE(StyleResourceLoader) | 49 DEFINE_TRACE(StyleResourceLoader) |
50 { | 50 { |
(...skipping 22 matching lines...) Expand all Loading... |
73 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); | 73 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 elementStyleResources.clearPendingSVGDocuments(); | 77 elementStyleResources.clearPendingSVGDocuments(); |
78 } | 78 } |
79 | 79 |
80 static PassRefPtrWillBeRawPtr<StyleImage> doLoadPendingImage(Document* document,
StylePendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderO
ptions& options) | 80 static PassRefPtrWillBeRawPtr<StyleImage> doLoadPendingImage(Document* document,
StylePendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderO
ptions& options) |
81 { | 81 { |
82 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 82 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
83 return imageValue->cachedImage(document, options); | 83 return imageValue->cacheImage(document, options); |
84 | 84 |
85 if (CSSImageGeneratorValue* imageGeneratorValue | 85 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene
ratorValue()) { |
86 = pendingImage->cssImageGeneratorValue()) { | |
87 imageGeneratorValue->loadSubimages(document); | 86 imageGeneratorValue->loadSubimages(document); |
88 return StyleGeneratedImage::create(imageGeneratorValue); | 87 return StyleGeneratedImage::create(imageGeneratorValue); |
89 } | 88 } |
90 | 89 |
91 if (CSSCursorImageValue* cursorImageValue | 90 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu
e()) |
92 = pendingImage->cssCursorImageValue()) | 91 return cursorImageValue->cacheImage(document, deviceScaleFactor); |
93 return cursorImageValue->cachedImage(document, deviceScaleFactor); | |
94 | 92 |
95 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) | 93 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) |
96 return imageSetValue->cachedImageSet(document, deviceScaleFactor, option
s); | 94 return imageSetValue->cacheImageSet(document, deviceScaleFactor, options
); |
97 | 95 |
98 return nullptr; | 96 return nullptr; |
99 } | 97 } |
100 | 98 |
101 PassRefPtrWillBeRawPtr<StyleImage> StyleResourceLoader::loadPendingImage(StylePe
ndingImage* pendingImage, float deviceScaleFactor) | 99 PassRefPtrWillBeRawPtr<StyleImage> StyleResourceLoader::loadPendingImage(StylePe
ndingImage* pendingImage, float deviceScaleFactor) |
102 { | 100 { |
103 return doLoadPendingImage(m_document, pendingImage, deviceScaleFactor, Resou
rceFetcher::defaultResourceOptions()); | 101 return doLoadPendingImage(m_document, pendingImage, deviceScaleFactor, Resou
rceFetcher::defaultResourceOptions()); |
104 } | 102 } |
105 | 103 |
106 void StyleResourceLoader::loadPendingShapeImage(ComputedStyle* computedStyle, Sh
apeValue* shapeValue, float deviceScaleFactor) | 104 void StyleResourceLoader::loadPendingShapeImage(ComputedStyle* computedStyle, Sh
apeValue* shapeValue, float deviceScaleFactor) |
(...skipping 11 matching lines...) Expand all Loading... |
118 options.corsEnabled = IsCORSEnabled; | 116 options.corsEnabled = IsCORSEnabled; |
119 | 117 |
120 shapeValue->setImage(doLoadPendingImage(m_document, toStylePendingImage(imag
e), deviceScaleFactor, options)); | 118 shapeValue->setImage(doLoadPendingImage(m_document, toStylePendingImage(imag
e), deviceScaleFactor, options)); |
121 } | 119 } |
122 | 120 |
123 void StyleResourceLoader::loadPendingImages(ComputedStyle* style, ElementStyleRe
sources& elementStyleResources) | 121 void StyleResourceLoader::loadPendingImages(ComputedStyle* style, ElementStyleRe
sources& elementStyleResources) |
124 { | 122 { |
125 if (elementStyleResources.pendingImageProperties().isEmpty()) | 123 if (elementStyleResources.pendingImageProperties().isEmpty()) |
126 return; | 124 return; |
127 | 125 |
128 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); | 126 for (CSSPropertyID property : elementStyleResources.pendingImageProperties()
) { |
129 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { | 127 switch (property) { |
130 CSSPropertyID currentProperty = *it; | |
131 | |
132 switch (currentProperty) { | |
133 case CSSPropertyBackgroundImage: { | 128 case CSSPropertyBackgroundImage: { |
134 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { | 129 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { |
135 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) | 130 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) |
136 backgroundLayer->setImage(loadPendingImage(toStylePendingIma
ge(backgroundLayer->image()), elementStyleResources.deviceScaleFactor())); | 131 backgroundLayer->setImage(loadPendingImage(toStylePendingIma
ge(backgroundLayer->image()), elementStyleResources.deviceScaleFactor())); |
137 } | 132 } |
138 break; | 133 break; |
139 } | 134 } |
140 case CSSPropertyContent: { | 135 case CSSPropertyContent: { |
141 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { | 136 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { |
142 if (contentData->isImage()) { | 137 if (contentData->isImage()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void StyleResourceLoader::loadPendingResources(ComputedStyle* computedStyle, Ele
mentStyleResources& elementStyleResources) | 203 void StyleResourceLoader::loadPendingResources(ComputedStyle* computedStyle, Ele
mentStyleResources& elementStyleResources) |
209 { | 204 { |
210 // Start loading images referenced by this style. | 205 // Start loading images referenced by this style. |
211 loadPendingImages(computedStyle, elementStyleResources); | 206 loadPendingImages(computedStyle, elementStyleResources); |
212 | 207 |
213 // Start loading the SVG Documents referenced by this style. | 208 // Start loading the SVG Documents referenced by this style. |
214 loadPendingSVGDocuments(computedStyle, elementStyleResources); | 209 loadPendingSVGDocuments(computedStyle, elementStyleResources); |
215 } | 210 } |
216 | 211 |
217 } | 212 } |
OLD | NEW |