mirror of
https://github.com/servo/servo.git
synced 2025-08-13 17:35:36 +01:00
Auto merge of #11427 - mbrubeck:under-display-none, r=pcwalton
Stop generating flows under display: none. Because this is a bottom-up traversal it can generates flows and throw them away. To prevent that, this cascades an internal `-servo-under-display-none` property and then checks that during flow construction. Fixes #1536. r? @pcwalton <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11427) <!-- Reviewable:end -->
This commit is contained in:
commit
92ae502765
5 changed files with 50 additions and 10 deletions
|
@ -80,6 +80,7 @@
|
|||
_error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
|
||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
||||
longhands::_servo_under_display_none::derive_from_display(context);
|
||||
}
|
||||
% endif
|
||||
|
||||
|
|
|
@ -88,3 +88,40 @@ ${helpers.single_keyword("color-adjust", "economy exact", products="gecko")}
|
|||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
// Used in the bottom-up flow construction traversal to avoid constructing flows for
|
||||
// descendants of nodes with `display: none`.
|
||||
<%helpers:longhand name="-servo-under-display-none" derived_from="display" products="servo">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, HeapSizeOf, Serialize, Deserialize)]
|
||||
pub struct SpecifiedValue(pub bool);
|
||||
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
}
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
SpecifiedValue(false)
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
Ok(()) // Internal property
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn derive_from_display<Cx: TContext>(context: &mut Cx) {
|
||||
use properties::style_struct_traits::Box;
|
||||
use super::display::computed_value::T as Display;
|
||||
|
||||
if context.style().get_box().clone_display() == Display::none {
|
||||
context.mutate_style().mutate_inheritedbox()
|
||||
.set__servo_under_display_none(SpecifiedValue(true));
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue