mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Add style adjustments for ruby.
This commit is contained in:
parent
f08c432b57
commit
6a12de1c1a
7 changed files with 158 additions and 8 deletions
|
@ -18,5 +18,15 @@ bitflags! {
|
|||
/// text-decoration-line is a reset property, but gets propagated in the
|
||||
/// frame/box tree.
|
||||
const HAS_TEXT_DECORATION_LINES = 1 << 0,
|
||||
|
||||
/// Whether line break inside should be suppressed.
|
||||
///
|
||||
/// If this flag is set, the line should not be broken inside,
|
||||
/// which means inlines act as if nowrap is set, <br> element is
|
||||
/// suppressed, and blocks are inlinized.
|
||||
///
|
||||
/// This bit is propagated to all children of line participants.
|
||||
/// It is currently used by ruby to make its content unbreakable.
|
||||
const SHOULD_SUPPRESS_LINEBREAK = 1 << 1,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,34 @@
|
|||
)
|
||||
}
|
||||
|
||||
/// Returns whether an element with this display type is a line
|
||||
/// participant, which means it may lay its children on the same
|
||||
/// line as itself.
|
||||
pub fn is_line_participant(&self) -> bool {
|
||||
matches!(*self,
|
||||
T::inline
|
||||
% if product == "gecko":
|
||||
| T::contents
|
||||
| T::ruby
|
||||
| T::ruby_base_container
|
||||
% endif
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns whether this "display" value is one of the types for
|
||||
/// ruby.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn is_ruby_type(&self) -> bool {
|
||||
matches!(*self, T::ruby | T::ruby_base | T::ruby_text |
|
||||
T::ruby_base_container | T::ruby_text_container)
|
||||
}
|
||||
|
||||
/// Returns whether this "display" value is a ruby level container.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn is_ruby_level_container(&self) -> bool {
|
||||
matches!(*self, T::ruby_base_container | T::ruby_text_container)
|
||||
}
|
||||
|
||||
/// Convert this display into an equivalent block display.
|
||||
///
|
||||
/// Also used for style adjustments.
|
||||
|
@ -82,6 +110,25 @@
|
|||
// Everything else becomes block.
|
||||
_ => T::block,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Convert this display into an inline-outside display.
|
||||
///
|
||||
/// Ideally it should implement spec: https://drafts.csswg.org/css-display/#inlinify
|
||||
/// but the spec isn't stable enough, so we copy what Gecko does for now.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn inlinify(&self) -> Self {
|
||||
match *self {
|
||||
T::block | T::flow_root => T::inline_block,
|
||||
T::table => T::inline_table,
|
||||
T::flex => T::inline_flex,
|
||||
T::grid => T::inline_grid,
|
||||
T::_moz_box => T::_moz_inline_box,
|
||||
T::_moz_stack => T::_moz_inline_stack,
|
||||
T::_webkit_box => T::_webkit_inline_box,
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
${helpers.single_keyword("unicode-bidi",
|
||||
"normal embed isolate bidi-override isolate-override plaintext",
|
||||
animation_value_type="discrete",
|
||||
need_clone="True",
|
||||
spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi")}
|
||||
|
||||
<%helpers:longhand name="text-decoration-line"
|
||||
|
|
|
@ -2486,6 +2486,12 @@ impl<'a> StyleBuilder<'a> {
|
|||
-> Option<<&mut style_structs::${style_struct.name}> {
|
||||
self.${style_struct.ident}.get_if_mutated()
|
||||
}
|
||||
|
||||
/// Reset the current `${style_struct.name}` style to its default value.
|
||||
pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValues) {
|
||||
self.${style_struct.ident} =
|
||||
StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc());
|
||||
}
|
||||
% endfor
|
||||
|
||||
/// Returns whether this computed style represents a floated object.
|
||||
|
@ -2597,8 +2603,8 @@ bitflags! {
|
|||
/// present, non-inherited styles are reset to their initial values.
|
||||
const INHERIT_ALL = 0x01,
|
||||
|
||||
/// Whether to skip any root element and flex/grid item display style
|
||||
/// fixup.
|
||||
/// Whether to skip any display style fixup for root element, flex/grid
|
||||
/// item, and ruby descendants.
|
||||
const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 0x02,
|
||||
|
||||
/// Whether to only cascade properties that are visited dependent.
|
||||
|
@ -2985,7 +2991,8 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
|
||||
{
|
||||
StyleAdjuster::new(&mut style)
|
||||
.adjust(context.layout_parent_style, flags);
|
||||
.adjust(context.layout_parent_style,
|
||||
context.device.default_computed_values(), flags);
|
||||
}
|
||||
|
||||
% if product == "gecko":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue