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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.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: Rebase 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
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
index 46aaa667af615c7f7d8d56196f31ec09d3e7f754..a6c69521e62559e48135901fc04157b53e05e0ab 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -198,9 +198,34 @@ void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolverState& stat
CSSValue* item = list->item(i);
if (item->isCursorImageValue()) {
CSSCursorImageValue* image = toCSSCursorImageValue(item);
- if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style.
+ IntPoint hotSpot = image->hotSpot();
+ bool hotSpotSpecified = image->hotSpotSpecified();
+
+ Element* element = state.element();
+ if (SVGCursorElement* cursorElement = image->getSVGCursorElement(element)) {
+ if (image->cachedImageURL() != element->document().completeURL(cursorElement->href()->currentValue()->value()))
+ image->clearImageResource();
+
+ // Set the hot spot if it wasn't specified in the CSS but is specified in the SVG.
+ if (!hotSpotSpecified) {
+ hotSpotSpecified = true;
+ SVGLengthContext lengthContext(0);
+ // x() and y() return 0 if they're not specified in cursorElement.
+ float svgX = roundf(cursorElement->x()->currentValue()->value(lengthContext));
+ hotSpot.setX(static_cast<int>(svgX));
+ float svgY = roundf(cursorElement->y()->currentValue()->value(lengthContext));
+ hotSpot.setY(static_cast<int>(svgY));
+ }
+
+ SVGElement* svgElement = toSVGElement(element);
+ svgElement->setCursorImageValue(image);
+ cursorElement->addClient(svgElement);
+
+ // Elements with SVG cursors are not allowed to share style.
state.style()->setUnique();
- state.style()->addCursor(state.styleImage(CSSPropertyCursor, *image), image->hotSpotSpecified(), image->hotSpot());
+ }
+
+ state.style()->addCursor(state.styleImage(CSSPropertyCursor, *image), hotSpotSpecified, hotSpot);
} else {
state.style()->setCursor(toCSSPrimitiveValue(item)->convertTo<ECursor>());
}
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCursorImageValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698