Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp

Issue 2469873002: [ImageResource 4] Split ImageResource into Resource and Image parts (Closed)
Patch Set: style Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return toCSSImageValue(value)->knownToBeOpaque(layoutObject); 52 return toCSSImageValue(value)->knownToBeOpaque(layoutObject);
53 53
54 if (value->isImageGeneratorValue()) 54 if (value->isImageGeneratorValue())
55 return toCSSImageGeneratorValue(value)->knownToBeOpaque(layoutObject); 55 return toCSSImageGeneratorValue(value)->knownToBeOpaque(layoutObject);
56 56
57 ASSERT_NOT_REACHED(); 57 ASSERT_NOT_REACHED();
58 58
59 return false; 59 return false;
60 } 60 }
61 61
62 static ImageResource* cachedImageForCSSValue(CSSValue* value, 62 static ImageResourceContent* cachedImageForCSSValue(CSSValue* value,
63 const Document& document) { 63 const Document& document) {
64 if (!value) 64 if (!value)
65 return nullptr; 65 return nullptr;
66 66
67 if (value->isImageValue()) { 67 if (value->isImageValue()) {
68 StyleImage* styleImageResource = 68 StyleImage* styleImageResource =
69 toCSSImageValue(value)->cacheImage(document); 69 toCSSImageValue(value)->cacheImage(document);
70 if (!styleImageResource) 70 if (!styleImageResource)
71 return nullptr; 71 return nullptr;
72 72
73 return styleImageResource->cachedImage(); 73 return styleImageResource->cachedImage();
74 } 74 }
75 75
76 if (value->isImageGeneratorValue()) { 76 if (value->isImageGeneratorValue()) {
77 toCSSImageGeneratorValue(value)->loadSubimages(document); 77 toCSSImageGeneratorValue(value)->loadSubimages(document);
78 // FIXME: Handle CSSImageGeneratorValue (and thus cross-fades with gradients 78 // FIXME: Handle CSSImageGeneratorValue (and thus cross-fades with gradients
79 // and canvas). 79 // and canvas).
80 return nullptr; 80 return nullptr;
81 } 81 }
82 82
83 ASSERT_NOT_REACHED(); 83 ASSERT_NOT_REACHED();
84 84
85 return nullptr; 85 return nullptr;
86 } 86 }
87 87
88 static Image* renderableImageForCSSValue(CSSValue* value, 88 static Image* renderableImageForCSSValue(CSSValue* value,
89 const LayoutObject& layoutObject) { 89 const LayoutObject& layoutObject) {
90 ImageResource* cachedImage = 90 ImageResourceContent* cachedImage =
91 cachedImageForCSSValue(value, layoutObject.document()); 91 cachedImageForCSSValue(value, layoutObject.document());
92 92
93 if (!cachedImage || cachedImage->errorOccurred() || 93 if (!cachedImage || cachedImage->errorOccurred() ||
94 cachedImage->getImage()->isNull()) 94 cachedImage->getImage()->isNull())
95 return nullptr; 95 return nullptr;
96 96
97 return cachedImage->getImage(); 97 return cachedImage->getImage();
98 } 98 }
99 99
100 static KURL urlForCSSValue(const CSSValue* value) { 100 static KURL urlForCSSValue(const CSSValue* value) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 subimageIsPending(m_toValue.get()); 192 subimageIsPending(m_toValue.get());
193 } 193 }
194 194
195 bool CSSCrossfadeValue::knownToBeOpaque( 195 bool CSSCrossfadeValue::knownToBeOpaque(
196 const LayoutObject& layoutObject) const { 196 const LayoutObject& layoutObject) const {
197 return subimageKnownToBeOpaque(m_fromValue.get(), layoutObject) && 197 return subimageKnownToBeOpaque(m_fromValue.get(), layoutObject) &&
198 subimageKnownToBeOpaque(m_toValue.get(), layoutObject); 198 subimageKnownToBeOpaque(m_toValue.get(), layoutObject);
199 } 199 }
200 200
201 void CSSCrossfadeValue::loadSubimages(const Document& document) { 201 void CSSCrossfadeValue::loadSubimages(const Document& document) {
202 ImageResource* oldCachedFromImage = m_cachedFromImage; 202 ImageResourceContent* oldCachedFromImage = m_cachedFromImage;
203 ImageResource* oldCachedToImage = m_cachedToImage; 203 ImageResourceContent* oldCachedToImage = m_cachedToImage;
204 204
205 m_cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document); 205 m_cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document);
206 m_cachedToImage = cachedImageForCSSValue(m_toValue.get(), document); 206 m_cachedToImage = cachedImageForCSSValue(m_toValue.get(), document);
207 207
208 if (m_cachedFromImage != oldCachedFromImage) { 208 if (m_cachedFromImage != oldCachedFromImage) {
209 if (oldCachedFromImage) 209 if (oldCachedFromImage)
210 oldCachedFromImage->removeObserver(&m_crossfadeSubimageObserver); 210 oldCachedFromImage->removeObserver(&m_crossfadeSubimageObserver);
211 if (m_cachedFromImage) 211 if (m_cachedFromImage)
212 m_cachedFromImage->addObserver(&m_crossfadeSubimageObserver); 212 m_cachedFromImage->addObserver(&m_crossfadeSubimageObserver);
213 } 213 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 bool CSSCrossfadeValue::willRenderImage() const { 260 bool CSSCrossfadeValue::willRenderImage() const {
261 for (const auto& curr : clients()) { 261 for (const auto& curr : clients()) {
262 if (const_cast<LayoutObject*>(curr.key)->willRenderImage()) 262 if (const_cast<LayoutObject*>(curr.key)->willRenderImage())
263 return true; 263 return true;
264 } 264 }
265 return false; 265 return false;
266 } 266 }
267 267
268 void CSSCrossfadeValue::CrossfadeSubimageObserverProxy::imageChanged( 268 void CSSCrossfadeValue::CrossfadeSubimageObserverProxy::imageChanged(
269 ImageResource*, 269 ImageResourceContent*,
270 const IntRect* rect) { 270 const IntRect* rect) {
271 if (m_ready) 271 if (m_ready)
272 m_ownerValue->crossfadeChanged(*rect); 272 m_ownerValue->crossfadeChanged(*rect);
273 } 273 }
274 274
275 bool CSSCrossfadeValue::CrossfadeSubimageObserverProxy::willRenderImage() { 275 bool CSSCrossfadeValue::CrossfadeSubimageObserverProxy::willRenderImage() {
276 // If the images are not ready/loaded we won't paint them. If the images 276 // If the images are not ready/loaded we won't paint them. If the images
277 // are ready then ask the clients. 277 // are ready then ask the clients.
278 return m_ready && m_ownerValue->willRenderImage(); 278 return m_ready && m_ownerValue->willRenderImage();
279 } 279 }
(...skipping 16 matching lines...) Expand all
296 visitor->trace(m_fromValue); 296 visitor->trace(m_fromValue);
297 visitor->trace(m_toValue); 297 visitor->trace(m_toValue);
298 visitor->trace(m_percentageValue); 298 visitor->trace(m_percentageValue);
299 visitor->trace(m_cachedFromImage); 299 visitor->trace(m_cachedFromImage);
300 visitor->trace(m_cachedToImage); 300 visitor->trace(m_cachedToImage);
301 visitor->trace(m_crossfadeSubimageObserver); 301 visitor->trace(m_crossfadeSubimageObserver);
302 CSSImageGeneratorValue::traceAfterDispatch(visitor); 302 CSSImageGeneratorValue::traceAfterDispatch(visitor);
303 } 303 }
304 304
305 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCrossfadeValue.h ('k') | third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698