Przeglądaj źródła

LibWeb: Support `valign` attribute on `tr` elements

implicitfield 1 rok temu
rodzic
commit
3d1fbcb26b

+ 24 - 0
Tests/LibWeb/Layout/expected/table/tr-valign.txt

@@ -0,0 +1,24 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (0,0) content-size 800x526 [BFC] children: not-inline
+    BlockContainer <body> at (8,8) content-size 784x510 children: not-inline
+      TableWrapper <(anonymous)> at (8,8) content-size 216x510 [BFC] children: not-inline
+        Box <table> at (9,9) content-size 214x508 table-box [TFC] children: not-inline
+          Box <tbody> at (9,9) content-size 208x504 table-row-group children: not-inline
+            Box <tr> at (11,11) content-size 208x504 table-row children: not-inline
+              BlockContainer <td> at (12,12) content-size 102x502 table-cell [BFC] children: not-inline
+                BlockContainer <div> at (13,13) content-size 100x500 children: not-inline
+              BlockContainer <td> at (118,12) content-size 102x102 table-cell [BFC] children: not-inline
+                BlockContainer <div> at (119,13) content-size 100x100 children: inline
+                  TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+  PaintableWithLines (BlockContainer<HTML>) [0,0 800x526]
+    PaintableWithLines (BlockContainer<BODY>) [8,8 784x510]
+      PaintableWithLines (TableWrapper(anonymous)) [8,8 216x510]
+        PaintableBox (Box<TABLE>) [8,8 216x510]
+          PaintableBox (Box<TBODY>) [9,9 208x504] overflow: [9,9 212x506]
+            PaintableBox (Box<TR>) [11,11 208x504] overflow: [11,11 210x504]
+              PaintableWithLines (BlockContainer<TD>) [11,11 104x504]
+                PaintableWithLines (BlockContainer<DIV>) [12,12 102x502]
+              PaintableWithLines (BlockContainer<TD>) [117,11 104x504]
+                PaintableWithLines (BlockContainer<DIV>) [118,12 102x102]

+ 11 - 0
Tests/LibWeb/Layout/input/table/tr-valign.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html><style>
+table {
+    height: 200px;
+    width: 200px;
+    border: 1px solid black;
+}
+div {
+    width: 100px;
+    border: 1px solid black;
+}
+</style><table><tr valign="top"><td><div style="height: 500px"></div></td><td><div style="height: 100px">

+ 7 - 0
Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp

@@ -5,8 +5,11 @@
  */
  */
 
 
 #include <LibWeb/Bindings/Intrinsics.h>
 #include <LibWeb/Bindings/Intrinsics.h>
+#include <LibWeb/CSS/Parser/Parser.h>
+#include <LibWeb/CSS/Parser/ParsingContext.h>
 #include <LibWeb/CSS/StyleProperties.h>
 #include <LibWeb/CSS/StyleProperties.h>
 #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
 #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
+#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
 #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
 #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/DOM/ElementFactory.h>
 #include <LibWeb/DOM/ElementFactory.h>
@@ -49,6 +52,10 @@ void HTMLTableRowElement::apply_presentational_hints(CSS::StyleProperties& style
             if (auto parsed_value = document().parse_url(value); parsed_value.is_valid())
             if (auto parsed_value = document().parse_url(value); parsed_value.is_valid())
                 style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value));
                 style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value));
             return;
             return;
+        } else if (name == HTML::AttributeNames::valign) {
+            if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign))
+                style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull());
+            return;
         }
         }
     });
     });
 }
 }