chromium/tools/style_variable_generator/tests/goldens/colors_tokens_test_expected.cc.generated

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

// This file is generated from:
//   tests/colors_ref_tokens_test.json5
//   tests/colors_sys_tokens_test.json5

#include "tools/style_variable_generator/colors_test_expected.h"

#include <optional>
#include "third_party/skia/include/core/SkColor.h"

namespace colors_test_expected {

bool g_dark_mode_enabled = false;
bool g_debug_colors_enabled = false;

bool DarkModeEnabled() {
  return g_dark_mode_enabled;
}

bool DebugColorsEnabled() {
  return g_debug_colors_enabled;
}

void SetDarkModeEnabled(bool enabled) {
  g_dark_mode_enabled = enabled;
}

void SetDebugColorsEnabled(bool enabled) {
  g_debug_colors_enabled = enabled;
}

SkAlpha GetOpacity(OpacityName opacity_name, bool is_dark_mode) {
  switch (opacity_name) {
    case OpacityName::kCrosSysDisabledOpacity:
      return 0x60;
    case OpacityName::kCrosSysReferenceOpacity:
      if (is_dark_mode) {
        return 0xFF;
      } else {
        return GetOpacity(OpacityName::kCrosSysDisabledOpacity, is_dark_mode);
      }
  }
}

std::optional<SkColor> GetDebugColor(ColorName color_name, bool is_dark_mode) {
  switch (color_name) {
    default:
      return std::nullopt;
  }
}

SkColor ResolveColor(ColorName color_name,
                     bool is_dark_mode,
                     bool use_debug_colors) {
  if (use_debug_colors) {
    auto debug_color = GetDebugColor(color_name, is_dark_mode);
    if (debug_color) {
      return *debug_color;
    }
  }
  switch (color_name) {
    case ColorName::kCrosRefPrimary50:
      return SkColorSetRGB(0x20, 0x21, 0x24);
    case ColorName::kCrosSysPrimary:
      if (is_dark_mode)
        return SkColorSetARGB(0x7F, 0x0, 0x0, 0x0);
      return ResolveColor(ColorName::kCrosRefPrimary50, is_dark_mode);
    case ColorName::kCrosSysOnPrimary:
      if (is_dark_mode)
        return ResolveColor(ColorName::kCrosRefPrimary50, is_dark_mode);
      return SkColorSetRGB(0xFF, 0xFF, 0xFF);
    case ColorName::kCrosSysPrimaryContainer:
      if (is_dark_mode)
        return SkColorSetA(ResolveColor(ColorName::kCrosRefPrimary50, is_dark_mode), GetOpacity(OpacityName::kCrosSysDisabledOpacity, is_dark_mode));
      return SkColorSetA(ResolveColor(ColorName::kCrosRefPrimary50, is_dark_mode), 0x19);
    case ColorName::kCrosSysOnPrimaryContainer:
      if (is_dark_mode)
        return SkColorSetRGB(0x29, 0x2A, 0x2D);
      return SkColorSetRGB(0xFF, 0xFF, 0xFF);
  }
}

char kDebugOverrideCssString[] = "html:not(body) {\n"
    "}\n";

}  // namespace colors_test_expected