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. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
4 * All rights reserved. | 4 * All rights reserved. |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "core/css/resolver/ElementStyleResources.h" | 24 #include "core/css/resolver/ElementStyleResources.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/CSSGradientValue.h" | 28 #include "core/css/CSSGradientValue.h" |
29 #include "core/css/CSSImageValue.h" | 29 #include "core/css/CSSImageValue.h" |
30 #include "core/css/CSSURIValue.h" | 30 #include "core/css/CSSURIValue.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/ComputedStyle.h" |
35 #include "core/style/ContentData.h" | 34 #include "core/style/ContentData.h" |
36 #include "core/style/CursorData.h" | 35 #include "core/style/CursorData.h" |
37 #include "core/style/FillLayer.h" | 36 #include "core/style/FillLayer.h" |
38 #include "core/style/FilterOperation.h" | 37 #include "core/style/FilterOperation.h" |
39 #include "core/style/StyleFetchedImage.h" | 38 #include "core/style/StyleFetchedImage.h" |
40 #include "core/style/StyleFetchedImageSet.h" | 39 #include "core/style/StyleFetchedImageSet.h" |
41 #include "core/style/StyleGeneratedImage.h" | 40 #include "core/style/StyleGeneratedImage.h" |
42 #include "core/style/StyleImage.h" | 41 #include "core/style/StyleImage.h" |
43 #include "core/style/StyleInvalidImage.h" | 42 #include "core/style/StyleInvalidImage.h" |
44 #include "core/style/StylePendingImage.h" | 43 #include "core/style/StylePendingImage.h" |
| 44 #include "core/svg/SVGElementProxy.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 ElementStyleResources::ElementStyleResources(Document& document, | 48 ElementStyleResources::ElementStyleResources(Document& document, |
49 float deviceScaleFactor) | 49 float deviceScaleFactor) |
50 : m_document(&document), m_deviceScaleFactor(deviceScaleFactor) {} | 50 : m_document(&document), m_deviceScaleFactor(deviceScaleFactor) {} |
51 | 51 |
52 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, | 52 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, |
53 const CSSValue& value) { | 53 const CSSValue& value) { |
54 if (value.isImageValue()) | 54 if (value.isImageValue()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 StyleImage* ElementStyleResources::cursorOrPendingFromValue( | 101 StyleImage* ElementStyleResources::cursorOrPendingFromValue( |
102 CSSPropertyID property, | 102 CSSPropertyID property, |
103 const CSSCursorImageValue& value) { | 103 const CSSCursorImageValue& value) { |
104 if (value.isCachePending(m_deviceScaleFactor)) { | 104 if (value.isCachePending(m_deviceScaleFactor)) { |
105 m_pendingImageProperties.add(property); | 105 m_pendingImageProperties.add(property); |
106 return StylePendingImage::create(value); | 106 return StylePendingImage::create(value); |
107 } | 107 } |
108 return value.cachedImage(m_deviceScaleFactor); | 108 return value.cachedImage(m_deviceScaleFactor); |
109 } | 109 } |
110 | 110 |
111 void ElementStyleResources::addPendingSVGDocument( | 111 SVGElementProxy& ElementStyleResources::cachedOrPendingFromValue( |
112 FilterOperation* filterOperation, | 112 const CSSURIValue& value) { |
113 const CSSURIValue* cssUriValue) { | 113 return value.ensureElementProxy(*m_document); |
114 m_pendingSVGDocuments.set(filterOperation, cssUriValue); | |
115 } | 114 } |
116 | 115 |
117 void ElementStyleResources::loadPendingSVGDocuments( | 116 void ElementStyleResources::loadPendingSVGDocuments( |
118 ComputedStyle* computedStyle) { | 117 ComputedStyle* computedStyle) { |
119 if (!computedStyle->hasFilter() || m_pendingSVGDocuments.isEmpty()) | 118 if (!computedStyle->hasFilter()) |
120 return; | 119 return; |
121 | |
122 FilterOperations::FilterOperationVector& filterOperations = | 120 FilterOperations::FilterOperationVector& filterOperations = |
123 computedStyle->mutableFilter().operations(); | 121 computedStyle->mutableFilter().operations(); |
124 for (unsigned i = 0; i < filterOperations.size(); ++i) { | 122 for (auto& filterOperation : filterOperations) { |
125 FilterOperation* filterOperation = filterOperations.at(i); | 123 if (filterOperation->type() != FilterOperation::REFERENCE) |
126 if (filterOperation->type() == FilterOperation::REFERENCE) { | 124 continue; |
127 ReferenceFilterOperation* referenceFilter = | 125 ReferenceFilterOperation& referenceOperation = |
128 toReferenceFilterOperation(filterOperation); | 126 toReferenceFilterOperation(*filterOperation); |
129 | 127 referenceOperation.elementProxy().resolve(*m_document); |
130 const CSSURIValue* value = m_pendingSVGDocuments.get(referenceFilter); | |
131 if (!value) | |
132 continue; | |
133 DocumentResource* resource = value->load(*m_document); | |
134 if (!resource) | |
135 continue; | |
136 | |
137 // Stash the DocumentResource on the reference filter. | |
138 ReferenceFilterBuilder::setDocumentResourceReference( | |
139 referenceFilter, new DocumentResourceReference(resource)); | |
140 } | |
141 } | 128 } |
142 } | 129 } |
143 | 130 |
144 StyleImage* ElementStyleResources::loadPendingImage( | 131 StyleImage* ElementStyleResources::loadPendingImage( |
145 ComputedStyle* style, | 132 ComputedStyle* style, |
146 StylePendingImage* pendingImage, | 133 StylePendingImage* pendingImage, |
147 CrossOriginAttributeValue crossOrigin) { | 134 CrossOriginAttributeValue crossOrigin) { |
148 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 135 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
149 return imageValue->cacheImage(*m_document, crossOrigin); | 136 return imageValue->cacheImage(*m_document, crossOrigin); |
150 | 137 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 273 } |
287 } | 274 } |
288 } | 275 } |
289 | 276 |
290 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { | 277 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { |
291 loadPendingImages(computedStyle); | 278 loadPendingImages(computedStyle); |
292 loadPendingSVGDocuments(computedStyle); | 279 loadPendingSVGDocuments(computedStyle); |
293 } | 280 } |
294 | 281 |
295 } // namespace blink | 282 } // namespace blink |
OLD | NEW |