-
Notifications
You must be signed in to change notification settings - Fork 165
implement direction property
#906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Blitz is currently running against #866. It's probably about time we merged that to
The other thing you can do (and I would encourage you to do for this PR), is to use Taffy's "generated test" setup. We have some documentation for that in CONTRIBUTING.md. Basically, we have a test generator in To test the |
|
@kane50613 I tried porting this to Blitz and running the WPT tests over it. Unfortunately it doesn't seem to improve test results (in fact it makes them slightly worse). Although it's possible I made some error in the port, as there is some interaction between Code if you want to look at it:
@alice-i-cecile do you have an opinion on whether we ought to consider the gentests in this PR sufficient to merge it vs. wanting to improve on WPT tests? (the gentests look good to me, but there aren't all that many of them) |
|
I'll try to collect more tests with Takumi |
|
Let's wait on the author for more tests, then merge :) |
|
I've also setup testing of this in Servo: That uses the branch from this PR as Servo is not yet using the version of Taffy that integrates floats. If there are regressions in the Servo test results that may be blocking as the Servo project probably won't accept Taffy upgrades with test regressions unless there is a good reason for them (a good reason would be something like: "the implementation has actually improved, but we previously passing tests when we shouldn't have been"). To run the tests locally:
More setup help is available in the Servo book https://book.servo.org/building/building.html |
src/tree/layout.rs
Outdated
| /// The direction of layout | ||
| pub direction: Direction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I am aware, there are no cases where a container's direction is determined by it's parent's layout algorithm (I believe that in all cases the value for direction comes directly from a node's styles).
As such, I think this extra parameter could be removed in favour of containers retrieving their own direction from the their style object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, I think I misunderstood the "inheritance" here
|
The test results are actually not bad. A lot more newly passing tests than newly failing tests (but I think we would expect a lot more new passes for an actually correct implementation). (it's only the "Stable unexpected results" we care about) |
|
Hmm... a little more sleuthing into some of the failing Blitz tests get me this. This is actually the ref that it compares against not the test (http://wpt.live/css/css-flexbox/reference/justify-content-001-ref.html): main (left) vs PR (right):
Looking at the code, I'm pretty sure it's something to do with floats that's messing this up (so essentially a merge a conflict), because there's nothing direction related here: <!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reference</title>
<link rel="author" title="Intel" href="[http://www.intel.com](view-source:http://www.intel.com/)">
<style>
#blue {
background: blue;
height: 100px;
width: 150px;
}
#orange {
background: orange;
height: 100px;
left: 150px;
position: relative;
top: -100px;
width: 150px;
}
</style>
<body>
<p>Test passes if there is a single blue rectangle on the left, a single orange rectangle directly to its right, and there is no red visible on the page.</p>
<div id="blue"></div>
<div id="orange"></div>
</body> |
|
I've tracked down and fixed the above issues on the direction-floats branch. There are now only two newly failing Blitz WPT tests, and they're both subgrid tests so I don't think we need to worry about that (we don't implement subgrid, so we wouldn't expect those tests to pass). However, there are no newly passing Blitz tests which is a bit of a shame. I suspect we may need to implement more values alignment enums to get the full benefit here. I believe the following are unimplemented:
|
diff is adopted from DioxusLabs#736 originally written by @tjamaan
This fixes errors introduced when resolving merge conflicts when rebasing the floats PR on top of the direction PR.
|
@kane50613 I have merged the floats PR. The direction-floats branch contains a version of this branch that I have rebased on top of latest |
|
ok I'll rebase this branch |
Signed-off-by: Nico Burns <nico@nicoburns.com>
Signed-off-by: Nico Burns <nico@nicoburns.com>
|
Should I avoid doing 96fd6e3 that creates huge diff or that's fine |
|
You could change: let direction = match style["direction"] {
Value::String(ref value) => match value.as_ref() {
"rtl" => quote!(direction: taffy::style::Direction::Rtl,),
"ltr" => quote!(direction: taffy::style::Direction::Ltr,),
_ => quote!(),
},
_ => quote!(),
};to let direction = match style["direction"] {
Value::String(ref value) => match value.as_ref() {
"rtl" => quote!(direction: taffy::style::Direction::Rtl,),
_ => quote!(),
},
_ => quote!(),
};relying on the fact that we know LTR is the default. That's what we've done in the test generator for other styles (omit the style if it's the default value) to try to help keep the tests small / readable. And it would allow you to use |
|
Good news, EDIT: caused by non-monospaced font |
|
|
|
It's an absurdly enormous diff (+177k LOC), and I'm not sure we can land it like this (becuause it's making the tests very slow to compile!). But nicoburns@66b37a6 creates That gives 4020 passed; 232 failed; which is actually not too bad! |
Does that mean RTL specific test cases from this PR like |
We should probably leave them for now, until such time as the perf problems with the other tests can be fixed. At some point we will also want tests that test "mixed direction". As the automated setup will only generate tests where all nodes are |
|
(didn't meant to close) |
|
69147b2 gets us to 4046 passed; 206 failed; And I've noticed a big unimplemented part of |
|
2436704 gets us to 4070 passed; 182 failed; |
| let (left, right) = match direction { | ||
| Direction::Ltr => ( | ||
| columns[item.column_indexes.start as usize + 1].offset, | ||
| columns[item.column_indexes.end as usize].offset, | ||
| ), | ||
| Direction::Rtl => ( | ||
| container_border_box.width - columns[item.column_indexes.end as usize].offset, | ||
| container_border_box.width - columns[item.column_indexes.start as usize + 1].offset, | ||
| ), | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is wrong (and same for absolute position below). This should use the LTR values for both LTR and RTL here. Instead of this, the placement algorithm should place items in a different order. The code here happens to work when the columns are all the same size and the padding/border on either side is the same, but fails is anything is non-symmetrical.
The scrollbar of items is within their width.
|
5c1880e gets us down to 174 failing tests (note that the number is really half of this, because each test has both content box and border box variants). We also seem to be running into #871. The fact that |


Objective
directionproperty (right-to-left layout) #213, Scope of RTL support kane50613/takumi#330Context
This change attempts to support bidi layout only for horizontal layout direction, i.e. it doesn't support vertical content such as CJK or Mongolian vertical writing systems.
Feedback wanted