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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 DocumentResource* resource = value->load(m_document); | 125 DocumentResource* resource = value->load(m_document); |
126 if (!resource) | 126 if (!resource) |
127 continue; | 127 continue; |
128 | 128 |
129 // Stash the DocumentResource on the reference filter. | 129 // Stash the DocumentResource on the reference filter. |
130 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); | 130 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 StyleImage* ElementStyleResources::loadPendingImage(StylePendingImage* pendingIm
age, CrossOriginAttributeValue crossOrigin) | 135 StyleImage* ElementStyleResources::loadPendingImage(ComputedStyle* style, StyleP
endingImage* pendingImage, CrossOriginAttributeValue crossOrigin) |
136 { | 136 { |
137 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 137 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
138 return imageValue->cacheImage(m_document, crossOrigin); | 138 return imageValue->cacheImage(m_document, crossOrigin); |
139 | 139 |
| 140 if (CSSPaintValue* paintValue = pendingImage->cssPaintValue()) { |
| 141 StyleGeneratedImage* image = StyleGeneratedImage::create(*paintValue); |
| 142 style->addPaintImage(image); |
| 143 return image; |
| 144 } |
| 145 |
140 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene
ratorValue()) { | 146 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene
ratorValue()) { |
141 imageGeneratorValue->loadSubimages(m_document); | 147 imageGeneratorValue->loadSubimages(m_document); |
142 return StyleGeneratedImage::create(*imageGeneratorValue); | 148 return StyleGeneratedImage::create(*imageGeneratorValue); |
143 } | 149 } |
144 | 150 |
145 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu
e()) | 151 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu
e()) |
146 return cursorImageValue->cacheImage(m_document, m_deviceScaleFactor); | 152 return cursorImageValue->cacheImage(m_document, m_deviceScaleFactor); |
147 | 153 |
148 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) | 154 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) |
149 return imageSetValue->cacheImage(m_document, m_deviceScaleFactor, crossO
rigin); | 155 return imageSetValue->cacheImage(m_document, m_deviceScaleFactor, crossO
rigin); |
(...skipping 20 matching lines...) Expand all Loading... |
170 // | 176 // |
171 // If we eagerly loaded the images we'd fetch a.png, even though it's not | 177 // If we eagerly loaded the images we'd fetch a.png, even though it's not |
172 // used. If we didn't null check below we'd crash since the none actually | 178 // used. If we didn't null check below we'd crash since the none actually |
173 // removed all background images. | 179 // removed all background images. |
174 | 180 |
175 for (CSSPropertyID property : m_pendingImageProperties) { | 181 for (CSSPropertyID property : m_pendingImageProperties) { |
176 switch (property) { | 182 switch (property) { |
177 case CSSPropertyBackgroundImage: { | 183 case CSSPropertyBackgroundImage: { |
178 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { | 184 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { |
179 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) | 185 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) |
180 backgroundLayer->setImage(loadPendingImage(toStylePendingIma
ge(backgroundLayer->image()))); | 186 backgroundLayer->setImage(loadPendingImage(style, toStylePen
dingImage(backgroundLayer->image()))); |
181 } | 187 } |
182 break; | 188 break; |
183 } | 189 } |
184 case CSSPropertyContent: { | 190 case CSSPropertyContent: { |
185 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { | 191 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { |
186 if (contentData->isImage()) { | 192 if (contentData->isImage()) { |
187 StyleImage* image = toImageContentData(contentData)->image()
; | 193 StyleImage* image = toImageContentData(contentData)->image()
; |
188 if (image->isPendingImage()) | 194 if (image->isPendingImage()) |
189 toImageContentData(contentData)->setImage(loadPendingIma
ge(toStylePendingImage(image))); | 195 toImageContentData(contentData)->setImage(loadPendingIma
ge(style, toStylePendingImage(image))); |
190 } | 196 } |
191 } | 197 } |
192 break; | 198 break; |
193 } | 199 } |
194 case CSSPropertyCursor: { | 200 case CSSPropertyCursor: { |
195 if (CursorList* cursorList = style->cursors()) { | 201 if (CursorList* cursorList = style->cursors()) { |
196 for (size_t i = 0; i < cursorList->size(); ++i) { | 202 for (size_t i = 0; i < cursorList->size(); ++i) { |
197 CursorData& currentCursor = cursorList->at(i); | 203 CursorData& currentCursor = cursorList->at(i); |
198 if (StyleImage* image = currentCursor.image()) { | 204 if (StyleImage* image = currentCursor.image()) { |
199 if (image->isPendingImage()) | 205 if (image->isPendingImage()) |
200 currentCursor.setImage(loadPendingImage(toStylePendi
ngImage(image))); | 206 currentCursor.setImage(loadPendingImage(style, toSty
lePendingImage(image))); |
201 } | 207 } |
202 } | 208 } |
203 } | 209 } |
204 break; | 210 break; |
205 } | 211 } |
206 case CSSPropertyListStyleImage: { | 212 case CSSPropertyListStyleImage: { |
207 if (style->listStyleImage() && style->listStyleImage()->isPendingIma
ge()) | 213 if (style->listStyleImage() && style->listStyleImage()->isPendingIma
ge()) |
208 style->setListStyleImage(loadPendingImage(toStylePendingImage(st
yle->listStyleImage()))); | 214 style->setListStyleImage(loadPendingImage(style, toStylePendingI
mage(style->listStyleImage()))); |
209 break; | 215 break; |
210 } | 216 } |
211 case CSSPropertyBorderImageSource: { | 217 case CSSPropertyBorderImageSource: { |
212 if (style->borderImageSource() && style->borderImageSource()->isPend
ingImage()) | 218 if (style->borderImageSource() && style->borderImageSource()->isPend
ingImage()) |
213 style->setBorderImageSource(loadPendingImage(toStylePendingImage
(style->borderImageSource()))); | 219 style->setBorderImageSource(loadPendingImage(style, toStylePendi
ngImage(style->borderImageSource()))); |
214 break; | 220 break; |
215 } | 221 } |
216 case CSSPropertyWebkitBoxReflect: { | 222 case CSSPropertyWebkitBoxReflect: { |
217 if (StyleReflection* reflection = style->boxReflect()) { | 223 if (StyleReflection* reflection = style->boxReflect()) { |
218 const NinePieceImage& maskImage = reflection->mask(); | 224 const NinePieceImage& maskImage = reflection->mask(); |
219 if (maskImage.image() && maskImage.image()->isPendingImage()) { | 225 if (maskImage.image() && maskImage.image()->isPendingImage()) { |
220 StyleImage* loadedImage = loadPendingImage(toStylePendingIma
ge(maskImage.image())); | 226 StyleImage* loadedImage = loadPendingImage(style, toStylePen
dingImage(maskImage.image())); |
221 reflection->setMask(NinePieceImage(loadedImage, maskImage.im
ageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), mas
kImage.horizontalRule(), maskImage.verticalRule())); | 227 reflection->setMask(NinePieceImage(loadedImage, maskImage.im
ageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), mas
kImage.horizontalRule(), maskImage.verticalRule())); |
222 } | 228 } |
223 } | 229 } |
224 break; | 230 break; |
225 } | 231 } |
226 case CSSPropertyWebkitMaskBoxImageSource: { | 232 case CSSPropertyWebkitMaskBoxImageSource: { |
227 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe
ndingImage()) | 233 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe
ndingImage()) |
228 style->setMaskBoxImageSource(loadPendingImage(toStylePendingImag
e(style->maskBoxImageSource()))); | 234 style->setMaskBoxImageSource(loadPendingImage(style, toStylePend
ingImage(style->maskBoxImageSource()))); |
229 break; | 235 break; |
230 } | 236 } |
231 case CSSPropertyWebkitMaskImage: { | 237 case CSSPropertyWebkitMaskImage: { |
232 for (FillLayer* maskLayer = &style->accessMaskLayers(); maskLayer; m
askLayer = maskLayer->next()) { | 238 for (FillLayer* maskLayer = &style->accessMaskLayers(); maskLayer; m
askLayer = maskLayer->next()) { |
233 if (maskLayer->image() && maskLayer->image()->isPendingImage()) | 239 if (maskLayer->image() && maskLayer->image()->isPendingImage()) |
234 maskLayer->setImage(loadPendingImage(toStylePendingImage(mas
kLayer->image()))); | 240 maskLayer->setImage(loadPendingImage(style, toStylePendingIm
age(maskLayer->image()))); |
235 } | 241 } |
236 break; | 242 break; |
237 } | 243 } |
238 case CSSPropertyShapeOutside: | 244 case CSSPropertyShapeOutside: |
239 if (style->shapeOutside() && style->shapeOutside()->image() && style
->shapeOutside()->image()->isPendingImage()) | 245 if (style->shapeOutside() && style->shapeOutside()->image() && style
->shapeOutside()->image()->isPendingImage()) |
240 style->shapeOutside()->setImage(loadPendingImage(toStylePendingI
mage(style->shapeOutside()->image()), CrossOriginAttributeAnonymous)); | 246 style->shapeOutside()->setImage(loadPendingImage(style, toStyleP
endingImage(style->shapeOutside()->image()), CrossOriginAttributeAnonymous)); |
241 break; | 247 break; |
242 default: | 248 default: |
243 ASSERT_NOT_REACHED(); | 249 ASSERT_NOT_REACHED(); |
244 } | 250 } |
245 } | 251 } |
246 } | 252 } |
247 | 253 |
248 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) | 254 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) |
249 { | 255 { |
250 loadPendingImages(computedStyle); | 256 loadPendingImages(computedStyle); |
251 loadPendingSVGDocuments(computedStyle); | 257 loadPendingSVGDocuments(computedStyle); |
252 } | 258 } |
253 | 259 |
254 } // namespace blink | 260 } // namespace blink |
OLD | NEW |