diff options
author | Oriol Brufau <obrufau@igalia.com> | 2024-04-29 12:40:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 10:40:44 +0000 |
commit | d490fdf83c84871ecf92f6ba9ca4216e41e0a977 (patch) | |
tree | 618b25534ece883913cf09fb8c4fb037651c7a16 /components/script/layout_dom/node.rs | |
parent | a1f8c19355f7e0e673511c24feeae60d47f19c1c (diff) | |
download | servo-d490fdf83c84871ecf92f6ba9ca4216e41e0a977.tar.gz servo-d490fdf83c84871ecf92f6ba9ca4216e41e0a977.zip |
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`.
Diffstat (limited to 'components/script/layout_dom/node.rs')
-rw-r--r-- | components/script/layout_dom/node.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/components/script/layout_dom/node.rs b/components/script/layout_dom/node.rs index 5267d687608..0cbdba64573 100644 --- a/components/script/layout_dom/node.rs +++ b/components/script/layout_dom/node.rs @@ -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 } } |