mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Reindent some code.
MozReview-Commit-ID: H2qucldbBkc Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
05371b56eb
commit
deefacc9de
2 changed files with 108 additions and 79 deletions
|
@ -394,51 +394,55 @@ trait PrivateMatchMethods: TElement {
|
|||
match difference.change {
|
||||
StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade,
|
||||
StyleChange::Changed { reset_only } => {
|
||||
if reset_only {
|
||||
let old_display = old_values.get_box().clone_display();
|
||||
let new_display = new_values.get_box().clone_display();
|
||||
|
||||
if old_display.is_item_container() != new_display.is_item_container() {
|
||||
// Blockification of children may depend on our display
|
||||
// value, so we need to actually do the recascade.
|
||||
return ChildCascadeRequirement::MustCascadeChildren
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use values::specified::align;
|
||||
|
||||
// Children with justify-items: legacy may depend on our
|
||||
// property value.
|
||||
//
|
||||
// TODO(emilio): We could special-case this even more
|
||||
// creating a new `ChildCascadeRequirement` variant, but
|
||||
// it's unclear it matters.
|
||||
let old_justify_items =
|
||||
old_values.get_position().clone_justify_items();
|
||||
let new_justify_items =
|
||||
new_values.get_position().clone_justify_items();
|
||||
|
||||
let was_legacy_justify_items =
|
||||
old_justify_items.computed.0.contains(align::ALIGN_LEGACY);
|
||||
|
||||
let is_legacy_justify_items =
|
||||
new_justify_items.computed.0.contains(align::ALIGN_LEGACY);
|
||||
|
||||
if is_legacy_justify_items != was_legacy_justify_items {
|
||||
return ChildCascadeRequirement::MustCascadeChildren;
|
||||
}
|
||||
|
||||
if was_legacy_justify_items &&
|
||||
old_justify_items.computed != new_justify_items.computed {
|
||||
return ChildCascadeRequirement::MustCascadeChildren;
|
||||
}
|
||||
}
|
||||
|
||||
ChildCascadeRequirement::MustCascadeChildrenIfInheritResetStyle
|
||||
} else {
|
||||
ChildCascadeRequirement::MustCascadeChildren
|
||||
// If inherited properties changed, the best we can do is
|
||||
// cascade the children.
|
||||
if !reset_only {
|
||||
return ChildCascadeRequirement::MustCascadeChildren
|
||||
}
|
||||
|
||||
let old_display = old_values.get_box().clone_display();
|
||||
let new_display = new_values.get_box().clone_display();
|
||||
|
||||
// Blockification of children may depend on our display value,
|
||||
// so we need to actually do the recascade. We could potentially
|
||||
// do better, but it doesn't seem worth it.
|
||||
if old_display.is_item_container() != new_display.is_item_container() {
|
||||
return ChildCascadeRequirement::MustCascadeChildren
|
||||
}
|
||||
|
||||
// Children with justify-items: auto may depend on our
|
||||
// justify-items property value.
|
||||
//
|
||||
// Similarly, we could potentially do better, but this really
|
||||
// seems not common enough to care about.
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use values::specified::align;
|
||||
|
||||
let old_justify_items =
|
||||
old_values.get_position().clone_justify_items();
|
||||
let new_justify_items =
|
||||
new_values.get_position().clone_justify_items();
|
||||
|
||||
let was_legacy_justify_items =
|
||||
old_justify_items.computed.0.contains(align::ALIGN_LEGACY);
|
||||
|
||||
let is_legacy_justify_items =
|
||||
new_justify_items.computed.0.contains(align::ALIGN_LEGACY);
|
||||
|
||||
if is_legacy_justify_items != was_legacy_justify_items {
|
||||
return ChildCascadeRequirement::MustCascadeChildren;
|
||||
}
|
||||
|
||||
if was_legacy_justify_items &&
|
||||
old_justify_items.computed != new_justify_items.computed {
|
||||
return ChildCascadeRequirement::MustCascadeChildren;
|
||||
}
|
||||
}
|
||||
|
||||
// We could prove that, if our children don't inherit reset
|
||||
// properties, we can stop the cascade.
|
||||
ChildCascadeRequirement::MustCascadeChildrenIfInheritResetStyle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,9 +50,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
|
||||
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
||||
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
||||
fn blockify_if_necessary(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags) {
|
||||
fn blockify_if_necessary(
|
||||
&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags,
|
||||
) {
|
||||
let mut blockify = false;
|
||||
macro_rules! blockify_if {
|
||||
($if_what:expr) => {
|
||||
|
@ -80,8 +82,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
let blockified_display =
|
||||
display.equivalent_block_display(flags.contains(IS_ROOT_ELEMENT));
|
||||
if display != blockified_display {
|
||||
self.style.mutate_box().set_adjusted_display(blockified_display,
|
||||
is_item_or_root);
|
||||
self.style.mutate_box().set_adjusted_display(
|
||||
blockified_display,
|
||||
is_item_or_root,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,10 +169,14 @@ 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();
|
||||
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();
|
||||
|
||||
if our_writing_mode != parent_writing_mode &&
|
||||
self.style.get_box().clone_display() == display::inline {
|
||||
|
@ -324,9 +332,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// If a <fieldset> has grid/flex display type, we need to inherit
|
||||
/// this type into its ::-moz-fieldset-content anonymous box.
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_fieldset_content(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags) {
|
||||
fn adjust_for_fieldset_content(
|
||||
&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags,
|
||||
) {
|
||||
use properties::IS_FIELDSET_CONTENT;
|
||||
if !flags.contains(IS_FIELDSET_CONTENT) {
|
||||
return;
|
||||
|
@ -337,8 +347,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
// when <fieldset> has "display: contents".
|
||||
let parent_display = layout_parent_style.get_box().clone_display();
|
||||
let new_display = match parent_display {
|
||||
display::flex | display::inline_flex => Some(display::flex),
|
||||
display::grid | display::inline_grid => Some(display::grid),
|
||||
display::flex |
|
||||
display::inline_flex => Some(display::flex),
|
||||
display::grid |
|
||||
display::inline_grid => Some(display::grid),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(new_display) = new_display {
|
||||
|
@ -355,22 +367,25 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_table_text_align(&mut self) {
|
||||
use properties::longhands::text_align::computed_value::T as text_align;
|
||||
if self.style.get_box().clone_display() != display::table {
|
||||
return;
|
||||
}
|
||||
if self.style.get_box().clone_display() != display::table {
|
||||
return;
|
||||
}
|
||||
|
||||
match self.style.get_inheritedtext().clone_text_align() {
|
||||
text_align::_moz_left |
|
||||
text_align::_moz_center |
|
||||
text_align::_moz_right => {}
|
||||
_ => return,
|
||||
}
|
||||
match self.style.get_inheritedtext().clone_text_align() {
|
||||
text_align::_moz_left |
|
||||
text_align::_moz_center |
|
||||
text_align::_moz_right => {},
|
||||
_ => return,
|
||||
}
|
||||
|
||||
self.style.mutate_inheritedtext().set_text_align(text_align::start);
|
||||
self.style.mutate_inheritedtext().set_text_align(text_align::start)
|
||||
}
|
||||
|
||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
|
||||
fn adjust_for_text_decoration_lines(
|
||||
&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
) {
|
||||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
||||
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
||||
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
||||
|
@ -379,7 +394,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
|
||||
fn should_suppress_linebreak(
|
||||
&self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
) -> bool {
|
||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||
// Line break suppression should only be propagated to in-flow children.
|
||||
if self.style.floated() || self.style.out_of_flow_positioned() {
|
||||
|
@ -395,13 +413,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
match self.style.get_box().clone_display() {
|
||||
// Ruby base and text are always non-breakable.
|
||||
display::ruby_base | display::ruby_text => true,
|
||||
display::ruby_base |
|
||||
display::ruby_text => true,
|
||||
// Ruby base container and text container are breakable.
|
||||
// Note that, when certain HTML tags, e.g. form controls, have ruby
|
||||
// level container display type, they could also escape from the
|
||||
// line break suppression flag while they shouldn't. However, it is
|
||||
// generally fine since they themselves are non-breakable.
|
||||
display::ruby_base_container | display::ruby_text_container => false,
|
||||
display::ruby_base_container |
|
||||
display::ruby_text_container => false,
|
||||
// Anything else is non-breakable if and only if its layout parent
|
||||
// has a ruby display type, because any of the ruby boxes can be
|
||||
// anonymous.
|
||||
|
@ -415,9 +435,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// * suppress border and padding for ruby level containers,
|
||||
/// * correct unicode-bidi.
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_ruby(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags) {
|
||||
fn adjust_for_ruby(
|
||||
&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags,
|
||||
) {
|
||||
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||
use properties::longhands::unicode_bidi::computed_value::T as unicode_bidi;
|
||||
|
@ -447,7 +469,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
// per spec https://drafts.csswg.org/css-ruby-1/#bidi
|
||||
if self_display.is_ruby_type() {
|
||||
let new_value = match self.style.get_text().clone_unicode_bidi() {
|
||||
unicode_bidi::normal | unicode_bidi::embed => Some(unicode_bidi::isolate),
|
||||
unicode_bidi::normal |
|
||||
unicode_bidi::embed => Some(unicode_bidi::isolate),
|
||||
unicode_bidi::bidi_override => Some(unicode_bidi::isolate_override),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -521,9 +544,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// When comparing to Gecko, this is similar to the work done by
|
||||
/// `nsStyleContext::ApplyStyleFixups`, plus some parts of
|
||||
/// `nsStyleSet::GetContext`.
|
||||
pub fn adjust(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags) {
|
||||
pub fn adjust(
|
||||
&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
flags: CascadeFlags,
|
||||
) {
|
||||
self.adjust_for_visited(flags);
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue