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. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
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" | |
28 #include "core/css/CSSGradientValue.h" | 27 #include "core/css/CSSGradientValue.h" |
29 #include "core/css/CSSImageValue.h" | 28 #include "core/css/CSSImageValue.h" |
30 #include "core/css/CSSURIValue.h" | 29 #include "core/css/CSSURIValue.h" |
31 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
32 #include "core/fetch/ResourceFetcher.h" | 31 #include "core/fetch/ResourceFetcher.h" |
33 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
34 #include "core/style/ContentData.h" | 33 #include "core/style/ContentData.h" |
35 #include "core/style/CursorData.h" | 34 #include "core/style/CursorData.h" |
36 #include "core/style/FillLayer.h" | 35 #include "core/style/FillLayer.h" |
37 #include "core/style/FilterOperation.h" | 36 #include "core/style/FilterOperation.h" |
(...skipping 16 matching lines...) Expand all Loading... |
54 if (value.isImageValue()) | 53 if (value.isImageValue()) |
55 return cachedOrPendingFromValue(property, toCSSImageValue(value)); | 54 return cachedOrPendingFromValue(property, toCSSImageValue(value)); |
56 | 55 |
57 if (value.isImageGeneratorValue()) | 56 if (value.isImageGeneratorValue()) |
58 return generatedOrPendingFromValue(property, | 57 return generatedOrPendingFromValue(property, |
59 toCSSImageGeneratorValue(value)); | 58 toCSSImageGeneratorValue(value)); |
60 | 59 |
61 if (value.isImageSetValue()) | 60 if (value.isImageSetValue()) |
62 return setOrPendingFromValue(property, toCSSImageSetValue(value)); | 61 return setOrPendingFromValue(property, toCSSImageSetValue(value)); |
63 | 62 |
64 if (value.isCursorImageValue()) | |
65 return cursorOrPendingFromValue(property, toCSSCursorImageValue(value)); | |
66 | |
67 return nullptr; | 63 return nullptr; |
68 } | 64 } |
69 | 65 |
70 StyleImage* ElementStyleResources::generatedOrPendingFromValue( | 66 StyleImage* ElementStyleResources::generatedOrPendingFromValue( |
71 CSSPropertyID property, | 67 CSSPropertyID property, |
72 const CSSImageGeneratorValue& value) { | 68 const CSSImageGeneratorValue& value) { |
73 if (value.isPending()) { | 69 if (value.isPending()) { |
74 m_pendingImageProperties.add(property); | 70 m_pendingImageProperties.add(property); |
75 return StylePendingImage::create(value); | 71 return StylePendingImage::create(value); |
76 } | 72 } |
(...skipping 14 matching lines...) Expand all Loading... |
91 CSSPropertyID property, | 87 CSSPropertyID property, |
92 const CSSImageValue& value) { | 88 const CSSImageValue& value) { |
93 if (value.isCachePending()) { | 89 if (value.isCachePending()) { |
94 m_pendingImageProperties.add(property); | 90 m_pendingImageProperties.add(property); |
95 return StylePendingImage::create(value); | 91 return StylePendingImage::create(value); |
96 } | 92 } |
97 value.restoreCachedResourceIfNeeded(*m_document); | 93 value.restoreCachedResourceIfNeeded(*m_document); |
98 return value.cachedImage(); | 94 return value.cachedImage(); |
99 } | 95 } |
100 | 96 |
101 StyleImage* ElementStyleResources::cursorOrPendingFromValue( | |
102 CSSPropertyID property, | |
103 const CSSCursorImageValue& value) { | |
104 if (value.isCachePending(m_deviceScaleFactor)) { | |
105 m_pendingImageProperties.add(property); | |
106 return StylePendingImage::create(value); | |
107 } | |
108 return value.cachedImage(m_deviceScaleFactor); | |
109 } | |
110 | |
111 SVGElementProxy& ElementStyleResources::cachedOrPendingFromValue( | 97 SVGElementProxy& ElementStyleResources::cachedOrPendingFromValue( |
112 const CSSURIValue& value) { | 98 const CSSURIValue& value) { |
113 return value.ensureElementProxy(*m_document); | 99 return value.ensureElementProxy(*m_document); |
114 } | 100 } |
115 | 101 |
116 void ElementStyleResources::loadPendingSVGDocuments( | 102 void ElementStyleResources::loadPendingSVGDocuments( |
117 ComputedStyle* computedStyle) { | 103 ComputedStyle* computedStyle) { |
118 if (!computedStyle->hasFilter()) | 104 if (!computedStyle->hasFilter()) |
119 return; | 105 return; |
120 FilterOperations::FilterOperationVector& filterOperations = | 106 FilterOperations::FilterOperationVector& filterOperations = |
(...skipping 19 matching lines...) Expand all Loading... |
140 style->addPaintImage(image); | 126 style->addPaintImage(image); |
141 return image; | 127 return image; |
142 } | 128 } |
143 | 129 |
144 if (CSSImageGeneratorValue* imageGeneratorValue = | 130 if (CSSImageGeneratorValue* imageGeneratorValue = |
145 pendingImage->cssImageGeneratorValue()) { | 131 pendingImage->cssImageGeneratorValue()) { |
146 imageGeneratorValue->loadSubimages(*m_document); | 132 imageGeneratorValue->loadSubimages(*m_document); |
147 return StyleGeneratedImage::create(*imageGeneratorValue); | 133 return StyleGeneratedImage::create(*imageGeneratorValue); |
148 } | 134 } |
149 | 135 |
150 if (CSSCursorImageValue* cursorImageValue = | |
151 pendingImage->cssCursorImageValue()) | |
152 return cursorImageValue->cacheImage(*m_document, m_deviceScaleFactor); | |
153 | |
154 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) | 136 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) |
155 return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, | 137 return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, |
156 crossOrigin); | 138 crossOrigin); |
157 | 139 |
158 ASSERT_NOT_REACHED(); | 140 ASSERT_NOT_REACHED(); |
159 return nullptr; | 141 return nullptr; |
160 } | 142 } |
161 | 143 |
162 void ElementStyleResources::loadPendingImages(ComputedStyle* style) { | 144 void ElementStyleResources::loadPendingImages(ComputedStyle* style) { |
163 // We must loop over the properties and then look at the style to see if | 145 // We must loop over the properties and then look at the style to see if |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 255 } |
274 } | 256 } |
275 } | 257 } |
276 | 258 |
277 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { | 259 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { |
278 loadPendingImages(computedStyle); | 260 loadPendingImages(computedStyle); |
279 loadPendingSVGDocuments(computedStyle); | 261 loadPendingSVGDocuments(computedStyle); |
280 } | 262 } |
281 | 263 |
282 } // namespace blink | 264 } // namespace blink |
OLD | NEW |