mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Skip root- and item-based display style fixup for Gecko NAC.
MozReview-Commit-ID: 6AV2UWyl6pl
This commit is contained in:
parent
be3f2579c4
commit
7a4a37870c
5 changed files with 31 additions and 4 deletions
|
@ -477,6 +477,10 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn skip_root_and_item_based_display_fixup(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> PartialEq for ServoLayoutElement<'le> {
|
impl<'le> PartialEq for ServoLayoutElement<'le> {
|
||||||
|
|
|
@ -269,4 +269,9 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
|
||||||
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> {
|
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> {
|
||||||
self.get_data().map(|x| x.borrow_mut())
|
self.get_data().map(|x| x.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether we should skip any root- or item-based display property
|
||||||
|
/// blockification on this element. (This function exists so that Gecko
|
||||||
|
/// native anonymous content can opt out of this style fixup.)
|
||||||
|
fn skip_root_and_item_based_display_fixup(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,15 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||||
unsafe { self.0.mServoData.get().as_ref() }
|
unsafe { self.0.mServoData.get().as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn skip_root_and_item_based_display_fixup(&self) -> bool {
|
||||||
|
// We don't want to fix up display values of native anonymous content.
|
||||||
|
// Additionally, we want to skip root-based display fixup for document
|
||||||
|
// level native anonymous content subtree roots, since they're not
|
||||||
|
// really roots from the style fixup perspective. Checking that we
|
||||||
|
// are NAC handles both cases.
|
||||||
|
self.flags() & (NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE as u32) != 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> PartialEq for GeckoElement<'le> {
|
impl<'le> PartialEq for GeckoElement<'le> {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use cascade_info::CascadeInfo;
|
||||||
use context::{SharedStyleContext, StyleContext};
|
use context::{SharedStyleContext, StyleContext};
|
||||||
use data::{ComputedStyle, ElementData, ElementStyles, PseudoStyles};
|
use data::{ComputedStyle, ElementData, ElementStyles, PseudoStyles};
|
||||||
use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
|
use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
|
||||||
use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
|
use properties::{CascadeFlags, ComputedValues, SHAREABLE, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade};
|
||||||
use properties::longhands::display::computed_value as display;
|
use properties::longhands::display::computed_value as display;
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
|
use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
|
||||||
|
@ -405,6 +405,9 @@ trait PrivateMatchMethods: TElement {
|
||||||
if booleans.shareable {
|
if booleans.shareable {
|
||||||
cascade_flags.insert(SHAREABLE)
|
cascade_flags.insert(SHAREABLE)
|
||||||
}
|
}
|
||||||
|
if self.skip_root_and_item_based_display_fixup() {
|
||||||
|
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
|
||||||
|
}
|
||||||
|
|
||||||
let this_style = match parent_style {
|
let this_style = match parent_style {
|
||||||
Some(ref parent_style) => {
|
Some(ref parent_style) => {
|
||||||
|
|
|
@ -1436,6 +1436,8 @@ bitflags! {
|
||||||
/// Whether to inherit all styles from the parent. If this flag is not present,
|
/// Whether to inherit all styles from the parent. If this flag is not present,
|
||||||
/// non-inherited styles are reset to their initial values.
|
/// non-inherited styles are reset to their initial values.
|
||||||
const INHERIT_ALL = 0x02,
|
const INHERIT_ALL = 0x02,
|
||||||
|
/// Whether to skip any root element and flex/grid item display style fixup.
|
||||||
|
const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 0x04,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1638,7 +1640,11 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
computed_values::display::T::grid |
|
computed_values::display::T::grid |
|
||||||
% endif
|
% endif
|
||||||
computed_values::display::T::flex);
|
computed_values::display::T::flex);
|
||||||
if positioned || floated || is_root_element || is_item {
|
let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
|
||||||
|
false => (is_root_element, is_item),
|
||||||
|
true => (false, false),
|
||||||
|
};
|
||||||
|
if positioned || floated || blockify_root || blockify_item {
|
||||||
use computed_values::display::T;
|
use computed_values::display::T;
|
||||||
|
|
||||||
let specified_display = style.get_box().clone_display();
|
let specified_display = style.get_box().clone_display();
|
||||||
|
@ -1653,7 +1659,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
|
|
||||||
// Special handling for contents and list-item on the root element for Gecko.
|
// Special handling for contents and list-item on the root element for Gecko.
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
T::contents | T::list_item if is_root_element => Some(T::block),
|
T::contents | T::list_item if blockify_root => Some(T::block),
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
// Values that are not changed by blockification.
|
// Values that are not changed by blockification.
|
||||||
|
@ -1669,7 +1675,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
let box_ = style.mutate_box();
|
let box_ = style.mutate_box();
|
||||||
box_.set_display(computed_display);
|
box_.set_display(computed_display);
|
||||||
% if product == "servo":
|
% if product == "servo":
|
||||||
box_.set__servo_display_for_hypothetical_box(if is_root_element || is_item {
|
box_.set__servo_display_for_hypothetical_box(if blockify_root || blockify_item {
|
||||||
computed_display
|
computed_display
|
||||||
} else {
|
} else {
|
||||||
specified_display
|
specified_display
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue