| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return nullptr; | 73 return nullptr; |
| 74 | 74 |
| 75 if (!hasFragmentInURL()) | 75 if (!hasFragmentInURL()) |
| 76 return nullptr; | 76 return nullptr; |
| 77 | 77 |
| 78 String url = toCSSImageValue(m_imageValue.get())->url(); | 78 String url = toCSSImageValue(m_imageValue.get())->url(); |
| 79 return resourceReferencedByCursorElement(url, element->treeScope()); | 79 return resourceReferencedByCursorElement(url, element->treeScope()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool CSSCursorImageValue::isCachePending(float deviceScaleFactor) const { | 82 bool CSSCursorImageValue::isCachePending(float deviceScaleFactor) const { |
| 83 // Need to delegate completely so that changes in device scale factor can be h
andled appropriately. | 83 // Need to delegate completely so that changes in device scale factor can be |
| 84 // handled appropriately. |
| 84 if (m_imageValue->isImageSetValue()) | 85 if (m_imageValue->isImageSetValue()) |
| 85 return toCSSImageSetValue(*m_imageValue).isCachePending(deviceScaleFactor); | 86 return toCSSImageSetValue(*m_imageValue).isCachePending(deviceScaleFactor); |
| 86 return m_isCachePending; | 87 return m_isCachePending; |
| 87 } | 88 } |
| 88 | 89 |
| 89 StyleImage* CSSCursorImageValue::cachedImage(float deviceScaleFactor) const { | 90 StyleImage* CSSCursorImageValue::cachedImage(float deviceScaleFactor) const { |
| 90 ASSERT(!isCachePending(deviceScaleFactor)); | 91 ASSERT(!isCachePending(deviceScaleFactor)); |
| 91 | 92 |
| 92 if (m_imageValue->isImageSetValue()) | 93 if (m_imageValue->isImageSetValue()) |
| 93 return toCSSImageSetValue(*m_imageValue).cachedImage(deviceScaleFactor); | 94 return toCSSImageSetValue(*m_imageValue).cachedImage(deviceScaleFactor); |
| 94 return m_cachedImage.get(); | 95 return m_cachedImage.get(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 StyleImage* CSSCursorImageValue::cacheImage(const Document& document, | 98 StyleImage* CSSCursorImageValue::cacheImage(const Document& document, |
| 98 float deviceScaleFactor) { | 99 float deviceScaleFactor) { |
| 99 if (m_imageValue->isImageSetValue()) | 100 if (m_imageValue->isImageSetValue()) |
| 100 return toCSSImageSetValue(*m_imageValue) | 101 return toCSSImageSetValue(*m_imageValue) |
| 101 .cacheImage(document, deviceScaleFactor); | 102 .cacheImage(document, deviceScaleFactor); |
| 102 | 103 |
| 103 if (m_isCachePending) { | 104 if (m_isCachePending) { |
| 104 m_isCachePending = false; | 105 m_isCachePending = false; |
| 105 | 106 |
| 106 // For SVG images we need to lazily substitute in the correct URL. Rather th
an attempt | 107 // For SVG images we need to lazily substitute in the correct URL. Rather |
| 107 // to change the URL of the CSSImageValue (which would then change behavior
like cssText), | 108 // than attempt to change the URL of the CSSImageValue (which would then |
| 108 // we create an alternate CSSImageValue to use. | 109 // change behavior like cssText), we create an alternate CSSImageValue to |
| 110 // use. |
| 109 if (hasFragmentInURL()) { | 111 if (hasFragmentInURL()) { |
| 110 CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); | 112 CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); |
| 111 // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 5
9827) | 113 // FIXME: This will fail if the <cursor> element is in a shadow DOM |
| 114 // (http://crbug/59827) |
| 112 if (SVGCursorElement* cursorElement = | 115 if (SVGCursorElement* cursorElement = |
| 113 resourceReferencedByCursorElement(imageValue->url(), document)) { | 116 resourceReferencedByCursorElement(imageValue->url(), document)) { |
| 114 CSSImageValue* svgImageValue = | 117 CSSImageValue* svgImageValue = |
| 115 CSSImageValue::create(document.completeURL( | 118 CSSImageValue::create(document.completeURL( |
| 116 cursorElement->href()->currentValue()->value())); | 119 cursorElement->href()->currentValue()->value())); |
| 117 svgImageValue->setReferrer(imageValue->referrer()); | 120 svgImageValue->setReferrer(imageValue->referrer()); |
| 118 m_cachedImage = svgImageValue->cacheImage(document); | 121 m_cachedImage = svgImageValue->cacheImage(document); |
| 119 return m_cachedImage.get(); | 122 return m_cachedImage.get(); |
| 120 } | 123 } |
| 121 } | 124 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 compareCSSValuePtr(m_imageValue, other.m_imageValue); | 159 compareCSSValuePtr(m_imageValue, other.m_imageValue); |
| 157 } | 160 } |
| 158 | 161 |
| 159 DEFINE_TRACE_AFTER_DISPATCH(CSSCursorImageValue) { | 162 DEFINE_TRACE_AFTER_DISPATCH(CSSCursorImageValue) { |
| 160 visitor->trace(m_imageValue); | 163 visitor->trace(m_imageValue); |
| 161 visitor->trace(m_cachedImage); | 164 visitor->trace(m_cachedImage); |
| 162 CSSValue::traceAfterDispatch(visitor); | 165 CSSValue::traceAfterDispatch(visitor); |
| 163 } | 166 } |
| 164 | 167 |
| 165 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |