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

Side by Side Diff: WebCore/css/SVGCSSStyleSelector.cpp

Issue 3521003: Merge 68340 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 2 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
« no previous file with comments | « LayoutTests/svg/css/invalid-color-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 2005 Apple Computer, Inc. 2 Copyright (C) 2005 Apple Computer, Inc.
3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 2004, 2005, 2008 Rob Buis <buis@kde.org> 4 2004, 2005, 2008 Rob Buis <buis@kde.org>
5 Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 5 Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
6 6
7 Based on khtml css code by: 7 Based on khtml css code by:
8 Copyright(C) 1999-2003 Lars Knoll(knoll@kde.org) 8 Copyright(C) 1999-2003 Lars Knoll(knoll@kde.org)
9 (C) 2003 Apple Computer, Inc. 9 (C) 2003 Apple Computer, Inc.
10 (C) 2004 Allan Sandfeld Jensen(kde@carewolf.com) 10 (C) 2004 Allan Sandfeld Jensen(kde@carewolf.com)
(...skipping 30 matching lines...) Expand all
41 #include "SVGPaint.h" 41 #include "SVGPaint.h"
42 #include "SVGRenderStyle.h" 42 #include "SVGRenderStyle.h"
43 #include "SVGRenderStyleDefs.h" 43 #include "SVGRenderStyleDefs.h"
44 #include "SVGStyledElement.h" 44 #include "SVGStyledElement.h"
45 #include "SVGURIReference.h" 45 #include "SVGURIReference.h"
46 #include <stdlib.h> 46 #include <stdlib.h>
47 #include <wtf/MathExtras.h> 47 #include <wtf/MathExtras.h>
48 48
49 #define HANDLE_INHERIT(prop, Prop) \ 49 #define HANDLE_INHERIT(prop, Prop) \
50 if (isInherit) \ 50 if (isInherit) \
51 {\ 51 { \
52 svgstyle->set##Prop(m_parentStyle->svgStyle()->prop());\ 52 svgstyle->set##Prop(m_parentStyle->svgStyle()->prop()); \
53 return;\ 53 return; \
54 } 54 }
55 55
56 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \ 56 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
57 HANDLE_INHERIT(prop, Prop) \ 57 HANDLE_INHERIT(prop, Prop) \
58 else if (isInitial) \ 58 if (isInitial) { \
59 svgstyle->set##Prop(SVGRenderStyle::initial##Prop()); 59 svgstyle->set##Prop(SVGRenderStyle::initial##Prop()); \
60 return; \
61 }
60 62
61 namespace WebCore { 63 namespace WebCore {
62 64
63 static float roundToNearestGlyphOrientationAngle(float angle) 65 static float roundToNearestGlyphOrientationAngle(float angle)
64 { 66 {
65 angle = fabsf(fmodf(angle, 360.0f)); 67 angle = fabsf(fmodf(angle, 360.0f));
66 68
67 if (angle <= 45.0f || angle > 315.0f) 69 if (angle <= 45.0f || angle > 315.0f)
68 return 0.0f; 70 return 0.0f;
69 else if (angle > 45.0f && angle <= 135.0f) 71 else if (angle > 45.0f && angle <= 135.0f)
(...skipping 13 matching lines...) Expand all
83 else if (angle == 90.0f) 85 else if (angle == 90.0f)
84 return GO_90DEG; 86 return GO_90DEG;
85 else if (angle == 180.0f) 87 else if (angle == 180.0f)
86 return GO_180DEG; 88 return GO_180DEG;
87 else if (angle == 270.0f) 89 else if (angle == 270.0f)
88 return GO_270DEG; 90 return GO_270DEG;
89 91
90 return -1; 92 return -1;
91 } 93 }
92 94
93 static Color colorFromSVGColorCSSValue(CSSValue* value, const Color& fgColor) 95 static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor)
94 { 96 {
95 ASSERT(value->isSVGColor());
96 SVGColor* c = static_cast<SVGColor*>(value);
97 Color color; 97 Color color;
98 if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR) 98 if (svgColor->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
99 color = fgColor; 99 color = fgColor;
100 else 100 else
101 color = c->color(); 101 color = svgColor->color();
102 return color; 102 return color;
103 } 103 }
104 104
105 void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) 105 void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
106 { 106 {
107 ASSERT(value); 107 ASSERT(value);
108 CSSPrimitiveValue* primitiveValue = 0; 108 CSSPrimitiveValue* primitiveValue = 0;
109 if (value->isPrimitiveValue()) 109 if (value->isPrimitiveValue())
110 primitiveValue = static_cast<CSSPrimitiveValue*>(value); 110 primitiveValue = static_cast<CSSPrimitiveValue*>(value);
111 111
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 case CSSPropertyWritingMode: 461 case CSSPropertyWritingMode:
462 { 462 {
463 HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode) 463 HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
464 if (primitiveValue) 464 if (primitiveValue)
465 svgstyle->setWritingMode(*primitiveValue); 465 svgstyle->setWritingMode(*primitiveValue);
466 break; 466 break;
467 } 467 }
468 case CSSPropertyStopColor: 468 case CSSPropertyStopColor:
469 { 469 {
470 HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor); 470 HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
471 svgstyle->setStopColor(colorFromSVGColorCSSValue(value, m_style->col or())); 471 if (value->isSVGColor())
472 svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVG Color*>(value), m_style->color()));
472 break; 473 break;
473 } 474 }
474 case CSSPropertyLightingColor: 475 case CSSPropertyLightingColor:
475 { 476 {
476 HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor); 477 HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
477 svgstyle->setLightingColor(colorFromSVGColorCSSValue(value, m_style- >color())); 478 if (value->isSVGColor())
479 svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast <SVGColor*>(value), m_style->color()));
478 break; 480 break;
479 } 481 }
480 case CSSPropertyFloodOpacity: 482 case CSSPropertyFloodOpacity:
481 { 483 {
482 HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity) 484 HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
483 if (!primitiveValue) 485 if (!primitiveValue)
484 return; 486 return;
485 487
486 float f = 0.0f; 488 float f = 0.0f;
487 int type = primitiveValue->primitiveType(); 489 int type = primitiveValue->primitiveType();
488 if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 490 if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
489 f = primitiveValue->getFloatValue() / 100.0f; 491 f = primitiveValue->getFloatValue() / 100.0f;
490 else if (type == CSSPrimitiveValue::CSS_NUMBER) 492 else if (type == CSSPrimitiveValue::CSS_NUMBER)
491 f = primitiveValue->getFloatValue(); 493 f = primitiveValue->getFloatValue();
492 else 494 else
493 return; 495 return;
494 496
495 svgstyle->setFloodOpacity(f); 497 svgstyle->setFloodOpacity(f);
496 break; 498 break;
497 } 499 }
498 case CSSPropertyFloodColor: 500 case CSSPropertyFloodColor:
499 { 501 {
500 if (isInitial) { 502 HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
501 svgstyle->setFloodColor(SVGRenderStyle::initialFloodColor()); 503 if (value->isSVGColor())
502 return; 504 svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SV GColor*>(value), m_style->color()));
503 }
504 svgstyle->setFloodColor(colorFromSVGColorCSSValue(value, m_style->co lor()));
505 break; 505 break;
506 } 506 }
507 case CSSPropertyGlyphOrientationHorizontal: 507 case CSSPropertyGlyphOrientationHorizontal:
508 { 508 {
509 HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientat ionHorizontal) 509 HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientat ionHorizontal)
510 if (!primitiveValue) 510 if (!primitiveValue)
511 return; 511 return;
512 512
513 if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) { 513 if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
514 int orientation = angleToGlyphOrientation(primitiveValue->getFlo atValue()); 514 int orientation = angleToGlyphOrientation(primitiveValue->getFlo atValue());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // If you crash here, it's because you added a css property and are not handling it 578 // If you crash here, it's because you added a css property and are not handling it
579 // in either this switch statement or the one in CSSStyleSelector::a pplyProperty 579 // in either this switch statement or the one in CSSStyleSelector::a pplyProperty
580 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id); 580 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
581 return; 581 return;
582 } 582 }
583 } 583 }
584 584
585 } 585 }
586 586
587 #endif 587 #endif
OLDNEW
« no previous file with comments | « LayoutTests/svg/css/invalid-color-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698