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 28 matching lines...) Expand all Loading... |
39 #include "core/rendering/style/StylePendingImage.h" | 39 #include "core/rendering/style/StylePendingImage.h" |
40 #include "core/rendering/svg/ReferenceFilterBuilder.h" | 40 #include "core/rendering/svg/ReferenceFilterBuilder.h" |
41 | 41 |
42 namespace WebCore { | 42 namespace WebCore { |
43 | 43 |
44 StyleResourceLoader::StyleResourceLoader(ResourceFetcher* fetcher) | 44 StyleResourceLoader::StyleResourceLoader(ResourceFetcher* fetcher) |
45 : m_fetcher(fetcher) | 45 : m_fetcher(fetcher) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 void StyleResourceLoader::loadPendingSVGDocuments(RenderStyle* renderStyle, cons
t ElementStyleResources& elementStyleResources) | 49 void StyleResourceLoader::loadPendingSVGDocuments(RenderStyle* renderStyle, Elem
entStyleResources& elementStyleResources) |
50 { | 50 { |
51 if (!renderStyle->hasFilter() || elementStyleResources.pendingSVGDocuments()
.isEmpty()) | 51 if (!renderStyle->hasFilter() || elementStyleResources.pendingSVGDocuments()
.isEmpty()) |
52 return; | 52 return; |
53 | 53 |
54 Vector<RefPtr<FilterOperation> >& filterOperations = renderStyle->mutableFil
ter().operations(); | 54 Vector<RefPtr<FilterOperation> >& filterOperations = renderStyle->mutableFil
ter().operations(); |
55 for (unsigned i = 0; i < filterOperations.size(); ++i) { | 55 for (unsigned i = 0; i < filterOperations.size(); ++i) { |
56 RefPtr<FilterOperation> filterOperation = filterOperations.at(i); | 56 RefPtr<FilterOperation> filterOperation = filterOperations.at(i); |
57 if (filterOperation->type() == FilterOperation::REFERENCE) { | 57 if (filterOperation->type() == FilterOperation::REFERENCE) { |
58 ReferenceFilterOperation* referenceFilter = toReferenceFilterOperati
on(filterOperation.get()); | 58 ReferenceFilterOperation* referenceFilter = toReferenceFilterOperati
on(filterOperation.get()); |
59 | 59 |
60 CSSSVGDocumentValue* value = elementStyleResources.pendingSVGDocumen
ts().get(referenceFilter); | 60 CSSSVGDocumentValue* value = elementStyleResources.pendingSVGDocumen
ts().get(referenceFilter); |
61 if (!value) | 61 if (!value) |
62 continue; | 62 continue; |
63 DocumentResource* resource = value->load(m_fetcher); | 63 DocumentResource* resource = value->load(m_fetcher); |
64 if (!resource) | 64 if (!resource) |
65 continue; | 65 continue; |
66 | 66 |
67 // Stash the DocumentResource on the reference filter. | 67 // Stash the DocumentResource on the reference filter. |
68 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); | 68 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); |
69 } | 69 } |
70 } | 70 } |
| 71 |
| 72 elementStyleResources.clearPendingSVGDocuments(); |
71 } | 73 } |
72 | 74 |
73 static PassRefPtr<StyleImage> doLoadPendingImage(ResourceFetcher* fetcher, Style
PendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderOptions
& options) | 75 static PassRefPtr<StyleImage> doLoadPendingImage(ResourceFetcher* fetcher, Style
PendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderOptions
& options) |
74 { | 76 { |
75 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 77 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
76 return imageValue->cachedImage(fetcher, options); | 78 return imageValue->cachedImage(fetcher, options); |
77 | 79 |
78 if (CSSImageGeneratorValue* imageGeneratorValue | 80 if (CSSImageGeneratorValue* imageGeneratorValue |
79 = pendingImage->cssImageGeneratorValue()) { | 81 = pendingImage->cssImageGeneratorValue()) { |
80 imageGeneratorValue->loadSubimages(fetcher); | 82 imageGeneratorValue->loadSubimages(fetcher); |
(...skipping 24 matching lines...) Expand all Loading... |
105 if (!image || !image->isPendingImage()) | 107 if (!image || !image->isPendingImage()) |
106 return; | 108 return; |
107 | 109 |
108 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); | 110 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); |
109 options.allowCredentials = DoNotAllowStoredCredentials; | 111 options.allowCredentials = DoNotAllowStoredCredentials; |
110 options.corsEnabled = IsCORSEnabled; | 112 options.corsEnabled = IsCORSEnabled; |
111 | 113 |
112 shapeValue->setImage(doLoadPendingImage(m_fetcher, toStylePendingImage(image
), deviceScaleFactor, options)); | 114 shapeValue->setImage(doLoadPendingImage(m_fetcher, toStylePendingImage(image
), deviceScaleFactor, options)); |
113 } | 115 } |
114 | 116 |
115 void StyleResourceLoader::loadPendingImages(RenderStyle* style, const ElementSty
leResources& elementStyleResources) | 117 void StyleResourceLoader::loadPendingImages(RenderStyle* style, ElementStyleReso
urces& elementStyleResources) |
116 { | 118 { |
117 if (elementStyleResources.pendingImageProperties().isEmpty()) | 119 if (elementStyleResources.pendingImageProperties().isEmpty()) |
118 return; | 120 return; |
119 | 121 |
120 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); | 122 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); |
121 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { | 123 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { |
122 CSSPropertyID currentProperty = *it; | 124 CSSPropertyID currentProperty = *it; |
123 | 125 |
124 switch (currentProperty) { | 126 switch (currentProperty) { |
125 case CSSPropertyBackgroundImage: { | 127 case CSSPropertyBackgroundImage: { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 case CSSPropertyShapeInside: | 191 case CSSPropertyShapeInside: |
190 loadPendingShapeImage(style, style->shapeInside(), elementStyleResou
rces.deviceScaleFactor()); | 192 loadPendingShapeImage(style, style->shapeInside(), elementStyleResou
rces.deviceScaleFactor()); |
191 break; | 193 break; |
192 case CSSPropertyShapeOutside: | 194 case CSSPropertyShapeOutside: |
193 loadPendingShapeImage(style, style->shapeOutside(), elementStyleReso
urces.deviceScaleFactor()); | 195 loadPendingShapeImage(style, style->shapeOutside(), elementStyleReso
urces.deviceScaleFactor()); |
194 break; | 196 break; |
195 default: | 197 default: |
196 ASSERT_NOT_REACHED(); | 198 ASSERT_NOT_REACHED(); |
197 } | 199 } |
198 } | 200 } |
| 201 |
| 202 elementStyleResources.clearPendingImageProperties(); |
199 } | 203 } |
200 | 204 |
201 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element
StyleResources& elementStyleResources) | 205 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element
StyleResources& elementStyleResources) |
202 { | 206 { |
203 // Start loading images referenced by this style. | 207 // Start loading images referenced by this style. |
204 loadPendingImages(renderStyle, elementStyleResources); | 208 loadPendingImages(renderStyle, elementStyleResources); |
205 | 209 |
206 // Start loading the SVG Documents referenced by this style. | 210 // Start loading the SVG Documents referenced by this style. |
207 loadPendingSVGDocuments(renderStyle, elementStyleResources); | 211 loadPendingSVGDocuments(renderStyle, elementStyleResources); |
208 } | 212 } |
209 | 213 |
210 } | 214 } |
OLD | NEW |