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
|
||||
|
||||
|
||||
def to_snake_case(ident):
|
||||
return re.sub("([A-Z]+)", lambda m: "_" + m.group(1).lower(), ident).strip("_")
|
||||
|
||||
|
||||
def to_camel_case(ident):
|
||||
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):
|
||||
self.gecko_struct_name = "Gecko" + 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.longhands = []
|
||||
self.inherited = inherited
|
||||
|
|
|
@ -3877,7 +3877,7 @@ where
|
|||
}
|
||||
% if category_to_cascade_now == "early":
|
||||
let writing_mode =
|
||||
WritingMode::new(context.builder.get_inheritedbox());
|
||||
WritingMode::new(context.builder.get_inherited_box());
|
||||
context.builder.writing_mode = writing_mode;
|
||||
|
||||
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::writing_mode::T as WritingMode;
|
||||
|
||||
let writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
||||
let text_combine_upright = self.style.get_inheritedtext().clone_text_combine_upright();
|
||||
let writing_mode = self.style.get_inherited_box().clone_writing_mode();
|
||||
let text_combine_upright = self.style.get_inherited_text().clone_text_combine_upright();
|
||||
|
||||
if writing_mode != WritingMode::HorizontalTb &&
|
||||
text_combine_upright == TextCombineUpright::All
|
||||
|
@ -266,7 +266,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
.flags
|
||||
.insert(ComputedValueFlags::IS_TEXT_COMBINED);
|
||||
self.style
|
||||
.mutate_inheritedbox()
|
||||
.mutate_inherited_box()
|
||||
.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://github.com/servo/servo/issues/15754>
|
||||
fn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues) {
|
||||
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
||||
let parent_writing_mode = layout_parent_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_inherited_box().clone_writing_mode();
|
||||
|
||||
if our_writing_mode != parent_writing_mode &&
|
||||
self.style.get_box().clone_display() == Display::Inline
|
||||
|
@ -496,13 +496,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
return;
|
||||
}
|
||||
|
||||
match self.style.get_inheritedtext().clone_text_align() {
|
||||
match self.style.get_inherited_text().clone_text_align() {
|
||||
TextAlign::MozLeft | TextAlign::MozCenter | TextAlign::MozRight => {},
|
||||
_ => return,
|
||||
}
|
||||
|
||||
self.style
|
||||
.mutate_inheritedtext()
|
||||
.mutate_inherited_text()
|
||||
.set_text_align(TextAlign::Start)
|
||||
}
|
||||
|
||||
|
@ -516,8 +516,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
use values::computed::text::TextDecorationsInEffect;
|
||||
|
||||
let decorations_in_effect = TextDecorationsInEffect::from_style(&self.style);
|
||||
if self.style.get_inheritedtext().text_decorations_in_effect != decorations_in_effect {
|
||||
self.style.mutate_inheritedtext().text_decorations_in_effect = decorations_in_effect;
|
||||
if self.style.get_inherited_text().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() {
|
||||
Display::InlineBlock | Display::InlineTable => Self::default(),
|
||||
_ => style
|
||||
.get_parent_inheritedtext()
|
||||
.get_parent_inherited_text()
|
||||
.text_decorations_in_effect
|
||||
.clone(),
|
||||
};
|
||||
|
|
|
@ -514,7 +514,7 @@ impl ToComputedValue for TextAlign {
|
|||
}
|
||||
let parent = _context
|
||||
.builder
|
||||
.get_parent_inheritedtext()
|
||||
.get_parent_inherited_text()
|
||||
.clone_text_align();
|
||||
let ltr = _context.builder.inherited_writing_mode().is_bidi_ltr();
|
||||
match (parent, ltr) {
|
||||
|
@ -529,7 +529,7 @@ impl ToComputedValue for TextAlign {
|
|||
TextAlign::MozCenterOrInherit => {
|
||||
let parent = _context
|
||||
.builder
|
||||
.get_parent_inheritedtext()
|
||||
.get_parent_inherited_text()
|
||||
.clone_text_align();
|
||||
if parent == TextAlignKeyword::Start {
|
||||
TextAlignKeyword::Center
|
||||
|
@ -653,7 +653,7 @@ impl ToComputedValue for TextEmphasisStyle {
|
|||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
match *self {
|
||||
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
|
||||
{
|
||||
TextEmphasisShapeKeyword::Circle
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue