blob: a846b21367e4068f980abf1ce6ab95dd9034d6b5 [file] [log] [blame]
// Copyright 2016 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 "core/css/CSSColorValue.h"
#include "core/css/CSSValuePool.h"
namespace blink {
namespace cssvalue {
CSSColorValue* CSSColorValue::Create(RGBA32 color) {
// These are the empty and deleted values of the hash table.
if (color == Color::kTransparent)
return CssValuePool().TransparentColor();
if (color == Color::kWhite)
return CssValuePool().WhiteColor();
// Just because it is common.
if (color == Color::kBlack)
return CssValuePool().BlackColor();
CSSValuePool::ColorValueCache::AddResult entry =
CssValuePool().GetColorCacheEntry(color);
if (entry.is_new_entry)
entry.stored_value->value = new CSSColorValue(color);
return entry.stored_value->value;
}
} // namespace cssvalue
} // namespace blink