mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Revert #19666 since we do create NAC elements and expect them to be inline.
This reverts commit1970e82b0d
, reversing changes made toe882660ea6
. The reparenting logic is still bogus, but I'll figure out how to deal with that in a bit.
This commit is contained in:
parent
1970e82b0d
commit
bab6077c1c
7 changed files with 49 additions and 29 deletions
|
@ -460,6 +460,10 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn skip_root_and_item_based_display_fixup(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||||
self.element.insert_selector_flags(flags);
|
self.element.insert_selector_flags(flags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,6 +670,11 @@ pub trait TElement
|
||||||
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;
|
||||||
|
|
||||||
/// Sets selector flags, which indicate what kinds of selectors may have
|
/// Sets selector flags, which indicate what kinds of selectors may have
|
||||||
/// matched on this element and therefore what kind of work may need to
|
/// matched on this element and therefore what kind of work may need to
|
||||||
/// be performed when DOM state changes.
|
/// be performed when DOM state changes.
|
||||||
|
|
|
@ -1256,6 +1256,19 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn skip_root_and_item_based_display_fixup(&self) -> bool {
|
||||||
|
if !self.is_native_anonymous() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(p) = self.implemented_pseudo_element() {
|
||||||
|
return p.skip_item_based_display_fixup();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.is_root_of_native_anonymous_subtree()
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||||
debug_assert!(!flags.is_empty());
|
debug_assert!(!flags.is_empty());
|
||||||
self.set_flags(selector_flags_to_node_flags(flags));
|
self.set_flags(selector_flags_to_node_flags(flags));
|
||||||
|
|
|
@ -3060,10 +3060,14 @@ bitflags! {
|
||||||
pub struct CascadeFlags: u8 {
|
pub struct CascadeFlags: u8 {
|
||||||
/// Whether to inherit all styles from the parent. If this flag is not
|
/// Whether to inherit all styles from the parent. If this flag is not
|
||||||
/// present, non-inherited styles are reset to their initial values.
|
/// present, non-inherited styles are reset to their initial values.
|
||||||
const INHERIT_ALL = 1 << 0;
|
const INHERIT_ALL = 1;
|
||||||
|
|
||||||
|
/// Whether to skip any display style fixup for root element, flex/grid
|
||||||
|
/// item, and ruby descendants.
|
||||||
|
const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 1 << 1;
|
||||||
|
|
||||||
/// Whether to only cascade properties that are visited dependent.
|
/// Whether to only cascade properties that are visited dependent.
|
||||||
const VISITED_DEPENDENT_ONLY = 1 << 1;
|
const VISITED_DEPENDENT_ONLY = 1 << 2;
|
||||||
|
|
||||||
/// Whether the given element we're styling is the document element,
|
/// Whether the given element we're styling is the document element,
|
||||||
/// that is, matches :root.
|
/// that is, matches :root.
|
||||||
|
@ -3073,15 +3077,15 @@ bitflags! {
|
||||||
///
|
///
|
||||||
/// This affects some style adjustments, like blockification, and means
|
/// This affects some style adjustments, like blockification, and means
|
||||||
/// that it may affect global state, like the Device's root font-size.
|
/// that it may affect global state, like the Device's root font-size.
|
||||||
const IS_ROOT_ELEMENT = 1 << 2;
|
const IS_ROOT_ELEMENT = 1 << 3;
|
||||||
|
|
||||||
/// Whether we're computing the style of a link, either visited or
|
/// Whether we're computing the style of a link, either visited or
|
||||||
/// unvisited.
|
/// unvisited.
|
||||||
const IS_LINK = 1 << 3;
|
const IS_LINK = 1 << 4;
|
||||||
|
|
||||||
/// Whether we're computing the style of a link element that happens to
|
/// Whether we're computing the style of a link element that happens to
|
||||||
/// be visited.
|
/// be visited.
|
||||||
const IS_VISITED_LINK = 1 << 4;
|
const IS_VISITED_LINK = 1 << 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
StyleAdjuster { style }
|
StyleAdjuster { style }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether to skip any display style fixup flex/grid item, and ruby
|
|
||||||
/// descendants.
|
|
||||||
fn skip_item_based_display_fixup(&self) -> bool {
|
|
||||||
self.style.pseudo.as_ref().map_or(false, |p| p.skip_item_based_display_fixup())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://fullscreen.spec.whatwg.org/#new-stacking-layer>
|
/// <https://fullscreen.spec.whatwg.org/#new-stacking-layer>
|
||||||
///
|
///
|
||||||
/// Any position value other than 'absolute' and 'fixed' are
|
/// Any position value other than 'absolute' and 'fixed' are
|
||||||
|
@ -72,11 +66,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockify_if!(flags.contains(CascadeFlags::IS_ROOT_ELEMENT));
|
if !flags.contains(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
|
||||||
blockify_if!(
|
blockify_if!(flags.contains(CascadeFlags::IS_ROOT_ELEMENT));
|
||||||
!self.skip_item_based_display_fixup() &&
|
blockify_if!(layout_parent_style.get_box().clone_display().is_item_container());
|
||||||
layout_parent_style.get_box().clone_display().is_item_container()
|
}
|
||||||
);
|
|
||||||
|
|
||||||
let is_item_or_root = blockify;
|
let is_item_or_root = blockify;
|
||||||
|
|
||||||
|
@ -454,7 +447,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
fn adjust_for_ruby(
|
fn adjust_for_ruby(
|
||||||
&mut self,
|
&mut self,
|
||||||
layout_parent_style: &ComputedValues,
|
layout_parent_style: &ComputedValues,
|
||||||
|
flags: CascadeFlags,
|
||||||
) {
|
) {
|
||||||
|
use properties::CascadeFlags;
|
||||||
use properties::computed_value_flags::ComputedValueFlags;
|
use properties::computed_value_flags::ComputedValueFlags;
|
||||||
use properties::longhands::unicode_bidi::computed_value::T as UnicodeBidi;
|
use properties::longhands::unicode_bidi::computed_value::T as UnicodeBidi;
|
||||||
|
|
||||||
|
@ -463,7 +458,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
if self.should_suppress_linebreak(layout_parent_style) {
|
if self.should_suppress_linebreak(layout_parent_style) {
|
||||||
self.style.flags.insert(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
self.style.flags.insert(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
||||||
// Inlinify the display type if allowed.
|
// Inlinify the display type if allowed.
|
||||||
if !self.skip_item_based_display_fixup() {
|
if !flags.contains(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
|
||||||
let inline_display = self_display.inlinify();
|
let inline_display = self_display.inlinify();
|
||||||
if self_display != inline_display {
|
if self_display != inline_display {
|
||||||
self.style.mutate_box().set_display(inline_display);
|
self.style.mutate_box().set_display(inline_display);
|
||||||
|
@ -599,7 +594,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
self.adjust_for_text_decoration_lines(layout_parent_style);
|
self.adjust_for_text_decoration_lines(layout_parent_style);
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
self.adjust_for_ruby(layout_parent_style);
|
self.adjust_for_ruby(layout_parent_style, flags);
|
||||||
}
|
}
|
||||||
self.set_bits();
|
self.set_bits();
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,6 +542,11 @@ where
|
||||||
|
|
||||||
let mut cascade_flags = CascadeFlags::empty();
|
let mut cascade_flags = CascadeFlags::empty();
|
||||||
|
|
||||||
|
if self.element.skip_root_and_item_based_display_fixup() ||
|
||||||
|
pseudo.map_or(false, |p| p.skip_item_based_display_fixup()) {
|
||||||
|
cascade_flags.insert(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP);
|
||||||
|
}
|
||||||
|
|
||||||
if pseudo.is_none() && self.element.is_link() {
|
if pseudo.is_none() && self.element.is_link() {
|
||||||
cascade_flags.insert(CascadeFlags::IS_LINK);
|
cascade_flags.insert(CascadeFlags::IS_LINK);
|
||||||
if self.element.is_visited_link() &&
|
if self.element.is_visited_link() &&
|
||||||
|
|
|
@ -2019,11 +2019,12 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||||
page_decls,
|
page_decls,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let cascade_flags = CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||||
data.stylist.precomputed_values_for_pseudo_with_rule_node(
|
data.stylist.precomputed_values_for_pseudo_with_rule_node(
|
||||||
&guards,
|
&guards,
|
||||||
&pseudo,
|
&pseudo,
|
||||||
parent_style_or_null.map(|x| &*x),
|
parent_style_or_null.map(|x| &*x),
|
||||||
CascadeFlags::empty(),
|
cascade_flags,
|
||||||
&metrics,
|
&metrics,
|
||||||
rule_node
|
rule_node
|
||||||
).into()
|
).into()
|
||||||
|
@ -3619,17 +3620,10 @@ pub extern "C" fn Servo_ReparentStyle(
|
||||||
let element = element.map(GeckoElement);
|
let element = element.map(GeckoElement);
|
||||||
|
|
||||||
let mut cascade_flags = CascadeFlags::empty();
|
let mut cascade_flags = CascadeFlags::empty();
|
||||||
|
if style_to_reparent.is_anon_box() {
|
||||||
|
cascade_flags.insert(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP);
|
||||||
|
}
|
||||||
if let Some(element) = element {
|
if let Some(element) = element {
|
||||||
// NOTE(emilio): This relies on element.is_some() => pseudo.is_none(),
|
|
||||||
// which the caller guarantees, fortunately. But this doesn't handle the
|
|
||||||
// IS_ROOT_ELEMENT flag correctly!
|
|
||||||
//
|
|
||||||
// I think it's not possible to wrap a root element in a first-line
|
|
||||||
// frame (and reparenting only happens for ::first-line and its
|
|
||||||
// descendants), so this may be fine...
|
|
||||||
//
|
|
||||||
// We should just get rid of all these flags which pass element / pseudo
|
|
||||||
// state.
|
|
||||||
if element.is_link() {
|
if element.is_link() {
|
||||||
cascade_flags.insert(CascadeFlags::IS_LINK);
|
cascade_flags.insert(CascadeFlags::IS_LINK);
|
||||||
if element.is_visited_link() && doc_data.visited_styles_enabled() {
|
if element.is_visited_link() && doc_data.visited_styles_enabled() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue