blob: 6b7bb401d7886cd2374a1f5932770cac82c5b1c7 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
namespace blink {
Color StyleColor::ColorFromKeyword(CSSValueID keyword) {
if (const char* value_name = getValueName(keyword)) {
if (const NamedColor* named_color =
FindColor(value_name, static_cast<wtf_size_t>(strlen(value_name))))
return Color(named_color->argb_value);
}
return LayoutTheme::GetTheme().SystemColor(keyword);
}
bool StyleColor::IsColorKeyword(CSSValueID id) {
// Named colors and color keywords:
//
// <named-color>
// 'aqua', 'black', 'blue', ..., 'yellow' (CSS3: "basic color keywords")
// 'aliceblue', ..., 'yellowgreen' (CSS3: "extended color keywords")
// 'transparent'
//
// 'currentcolor'
//
// <deprecated-system-color>
// 'ActiveBorder', ..., 'WindowText'
//
// WebKit proprietary/internal:
// '-webkit-link'
// '-webkit-activelink'
// '-internal-active-list-box-selection'
// '-internal-active-list-box-selection-text'
// '-internal-inactive-list-box-selection'
// '-internal-inactive-list-box-selection-text'
// '-webkit-focus-ring-color'
// '-internal-quirk-inherit'
// '-internal-root-color'
//
return (id >= CSSValueID::kAqua && id <= CSSValueID::kInternalRootColor) ||
(id >= CSSValueID::kAliceblue && id <= CSSValueID::kYellowgreen) ||
id == CSSValueID::kMenu;
}
bool StyleColor::IsSystemColor(CSSValueID id) {
return (id >= CSSValueID::kActiveborder && id <= CSSValueID::kWindowtext) ||
id == CSSValueID::kMenu;
}
} // namespace blink