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, Elem
entStyleResources& elementStyleResources) | 49 void StyleResourceLoader::loadPendingSVGDocuments(RenderStyle* renderStyle, cons
t ElementStyleResources& 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(); | |
73 } | 71 } |
74 | 72 |
75 static PassRefPtr<StyleImage> doLoadPendingImage(ResourceFetcher* fetcher, Style
PendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderOptions
& options) | 73 static PassRefPtr<StyleImage> doLoadPendingImage(ResourceFetcher* fetcher, Style
PendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderOptions
& options) |
76 { | 74 { |
77 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 75 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
78 return imageValue->cachedImage(fetcher, options); | 76 return imageValue->cachedImage(fetcher, options); |
79 | 77 |
80 if (CSSImageGeneratorValue* imageGeneratorValue | 78 if (CSSImageGeneratorValue* imageGeneratorValue |
81 = pendingImage->cssImageGeneratorValue()) { | 79 = pendingImage->cssImageGeneratorValue()) { |
82 imageGeneratorValue->loadSubimages(fetcher); | 80 imageGeneratorValue->loadSubimages(fetcher); |
(...skipping 24 matching lines...) Expand all Loading... |
107 if (!image || !image->isPendingImage()) | 105 if (!image || !image->isPendingImage()) |
108 return; | 106 return; |
109 | 107 |
110 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); | 108 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); |
111 options.allowCredentials = DoNotAllowStoredCredentials; | 109 options.allowCredentials = DoNotAllowStoredCredentials; |
112 options.corsEnabled = IsCORSEnabled; | 110 options.corsEnabled = IsCORSEnabled; |
113 | 111 |
114 shapeValue->setImage(doLoadPendingImage(m_fetcher, toStylePendingImage(image
), deviceScaleFactor, options)); | 112 shapeValue->setImage(doLoadPendingImage(m_fetcher, toStylePendingImage(image
), deviceScaleFactor, options)); |
115 } | 113 } |
116 | 114 |
117 void StyleResourceLoader::loadPendingImages(RenderStyle* style, ElementStyleReso
urces& elementStyleResources) | 115 void StyleResourceLoader::loadPendingImages(RenderStyle* style, const ElementSty
leResources& elementStyleResources) |
118 { | 116 { |
119 if (elementStyleResources.pendingImageProperties().isEmpty()) | 117 if (elementStyleResources.pendingImageProperties().isEmpty()) |
120 return; | 118 return; |
121 | 119 |
122 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); | 120 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); |
123 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { | 121 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { |
124 CSSPropertyID currentProperty = *it; | 122 CSSPropertyID currentProperty = *it; |
125 | 123 |
126 switch (currentProperty) { | 124 switch (currentProperty) { |
127 case CSSPropertyBackgroundImage: { | 125 case CSSPropertyBackgroundImage: { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 case CSSPropertyShapeInside: | 189 case CSSPropertyShapeInside: |
192 loadPendingShapeImage(style, style->shapeInside(), elementStyleResou
rces.deviceScaleFactor()); | 190 loadPendingShapeImage(style, style->shapeInside(), elementStyleResou
rces.deviceScaleFactor()); |
193 break; | 191 break; |
194 case CSSPropertyShapeOutside: | 192 case CSSPropertyShapeOutside: |
195 loadPendingShapeImage(style, style->shapeOutside(), elementStyleReso
urces.deviceScaleFactor()); | 193 loadPendingShapeImage(style, style->shapeOutside(), elementStyleReso
urces.deviceScaleFactor()); |
196 break; | 194 break; |
197 default: | 195 default: |
198 ASSERT_NOT_REACHED(); | 196 ASSERT_NOT_REACHED(); |
199 } | 197 } |
200 } | 198 } |
201 | |
202 elementStyleResources.clearPendingImageProperties(); | |
203 } | 199 } |
204 | 200 |
205 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element
StyleResources& elementStyleResources) | 201 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element
StyleResources& elementStyleResources) |
206 { | 202 { |
207 // Start loading images referenced by this style. | 203 // Start loading images referenced by this style. |
208 loadPendingImages(renderStyle, elementStyleResources); | 204 loadPendingImages(renderStyle, elementStyleResources); |
209 | 205 |
210 // Start loading the SVG Documents referenced by this style. | 206 // Start loading the SVG Documents referenced by this style. |
211 loadPendingSVGDocuments(renderStyle, elementStyleResources); | 207 loadPendingSVGDocuments(renderStyle, elementStyleResources); |
212 } | 208 } |
213 | 209 |
214 } | 210 } |
OLD | NEW |