Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport logical properties in style #14120
Conversation
highfive
commented
Nov 7, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Nov 7, 2016
|
I'm unsure about the cascade behavior; currently the logical properties cascade normally, but their In particular, I'm not sure how to handle |
6068179
to
933ae4f
|
Manually tested a bit, seems to work. Some prefs need to be enabled for writing-mode to work. |
|
I created a nice testcase for this, which shows up as (in pure gecko) (Styled version of https://drafts.csswg.org/css-writing-modes/#logical-to-physical) <!DOCTYPE html>
<html>
<head>
<style>
#block-start div.outer div {
border-block-start-color: red;
border-block-start-width: 2px;
border-block-start-style: dotted;
}
#block-end div.outer div {
border-block-end-color: red;
border-block-end-width: 2px;
border-block-end-style: dotted;
}
#inline-start div.outer div {
border-inline-start-color: red;
border-inline-start-width: 2px;
border-inline-start-style: dotted;
}
#inline-end div.outer div {
border-inline-end-color: red;
border-inline-end-width: 2px;
border-inline-end-style: dotted;
}
#body tr td:nth-child(2) div {
writing-mode: horizontal-tb;
}
#body tr td:nth-child(3) div {
writing-mode: horizontal-tb;
}
#body tr td:nth-child(4) div {
writing-mode: vertical-rl;
}
#body tr td:nth-child(5) div {
writing-mode: vertical-rl;
}
#body tr td:nth-child(6) div {
writing-mode: vertical-lr;
}
#body tr td:nth-child(7) div {
writing-mode: vertical-lr;
}
/* gecko */
#body tr td:nth-child(8) div {
writing-mode: sideways-lr;
}
#body tr td:nth-child(9) div {
writing-mode: sideways-lr;
}
/* servo */
/*
#body tr td:nth-child(8) div {
writing-mode: vertical-lr;
text-orientation: sideways;
}
#body tr td:nth-child(9) div {
writing-mode: vertical-lr;
text-orientation: sideways;
}
*/
#body tr td:nth-child(2n+2) div {
direction: ltr;
}
#body tr td:nth-child(2n+3) div {
direction: rtl;
}
td {
padding: 50px;
background-color: yellow;
}
.top {
border-bottom: 2px dotted green;
}
.right {
border-left: 2px dotted green;
}
.bottom {
border-top: 2px dotted green;
}
.left {
border-right: 2px dotted green;
}
</style>
</head>
<body>
<table>
<thead>
<tr><th>writing mode</th><th colspan=2>horizontal-tb</th><th colspan=2>vertical-rl</th><th colspan=2>vertical-lr</th><th colspan=2>sideways-lr</th></tr>
<tr><th>direction</th><th>ltr</th><th>rtl</th><th>ltr</th><th>rtl</th><th>ltr</th><th>rtl</th><th>ltr</th><th>rtl</th></tr>
</thead>
<tbody id=body>
<tr id=block-start><th>block-start</th> <td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=left>left</div></div></td></tr>
<tr id=block-end><th>block-end</th> <td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=right>right</div></div></td></tr>
<tr id=inline-start><th>inline-start</th> <td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=top>top</div></div></td></tr>
<tr id=inline-end><th>inline-end</th> <td><div class=outer><div class=right>right</div></div></td><td><div class=outer><div class=left>left</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=top>top</div></div></td><td><div class=outer><div class=bottom>bottom</div></div></td></tr>
</tbody>
</table>
</body>
</html>The test passes when the green dotted line is opposite the red one. Servo doesn't support However, writing modes in general are broken in Servo layout so instead we get something like After inspecting this a bit more and looking at individual cases it seems like this PR handles the logical mapping correctly, except for <!DOCTYPE html>
<html>
<head>
<style>
#testing {
writing-mode: vertical-lr;
width: 300px;
height: 300px;
position: relative;
top: 100px;
left: 100px;
background-color: yellow;
}
#testing div {
border-inline-start-color: red;
border-inline-start-width: 5px;
border-inline-start-style: dotted;
border-top: blue 5px dotted;
width: 100px;
height: 100px;
background-color: green;
}
</style>
</head>
<body>
<div id=testing>
<div>AAAAA </div>
</div>
<script type="text/javascript">
console.log(getComputedStyle(document.querySelector("#testing div")).borderBottomColor);
</script>
</body>
</html>Should print the default color (white or currentColor) to the console, instead prints red. When displaying (hard to get it to display), the blue border should coincide with the red one, but they're on opposite sides in Servo. Probably just needs swapping in the WritingMode methods. Though we may need more changes to support sideways-*. |
|
Filed #14144 for the writing mode stuff. |
|
@bors-servo try |
|
This PR is more or less complete. Manually tested in stylo and works. Servo regurgitates writing modes so it's a bit harder to test, but no reason why it shouldn't work. The current test is manual; I'll see if I can get it into the CSS wg testsuite. A similar test can be written with JS and getComputedStyle, not sure if it's worth it. r? @SimonSapin |
|
Reftests put up in https://bugzilla.mozilla.org/show_bug.cgi?id=1316172 . The exact reftest won't work for stylo until we sort out #14144. |
|
@bors-servo try |
Support logical properties in style Adds support for the logical block-end/inline-start/etc properties. These properties (like `border-block-end-color`) map to "physical" properties (e.g. `border-top-color`) depending on the writing mode. Todo: - [x] Handle shorthands - [x] Make geckolib setters work - [x] Handle padding/offset logical properties - [x] Perhaps handle `-block-size`, `-inline-size` type logical properties? - [x] Tests? This will overall add 16 new longhands and 4 new shorthands, taking a big bite out of the [remaining properties work](https://manishearth.github.io/css-properties-list/?stylo=hide&servo=hide&firefox=only&chrome=show&mdn=false&alexa=false) f? @emilio @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14120) <!-- Reviewable:end -->
|
|
|
r=me with those nits addressed :) |
| if isinstance(arg, bool): | ||
| return arg | ||
| else: | ||
| assert arg == "True" or arg == "False" |
This comment has been minimized.
This comment has been minimized.
emilio
Nov 11, 2016
Member
nit: No need for the else branch, you can just dedent this block. Also, assert arg in ["True", "False"]?
| if len(maybe_side) == 1: | ||
| side = maybe_side[0] | ||
| elif len(maybe_size) == 1: | ||
| size = maybe_size[0] |
This comment has been minimized.
This comment has been minimized.
emilio
Nov 11, 2016
Member
Probably just assert size is not None or side is not None, and just use else below?
This comment has been minimized.
This comment has been minimized.
| </%def> | ||
|
|
||
| <%def name="logical_setter(name, need_clone=False)"> | ||
|
|
This comment has been minimized.
This comment has been minimized.
| % for (size, logical) in ALL_SIZES: | ||
| // width, height, block-size, inline-size | ||
| ${helpers.predefined_type("%s" % size, | ||
| "LengthOrPercentageOrAuto", |
This comment has been minimized.
This comment has been minimized.
|
Addressed, except for changing the exception to an assert |
|
Ok, it's fine :) @bors-servo r+ |
|
|
Support logical properties in style Adds support for the logical block-end/inline-start/etc properties. These properties (like `border-block-end-color`) map to "physical" properties (e.g. `border-top-color`) depending on the writing mode. Todo: - [x] Handle shorthands - [x] Make geckolib setters work - [x] Handle padding/offset logical properties - [x] Perhaps handle `-block-size`, `-inline-size` type logical properties? - [x] Tests? This will overall add 16 new longhands and 4 new shorthands, taking a big bite out of the [remaining properties work](https://manishearth.github.io/css-properties-list/?stylo=hide&servo=hide&firefox=only&chrome=show&mdn=false&alexa=false) f? @emilio @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14120) <!-- Reviewable:end -->
|
|



Manishearth commentedNov 7, 2016
•
edited
Adds support for the logical block-end/inline-start/etc properties. These properties (like
border-block-end-color) map to "physical" properties (e.g.border-top-color) depending on the writing mode.Todo:
-block-size,-inline-sizetype logical properties?This will overall add 16 new longhands and 4 new shorthands, taking a big bite out of the remaining properties work
f? @emilio @SimonSapin
This change is