diff options
Diffstat (limited to 'Libraries/LibWeb/CSS/StyleValue.cpp')
-rw-r--r-- | Libraries/LibWeb/CSS/StyleValue.cpp | 229 |
1 files changed, 56 insertions, 173 deletions
diff --git a/Libraries/LibWeb/CSS/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValue.cpp index 6c37d102f6..f961649bdd 100644 --- a/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValue.cpp @@ -47,241 +47,124 @@ StyleValue::~StyleValue() String IdentifierStyleValue::to_string() const { - switch (id()) { - case CSS::ValueID::Invalid: - return "(invalid)"; - case CSS::ValueID::VendorSpecificLink: - return "-libweb-link"; - case CSS::ValueID::VendorSpecificCenter: - return "-libweb-center"; - case CSS::ValueID::VendorSpecificPaletteDesktopBackground: - return "-libweb-palette-desktop-background"; - case CSS::ValueID::VendorSpecificPaletteActiveWindowBorder1: - return "-libweb-palette-active-window-border1"; - case CSS::ValueID::VendorSpecificPaletteActiveWindowBorder2: - return "-libweb-palette-active-window-border2"; - case CSS::ValueID::VendorSpecificPaletteActiveWindowTitle: - return "-libweb-palette-active-window-title"; - case CSS::ValueID::VendorSpecificPaletteInactiveWindowBorder1: - return "-libweb-palette-inactive-window-border1"; - case CSS::ValueID::VendorSpecificPaletteInactiveWindowBorder2: - return "-libweb-palette-inactive-window-border2"; - case CSS::ValueID::VendorSpecificPaletteInactiveWindowTitle: - return "-libweb-palette-inactive-window-title"; - case CSS::ValueID::VendorSpecificPaletteMovingWindowBorder1: - return "-libweb-palette-moving-window-border1"; - case CSS::ValueID::VendorSpecificPaletteMovingWindowBorder2: - return "-libweb-palette-moving-window-border2"; - case CSS::ValueID::VendorSpecificPaletteMovingWindowTitle: - return "-libweb-palette-moving-window-title"; - case CSS::ValueID::VendorSpecificPaletteHighlightWindowBorder1: - return "-libweb-palette-highlight-window-border1"; - case CSS::ValueID::VendorSpecificPaletteHighlightWindowBorder2: - return "-libweb-palette-highlight-window-border2"; - case CSS::ValueID::VendorSpecificPaletteHighlightWindowTitle: - return "-libweb-palette-highlight-window-title"; - case CSS::ValueID::VendorSpecificPaletteMenuStripe: - return "-libweb-palette-menu-stripe"; - case CSS::ValueID::VendorSpecificPaletteMenuBase: - return "-libweb-palette-menu-base"; - case CSS::ValueID::VendorSpecificPaletteMenuBaseText: - return "-libweb-palette-menu-base-text"; - case CSS::ValueID::VendorSpecificPaletteMenuSelection: - return "-libweb-palette-menu-selection"; - case CSS::ValueID::VendorSpecificPaletteMenuSelectionText: - return "-libweb-palette-menu-selection-text"; - case CSS::ValueID::VendorSpecificPaletteWindow: - return "-libweb-palette-window"; - case CSS::ValueID::VendorSpecificPaletteWindowText: - return "-libweb-palette-window-text"; - case CSS::ValueID::VendorSpecificPaletteButton: - return "-libweb-palette-button"; - case CSS::ValueID::VendorSpecificPaletteButtonText: - return "-libweb-palette-button-text"; - case CSS::ValueID::VendorSpecificPaletteBase: - return "-libweb-palette-base"; - case CSS::ValueID::VendorSpecificPaletteBaseText: - return "-libweb-palette-base-text"; - case CSS::ValueID::VendorSpecificPaletteThreedHighlight: - return "-libweb-palette-threed-highlight"; - case CSS::ValueID::VendorSpecificPaletteThreedShadow1: - return "-libweb-palette-threed-shadow1"; - case CSS::ValueID::VendorSpecificPaletteThreedShadow2: - return "-libweb-palette-threed-shadow2"; - case CSS::ValueID::VendorSpecificPaletteHoverHighlight: - return "-libweb-palette-hover-highlight"; - case CSS::ValueID::VendorSpecificPaletteSelection: - return "-libweb-palette-selection"; - case CSS::ValueID::VendorSpecificPaletteSelectionText: - return "-libweb-palette-selection-text"; - case CSS::ValueID::VendorSpecificPaletteInactiveSelection: - return "-libweb-palette-inactive-selection"; - case CSS::ValueID::VendorSpecificPaletteInactiveSelectionText: - return "-libweb-palette-inactive-selection-text"; - case CSS::ValueID::VendorSpecificPaletteRubberBandFill: - return "-libweb-palette-rubber-band-fill"; - case CSS::ValueID::VendorSpecificPaletteRubberBandBorder: - return "-libweb-palette-rubber-band-border"; - case CSS::ValueID::VendorSpecificPaletteLink: - return "-libweb-palette-link"; - case CSS::ValueID::VendorSpecificPaletteActiveLink: - return "-libweb-palette-active-link"; - case CSS::ValueID::VendorSpecificPaletteVisitedLink: - return "-libweb-palette-visited-link"; - case CSS::ValueID::VendorSpecificPaletteRuler: - return "-libweb-palette-ruler"; - case CSS::ValueID::VendorSpecificPaletteRulerBorder: - return "-libweb-palette-ruler-border"; - case CSS::ValueID::VendorSpecificPaletteRulerActiveText: - return "-libweb-palette-ruler-active-text"; - case CSS::ValueID::VendorSpecificPaletteRulerInactiveText: - return "-libweb-palette-ruler-inactive-text"; - case CSS::ValueID::VendorSpecificPaletteTextCursor: - return "-libweb-palette-text-cursor"; - case CSS::ValueID::VendorSpecificPaletteFocusOutline: - return "-libweb-palette-focus-outline"; - case CSS::ValueID::VendorSpecificPaletteSyntaxComment: - return "-libweb-palette-syntax-comment"; - case CSS::ValueID::VendorSpecificPaletteSyntaxNumber: - return "-libweb-palette-syntax-number"; - case CSS::ValueID::VendorSpecificPaletteSyntaxString: - return "-libweb-palette-syntax-string"; - case CSS::ValueID::VendorSpecificPaletteSyntaxType: - return "-libweb-palette-syntax-type"; - case CSS::ValueID::VendorSpecificPaletteSyntaxPunctuation: - return "-libweb-palette-syntax-punctuation"; - case CSS::ValueID::VendorSpecificPaletteSyntaxOperator: - return "-libweb-palette-syntax-operator"; - case CSS::ValueID::VendorSpecificPaletteSyntaxKeyword: - return "-libweb-palette-syntax-keyword"; - case CSS::ValueID::VendorSpecificPaletteSyntaxControlKeyword: - return "-libweb-palette-syntax-control-keyword"; - case CSS::ValueID::VendorSpecificPaletteSyntaxIdentifier: - return "-libweb-palette-syntax-identifier"; - case CSS::ValueID::VendorSpecificPaletteSyntaxPreprocessorStatement: - return "-libweb-palette-syntax-preprocessor-statement"; - case CSS::ValueID::VendorSpecificPaletteSyntaxPreprocessorValue: - return "-libweb-palette-syntax-preprocessor-value"; - default: - return String::formatted("-fixme-css-value-id-{}", (int)id()); - } + return CSS::string_from_value_id(m_id); } Color IdentifierStyleValue::to_color(const DOM::Document& document) const { - if (id() == CSS::ValueID::VendorSpecificLink) + if (id() == CSS::ValueID::LibwebLink) return document.link_color(); ASSERT(document.page()); auto palette = document.page()->palette(); switch (id()) { - case CSS::ValueID::VendorSpecificPaletteDesktopBackground: + case CSS::ValueID::LibwebPaletteDesktopBackground: return palette.color(ColorRole::DesktopBackground); - case CSS::ValueID::VendorSpecificPaletteActiveWindowBorder1: + case CSS::ValueID::LibwebPaletteActiveWindowBorder1: return palette.color(ColorRole::ActiveWindowBorder1); - case CSS::ValueID::VendorSpecificPaletteActiveWindowBorder2: + case CSS::ValueID::LibwebPaletteActiveWindowBorder2: return palette.color(ColorRole::ActiveWindowBorder2); - case CSS::ValueID::VendorSpecificPaletteActiveWindowTitle: + case CSS::ValueID::LibwebPaletteActiveWindowTitle: return palette.color(ColorRole::ActiveWindowTitle); - case CSS::ValueID::VendorSpecificPaletteInactiveWindowBorder1: + case CSS::ValueID::LibwebPaletteInactiveWindowBorder1: return palette.color(ColorRole::InactiveWindowBorder1); - case CSS::ValueID::VendorSpecificPaletteInactiveWindowBorder2: + case CSS::ValueID::LibwebPaletteInactiveWindowBorder2: return palette.color(ColorRole::InactiveWindowBorder2); - case CSS::ValueID::VendorSpecificPaletteInactiveWindowTitle: + case CSS::ValueID::LibwebPaletteInactiveWindowTitle: return palette.color(ColorRole::InactiveWindowTitle); - case CSS::ValueID::VendorSpecificPaletteMovingWindowBorder1: + case CSS::ValueID::LibwebPaletteMovingWindowBorder1: return palette.color(ColorRole::MovingWindowBorder1); - case CSS::ValueID::VendorSpecificPaletteMovingWindowBorder2: + case CSS::ValueID::LibwebPaletteMovingWindowBorder2: return palette.color(ColorRole::MovingWindowBorder2); - case CSS::ValueID::VendorSpecificPaletteMovingWindowTitle: + case CSS::ValueID::LibwebPaletteMovingWindowTitle: return palette.color(ColorRole::MovingWindowTitle); - case CSS::ValueID::VendorSpecificPaletteHighlightWindowBorder1: + case CSS::ValueID::LibwebPaletteHighlightWindowBorder1: return palette.color(ColorRole::HighlightWindowBorder1); - case CSS::ValueID::VendorSpecificPaletteHighlightWindowBorder2: + case CSS::ValueID::LibwebPaletteHighlightWindowBorder2: return palette.color(ColorRole::HighlightWindowBorder2); - case CSS::ValueID::VendorSpecificPaletteHighlightWindowTitle: + case CSS::ValueID::LibwebPaletteHighlightWindowTitle: return palette.color(ColorRole::HighlightWindowTitle); - case CSS::ValueID::VendorSpecificPaletteMenuStripe: + case CSS::ValueID::LibwebPaletteMenuStripe: return palette.color(ColorRole::MenuStripe); - case CSS::ValueID::VendorSpecificPaletteMenuBase: + case CSS::ValueID::LibwebPaletteMenuBase: return palette.color(ColorRole::MenuBase); - case CSS::ValueID::VendorSpecificPaletteMenuBaseText: + case CSS::ValueID::LibwebPaletteMenuBaseText: return palette.color(ColorRole::MenuBaseText); - case CSS::ValueID::VendorSpecificPaletteMenuSelection: + case CSS::ValueID::LibwebPaletteMenuSelection: return palette.color(ColorRole::MenuSelection); - case CSS::ValueID::VendorSpecificPaletteMenuSelectionText: + case CSS::ValueID::LibwebPaletteMenuSelectionText: return palette.color(ColorRole::MenuSelectionText); - case CSS::ValueID::VendorSpecificPaletteWindow: + case CSS::ValueID::LibwebPaletteWindow: return palette.color(ColorRole::Window); - case CSS::ValueID::VendorSpecificPaletteWindowText: + case CSS::ValueID::LibwebPaletteWindowText: return palette.color(ColorRole::WindowText); - case CSS::ValueID::VendorSpecificPaletteButton: + case CSS::ValueID::LibwebPaletteButton: return palette.color(ColorRole::Button); - case CSS::ValueID::VendorSpecificPaletteButtonText: + case CSS::ValueID::LibwebPaletteButtonText: return palette.color(ColorRole::ButtonText); - case CSS::ValueID::VendorSpecificPaletteBase: + case CSS::ValueID::LibwebPaletteBase: return palette.color(ColorRole::Base); - case CSS::ValueID::VendorSpecificPaletteBaseText: + case CSS::ValueID::LibwebPaletteBaseText: return palette.color(ColorRole::BaseText); - case CSS::ValueID::VendorSpecificPaletteThreedHighlight: + case CSS::ValueID::LibwebPaletteThreedHighlight: return palette.color(ColorRole::ThreedHighlight); - case CSS::ValueID::VendorSpecificPaletteThreedShadow1: + case CSS::ValueID::LibwebPaletteThreedShadow1: return palette.color(ColorRole::ThreedShadow1); - case CSS::ValueID::VendorSpecificPaletteThreedShadow2: + case CSS::ValueID::LibwebPaletteThreedShadow2: return palette.color(ColorRole::ThreedShadow2); - case CSS::ValueID::VendorSpecificPaletteHoverHighlight: + case CSS::ValueID::LibwebPaletteHoverHighlight: return palette.color(ColorRole::HoverHighlight); - case CSS::ValueID::VendorSpecificPaletteSelection: + case CSS::ValueID::LibwebPaletteSelection: return palette.color(ColorRole::Selection); - case CSS::ValueID::VendorSpecificPaletteSelectionText: + case CSS::ValueID::LibwebPaletteSelectionText: return palette.color(ColorRole::SelectionText); - case CSS::ValueID::VendorSpecificPaletteInactiveSelection: + case CSS::ValueID::LibwebPaletteInactiveSelection: return palette.color(ColorRole::InactiveSelection); - case CSS::ValueID::VendorSpecificPaletteInactiveSelectionText: + case CSS::ValueID::LibwebPaletteInactiveSelectionText: return palette.color(ColorRole::InactiveSelectionText); - case CSS::ValueID::VendorSpecificPaletteRubberBandFill: + case CSS::ValueID::LibwebPaletteRubberBandFill: return palette.color(ColorRole::RubberBandFill); - case CSS::ValueID::VendorSpecificPaletteRubberBandBorder: + case CSS::ValueID::LibwebPaletteRubberBandBorder: return palette.color(ColorRole::RubberBandBorder); - case CSS::ValueID::VendorSpecificPaletteLink: + case CSS::ValueID::LibwebPaletteLink: return palette.color(ColorRole::Link); - case CSS::ValueID::VendorSpecificPaletteActiveLink: + case CSS::ValueID::LibwebPaletteActiveLink: return palette.color(ColorRole::ActiveLink); - case CSS::ValueID::VendorSpecificPaletteVisitedLink: + case CSS::ValueID::LibwebPaletteVisitedLink: return palette.color(ColorRole::VisitedLink); - case CSS::ValueID::VendorSpecificPaletteRuler: + case CSS::ValueID::LibwebPaletteRuler: return palette.color(ColorRole::Ruler); - case CSS::ValueID::VendorSpecificPaletteRulerBorder: + case CSS::ValueID::LibwebPaletteRulerBorder: return palette.color(ColorRole::RulerBorder); - case CSS::ValueID::VendorSpecificPaletteRulerActiveText: + case CSS::ValueID::LibwebPaletteRulerActiveText: return palette.color(ColorRole::RulerActiveText); - case CSS::ValueID::VendorSpecificPaletteRulerInactiveText: + case CSS::ValueID::LibwebPaletteRulerInactiveText: return palette.color(ColorRole::RulerInactiveText); - case CSS::ValueID::VendorSpecificPaletteTextCursor: + case CSS::ValueID::LibwebPaletteTextCursor: return palette.color(ColorRole::TextCursor); - case CSS::ValueID::VendorSpecificPaletteFocusOutline: + case CSS::ValueID::LibwebPaletteFocusOutline: return palette.color(ColorRole::FocusOutline); - case CSS::ValueID::VendorSpecificPaletteSyntaxComment: + case CSS::ValueID::LibwebPaletteSyntaxComment: return palette.color(ColorRole::SyntaxComment); - case CSS::ValueID::VendorSpecificPaletteSyntaxNumber: + case CSS::ValueID::LibwebPaletteSyntaxNumber: return palette.color(ColorRole::SyntaxNumber); - case CSS::ValueID::VendorSpecificPaletteSyntaxString: + case CSS::ValueID::LibwebPaletteSyntaxString: return palette.color(ColorRole::SyntaxString); - case CSS::ValueID::VendorSpecificPaletteSyntaxType: + case CSS::ValueID::LibwebPaletteSyntaxType: return palette.color(ColorRole::SyntaxType); - case CSS::ValueID::VendorSpecificPaletteSyntaxPunctuation: + case CSS::ValueID::LibwebPaletteSyntaxPunctuation: return palette.color(ColorRole::SyntaxPunctuation); - case CSS::ValueID::VendorSpecificPaletteSyntaxOperator: + case CSS::ValueID::LibwebPaletteSyntaxOperator: return palette.color(ColorRole::SyntaxOperator); - case CSS::ValueID::VendorSpecificPaletteSyntaxKeyword: + case CSS::ValueID::LibwebPaletteSyntaxKeyword: return palette.color(ColorRole::SyntaxKeyword); - case CSS::ValueID::VendorSpecificPaletteSyntaxControlKeyword: + case CSS::ValueID::LibwebPaletteSyntaxControlKeyword: return palette.color(ColorRole::SyntaxControlKeyword); - case CSS::ValueID::VendorSpecificPaletteSyntaxIdentifier: + case CSS::ValueID::LibwebPaletteSyntaxIdentifier: return palette.color(ColorRole::SyntaxIdentifier); - case CSS::ValueID::VendorSpecificPaletteSyntaxPreprocessorStatement: + case CSS::ValueID::LibwebPaletteSyntaxPreprocessorStatement: return palette.color(ColorRole::SyntaxPreprocessorStatement); - case CSS::ValueID::VendorSpecificPaletteSyntaxPreprocessorValue: + case CSS::ValueID::LibwebPaletteSyntaxPreprocessorValue: return palette.color(ColorRole::SyntaxPreprocessorValue); default: return {}; |