mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +01:00
Auto merge of #14120 - Manishearth:logical, r=emilio
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 -->
This commit is contained in:
commit
4b9693cf81
10 changed files with 240 additions and 89 deletions
|
@ -894,6 +894,7 @@ pub mod style_structs {
|
|||
use fnv::FnvHasher;
|
||||
use super::longhands;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use logical_geometry::WritingMode;
|
||||
|
||||
% for style_struct in data.active_style_structs():
|
||||
% if style_struct.name == "Font":
|
||||
|
@ -924,24 +925,27 @@ pub mod style_structs {
|
|||
|
||||
impl ${style_struct.name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
||||
self.${longhand.ident} = v;
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
||||
self.${longhand.ident} = other.${longhand.ident}.clone();
|
||||
}
|
||||
% if longhand.need_clone:
|
||||
% if longhand.logical:
|
||||
${helpers.logical_setter(name=longhand.name)}
|
||||
% else:
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T {
|
||||
self.${longhand.ident}.clone()
|
||||
pub fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
||||
self.${longhand.ident} = v;
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
||||
self.${longhand.ident} = other.${longhand.ident}.clone();
|
||||
}
|
||||
% if longhand.need_clone:
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T {
|
||||
self.${longhand.ident}.clone()
|
||||
}
|
||||
% endif
|
||||
% endif
|
||||
|
||||
% if longhand.need_index:
|
||||
#[allow(non_snake_case)]
|
||||
pub fn ${longhand.ident}_count(&self) -> usize {
|
||||
|
@ -1562,7 +1566,9 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
PropertyDeclaration::Position(_) |
|
||||
PropertyDeclaration::Float(_) |
|
||||
PropertyDeclaration::TextDecoration${'' if product == 'servo' else 'Line'}(_) |
|
||||
PropertyDeclaration::WritingMode(_)
|
||||
PropertyDeclaration::WritingMode(_) |
|
||||
PropertyDeclaration::Direction(_) |
|
||||
PropertyDeclaration::TextOrientation(_)
|
||||
);
|
||||
if
|
||||
% if category_to_cascade_now == "early":
|
||||
|
@ -1582,6 +1588,10 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
&mut cascade_info,
|
||||
&mut error_reporter);
|
||||
}
|
||||
% if category_to_cascade_now == "early":
|
||||
let mode = get_writing_mode(context.style.get_inheritedbox());
|
||||
context.style.set_writing_mode(mode);
|
||||
% endif
|
||||
% endfor
|
||||
});
|
||||
|
||||
|
@ -1688,8 +1698,6 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
style.mutate_font().compute_font_hash();
|
||||
}
|
||||
|
||||
let mode = get_writing_mode(style.get_inheritedbox());
|
||||
style.set_writing_mode(mode);
|
||||
style
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue