1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32

content / public / common / color_parser.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_COMMON_COLOR_PARSER_H_
#define CONTENT_PUBLIC_COMMON_COLOR_PARSER_H_

#include <string>

#include "content/common/content_export.h"

typedef unsigned int SkColor;

namespace content {

// Parses a CSS-style color string from hex (3- or 6-digit), rgb(), rgba(),
// hsl() or hsla() formats. Returns true on success.
CONTENT_EXPORT bool ParseCssColorString(const std::string& color_string,
                                        SkColor* result);

// Parses a RGB or RGBA string like #FF9982CC, #FF9982, #EEEE, or #EEE to a
// color. Returns true for success.
CONTENT_EXPORT bool ParseHexColorString(const std::string& color_string,
                                        SkColor* result);

// Parses rgb() or rgba() string to a color. Returns true for success.
CONTENT_EXPORT bool ParseRgbColorString(const std::string& color_string,
                                        SkColor* result);

}  // namespace content

#endif  // CONTENT_PUBLIC_COMMON_COLOR_PARSER_H_