1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #include "config.h" 32 #include "public/web/WebColorName.h" 33 34 #include "core/CSSValueKeywords.h" 35 #include "core/rendering/RenderTheme.h" 36 #include "platform/graphics/Color.h" 37 #include "public/platform/WebColor.h" 38 39 using namespace::WebCore; 40 41 namespace blink { 42 43 static int toCSSValueKeyword(WebColorName name) 44 { 45 switch (name) { 46 case WebColorActiveBorder: 47 return CSSValueActiveborder; 48 case WebColorActiveCaption: 49 return CSSValueActivecaption; 50 case WebColorAppworkspace: 51 return CSSValueAppworkspace; 52 case WebColorBackground: 53 return CSSValueBackground; 54 case WebColorButtonFace: 55 return CSSValueButtonface; 56 case WebColorButtonHighlight: 57 return CSSValueButtonhighlight; 58 case WebColorButtonShadow: 59 return CSSValueButtonshadow; 60 case WebColorButtonText: 61 return CSSValueButtontext; 62 case WebColorCaptionText: 63 return CSSValueCaptiontext; 64 case WebColorGrayText: 65 return CSSValueGraytext; 66 case WebColorHighlight: 67 return CSSValueHighlight; 68 case WebColorHighlightText: 69 return CSSValueHighlighttext; 70 case WebColorInactiveBorder: 71 return CSSValueInactiveborder; 72 case WebColorInactiveCaption: 73 return CSSValueInactivecaption; 74 case WebColorInactiveCaptionText: 75 return CSSValueInactivecaptiontext; 76 case WebColorInfoBackground: 77 return CSSValueInfobackground; 78 case WebColorInfoText: 79 return CSSValueInfotext; 80 case WebColorMenu: 81 return CSSValueMenu; 82 case WebColorMenuText: 83 return CSSValueMenutext; 84 case WebColorScrollbar: 85 return CSSValueScrollbar; 86 case WebColorText: 87 return CSSValueText; 88 case WebColorThreedDarkShadow: 89 return CSSValueThreeddarkshadow; 90 case WebColorThreedShadow: 91 return CSSValueThreedshadow; 92 case WebColorThreedFace: 93 return CSSValueThreedface; 94 case WebColorThreedHighlight: 95 return CSSValueThreedhighlight; 96 case WebColorThreedLightShadow: 97 return CSSValueThreedlightshadow; 98 case WebColorWebkitFocusRingColor: 99 return CSSValueWebkitFocusRingColor; 100 case WebColorWindow: 101 return CSSValueWindow; 102 case WebColorWindowFrame: 103 return CSSValueWindowframe; 104 case WebColorWindowText: 105 return CSSValueWindowtext; 106 default: 107 return CSSValueInvalid; 108 } 109 } 110 111 void setNamedColors(const WebColorName* colorNames, const WebColor* colors, size_t length) 112 { 113 for (size_t i = 0; i < length; ++i) { 114 WebColorName colorName = colorNames[i]; 115 WebColor color = colors[i]; 116 117 // Convert color to internal value identifier. 118 int internalColorName = toCSSValueKeyword(colorName); 119 if (internalColorName == CSSValueWebkitFocusRingColor) { 120 RenderTheme::theme().setCustomFocusRingColor(color); 121 continue; 122 } 123 } 124 125 // TODO(jeremy): Tell RenderTheme to update colors. 126 } 127 128 } // WebKit 129