Skip to content

Commit

Permalink
LibWeb: Support valign attribute on td elements
Browse files Browse the repository at this point in the history
This presentational hint maps to the CSS `vertical-align` property.

Fixes SerenityOS#19786.
  • Loading branch information
awesomekling committed Jul 4, 2023
1 parent a75377d commit 224e7e4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Tests/LibWeb/Layout/expected/table/td-valign.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x220 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x204 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 144.1875x204 [BFC] children: not-inline
Box <table> at (9,9) content-size 142.1875x202 table-box [TFC] children: not-inline
Box <tbody> at (9,9) content-size 134.1875x198 table-row-group children: not-inline
Box <tr> at (11,11) content-size 134.1875x198 table-row children: not-inline
BlockContainer <td> at (12,12) content-size 26.640625x17.46875 table-cell [BFC] children: inline
line 0 width: 26.640625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 3, rect: [12,12 26.640625x17.46875]
"top"
TextNode <#text>
BlockContainer <td> at (42.640625,101.265625) content-size 45.4375x17.46875 table-cell [BFC] children: inline
line 0 width: 45.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 6, rect: [42.640625,101.265625 45.4375x17.46875]
"middle"
TextNode <#text>
BlockContainer <td> at (92.078125,190.53125) content-size 56.109375x17.46875 table-cell [BFC] children: inline
line 0 width: 56.109375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 6, rect: [92.078125,190.53125 56.109375x17.46875]
"bottom"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
6 changes: 6 additions & 0 deletions Tests/LibWeb/Layout/input/table/td-valign.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!doctype html><style>
table {
height: 200px;
border: 1px solid black;
}
</style><table><td valign=top>top</td><td valign=middle>middle</td><td valign=bottom>bottom</td>
5 changes: 5 additions & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors());
return;
}
if (name == HTML::AttributeNames::valign) {
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull());
return;
}
if (name == HTML::AttributeNames::align) {
if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter).release_value_but_fixme_should_propagate_errors());
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/HTML/HTMLTableColElement.h>
Expand Down

0 comments on commit 224e7e4

Please sign in to comment.