summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@gmail.com>2021-08-16 16:07:13 +0100
committerAndreas Kling <kling@serenityos.org>2021-08-16 23:26:16 +0200
commit0fba71a6550753e13d9561ab80f6885981b4aa70 (patch)
tree52154bcdbd1529c9236ae7bf670f36c652ae1ce3 /Userland/Libraries/LibWeb/CSS
parentea2b02186c11fc3d077673064efb9ad003d9a2fb (diff)
downloadserenity-0fba71a6550753e13d9561ab80f6885981b4aa70.zip
LibWeb: Replace is_inherited_property() with generated code
We already include the inheritance for each property in Properties.json, so made sense to use that instead of a list in StyleResolver. Added `inherited: true` to a couple of properties to match the previous code's behavior. One of those had a FIXME which I've moved to the JSON file, which is hacky, but it works.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Properties.json4
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleResolver.cpp32
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleResolver.h2
3 files changed, 3 insertions, 35 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json
index 2fbc714e01..92f47cc5c5 100644
--- a/Userland/Libraries/LibWeb/CSS/Properties.json
+++ b/Userland/Libraries/LibWeb/CSS/Properties.json
@@ -293,6 +293,7 @@
"initial": "normal"
},
"list-style": {
+ "inherited": true,
"longhands": [
"list-style-type",
"list-style-position",
@@ -422,7 +423,8 @@
"initial": "none"
},
"text-decoration-line": {
- "inherited": false,
+ "__comment": "FIXME: This property is not supposed to be inherited, but we currently rely on inheritance to propagate decorations into line boxes.",
+ "inherited": true,
"initial": "none"
},
"text-decoration-style": {
diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
index 7a5f9124f9..245dfa5aef 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
@@ -102,38 +102,6 @@ void StyleResolver::sort_matching_rules(Vector<MatchingRule>& matching_rules) co
});
}
-bool StyleResolver::is_inherited_property(CSS::PropertyID property_id)
-{
- static HashTable<CSS::PropertyID> inherited_properties;
- if (inherited_properties.is_empty()) {
- inherited_properties.set(CSS::PropertyID::BorderCollapse);
- inherited_properties.set(CSS::PropertyID::BorderSpacing);
- inherited_properties.set(CSS::PropertyID::Color);
- inherited_properties.set(CSS::PropertyID::FontFamily);
- inherited_properties.set(CSS::PropertyID::FontSize);
- inherited_properties.set(CSS::PropertyID::FontStyle);
- inherited_properties.set(CSS::PropertyID::FontVariant);
- inherited_properties.set(CSS::PropertyID::FontWeight);
- inherited_properties.set(CSS::PropertyID::LetterSpacing);
- inherited_properties.set(CSS::PropertyID::LineHeight);
- inherited_properties.set(CSS::PropertyID::ListStyle);
- inherited_properties.set(CSS::PropertyID::ListStyleImage);
- inherited_properties.set(CSS::PropertyID::ListStylePosition);
- inherited_properties.set(CSS::PropertyID::ListStyleType);
- inherited_properties.set(CSS::PropertyID::TextAlign);
- inherited_properties.set(CSS::PropertyID::TextIndent);
- inherited_properties.set(CSS::PropertyID::TextTransform);
- inherited_properties.set(CSS::PropertyID::Visibility);
- inherited_properties.set(CSS::PropertyID::WhiteSpace);
- inherited_properties.set(CSS::PropertyID::WordSpacing);
-
- // FIXME: This property is not supposed to be inherited, but we currently
- // rely on inheritance to propagate decorations into line boxes.
- inherited_properties.set(CSS::PropertyID::TextDecorationLine);
- }
- return inherited_properties.contains(property_id);
-}
-
enum class Edge {
Top,
Right,
diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.h b/Userland/Libraries/LibWeb/CSS/StyleResolver.h
index 7fa000c016..f21415706f 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleResolver.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.h
@@ -41,8 +41,6 @@ public:
CustomPropertyResolutionTuple resolve_custom_property_with_specificity(DOM::Element&, String const&) const;
Optional<StyleProperty> resolve_custom_property(DOM::Element&, String const&) const;
- static bool is_inherited_property(CSS::PropertyID);
-
private:
template<typename Callback>
void for_each_stylesheet(Callback) const;