소스 검색

LibWeb: Respect the bgcolor attribute on <marquee> elements

We don't yet animate marquees, but we can at least fill them with the
right background color.
Andreas Kling 4 년 전
부모
커밋
acd46dcb0c
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp
  2. 3 0
      Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h

+ 12 - 0
Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp

@@ -37,4 +37,16 @@ HTMLMarqueeElement::~HTMLMarqueeElement()
 {
 }
 
+void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style) const
+{
+    HTMLElement::apply_presentational_hints(style);
+    for_each_attribute([&](auto& name, auto& value) {
+        if (name == HTML::AttributeNames::bgcolor) {
+            auto color = Color::from_string(value);
+            if (color.has_value())
+                style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
+        }
+    });
+}
+
 }

+ 3 - 0
Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h

@@ -37,6 +37,9 @@ public:
 
     HTMLMarqueeElement(DOM::Document&, QualifiedName);
     virtual ~HTMLMarqueeElement() override;
+
+private:
+    virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
 };
 
 }