From 78595f05d86ff2ad48edec68b015ee9c897c3d19 Mon Sep 17 00:00:00 2001 From: Pavel Shliak Date: Fri, 20 Dec 2024 02:04:02 +0400 Subject: [PATCH] Meta/LibWeb: Use correct shorthand range in is_inherited_property --- .../LibWeb/GenerateCSSPropertyID.cpp | 2 +- Tests/LibWeb/CMakeLists.txt | 1 + Tests/LibWeb/TestCSSInheritedProperty.cpp | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/TestCSSInheritedProperty.cpp diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 601412dafc8..197298e1a27 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -595,7 +595,7 @@ bool is_animatable_property(PropertyID property_id) bool is_inherited_property(PropertyID property_id) { - if (property_id >= first_inherited_shorthand_property_id && property_id <= last_inherited_longhand_property_id) + if (property_id >= first_inherited_shorthand_property_id && property_id <= last_inherited_shorthand_property_id) return true; if (property_id >= first_inherited_longhand_property_id && property_id <= last_inherited_longhand_property_id) return true; diff --git a/Tests/LibWeb/CMakeLists.txt b/Tests/LibWeb/CMakeLists.txt index a3020b66afa..bd34970a44f 100644 --- a/Tests/LibWeb/CMakeLists.txt +++ b/Tests/LibWeb/CMakeLists.txt @@ -2,6 +2,7 @@ set(TEST_SOURCES TestCSSIDSpeed.cpp TestCSSPixels.cpp TestCSSTokenStream.cpp + TestCSSInheritedProperty.cpp TestFetchInfrastructure.cpp TestFetchURL.cpp TestHTMLTokenizer.cpp diff --git a/Tests/LibWeb/TestCSSInheritedProperty.cpp b/Tests/LibWeb/TestCSSInheritedProperty.cpp new file mode 100644 index 00000000000..6f1e167f97b --- /dev/null +++ b/Tests/LibWeb/TestCSSInheritedProperty.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024, Pavel Shliak + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace Web { + +TEST_CASE(is_inherited_property_test) +{ + // Test inherited properties + EXPECT(CSS::is_inherited_property(CSS::PropertyID::Color)); + EXPECT(CSS::is_inherited_property(CSS::PropertyID::FontSize)); + EXPECT(CSS::is_inherited_property(CSS::PropertyID::Visibility)); + + // Test non-inherited properties + EXPECT(!CSS::is_inherited_property(CSS::PropertyID::Margin)); + EXPECT(!CSS::is_inherited_property(CSS::PropertyID::Padding)); + EXPECT(!CSS::is_inherited_property(CSS::PropertyID::Border)); + + // Edge cases + EXPECT(!CSS::is_inherited_property(CSS::PropertyID::Invalid)); + EXPECT(!CSS::is_inherited_property(CSS::PropertyID::All)); +} + +}