OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 static inline SVGCursorElement* resourceReferencedByCursorElement(const String&
url, TreeScope& treeScope) | 41 static inline SVGCursorElement* resourceReferencedByCursorElement(const String&
url, TreeScope& treeScope) |
42 { | 42 { |
43 Element* element = SVGURIReference::targetElementFromIRIString(url, treeScop
e); | 43 Element* element = SVGURIReference::targetElementFromIRIString(url, treeScop
e); |
44 return isSVGCursorElement(element) ? toSVGCursorElement(element) : 0; | 44 return isSVGCursorElement(element) ? toSVGCursorElement(element) : 0; |
45 } | 45 } |
46 | 46 |
47 CSSCursorImageValue::CSSCursorImageValue(PassRefPtrWillBeRawPtr<CSSValue> imageV
alue, bool hotSpotSpecified, const IntPoint& hotSpot) | 47 CSSCursorImageValue::CSSCursorImageValue(PassRefPtr<CSSValue> imageValue, bool h
otSpotSpecified, const IntPoint& hotSpot) |
48 : CSSValue(CursorImageClass) | 48 : CSSValue(CursorImageClass) |
49 , m_imageValue(imageValue) | 49 , m_imageValue(imageValue) |
50 , m_hotSpotSpecified(hotSpotSpecified) | 50 , m_hotSpotSpecified(hotSpotSpecified) |
51 , m_hotSpot(hotSpot) | 51 , m_hotSpot(hotSpot) |
52 , m_accessedImage(false) | 52 , m_accessedImage(false) |
53 { | 53 { |
54 } | 54 } |
55 | 55 |
56 CSSCursorImageValue::~CSSCursorImageValue() | 56 CSSCursorImageValue::~CSSCursorImageValue() |
57 { | 57 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 RefPtr<CSSImageValue> imageValue = toCSSImageValue(m_imageValue.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 RefPtr<CSSImageValue> svgImageValue = CSSImageValue::create(docu
ment->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); |
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)
; |
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.get()); |
152 return 0; | 152 return 0; |
153 } | 153 } |
154 | 154 |
155 StyleImage* CSSCursorImageValue::cachedOrPendingImage(float deviceScaleFactor) | 155 StyleImage* CSSCursorImageValue::cachedOrPendingImage(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 } |
166 | 166 |
167 bool CSSCursorImageValue::isSVGCursor() const | 167 bool CSSCursorImageValue::isSVGCursor() const |
168 { | 168 { |
169 if (m_imageValue->isImageValue()) { | 169 if (m_imageValue->isImageValue()) { |
170 RefPtrWillBeRawPtr<CSSImageValue> imageValue = toCSSImageValue(m_imageVa
lue.get()); | 170 RefPtr<CSSImageValue> imageValue = toCSSImageValue(m_imageValue.get()); |
171 KURL kurl(ParsedURLString, imageValue->url()); | 171 KURL kurl(ParsedURLString, imageValue->url()); |
172 return kurl.hasFragmentIdentifier(); | 172 return kurl.hasFragmentIdentifier(); |
173 } | 173 } |
174 return false; | 174 return false; |
175 } | 175 } |
176 | 176 |
177 String CSSCursorImageValue::cachedImageURL() | 177 String CSSCursorImageValue::cachedImageURL() |
178 { | 178 { |
179 if (!m_image || !m_image->isImageResource()) | 179 if (!m_image || !m_image->isImageResource()) |
180 return String(); | 180 return String(); |
181 return toStyleFetchedImage(m_image)->cachedImage()->url().string(); | 181 return toStyleFetchedImage(m_image.get())->cachedImage()->url().string(); |
182 } | 182 } |
183 | 183 |
184 void CSSCursorImageValue::clearImageResource() | 184 void CSSCursorImageValue::clearImageResource() |
185 { | 185 { |
186 m_image = nullptr; | 186 m_image = nullptr; |
187 m_accessedImage = false; | 187 m_accessedImage = false; |
188 } | 188 } |
189 | 189 |
190 #if !ENABLE(OILPAN) | 190 #if !ENABLE(OILPAN) |
191 void CSSCursorImageValue::removeReferencedElement(SVGElement* element) | 191 void CSSCursorImageValue::removeReferencedElement(SVGElement* element) |
192 { | 192 { |
193 m_referencedElements.remove(element); | 193 m_referencedElements.remove(element); |
194 } | 194 } |
195 #endif | 195 #endif |
196 | 196 |
197 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const | 197 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const |
198 { | 198 { |
199 return (m_hotSpotSpecified ? other.m_hotSpotSpecified && m_hotSpot == other.
m_hotSpot : !other.m_hotSpotSpecified) | 199 return (m_hotSpotSpecified ? other.m_hotSpotSpecified && m_hotSpot == other.
m_hotSpot : !other.m_hotSpotSpecified) |
200 && compareCSSValuePtr(m_imageValue, other.m_imageValue); | 200 && compareCSSValuePtr(m_imageValue, other.m_imageValue); |
201 } | 201 } |
202 | 202 |
203 DEFINE_TRACE_AFTER_DISPATCH(CSSCursorImageValue) | |
204 { | |
205 visitor->trace(m_imageValue); | |
206 visitor->trace(m_image); | |
207 CSSValue::traceAfterDispatch(visitor); | |
208 } | |
209 | |
210 } // namespace blink | 203 } // namespace blink |
OLD | NEW |