mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Add Web::CSS::PreferredColorScheme enum
This commit is contained in:
parent
079d9e2e0b
commit
c8550da9c5
Notes:
sideshowbarker
2024-07-18 01:40:30 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/c8550da9c54 Pull-request: https://github.com/SerenityOS/serenity/pull/10609 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg
3 changed files with 57 additions and 0 deletions
|
@ -36,6 +36,7 @@ set(SOURCES
|
|||
CSS/Parser/StyleRules.cpp
|
||||
CSS/Parser/Token.cpp
|
||||
CSS/Parser/Tokenizer.cpp
|
||||
CSS/PreferredColorScheme.cpp
|
||||
CSS/PropertyID.cpp
|
||||
CSS/PropertyID.h
|
||||
CSS/QuirksModeStyleSheetSource.cpp
|
||||
|
|
33
Userland/Libraries/LibWeb/CSS/PreferredColorScheme.cpp
Normal file
33
Userland/Libraries/LibWeb/CSS/PreferredColorScheme.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/PreferredColorScheme.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
PreferredColorScheme preferred_color_scheme_from_string(String const& value)
|
||||
{
|
||||
if (value.equals_ignoring_case("light"))
|
||||
return PreferredColorScheme::Light;
|
||||
if (value.equals_ignoring_case("dark"))
|
||||
return PreferredColorScheme::Dark;
|
||||
return PreferredColorScheme::Auto;
|
||||
}
|
||||
|
||||
StringView preferred_color_scheme_to_string(PreferredColorScheme value)
|
||||
{
|
||||
switch (value) {
|
||||
case PreferredColorScheme::Light:
|
||||
return "light"sv;
|
||||
case PreferredColorScheme::Dark:
|
||||
return "dark"sv;
|
||||
case PreferredColorScheme::Auto:
|
||||
return "auto"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
23
Userland/Libraries/LibWeb/CSS/PreferredColorScheme.h
Normal file
23
Userland/Libraries/LibWeb/CSS/PreferredColorScheme.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
enum class PreferredColorScheme {
|
||||
Auto,
|
||||
Dark,
|
||||
Light,
|
||||
};
|
||||
|
||||
PreferredColorScheme preferred_color_scheme_from_string(String const&);
|
||||
StringView preferred_color_scheme_to_string(PreferredColorScheme);
|
||||
|
||||
}
|
Loading…
Reference in a new issue