Turn white-space into a shorthand (#32146)

Bumps Stylo to servo/stylo#37

`white-space` is split into `white-space-collapse` and `text-wrap-mode`:

| white-space | white-space-collapse | text-wrap-mode |
| ----------- | -------------------- | -------------- |
| normal      | collapse             | wrap           |
| nowrap      | collapse             | nowrap         |
| pre-wrap    | preserve             | wrap           |
| pre         | preserve             | nowrap         |
| pre-line    | preserve-breaks      | wrap           |
| -           | preserve-breaks      | nowrap         |

Note this introduces a combination that wasn't previously possible,
but I think the existing logic can handle it well enough.

The old `allow_wrap()` is replaced by checking whether `text-wrap-mode`
is set to `wrap`.

The old `preserve_newlines()` is replaced by checking whether
`white-space-collapse` is *not* set to `collapse`.

The old `preserve_spaces()` is replaced by checking whether
`white-space-collapse` is set to `preserve`.
This commit is contained in:
Oriol Brufau 2024-04-29 12:40:44 +02:00 committed by GitHub
parent a1f8c19355
commit d490fdf83c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 141 additions and 454 deletions

View file

@ -23,6 +23,7 @@ use script_layout_interface::{
use servo_arc::Arc;
use servo_url::ServoUrl;
use style;
use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
use style::context::SharedStyleContext;
use style::dom::{NodeInfo, TElement, TNode, TShadowRoot};
use style::properties::ComputedValues;
@ -337,11 +338,10 @@ impl<'dom> ThreadSafeLayoutNode<'dom> for ServoThreadSafeLayoutNode<'dom> {
//
// If you implement other values for this property, you will almost certainly
// want to update this check.
!self
.style(context)
self.style(context)
.get_inherited_text()
.white_space
.preserve_newlines()
.white_space_collapse ==
WhiteSpaceCollapse::Collapse
}
}