Skip to content

Commit

Permalink
LibWeb: Handle inline-start and inline-end as float values
Browse files Browse the repository at this point in the history
Should resolve LadybirdBrowser#449 for LTR languages at least
  • Loading branch information
vpzomtrrfrt authored and awesomekling committed Jul 10, 2024
1 parent 1103908 commit d427344
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Tests/LibWeb/Layout/expected/block-and-inline/float-logical.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x60 [BFC] children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text>
BlockContainer <body> at (8,8) content-size 784x0 children: inline
TextNode <#text>
BlockContainer <div#b> at (9,9) content-size 50x50 floating [BFC] children: not-inline
TextNode <#text>
BlockContainer <div#c> at (741,9) content-size 50x50 floating [BFC] children: not-inline
TextNode <#text>

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x60]
PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>#b) [8,8 52x52]
PaintableWithLines (BlockContainer<DIV>#c) [740,8 52x52]
23 changes: 23 additions & 0 deletions Tests/LibWeb/Layout/input/block-and-inline/float-logical.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<style>
#b {
border: 1px solid red;
width: 50px;
height: 50px;
float: inline-start;
}
#c {
border: 1px solid blue;
width: 50px;
height: 50px;
float: inline-end;
}
</style>
</head>
<body>
<div id=b></div>
<div id=c></div>
</body>
</html>
4 changes: 3 additions & 1 deletion Userland/Libraries/LibWeb/CSS/Enums.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@
"float": [
"none",
"left",
"right"
"right",
"inline-start",
"inline-end"
],
"font-variant": [
"normal",
Expand Down
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/CSS/Identifiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@
"initial-only",
"inline",
"inline-block",
"inline-end",
"inline-flex",
"inline-grid",
"inline-start",
"inline-table",
"inset",
"inside",
Expand Down
13 changes: 13 additions & 0 deletions Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,19 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
return;
}

if (property_id == CSS::PropertyID::Float) {
auto ident = value.to_identifier();

// FIXME: Honor writing-mode, direction and text-orientation.
if (ident == CSS::ValueID::InlineStart) {
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Left));
return;
} else if (ident == CSS::ValueID::InlineEnd) {
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Right));
return;
}
}

if (property_is_shorthand(property_id)) {
// ShorthandStyleValue was handled already.
// That means if we got here, that `value` must be a CSS-wide keyword, which we should apply to our longhand properties.
Expand Down

0 comments on commit d427344

Please sign in to comment.