Prechádzať zdrojové kódy

LibWeb: Turn <table width> into the CSS width property

Andreas Kling 5 rokov pred
rodič
commit
c5a3d99dd5

+ 10 - 0
Libraries/LibWeb/DOM/HTMLTableElement.cpp

@@ -25,6 +25,7 @@
  */
  */
 
 
 #include <LibWeb/DOM/HTMLTableElement.h>
 #include <LibWeb/DOM/HTMLTableElement.h>
+#include <LibWeb/Parser/CSSParser.h>
 
 
 namespace Web {
 namespace Web {
 
 
@@ -37,4 +38,13 @@ HTMLTableElement::~HTMLTableElement()
 {
 {
 }
 }
 
 
+void HTMLTableElement::apply_presentational_hints(StyleProperties& style) const
+{
+    for_each_attribute([&](auto& name, auto& value) {
+        if (name == HTML::AttributeNames::width) {
+            style.set_property(CSS::PropertyID::Width, parse_css_value(value));
+        }
+    });
+}
+
 }
 }

+ 4 - 1
Libraries/LibWeb/DOM/HTMLTableElement.h

@@ -30,10 +30,13 @@
 
 
 namespace Web {
 namespace Web {
 
 
-class HTMLTableElement : public HTMLElement {
+class HTMLTableElement final : public HTMLElement {
 public:
 public:
     HTMLTableElement(Document&, const FlyString& tag_name);
     HTMLTableElement(Document&, const FlyString& tag_name);
     virtual ~HTMLTableElement() override;
     virtual ~HTMLTableElement() override;
+
+private:
+    virtual void apply_presentational_hints(StyleProperties&) const override;
 };
 };
 
 
 template<>
 template<>