mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Make StyleStruct.name_lower snake case.
Bug: 1468651 Reviewed-by: heycam MozReview-Commit-ID: A3TpDTmFgF
This commit is contained in:
parent
4571a71bfc
commit
a4dcb33986
5 changed files with 19 additions and 15 deletions
|
@ -38,6 +38,10 @@ def to_rust_ident(name):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def to_snake_case(ident):
|
||||||
|
return re.sub("([A-Z]+)", lambda m: "_" + m.group(1).lower(), ident).strip("_")
|
||||||
|
|
||||||
|
|
||||||
def to_camel_case(ident):
|
def to_camel_case(ident):
|
||||||
return re.sub("(^|_|-)([a-z0-9])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
|
return re.sub("(^|_|-)([a-z0-9])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
|
||||||
|
|
||||||
|
@ -451,7 +455,7 @@ class StyleStruct(object):
|
||||||
def __init__(self, name, inherited, gecko_name=None, additional_methods=None):
|
def __init__(self, name, inherited, gecko_name=None, additional_methods=None):
|
||||||
self.gecko_struct_name = "Gecko" + name
|
self.gecko_struct_name = "Gecko" + name
|
||||||
self.name = name
|
self.name = name
|
||||||
self.name_lower = name.lower()
|
self.name_lower = to_snake_case(name)
|
||||||
self.ident = to_rust_ident(self.name_lower)
|
self.ident = to_rust_ident(self.name_lower)
|
||||||
self.longhands = []
|
self.longhands = []
|
||||||
self.inherited = inherited
|
self.inherited = inherited
|
||||||
|
|
|
@ -3877,7 +3877,7 @@ where
|
||||||
}
|
}
|
||||||
% if category_to_cascade_now == "early":
|
% if category_to_cascade_now == "early":
|
||||||
let writing_mode =
|
let writing_mode =
|
||||||
WritingMode::new(context.builder.get_inheritedbox());
|
WritingMode::new(context.builder.get_inherited_box());
|
||||||
context.builder.writing_mode = writing_mode;
|
context.builder.writing_mode = writing_mode;
|
||||||
|
|
||||||
let mut _skip_font_family = false;
|
let mut _skip_font_family = false;
|
||||||
|
|
|
@ -256,8 +256,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
use computed_values::text_combine_upright::T as TextCombineUpright;
|
use computed_values::text_combine_upright::T as TextCombineUpright;
|
||||||
use computed_values::writing_mode::T as WritingMode;
|
use computed_values::writing_mode::T as WritingMode;
|
||||||
|
|
||||||
let writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
let writing_mode = self.style.get_inherited_box().clone_writing_mode();
|
||||||
let text_combine_upright = self.style.get_inheritedtext().clone_text_combine_upright();
|
let text_combine_upright = self.style.get_inherited_text().clone_text_combine_upright();
|
||||||
|
|
||||||
if writing_mode != WritingMode::HorizontalTb &&
|
if writing_mode != WritingMode::HorizontalTb &&
|
||||||
text_combine_upright == TextCombineUpright::All
|
text_combine_upright == TextCombineUpright::All
|
||||||
|
@ -266,7 +266,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
.flags
|
.flags
|
||||||
.insert(ComputedValueFlags::IS_TEXT_COMBINED);
|
.insert(ComputedValueFlags::IS_TEXT_COMBINED);
|
||||||
self.style
|
self.style
|
||||||
.mutate_inheritedbox()
|
.mutate_inherited_box()
|
||||||
.set_writing_mode(WritingMode::HorizontalTb);
|
.set_writing_mode(WritingMode::HorizontalTb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,8 +305,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// <https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html>
|
/// <https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html>
|
||||||
/// <https://github.com/servo/servo/issues/15754>
|
/// <https://github.com/servo/servo/issues/15754>
|
||||||
fn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues) {
|
fn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues) {
|
||||||
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
let our_writing_mode = self.style.get_inherited_box().clone_writing_mode();
|
||||||
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
let parent_writing_mode = layout_parent_style.get_inherited_box().clone_writing_mode();
|
||||||
|
|
||||||
if our_writing_mode != parent_writing_mode &&
|
if our_writing_mode != parent_writing_mode &&
|
||||||
self.style.get_box().clone_display() == Display::Inline
|
self.style.get_box().clone_display() == Display::Inline
|
||||||
|
@ -496,13 +496,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.style.get_inheritedtext().clone_text_align() {
|
match self.style.get_inherited_text().clone_text_align() {
|
||||||
TextAlign::MozLeft | TextAlign::MozCenter | TextAlign::MozRight => {},
|
TextAlign::MozLeft | TextAlign::MozCenter | TextAlign::MozRight => {},
|
||||||
_ => return,
|
_ => return,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.style
|
self.style
|
||||||
.mutate_inheritedtext()
|
.mutate_inherited_text()
|
||||||
.set_text_align(TextAlign::Start)
|
.set_text_align(TextAlign::Start)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +516,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
use values::computed::text::TextDecorationsInEffect;
|
use values::computed::text::TextDecorationsInEffect;
|
||||||
|
|
||||||
let decorations_in_effect = TextDecorationsInEffect::from_style(&self.style);
|
let decorations_in_effect = TextDecorationsInEffect::from_style(&self.style);
|
||||||
if self.style.get_inheritedtext().text_decorations_in_effect != decorations_in_effect {
|
if self.style.get_inherited_text().text_decorations_in_effect != decorations_in_effect {
|
||||||
self.style.mutate_inheritedtext().text_decorations_in_effect = decorations_in_effect;
|
self.style.mutate_inherited_text().text_decorations_in_effect = decorations_in_effect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl TextDecorationsInEffect {
|
||||||
let mut result = match style.get_box().clone_display() {
|
let mut result = match style.get_box().clone_display() {
|
||||||
Display::InlineBlock | Display::InlineTable => Self::default(),
|
Display::InlineBlock | Display::InlineTable => Self::default(),
|
||||||
_ => style
|
_ => style
|
||||||
.get_parent_inheritedtext()
|
.get_parent_inherited_text()
|
||||||
.text_decorations_in_effect
|
.text_decorations_in_effect
|
||||||
.clone(),
|
.clone(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -514,7 +514,7 @@ impl ToComputedValue for TextAlign {
|
||||||
}
|
}
|
||||||
let parent = _context
|
let parent = _context
|
||||||
.builder
|
.builder
|
||||||
.get_parent_inheritedtext()
|
.get_parent_inherited_text()
|
||||||
.clone_text_align();
|
.clone_text_align();
|
||||||
let ltr = _context.builder.inherited_writing_mode().is_bidi_ltr();
|
let ltr = _context.builder.inherited_writing_mode().is_bidi_ltr();
|
||||||
match (parent, ltr) {
|
match (parent, ltr) {
|
||||||
|
@ -529,7 +529,7 @@ impl ToComputedValue for TextAlign {
|
||||||
TextAlign::MozCenterOrInherit => {
|
TextAlign::MozCenterOrInherit => {
|
||||||
let parent = _context
|
let parent = _context
|
||||||
.builder
|
.builder
|
||||||
.get_parent_inheritedtext()
|
.get_parent_inherited_text()
|
||||||
.clone_text_align();
|
.clone_text_align();
|
||||||
if parent == TextAlignKeyword::Start {
|
if parent == TextAlignKeyword::Start {
|
||||||
TextAlignKeyword::Center
|
TextAlignKeyword::Center
|
||||||
|
@ -653,7 +653,7 @@ impl ToComputedValue for TextEmphasisStyle {
|
||||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
match *self {
|
match *self {
|
||||||
TextEmphasisStyle::Keyword(ref keyword) => {
|
TextEmphasisStyle::Keyword(ref keyword) => {
|
||||||
let default_shape = if context.style().get_inheritedbox().clone_writing_mode() ==
|
let default_shape = if context.style().get_inherited_box().clone_writing_mode() ==
|
||||||
SpecifiedWritingMode::HorizontalTb
|
SpecifiedWritingMode::HorizontalTb
|
||||||
{
|
{
|
||||||
TextEmphasisShapeKeyword::Circle
|
TextEmphasisShapeKeyword::Circle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue