| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/css/parser/CSSParser.h" | 33 #include "core/css/parser/CSSParser.h" |
| 34 #include "core/html/HTMLCanvasElement.h" | 34 #include "core/html/HTMLCanvasElement.h" |
| 35 #include "modules/canvas2d/CanvasGradient.h" | 35 #include "modules/canvas2d/CanvasGradient.h" |
| 36 #include "modules/canvas2d/CanvasPattern.h" | 36 #include "modules/canvas2d/CanvasPattern.h" |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParsedSystemColor, Parse
Failed }; | 41 enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParsedSystemColor, Parse
Failed }; |
| 42 | 42 |
| 43 static ColorParseResult parseColor(Color& parsedColor, const String& colorString
) | 43 static ColorParseResult parseColor(Color& parsedColor, const String& colorString
, CSSValuePool* localCssValuePool) |
| 44 { | 44 { |
| 45 if (equalIgnoringCase(colorString, "currentcolor")) | 45 if (equalIgnoringCase(colorString, "currentcolor")) |
| 46 return ParsedCurrentColor; | 46 return ParsedCurrentColor; |
| 47 const bool useStrictParsing = true; | 47 const bool useStrictParsing = true; |
| 48 if (CSSParser::parseColor(parsedColor, colorString, useStrictParsing)) | 48 if (CSSParser::parseColor(parsedColor, colorString, localCssValuePool, useSt
rictParsing)) |
| 49 return ParsedRGBA; | 49 return ParsedRGBA; |
| 50 if (CSSParser::parseSystemColor(parsedColor, colorString)) | 50 if (CSSParser::parseSystemColor(parsedColor, colorString)) |
| 51 return ParsedSystemColor; | 51 return ParsedSystemColor; |
| 52 return ParseFailed; | 52 return ParseFailed; |
| 53 } | 53 } |
| 54 | 54 |
| 55 static Color currentColor(HTMLCanvasElement* canvas) | 55 static Color currentColor(HTMLCanvasElement* canvas, CSSValuePool* localCssValue
Pool) |
| 56 { | 56 { |
| 57 if (!canvas || !canvas->inDocument() || !canvas->inlineStyle()) | 57 if (!localCssValuePool && (!canvas || !canvas->inDocument() || !canvas->inli
neStyle())) |
| 58 return Color::black; | 58 return Color::black; |
| 59 Color color = Color::black; | 59 Color color = Color::black; |
| 60 CSSParser::parseColor(color, canvas->inlineStyle()->getPropertyValue(CSSProp
ertyColor)); | 60 CSSParser::parseColor(color, canvas->inlineStyle()->getPropertyValue(CSSProp
ertyColor), localCssValuePool); |
| 61 return color; | 61 return color; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool parseColorOrCurrentColor(Color& parsedColor, const String& colorString, HTM
LCanvasElement* canvas) | 64 bool parseColorOrCurrentColor(Color& parsedColor, const String& colorString, HTM
LCanvasElement* canvas, CSSValuePool* localCssValuePool) |
| 65 { | 65 { |
| 66 ColorParseResult parseResult = parseColor(parsedColor, colorString); | 66 ColorParseResult parseResult = parseColor(parsedColor, colorString, localCss
ValuePool); |
| 67 switch (parseResult) { | 67 switch (parseResult) { |
| 68 case ParsedRGBA: | 68 case ParsedRGBA: |
| 69 case ParsedSystemColor: | 69 case ParsedSystemColor: |
| 70 return true; | 70 return true; |
| 71 case ParsedCurrentColor: | 71 case ParsedCurrentColor: |
| 72 parsedColor = canvas ? currentColor(canvas) : Color::black; | 72 parsedColor = currentColor(canvas, localCssValuePool); |
| 73 return true; | 73 return true; |
| 74 case ParseFailed: | 74 case ParseFailed: |
| 75 return false; | 75 return false; |
| 76 default: | 76 default: |
| 77 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 CanvasStyle::CanvasStyle(RGBA32 rgba) | 82 CanvasStyle::CanvasStyle(RGBA32 rgba) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return Color::black; | 134 return Color::black; |
| 135 } | 135 } |
| 136 | 136 |
| 137 DEFINE_TRACE(CanvasStyle) | 137 DEFINE_TRACE(CanvasStyle) |
| 138 { | 138 { |
| 139 visitor->trace(m_gradient); | 139 visitor->trace(m_gradient); |
| 140 visitor->trace(m_pattern); | 140 visitor->trace(m_pattern); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |