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

Side by Side 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: Some kind of test... Not working though Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 { 191 {
192 state.style()->clearCursorList(); 192 state.style()->clearCursorList();
193 if (value->isValueList()) { 193 if (value->isValueList()) {
194 CSSValueList* list = toCSSValueList(value); 194 CSSValueList* list = toCSSValueList(value);
195 int len = list->length(); 195 int len = list->length();
196 state.style()->setCursor(CURSOR_AUTO); 196 state.style()->setCursor(CURSOR_AUTO);
197 for (int i = 0; i < len; i++) { 197 for (int i = 0; i < len; i++) {
198 CSSValue* item = list->item(i); 198 CSSValue* item = list->item(i);
199 if (item->isCursorImageValue()) { 199 if (item->isCursorImageValue()) {
200 CSSCursorImageValue* image = toCSSCursorImageValue(item); 200 CSSCursorImageValue* image = toCSSCursorImageValue(item);
201 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style. 201 IntPoint hotSpot = image->hotSpot();
202 bool hotSpotSpecified = image->hotSpotSpecified();
203
204 Element* element = state.element();
205 if (SVGCursorElement* cursorElement = image->getSVGCursorElement (element)) {
206 // Override the hot spot if it wasn't specified in the CSS b ut is specified in the SVG.
Timothy Loh 2016/05/30 01:38:34 It's not really overriding anything
sashab 2016/05/31 04:22:37 Changed to 'set'
207 SVGLengthContext lengthContext(0);
208 if (!hotSpotSpecified && cursorElement->x()) {
209 float x = roundf(cursorElement->x()->currentValue()->val ue(lengthContext));
210 hotSpot.setX(static_cast<int>(x));
211 }
212 if (!hotSpotSpecified && cursorElement->y()) {
213 float y = roundf(cursorElement->y()->currentValue()->val ue(lengthContext));
214 hotSpot.setY(static_cast<int>(y));
215 }
216
Timothy Loh 2016/05/30 01:38:34 don't we need to set hotSpotSpecified to true some
sashab 2016/05/31 04:22:37 Hhhhmmm maybe that's why my tests weren't working.
217 image->clearCachedImageIfNotURL(element->document().complete URL(cursorElement->href()->currentValue()->value()));
Timothy Loh 2016/05/30 01:38:34 probably clearer if this moved to the top of this
sashab 2016/05/31 04:22:37 Yup agreed done
218
219 SVGElement* svgElement = toSVGElement(element);
220 svgElement->setCursorImageValue(image);
221 cursorElement->addClient(svgElement);
222
223 // Elements with SVG cursors are not allowed to share style.
202 state.style()->setUnique(); 224 state.style()->setUnique();
203 state.style()->addCursor(state.styleImage(CSSPropertyCursor, *im age), image->hotSpotSpecified(), image->hotSpot()); 225 }
226 state.style()->addCursor(state.styleImage(CSSPropertyCursor, *im age), hotSpotSpecified, hotSpot);
204 } else { 227 } else {
205 state.style()->setCursor(toCSSPrimitiveValue(item)->convertTo<EC ursor>()); 228 state.style()->setCursor(toCSSPrimitiveValue(item)->convertTo<EC ursor>());
206 } 229 }
207 } 230 }
208 } else { 231 } else {
209 state.style()->setCursor(toCSSPrimitiveValue(value)->convertTo<ECursor>( )); 232 state.style()->setCursor(toCSSPrimitiveValue(value)->convertTo<ECursor>( ));
210 } 233 }
211 } 234 }
212 235
213 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& s tate, CSSValue* value) 236 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& s tate, CSSValue* value)
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 869 }
847 } 870 }
848 871
849 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState& state) 872 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState& state)
850 { 873 {
851 if (!state.parentNode()->isDocumentNode()) 874 if (!state.parentNode()->isDocumentNode())
852 state.style()->setPosition(state.parentStyle()->position()); 875 state.style()->setPosition(state.parentStyle()->position());
853 } 876 }
854 877
855 } // namespace blink 878 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698