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

Unified Diff: third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp

Issue 2018923002: Fixed cursor hotspot SVG override and made CSSCursorImageValue constant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed test to use harness Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698