SVGCSSStyleSelector.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. Copyright (C) 2005 Apple Computer, Inc.
  3. Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
  4. 2004, 2005, 2008 Rob Buis <buis@kde.org>
  5. Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  6. Based on khtml css code by:
  7. Copyright(C) 1999-2003 Lars Knoll(knoll@kde.org)
  8. (C) 2003 Apple Computer, Inc.
  9. (C) 2004 Allan Sandfeld Jensen(kde@carewolf.com)
  10. (C) 2004 Germain Garand(germain@ebooksfrance.org)
  11. This library is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU Library General Public
  13. License as published by the Free Software Foundation; either
  14. version 2 of the License, or (at your option) any later version.
  15. This library is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. Library General Public License for more details.
  19. You should have received a copy of the GNU Library General Public License
  20. along with this library; see the file COPYING.LIB. If not, write to
  21. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. Boston, MA 02110-1301, USA.
  23. */
  24. #include "config.h"
  25. #if ENABLE(SVG)
  26. #include "StyleResolver.h"
  27. #include "CSSPrimitiveValueMappings.h"
  28. #include "CSSPropertyNames.h"
  29. #include "CSSValueList.h"
  30. #include "Document.h"
  31. #include "ShadowValue.h"
  32. #include "SVGColor.h"
  33. #include "SVGNames.h"
  34. #include "SVGPaint.h"
  35. #include "SVGRenderStyle.h"
  36. #include "SVGRenderStyleDefs.h"
  37. #include "SVGStyledElement.h"
  38. #include "SVGURIReference.h"
  39. #include <stdlib.h>
  40. #include <wtf/MathExtras.h>
  41. #define HANDLE_INHERIT(prop, Prop) \
  42. if (isInherit) \
  43. { \
  44. svgstyle->set##Prop(state.parentStyle()->svgStyle()->prop()); \
  45. return; \
  46. }
  47. #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
  48. HANDLE_INHERIT(prop, Prop) \
  49. if (isInitial) { \
  50. svgstyle->set##Prop(SVGRenderStyle::initial##Prop()); \
  51. return; \
  52. }
  53. namespace WebCore {
  54. static float roundToNearestGlyphOrientationAngle(float angle)
  55. {
  56. angle = fabsf(fmodf(angle, 360.0f));
  57. if (angle <= 45.0f || angle > 315.0f)
  58. return 0.0f;
  59. else if (angle > 45.0f && angle <= 135.0f)
  60. return 90.0f;
  61. else if (angle > 135.0f && angle <= 225.0f)
  62. return 180.0f;
  63. return 270.0f;
  64. }
  65. static int angleToGlyphOrientation(float angle)
  66. {
  67. angle = roundToNearestGlyphOrientationAngle(angle);
  68. if (angle == 0.0f)
  69. return GO_0DEG;
  70. else if (angle == 90.0f)
  71. return GO_90DEG;
  72. else if (angle == 180.0f)
  73. return GO_180DEG;
  74. else if (angle == 270.0f)
  75. return GO_270DEG;
  76. return -1;
  77. }
  78. static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor)
  79. {
  80. Color color;
  81. if (svgColor->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
  82. color = fgColor;
  83. else
  84. color = svgColor->color();
  85. return color;
  86. }
  87. void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value)
  88. {
  89. ASSERT(value);
  90. CSSPrimitiveValue* primitiveValue = 0;
  91. if (value->isPrimitiveValue())
  92. primitiveValue = static_cast<CSSPrimitiveValue*>(value);
  93. const State& state = m_state;
  94. SVGRenderStyle* svgstyle = state.style()->accessSVGStyle();
  95. bool isInherit = state.parentNode() && value->isInheritedValue();
  96. bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
  97. // What follows is a list that maps the CSS properties into their
  98. // corresponding front-end RenderStyle values. Shorthands(e.g. border,
  99. // background) occur in this list as well and are only hit when mapping
  100. // "inherit" or "initial" into front-end values.
  101. switch (id)
  102. {
  103. // ident only properties
  104. case CSSPropertyAlignmentBaseline:
  105. {
  106. HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
  107. if (!primitiveValue)
  108. break;
  109. svgstyle->setAlignmentBaseline(*primitiveValue);
  110. break;
  111. }
  112. case CSSPropertyBaselineShift:
  113. {
  114. HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
  115. if (!primitiveValue)
  116. break;
  117. if (primitiveValue->getIdent()) {
  118. switch (primitiveValue->getIdent()) {
  119. case CSSValueBaseline:
  120. svgstyle->setBaselineShift(BS_BASELINE);
  121. break;
  122. case CSSValueSub:
  123. svgstyle->setBaselineShift(BS_SUB);
  124. break;
  125. case CSSValueSuper:
  126. svgstyle->setBaselineShift(BS_SUPER);
  127. break;
  128. default:
  129. break;
  130. }
  131. } else {
  132. svgstyle->setBaselineShift(BS_LENGTH);
  133. svgstyle->setBaselineShiftValue(SVGLength::fromCSSPrimitiveValue(primitiveValue));
  134. }
  135. break;
  136. }
  137. case CSSPropertyKerning:
  138. {
  139. HANDLE_INHERIT_AND_INITIAL(kerning, Kerning);
  140. if (primitiveValue)
  141. svgstyle->setKerning(SVGLength::fromCSSPrimitiveValue(primitiveValue));
  142. break;
  143. }
  144. case CSSPropertyDominantBaseline:
  145. {
  146. HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
  147. if (primitiveValue)
  148. svgstyle->setDominantBaseline(*primitiveValue);
  149. break;
  150. }
  151. case CSSPropertyColorInterpolation:
  152. {
  153. HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
  154. if (primitiveValue)
  155. svgstyle->setColorInterpolation(*primitiveValue);
  156. break;
  157. }
  158. case CSSPropertyColorInterpolationFilters:
  159. {
  160. HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
  161. if (primitiveValue)
  162. svgstyle->setColorInterpolationFilters(*primitiveValue);
  163. break;
  164. }
  165. case CSSPropertyColorProfile:
  166. {
  167. // Not implemented.
  168. break;
  169. }
  170. case CSSPropertyColorRendering:
  171. {
  172. HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
  173. if (primitiveValue)
  174. svgstyle->setColorRendering(*primitiveValue);
  175. break;
  176. }
  177. case CSSPropertyClipRule:
  178. {
  179. HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
  180. if (primitiveValue)
  181. svgstyle->setClipRule(*primitiveValue);
  182. break;
  183. }
  184. case CSSPropertyFillRule:
  185. {
  186. HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
  187. if (primitiveValue)
  188. svgstyle->setFillRule(*primitiveValue);
  189. break;
  190. }
  191. case CSSPropertyStrokeLinejoin:
  192. {
  193. HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
  194. if (primitiveValue)
  195. svgstyle->setJoinStyle(*primitiveValue);
  196. break;
  197. }
  198. case CSSPropertyShapeRendering:
  199. {
  200. HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
  201. if (primitiveValue)
  202. svgstyle->setShapeRendering(*primitiveValue);
  203. break;
  204. }
  205. // end of ident only properties
  206. case CSSPropertyFill:
  207. {
  208. if (isInherit) {
  209. const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
  210. svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  211. return;
  212. }
  213. if (isInitial) {
  214. svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  215. return;
  216. }
  217. if (value->isSVGPaint()) {
  218. SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
  219. svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  220. }
  221. break;
  222. }
  223. case CSSPropertyStroke:
  224. {
  225. if (isInherit) {
  226. const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
  227. svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  228. return;
  229. }
  230. if (isInitial) {
  231. svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  232. return;
  233. }
  234. if (value->isSVGPaint()) {
  235. SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
  236. svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
  237. }
  238. break;
  239. }
  240. case CSSPropertyStrokeWidth:
  241. {
  242. HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
  243. if (primitiveValue)
  244. svgstyle->setStrokeWidth(SVGLength::fromCSSPrimitiveValue(primitiveValue));
  245. break;
  246. }
  247. case CSSPropertyStrokeDasharray:
  248. {
  249. HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
  250. if (!value->isValueList()) {
  251. svgstyle->setStrokeDashArray(SVGRenderStyle::initialStrokeDashArray());
  252. break;
  253. }
  254. CSSValueList* dashes = static_cast<CSSValueList*>(value);
  255. Vector<SVGLength> array;
  256. size_t length = dashes->length();
  257. for (size_t i = 0; i < length; ++i) {
  258. CSSValue* currValue = dashes->itemWithoutBoundsCheck(i);
  259. if (!currValue->isPrimitiveValue())
  260. continue;
  261. CSSPrimitiveValue* dash = static_cast<CSSPrimitiveValue*>(dashes->itemWithoutBoundsCheck(i));
  262. array.append(SVGLength::fromCSSPrimitiveValue(dash));
  263. }
  264. svgstyle->setStrokeDashArray(array);
  265. break;
  266. }
  267. case CSSPropertyStrokeDashoffset:
  268. {
  269. HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
  270. if (primitiveValue)
  271. svgstyle->setStrokeDashOffset(SVGLength::fromCSSPrimitiveValue(primitiveValue));
  272. break;
  273. }
  274. case CSSPropertyFillOpacity:
  275. {
  276. HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
  277. if (!primitiveValue)
  278. return;
  279. float f = 0.0f;
  280. int type = primitiveValue->primitiveType();
  281. if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
  282. f = primitiveValue->getFloatValue() / 100.0f;
  283. else if (type == CSSPrimitiveValue::CSS_NUMBER)
  284. f = primitiveValue->getFloatValue();
  285. else
  286. return;
  287. svgstyle->setFillOpacity(f);
  288. break;
  289. }
  290. case CSSPropertyStrokeOpacity:
  291. {
  292. HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
  293. if (!primitiveValue)
  294. return;
  295. float f = 0.0f;
  296. int type = primitiveValue->primitiveType();
  297. if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
  298. f = primitiveValue->getFloatValue() / 100.0f;
  299. else if (type == CSSPrimitiveValue::CSS_NUMBER)
  300. f = primitiveValue->getFloatValue();
  301. else
  302. return;
  303. svgstyle->setStrokeOpacity(f);
  304. break;
  305. }
  306. case CSSPropertyStopOpacity:
  307. {
  308. HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
  309. if (!primitiveValue)
  310. return;
  311. float f = 0.0f;
  312. int type = primitiveValue->primitiveType();
  313. if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
  314. f = primitiveValue->getFloatValue() / 100.0f;
  315. else if (type == CSSPrimitiveValue::CSS_NUMBER)
  316. f = primitiveValue->getFloatValue();
  317. else
  318. return;
  319. svgstyle->setStopOpacity(f);
  320. break;
  321. }
  322. case CSSPropertyMarkerStart:
  323. {
  324. HANDLE_INHERIT_AND_INITIAL(markerStartResource, MarkerStartResource)
  325. if (!primitiveValue)
  326. return;
  327. String s;
  328. int type = primitiveValue->primitiveType();
  329. if (type == CSSPrimitiveValue::CSS_URI)
  330. s = primitiveValue->getStringValue();
  331. svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  332. break;
  333. }
  334. case CSSPropertyMarkerMid:
  335. {
  336. HANDLE_INHERIT_AND_INITIAL(markerMidResource, MarkerMidResource)
  337. if (!primitiveValue)
  338. return;
  339. String s;
  340. int type = primitiveValue->primitiveType();
  341. if (type == CSSPrimitiveValue::CSS_URI)
  342. s = primitiveValue->getStringValue();
  343. svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  344. break;
  345. }
  346. case CSSPropertyMarkerEnd:
  347. {
  348. HANDLE_INHERIT_AND_INITIAL(markerEndResource, MarkerEndResource)
  349. if (!primitiveValue)
  350. return;
  351. String s;
  352. int type = primitiveValue->primitiveType();
  353. if (type == CSSPrimitiveValue::CSS_URI)
  354. s = primitiveValue->getStringValue();
  355. svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  356. break;
  357. }
  358. case CSSPropertyStrokeLinecap:
  359. {
  360. HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
  361. if (primitiveValue)
  362. svgstyle->setCapStyle(*primitiveValue);
  363. break;
  364. }
  365. case CSSPropertyStrokeMiterlimit:
  366. {
  367. HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
  368. if (!primitiveValue)
  369. return;
  370. float f = 0.0f;
  371. int type = primitiveValue->primitiveType();
  372. if (type == CSSPrimitiveValue::CSS_NUMBER)
  373. f = primitiveValue->getFloatValue();
  374. else
  375. return;
  376. svgstyle->setStrokeMiterLimit(f);
  377. break;
  378. }
  379. case CSSPropertyFilter:
  380. {
  381. HANDLE_INHERIT_AND_INITIAL(filterResource, FilterResource)
  382. if (!primitiveValue)
  383. return;
  384. String s;
  385. int type = primitiveValue->primitiveType();
  386. if (type == CSSPrimitiveValue::CSS_URI)
  387. s = primitiveValue->getStringValue();
  388. svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  389. break;
  390. }
  391. case CSSPropertyMask:
  392. {
  393. HANDLE_INHERIT_AND_INITIAL(maskerResource, MaskerResource)
  394. if (!primitiveValue)
  395. return;
  396. String s;
  397. int type = primitiveValue->primitiveType();
  398. if (type == CSSPrimitiveValue::CSS_URI)
  399. s = primitiveValue->getStringValue();
  400. svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  401. break;
  402. }
  403. case CSSPropertyClipPath:
  404. {
  405. HANDLE_INHERIT_AND_INITIAL(clipperResource, ClipperResource)
  406. if (!primitiveValue)
  407. return;
  408. String s;
  409. int type = primitiveValue->primitiveType();
  410. if (type == CSSPrimitiveValue::CSS_URI)
  411. s = primitiveValue->getStringValue();
  412. svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
  413. break;
  414. }
  415. case CSSPropertyTextAnchor:
  416. {
  417. HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
  418. if (primitiveValue)
  419. svgstyle->setTextAnchor(*primitiveValue);
  420. break;
  421. }
  422. case CSSPropertyWritingMode:
  423. {
  424. HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
  425. if (primitiveValue)
  426. svgstyle->setWritingMode(*primitiveValue);
  427. break;
  428. }
  429. case CSSPropertyStopColor:
  430. {
  431. HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
  432. if (value->isSVGColor())
  433. svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
  434. break;
  435. }
  436. case CSSPropertyLightingColor:
  437. {
  438. HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
  439. if (value->isSVGColor())
  440. svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
  441. break;
  442. }
  443. case CSSPropertyFloodOpacity:
  444. {
  445. HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
  446. if (!primitiveValue)
  447. return;
  448. float f = 0.0f;
  449. int type = primitiveValue->primitiveType();
  450. if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
  451. f = primitiveValue->getFloatValue() / 100.0f;
  452. else if (type == CSSPrimitiveValue::CSS_NUMBER)
  453. f = primitiveValue->getFloatValue();
  454. else
  455. return;
  456. svgstyle->setFloodOpacity(f);
  457. break;
  458. }
  459. case CSSPropertyFloodColor:
  460. {
  461. HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
  462. if (value->isSVGColor())
  463. svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
  464. break;
  465. }
  466. case CSSPropertyGlyphOrientationHorizontal:
  467. {
  468. HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
  469. if (!primitiveValue)
  470. return;
  471. if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
  472. int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
  473. ASSERT(orientation != -1);
  474. svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
  475. }
  476. break;
  477. }
  478. case CSSPropertyGlyphOrientationVertical:
  479. {
  480. HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
  481. if (!primitiveValue)
  482. return;
  483. if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
  484. int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
  485. ASSERT(orientation != -1);
  486. svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
  487. } else if (primitiveValue->getIdent() == CSSValueAuto)
  488. svgstyle->setGlyphOrientationVertical(GO_AUTO);
  489. break;
  490. }
  491. case CSSPropertyEnableBackground:
  492. // Silently ignoring this property for now
  493. // http://bugs.webkit.org/show_bug.cgi?id=6022
  494. break;
  495. case CSSPropertyWebkitSvgShadow: {
  496. if (isInherit)
  497. return svgstyle->setShadow(adoptPtr(state.parentStyle()->svgStyle()->shadow() ? new ShadowData(*state.parentStyle()->svgStyle()->shadow()) : 0));
  498. if (isInitial || primitiveValue) // initial | none
  499. return svgstyle->setShadow(nullptr);
  500. if (!value->isValueList())
  501. return;
  502. CSSValueList *list = static_cast<CSSValueList*>(value);
  503. if (!list->length())
  504. return;
  505. CSSValue* firstValue = list->itemWithoutBoundsCheck(0);
  506. if (!firstValue->isShadowValue())
  507. return;
  508. ShadowValue* item = static_cast<ShadowValue*>(firstValue);
  509. IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()),
  510. item->y->computeLength<int>(state.style(), state.rootElementStyle()));
  511. int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0;
  512. Color color;
  513. if (item->color)
  514. color = colorFromPrimitiveValue(item->color.get());
  515. // -webkit-svg-shadow does should not have a spread or style
  516. ASSERT(!item->spread);
  517. ASSERT(!item->style);
  518. OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(location, blur, 0, Normal, false, color.isValid() ? color : Color::transparent));
  519. svgstyle->setShadow(shadowData.release());
  520. return;
  521. }
  522. case CSSPropertyVectorEffect: {
  523. HANDLE_INHERIT_AND_INITIAL(vectorEffect, VectorEffect)
  524. if (!primitiveValue)
  525. break;
  526. svgstyle->setVectorEffect(*primitiveValue);
  527. break;
  528. }
  529. case CSSPropertyBufferedRendering: {
  530. HANDLE_INHERIT_AND_INITIAL(bufferedRendering, BufferedRendering)
  531. if (!primitiveValue)
  532. break;
  533. svgstyle->setBufferedRendering(*primitiveValue);
  534. break;
  535. }
  536. case CSSPropertyMaskType: {
  537. HANDLE_INHERIT_AND_INITIAL(maskType, MaskType)
  538. if (!primitiveValue)
  539. break;
  540. svgstyle->setMaskType(*primitiveValue);
  541. break;
  542. }
  543. default:
  544. // If you crash here, it's because you added a css property and are not handling it
  545. // in either this switch statement or the one in StyleResolver::applyProperty
  546. ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
  547. return;
  548. }
  549. }
  550. }
  551. #endif