OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "core/css/parser/CSSParser.h" | 34 #include "core/css/parser/CSSParser.h" |
35 #include "core/html/HTMLCanvasElement.h" | 35 #include "core/html/HTMLCanvasElement.h" |
36 #include "modules/canvas2d/CanvasGradient.h" | 36 #include "modules/canvas2d/CanvasGradient.h" |
37 #include "modules/canvas2d/CanvasPattern.h" | 37 #include "modules/canvas2d/CanvasPattern.h" |
38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParsedSystemColor, Parse
Failed }; | 42 enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParsedSystemColor, Parse
Failed }; |
43 | 43 |
44 static ColorParseResult parseColor(RGBA32& parsedColor, const String& colorStrin
g) | 44 static ColorParseResult parseColor(Color& parsedColor, const String& colorString
) |
45 { | 45 { |
46 if (equalIgnoringCase(colorString, "currentcolor")) | 46 if (equalIgnoringCase(colorString, "currentcolor")) |
47 return ParsedCurrentColor; | 47 return ParsedCurrentColor; |
48 const bool useStrictParsing = true; | 48 const bool useStrictParsing = true; |
49 if (CSSParser::parseColor(parsedColor, colorString, useStrictParsing)) | 49 if (CSSParser::parseColor(parsedColor, colorString, useStrictParsing)) |
50 return ParsedRGBA; | 50 return ParsedRGBA; |
51 if (CSSParser::parseSystemColor(parsedColor, colorString)) | 51 if (CSSParser::parseSystemColor(parsedColor, colorString)) |
52 return ParsedSystemColor; | 52 return ParsedSystemColor; |
53 return ParseFailed; | 53 return ParseFailed; |
54 } | 54 } |
55 | 55 |
56 static RGBA32 currentColor(HTMLCanvasElement* canvas) | 56 static Color currentColor(HTMLCanvasElement* canvas) |
57 { | 57 { |
58 if (!canvas || !canvas->inDocument() || !canvas->inlineStyle()) | 58 if (!canvas || !canvas->inDocument() || !canvas->inlineStyle()) |
59 return Color::black; | 59 return Color::black; |
60 RGBA32 rgba = Color::black; | 60 Color color = Color::black; |
61 CSSParser::parseColor(rgba, canvas->inlineStyle()->getPropertyValue(CSSPrope
rtyColor)); | 61 CSSParser::parseColor(color, canvas->inlineStyle()->getPropertyValue(CSSProp
ertyColor)); |
62 return rgba; | 62 return color; |
63 } | 63 } |
64 | 64 |
65 bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HT
MLCanvasElement* canvas) | 65 bool parseColorOrCurrentColor(Color& parsedColor, const String& colorString, HTM
LCanvasElement* canvas) |
66 { | 66 { |
67 ColorParseResult parseResult = parseColor(parsedColor, colorString); | 67 ColorParseResult parseResult = parseColor(parsedColor, colorString); |
68 switch (parseResult) { | 68 switch (parseResult) { |
69 case ParsedRGBA: | 69 case ParsedRGBA: |
70 case ParsedSystemColor: | 70 case ParsedSystemColor: |
71 return true; | 71 return true; |
72 case ParsedCurrentColor: | 72 case ParsedCurrentColor: |
73 parsedColor = currentColor(canvas); | 73 parsedColor = currentColor(canvas); |
74 return true; | 74 return true; |
75 case ParseFailed: | 75 case ParseFailed: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return Color::black; | 135 return Color::black; |
136 } | 136 } |
137 | 137 |
138 DEFINE_TRACE(CanvasStyle) | 138 DEFINE_TRACE(CanvasStyle) |
139 { | 139 { |
140 visitor->trace(m_gradient); | 140 visitor->trace(m_gradient); |
141 visitor->trace(m_pattern); | 141 visitor->trace(m_pattern); |
142 } | 142 } |
143 | 143 |
144 } | 144 } |
OLD | NEW |