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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (!isSVGCursor()) | 62 if (!isSVGCursor()) |
63 return; | 63 return; |
64 | 64 |
65 HashSet<SVGElement*>::const_iterator it = m_referencedElements.begin(); | 65 HashSet<SVGElement*>::const_iterator it = m_referencedElements.begin(); |
66 HashSet<SVGElement*>::const_iterator end = m_referencedElements.end(); | 66 HashSet<SVGElement*>::const_iterator end = m_referencedElements.end(); |
67 String url = toCSSImageValue(m_imageValue.get())->url(); | 67 String url = toCSSImageValue(m_imageValue.get())->url(); |
68 | 68 |
69 for (; it != end; ++it) { | 69 for (; it != end; ++it) { |
70 SVGElement* referencedElement = *it; | 70 SVGElement* referencedElement = *it; |
71 referencedElement->cursorImageValueRemoved(); | 71 referencedElement->cursorImageValueRemoved(); |
72 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(
url, referencedElement->document())) | 72 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(
url, &referencedElement->document())) |
73 cursorElement->removeClient(referencedElement); | 73 cursorElement->removeClient(referencedElement); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 String CSSCursorImageValue::customCssText() const | 77 String CSSCursorImageValue::customCssText() const |
78 { | 78 { |
79 StringBuilder result; | 79 StringBuilder result; |
80 result.append(m_imageValue->cssText()); | 80 result.append(m_imageValue->cssText()); |
81 if (m_hasHotSpot) { | 81 if (m_hasHotSpot) { |
82 result.append(' '); | 82 result.append(' '); |
83 result.appendNumber(m_hotSpot.x()); | 83 result.appendNumber(m_hotSpot.x()); |
84 result.append(' '); | 84 result.append(' '); |
85 result.appendNumber(m_hotSpot.y()); | 85 result.appendNumber(m_hotSpot.y()); |
86 } | 86 } |
87 return result.toString(); | 87 return result.toString(); |
88 } | 88 } |
89 | 89 |
90 bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element) | 90 bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element) |
91 { | 91 { |
92 if (!element || !element->isSVGElement()) | 92 if (!element || !element->isSVGElement()) |
93 return false; | 93 return false; |
94 | 94 |
95 if (!isSVGCursor()) | 95 if (!isSVGCursor()) |
96 return false; | 96 return false; |
97 | 97 |
98 String url = toCSSImageValue(m_imageValue.get())->url(); | 98 String url = toCSSImageValue(m_imageValue.get())->url(); |
99 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url,
element->document())) { | 99 if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url,
&element->document())) { |
100 // FIXME: This will override hot spot specified in CSS, which is probabl
y incorrect. | 100 // FIXME: This will override hot spot specified in CSS, which is probabl
y incorrect. |
101 SVGLengthContext lengthContext(0); | 101 SVGLengthContext lengthContext(0); |
102 m_hasHotSpot = true; | 102 m_hasHotSpot = true; |
103 float x = roundf(cursorElement->xCurrentValue().value(lengthContext)); | 103 float x = roundf(cursorElement->xCurrentValue().value(lengthContext)); |
104 m_hotSpot.setX(static_cast<int>(x)); | 104 m_hotSpot.setX(static_cast<int>(x)); |
105 | 105 |
106 float y = roundf(cursorElement->yCurrentValue().value(lengthContext)); | 106 float y = roundf(cursorElement->yCurrentValue().value(lengthContext)); |
107 m_hotSpot.setY(static_cast<int>(y)); | 107 m_hotSpot.setY(static_cast<int>(y)); |
108 | 108 |
109 if (cachedImageURL() != element->document()->completeURL(cursorElement->
hrefCurrentValue())) | 109 if (cachedImageURL() != element->document().completeURL(cursorElement->h
refCurrentValue())) |
110 clearImageResource(); | 110 clearImageResource(); |
111 | 111 |
112 SVGElement* svgElement = toSVGElement(element); | 112 SVGElement* svgElement = toSVGElement(element); |
113 m_referencedElements.add(svgElement); | 113 m_referencedElements.add(svgElement); |
114 svgElement->setCursorImageValue(this); | 114 svgElement->setCursorImageValue(this); |
115 cursorElement->addClient(svgElement); | 115 cursorElement->addClient(svgElement); |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 return false; | 119 return false; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 m_referencedElements.remove(element); | 191 m_referencedElements.remove(element); |
192 } | 192 } |
193 | 193 |
194 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const | 194 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const |
195 { | 195 { |
196 return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !
other.m_hasHotSpot | 196 return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !
other.m_hasHotSpot |
197 && compareCSSValuePtr(m_imageValue, other.m_imageValue); | 197 && compareCSSValuePtr(m_imageValue, other.m_imageValue); |
198 } | 198 } |
199 | 199 |
200 } // namespace WebCore | 200 } // namespace WebCore |
OLD | NEW |