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

Side by Side Diff: Source/core/css/CSSCursorImageValue.cpp

Issue 1308953009: Move Image ownership out of CSSValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSCursorImageValue.h ('k') | Source/core/css/CSSGradientValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Rob Buis <buis@kde.org> 2 * Copyright (C) 2006 Rob Buis <buis@kde.org>
3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 m_referencedElements.add(svgElement); 113 m_referencedElements.add(svgElement);
114 #endif 114 #endif
115 svgElement->setCursorImageValue(this); 115 svgElement->setCursorImageValue(this);
116 cursorElement->addClient(svgElement); 116 cursorElement->addClient(svgElement);
117 return true; 117 return true;
118 } 118 }
119 119
120 return false; 120 return false;
121 } 121 }
122 122
123 StyleImage* CSSCursorImageValue::cachedImage(Document* document, float deviceSca leFactor) 123 StyleImage* CSSCursorImageValue::cachedImage(Document* document, CSSStyleImageMa p& imageMap, float deviceScaleFactor)
124 { 124 {
125 if (m_imageValue->isImageSetValue()) 125 if (m_imageValue->isImageSetValue())
126 return toCSSImageSetValue(m_imageValue.get())->cachedImageSet(document, deviceScaleFactor); 126 return toCSSImageSetValue(m_imageValue.get())->cachedImageSet(document, deviceScaleFactor);
127 127
128 if (!m_accessedImage) { 128 if (!m_accessedImage) {
129 m_accessedImage = true; 129 m_accessedImage = true;
130 130
131 // For SVG images we need to lazily substitute in the correct URL. Rathe r than attempt 131 // For SVG images we need to lazily substitute in the correct URL. Rathe r than attempt
132 // to change the URL of the CSSImageValue (which would then change behav ior like cssText), 132 // to change the URL of the CSSImageValue (which would then change behav ior like cssText),
133 // we create an alternate CSSImageValue to use. 133 // we create an alternate CSSImageValue to use.
134 if (isSVGCursor() && document) { 134 if (isSVGCursor() && document) {
135 RefPtrWillBeRawPtr<CSSImageValue> imageValue = toCSSImageValue(m_ima geValue.get()); 135 RefPtrWillBeRawPtr<CSSImageValue> imageValue = toCSSImageValue(m_ima geValue.get());
136 // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827) 136 // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
137 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElem ent(imageValue->url(), *document)) { 137 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElem ent(imageValue->url(), *document)) {
138 RefPtrWillBeRawPtr<CSSImageValue> svgImageValue = CSSImageValue: :create(document->completeURL(cursorElement->href()->currentValue()->value())); 138 RefPtrWillBeRawPtr<CSSImageValue> svgImageValue = CSSImageValue: :create(document->completeURL(cursorElement->href()->currentValue()->value()));
139 svgImageValue->setReferrer(imageValue->referrer()); 139 svgImageValue->setReferrer(imageValue->referrer());
140 StyleFetchedImage* cachedImage = svgImageValue->cachedImage(docu ment); 140 StyleFetchedImage* cachedImage = svgImageValue->cachedImage(docu ment, imageMap);
141 m_image = cachedImage; 141 m_image = cachedImage;
142 return cachedImage; 142 return cachedImage;
143 } 143 }
144 } 144 }
145 145
146 if (m_imageValue->isImageValue()) 146 if (m_imageValue->isImageValue())
147 m_image = toCSSImageValue(m_imageValue.get())->cachedImage(document) ; 147 m_image = toCSSImageValue(m_imageValue.get())->cachedImage(document, imageMap);
148 } 148 }
149 149
150 if (m_image && m_image->isImageResource()) 150 if (m_image && m_image->isImageResource())
151 return toStyleFetchedImage(m_image); 151 return toStyleFetchedImage(m_image);
152 return 0; 152 return 0;
153 } 153 }
154 154
155 StyleImage* CSSCursorImageValue::cachedOrPendingImage(float deviceScaleFactor) 155 StyleImage* CSSCursorImageValue::cachedOrPendingImage(CSSStyleImageMap& imageMap , float deviceScaleFactor)
156 { 156 {
157 // Need to delegate completely so that changes in device scale factor can be handled appropriately. 157 // Need to delegate completely so that changes in device scale factor can be handled appropriately.
158 if (m_imageValue->isImageSetValue()) 158 if (m_imageValue->isImageSetValue())
159 return toCSSImageSetValue(m_imageValue.get())->cachedOrPendingImageSet(d eviceScaleFactor); 159 return toCSSImageSetValue(m_imageValue.get())->cachedOrPendingImageSet(d eviceScaleFactor);
160 160
161 if (!m_image) 161 if (!m_image)
162 m_image = StylePendingImage::create(this); 162 m_image = StylePendingImage::create(this);
163 163
164 return m_image.get(); 164 return m_image.get();
165 } 165 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 DEFINE_TRACE_AFTER_DISPATCH(CSSCursorImageValue) 203 DEFINE_TRACE_AFTER_DISPATCH(CSSCursorImageValue)
204 { 204 {
205 visitor->trace(m_imageValue); 205 visitor->trace(m_imageValue);
206 visitor->trace(m_image); 206 visitor->trace(m_image);
207 CSSValue::traceAfterDispatch(visitor); 207 CSSValue::traceAfterDispatch(visitor);
208 } 208 }
209 209
210 } // namespace blink 210 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSCursorImageValue.h ('k') | Source/core/css/CSSGradientValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698