Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp |
| diff --git a/third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp b/third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp |
| index 3021886a087432347d10a903c84c01afa951a41f..80c70ea48c929c83efef6518198b6346bc14ca16 100644 |
| --- a/third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp |
| +++ b/third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp |
| @@ -68,35 +68,22 @@ String CSSCursorImageValue::customCSSText() const |
| return result.toString(); |
| } |
| -bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element) |
| +SVGCursorElement* CSSCursorImageValue::getSVGCursorElement(Element* element) const |
| { |
| if (!element || !element->isSVGElement()) |
| - return false; |
| + return nullptr; |
| - if (!isSVGCursor()) |
| - return false; |
| + if (!hasFragmentInURL()) |
| + return nullptr; |
| String url = toCSSImageValue(m_imageValue.get())->url(); |
| - if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->treeScope())) { |
| - // FIXME: This will override hot spot specified in CSS, which is probably incorrect. |
| - SVGLengthContext lengthContext(0); |
| - m_hotSpotSpecified = true; |
| - float x = roundf(cursorElement->x()->currentValue()->value(lengthContext)); |
| - m_hotSpot.setX(static_cast<int>(x)); |
| - |
| - float y = roundf(cursorElement->y()->currentValue()->value(lengthContext)); |
| - m_hotSpot.setY(static_cast<int>(y)); |
| - |
| - if (cachedImageURL() != element->document().completeURL(cursorElement->href()->currentValue()->value())) |
| - clearImageResource(); |
| - |
| - SVGElement* svgElement = toSVGElement(element); |
| - svgElement->setCursorImageValue(this); |
| - cursorElement->addClient(svgElement); |
| - return true; |
| - } |
| + return resourceReferencedByCursorElement(url, element->treeScope()); |
| +} |
| - return false; |
| +void CSSCursorImageValue::clearCachedImage() const |
| +{ |
| + m_cachedImage = nullptr; |
| + m_isCachePending = true; |
| } |
| bool CSSCursorImageValue::isCachePending(float deviceScaleFactor) const |
| @@ -107,6 +94,13 @@ bool CSSCursorImageValue::isCachePending(float deviceScaleFactor) const |
| return m_isCachePending; |
| } |
| +String CSSCursorImageValue::cachedImageURL() const |
| +{ |
| + if (!m_cachedImage || !m_cachedImage->isImageResource()) |
| + return String(); |
| + return toStyleFetchedImage(m_cachedImage)->cachedImage()->url().getString(); |
| +} |
| + |
| StyleImage* CSSCursorImageValue::cachedImage(float deviceScaleFactor) const |
| { |
| ASSERT(!isCachePending(deviceScaleFactor)); |
| @@ -127,7 +121,7 @@ StyleImage* CSSCursorImageValue::cacheImage(Document* document, float deviceScal |
| // For SVG images we need to lazily substitute in the correct URL. Rather than attempt |
| // to change the URL of the CSSImageValue (which would then change behavior like cssText), |
| // we create an alternate CSSImageValue to use. |
| - if (isSVGCursor() && document) { |
| + if (hasFragmentInURL() && document) { |
| CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); |
| // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827) |
| if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), *document)) { |
| @@ -147,7 +141,7 @@ StyleImage* CSSCursorImageValue::cacheImage(Document* document, float deviceScal |
| return nullptr; |
| } |
| -bool CSSCursorImageValue::isSVGCursor() const |
| +bool CSSCursorImageValue::hasFragmentInURL() const |
| { |
| if (m_imageValue->isImageValue()) { |
| CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); |
| @@ -157,19 +151,6 @@ bool CSSCursorImageValue::isSVGCursor() const |
| return false; |
| } |
| -String CSSCursorImageValue::cachedImageURL() |
|
Timothy Loh
2016/05/31 05:04:35
would be nicer if you left the functions in the sa
sashab
2016/05/31 05:24:12
Done, also renamed clearCachedImage() back to clea
|
| -{ |
| - if (!m_cachedImage || !m_cachedImage->isImageResource()) |
| - return String(); |
| - return toStyleFetchedImage(m_cachedImage)->cachedImage()->url().getString(); |
| -} |
| - |
| -void CSSCursorImageValue::clearImageResource() |
| -{ |
| - m_cachedImage = nullptr; |
| - m_isCachePending = true; |
| -} |
| - |
| bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const |
| { |
| return (m_hotSpotSpecified ? other.m_hotSpotSpecified && m_hotSpot == other.m_hotSpot : !other.m_hotSpotSpecified) |