Skip to content
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

writing mode needs to affect computed display #15754

Closed
bzbarsky opened this issue Feb 27, 2017 · 6 comments
Closed

writing mode needs to affect computed display #15754

bzbarsky opened this issue Feb 27, 2017 · 6 comments

Comments

@bzbarsky
Copy link
Contributor

@bzbarsky bzbarsky commented Feb 27, 2017

See https://bugzilla.mozilla.org/show_bug.cgi?id=1342739 and the following two testcases that stylo fails but gecko passes:

<div>
  <span style="writing-mode: vertical-rl">Text</span>
</div>
<script>
  document.write(getComputedStyle(document.querySelector("span")).display);
</script>

(should output "inline-block") and:

<div>
  <span style="writing-mode: vertical-rl; border: 20px solid green">Text</span>
</div>

(should not have the green border overlapping the text). That's because servo doesn't implement the provisions in https://drafts.csswg.org/css-writing-modes-3/#block-flow for boxes with specified display of "inline".

For stylo this should happen unconditionally. For servo, I guess this should happen only when "layout.writing-mode.enabled" is on? The rendering in that mode is way more broken than the stylo rendering anyway; there be problems there.

@bd339
Copy link
Contributor

@bd339 bd339 commented Mar 10, 2017

I would like to look into this, if I can get some help on how to get started 🙂

@emilio
Copy link
Member

@emilio emilio commented Mar 13, 2017

Hi @bd339, thanks for taking a look at this!

So, the specified display adjustment lives at components/style/properties/properties.mako.rs. There, we need to check if the specified display is inline and the parent containing block writing-mode is different from the current one, with something like:

if context.layout_parent_style.writing_mode != style.writing_mode && style.get_box().clone_display() == display::T::inline {
    style.mutate_box().set_display(display::T::inline_block);
}

Note that may be somewhat tricky because we need to skip text nodes from this, which is tricky because even though they inherit style from the parent, the writing mode should not change, but could with display: contents.

@bzbarsky
Copy link
Contributor Author

@bzbarsky bzbarsky commented Mar 13, 2017

I should note that there are some spec-side issues here too. I just sent https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html describing those. But it sounds like @emilio's suggestion matches Gecko which is about right for now.

@emilio
Copy link
Member

@emilio emilio commented Mar 13, 2017

Yeah, note that for this to match gecko, as noted in the email above, that piece of code should be under the existing display adjustments, and should call set_display (not set_adjusted_display), that is, also reset mOriginalDisplay. This bit is a bit fishy TBH :/

@bd339
Copy link
Contributor

@bd339 bd339 commented Mar 14, 2017

Thanks for pointing me in the right direction @bzbarsky and @emilio . I'm not sure I understand what you said about text nodes, so I'll show an example so you can correct me.

First off, if we assume display: contents is not a thing, skipping text nodes would happen automatically because they inherit writing-mode from their parent and wouldn't get through the if you posted? Is that what you said in the first part about text nodes?

Finally (because display: contents is a thing), would this be an example of what we need to watch out for?

<div>
  <span style="writing-mode: vertical-rl; display: contents">A text node</span>
</div>

As in: "A text node" inherits the vertical-rl writing-mode from the span but because of display: contents, it would be as if "A text node" is a direct child of the div, and its writing-mode would actually differ from its parent's?

@bzbarsky
Copy link
Contributor Author

@bzbarsky bzbarsky commented Mar 14, 2017

@bd339 That's correct.

For what it's worth, Gecko skips this writing mode fixup at this point in two situations: for text and for first-letter continuations. I think first-letter continuations can never have a writing-mode different from their "containing block", because they inherit either from the block directly or from the first-line, the "writing-mode" property does not apply to either first-letter or first-line, and things with "display:contents" don't generate first-letters. We should probably add asserts that we don't have a first-letter continuation ever hitting this case...

@bd339 bd339 mentioned this issue Mar 20, 2017
4 of 5 tasks complete
bd339 added a commit to bd339/servo that referenced this issue Mar 20, 2017
If a box has a different writing-mode than its containing block, and has a specified display of inline, change the computed display to inline-block.
Also adds the second manual testcase from servo#15754 as a WPT to assert that the computed display does in fact change.
bors-servo added a commit that referenced this issue Mar 23, 2017
Make writing-mode affect computed display

<!-- Please describe your changes on the following line: -->
The first manual test-case in #15754 passes now, but the second test-case still renders "Text" horizontally, which is apparently because of servo's experimental support for writing-mode.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15754 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16044)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Mar 24, 2017
Make writing-mode affect computed display

<!-- Please describe your changes on the following line: -->
The first manual test-case in #15754 passes now, but the second test-case still renders "Text" horizontally, which is apparently because of servo's experimental support for writing-mode.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15754 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16044)
<!-- Reviewable:end -->
clementmiao added a commit to clementmiao/servo that referenced this issue Apr 7, 2017
If a box has a different writing-mode than its containing block, and has a specified display of inline, change the computed display to inline-block.
Also adds the second manual testcase from servo#15754 as a WPT to assert that the computed display does in fact change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.