OLD | NEW |
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. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 8 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
9 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 9 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
10 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 StyleResolverState& state) { | 206 StyleResolverState& state) { |
207 state.style()->setCursor(state.parentStyle()->cursor()); | 207 state.style()->setCursor(state.parentStyle()->cursor()); |
208 state.style()->setCursorList(state.parentStyle()->cursors()); | 208 state.style()->setCursorList(state.parentStyle()->cursors()); |
209 } | 209 } |
210 | 210 |
211 void StyleBuilderFunctions::applyValueCSSPropertyCursor( | 211 void StyleBuilderFunctions::applyValueCSSPropertyCursor( |
212 StyleResolverState& state, | 212 StyleResolverState& state, |
213 const CSSValue& value) { | 213 const CSSValue& value) { |
214 state.style()->clearCursorList(); | 214 state.style()->clearCursorList(); |
215 if (value.isValueList()) { | 215 if (value.isValueList()) { |
216 const CSSValueList& list = toCSSValueList(value); | |
217 int len = list.length(); | |
218 state.style()->setCursor(ECursor::Auto); | 216 state.style()->setCursor(ECursor::Auto); |
219 for (int i = 0; i < len; i++) { | 217 for (const auto& item : toCSSValueList(value)) { |
220 const CSSValue& item = list.item(i); | 218 if (item->isCursorImageValue()) { |
221 if (item.isCursorImageValue()) { | 219 const CSSCursorImageValue& cursor = toCSSCursorImageValue(*item); |
222 const CSSCursorImageValue& image = toCSSCursorImageValue(item); | 220 const CSSValue& image = cursor.imageValue(); |
223 IntPoint hotSpot = image.hotSpot(); | |
224 bool hotSpotSpecified = image.hotSpotSpecified(); | |
225 | |
226 Element* element = state.element(); | |
227 if (SVGCursorElement* cursorElement = | |
228 image.getSVGCursorElement(element)) { | |
229 if (image.cachedImageURL() != | |
230 element->document().completeURL( | |
231 cursorElement->href()->currentValue()->value())) | |
232 image.clearImageResource(); | |
233 | |
234 // Set the hot spot if it wasn't specified in the CSS but is specified | |
235 // in the SVG. | |
236 if (!hotSpotSpecified) { | |
237 hotSpotSpecified = true; | |
238 SVGLengthContext lengthContext(0); | |
239 // x() and y() return 0 if they're not specified in cursorElement. | |
240 float svgX = roundf( | |
241 cursorElement->x()->currentValue()->value(lengthContext)); | |
242 hotSpot.setX(static_cast<int>(svgX)); | |
243 float svgY = roundf( | |
244 cursorElement->y()->currentValue()->value(lengthContext)); | |
245 hotSpot.setY(static_cast<int>(svgY)); | |
246 } | |
247 | |
248 SVGElement* svgElement = toSVGElement(element); | |
249 svgElement->setCursorImageValue(&image); | |
250 cursorElement->addClient(svgElement); | |
251 | |
252 // Elements with SVG cursors are not allowed to share style. | |
253 state.style()->setUnique(); | |
254 } | |
255 | |
256 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image), | 221 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image), |
257 hotSpotSpecified, hotSpot); | 222 cursor.hotSpotSpecified(), cursor.hotSpot()); |
258 } else { | 223 } else { |
259 state.style()->setCursor( | 224 state.style()->setCursor( |
260 toCSSIdentifierValue(item).convertTo<ECursor>()); | 225 toCSSIdentifierValue(*item).convertTo<ECursor>()); |
261 } | 226 } |
262 } | 227 } |
263 } else { | 228 } else { |
264 state.style()->setCursor(toCSSIdentifierValue(value).convertTo<ECursor>()); | 229 state.style()->setCursor(toCSSIdentifierValue(value).convertTo<ECursor>()); |
265 } | 230 } |
266 } | 231 } |
267 | 232 |
268 void StyleBuilderFunctions::applyValueCSSPropertyDirection( | 233 void StyleBuilderFunctions::applyValueCSSPropertyDirection( |
269 StyleResolverState& state, | 234 StyleResolverState& state, |
270 const CSSValue& value) { | 235 const CSSValue& value) { |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 state.style()->setCaretColor( | 1033 state.style()->setCaretColor( |
1069 StyleBuilderConverter::convertStyleAutoColor(state, value)); | 1034 StyleBuilderConverter::convertStyleAutoColor(state, value)); |
1070 } | 1035 } |
1071 if (state.applyPropertyToVisitedLinkStyle()) { | 1036 if (state.applyPropertyToVisitedLinkStyle()) { |
1072 state.style()->setVisitedLinkCaretColor( | 1037 state.style()->setVisitedLinkCaretColor( |
1073 StyleBuilderConverter::convertStyleAutoColor(state, value, true)); | 1038 StyleBuilderConverter::convertStyleAutoColor(state, value, true)); |
1074 } | 1039 } |
1075 } | 1040 } |
1076 | 1041 |
1077 } // namespace blink | 1042 } // namespace blink |
OLD | NEW |