mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #25817 - ferjm:before.after.layout.2020, r=SimonSapin
Generate ::before and ::after content for layout_2020 - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes This PR generates content from the `<string>` and `attr(<identifier>)` `content` property values. I'll work on other values in follow-ups.
This commit is contained in:
commit
54015be6bf
163 changed files with 380 additions and 30 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2917,6 +2917,7 @@ dependencies = [
|
|||
"fnv",
|
||||
"gfx",
|
||||
"gfx_traits",
|
||||
"html5ever",
|
||||
"ipc-channel",
|
||||
"libc",
|
||||
"mitochondria",
|
||||
|
|
|
@ -21,6 +21,7 @@ euclid = "0.20"
|
|||
fnv = "1.0"
|
||||
gfx = {path = "../gfx"}
|
||||
gfx_traits = {path = "../gfx_traits"}
|
||||
html5ever = "0.25"
|
||||
ipc-channel = "0.14"
|
||||
libc = "0.2"
|
||||
msg = {path = "../msg"}
|
||||
|
|
|
@ -9,16 +9,21 @@ use crate::replaced::ReplacedContent;
|
|||
use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside};
|
||||
use crate::wrapper::GetRawData;
|
||||
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
|
||||
use html5ever::LocalName;
|
||||
use net_traits::image::base::Image as NetImage;
|
||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use script_layout_interface::wrapper_traits::{
|
||||
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||
};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use std::marker::PhantomData as marker;
|
||||
use std::sync::Arc;
|
||||
use style::dom::{OpaqueNode, TNode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::PseudoElement;
|
||||
use style::values::generics::counters::Content;
|
||||
use style::values::generics::counters::ContentItem;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum WhichPseudoElement {
|
||||
Before,
|
||||
After,
|
||||
|
@ -44,6 +49,7 @@ pub(super) enum NonReplacedContents {
|
|||
|
||||
pub(super) enum PseudoElementContentItem {
|
||||
Text(String),
|
||||
#[allow(dead_code)]
|
||||
Replaced(ReplacedContent),
|
||||
}
|
||||
|
||||
|
@ -244,29 +250,61 @@ impl NonReplacedContents {
|
|||
}
|
||||
|
||||
fn pseudo_element_style<'dom, Node>(
|
||||
_which: WhichPseudoElement,
|
||||
_element: Node,
|
||||
_context: &LayoutContext,
|
||||
which: WhichPseudoElement,
|
||||
element: Node,
|
||||
context: &LayoutContext,
|
||||
) -> Option<ServoArc<ComputedValues>>
|
||||
where
|
||||
Node: NodeExt<'dom>,
|
||||
{
|
||||
// FIXME: run the cascade, then return None for `content: normal` or `content: none`
|
||||
// https://drafts.csswg.org/css2/generate.html#content
|
||||
match which {
|
||||
WhichPseudoElement::Before => element.to_threadsafe().get_before_pseudo(),
|
||||
WhichPseudoElement::After => element.to_threadsafe().get_after_pseudo(),
|
||||
}
|
||||
.and_then(|pseudo_element| {
|
||||
let style = pseudo_element.style(context.shared_context());
|
||||
if style.ineffective_content_property() {
|
||||
None
|
||||
} else {
|
||||
Some(style)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn generate_pseudo_element_content<'dom, Node>(
|
||||
_pseudo_element_style: &ComputedValues,
|
||||
_element: Node,
|
||||
pseudo_element_style: &ComputedValues,
|
||||
element: Node,
|
||||
_context: &LayoutContext,
|
||||
) -> Vec<PseudoElementContentItem>
|
||||
where
|
||||
Node: NodeExt<'dom>,
|
||||
{
|
||||
let _ = PseudoElementContentItem::Text;
|
||||
let _ = PseudoElementContentItem::Replaced;
|
||||
unimplemented!()
|
||||
match &pseudo_element_style.get_counters().content {
|
||||
Content::Items(ref items) => {
|
||||
let mut vec = vec![];
|
||||
for item in items.iter() {
|
||||
match item {
|
||||
ContentItem::String(s) => {
|
||||
vec.push(PseudoElementContentItem::Text(s.to_string()));
|
||||
},
|
||||
ContentItem::Attr(attr) => {
|
||||
let element = element
|
||||
.to_threadsafe()
|
||||
.as_element()
|
||||
.expect("Expected an element");
|
||||
let attr_val = element
|
||||
.get_attr(&attr.namespace_url, &LocalName::from(&*attr.attribute));
|
||||
vec.push(PseudoElementContentItem::Text(
|
||||
attr_val.map_or("".to_string(), |s| s.to_string()),
|
||||
));
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
vec
|
||||
},
|
||||
Content::Normal | Content::None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BoxSlot<'dom> {
|
||||
|
|
|
@ -11,7 +11,6 @@ ${helpers.predefined_type(
|
|||
"Content",
|
||||
"computed::Content::normal()",
|
||||
engines="gecko servo-2013 servo-2020",
|
||||
servo_2020_pref="layout.2020.unimplemented",
|
||||
initial_specified_value="specified::Content::normal()",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-content/#propdef-content",
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use crate::computed_values::list_style_type::T as ListStyleType;
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::values::generics::CounterStyle;
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(any(feature = "gecko", feature = "servo-layout-2020"))]
|
||||
use crate::values::specified::Attr;
|
||||
use crate::values::CustomIdent;
|
||||
use std::ops::Deref;
|
||||
|
@ -212,7 +212,7 @@ pub enum GenericContentItem<ImageUrl> {
|
|||
#[cfg(feature = "gecko")]
|
||||
MozAltContent,
|
||||
/// `attr([namespace? `|`]? ident)`
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(any(feature = "gecko", feature = "servo-layout-2020"))]
|
||||
Attr(Attr),
|
||||
/// `url(url)`
|
||||
Url(ImageUrl),
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::values::generics::counters::CounterPair;
|
|||
#[cfg(feature = "gecko")]
|
||||
use crate::values::generics::CounterStyle;
|
||||
use crate::values::specified::url::SpecifiedImageUrl;
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(any(feature = "gecko", feature = "servo-layout-2020"))]
|
||||
use crate::values::specified::Attr;
|
||||
use crate::values::specified::Integer;
|
||||
use crate::values::CustomIdent;
|
||||
|
@ -163,7 +163,7 @@ impl Parse for Content {
|
|||
let style = Content::parse_counter_style(context, input);
|
||||
Ok(generics::ContentItem::Counters(name, separator, style))
|
||||
}),
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(any(feature = "gecko", feature = "servo-layout-2020"))]
|
||||
"attr" => input.parse_nested_block(|input| {
|
||||
Ok(generics::ContentItem::Attr(Attr::parse_function(context, input)?))
|
||||
}),
|
||||
|
|
|
@ -13,12 +13,16 @@ skip: true
|
|||
skip: false
|
||||
[box-display]
|
||||
skip: false
|
||||
[generated-content]
|
||||
skip: false
|
||||
[zindex]
|
||||
skip: false
|
||||
[zorder]
|
||||
skip: false
|
||||
[css-backgrounds]
|
||||
skip: false
|
||||
[css-content]
|
||||
skip: false
|
||||
[css-color]
|
||||
skip: false
|
||||
[css-transforms]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-006.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-008.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-009.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-010.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-011.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-012.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-013.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-014.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-015.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[after-content-display-018.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-011.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-display-types-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-floated-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-positioned-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-table-parts-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-after-table-whitespace-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-005.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-006.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-008.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-009.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-010.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-011.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-012.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-013.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-014.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[before-content-display-015.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[bidi-generated-content-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[bidi-generated-content-002.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-004.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-005.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-006.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-007.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-009.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-010.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-011.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-012.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-013.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-014.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-015.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-016.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-017.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-018.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-019.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-021.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-022.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-023.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-025.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-026.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-027.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-028.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-029.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-030.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-031.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-032.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-033.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-034.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-035.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-156.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-157.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-158.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-159.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-171.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-174.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-175.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-attr-case-001.html]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-auto-reset-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-000.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-002.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-003.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-004.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-005.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-006.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-007.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-008.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-009.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-010.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-011.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-012.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-013.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-014.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-015.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-counter-016.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-newline-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-white-space-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[content-white-space-003.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-hidden-000.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-hidden-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-hidden-002.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-multi-000.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-multi-001.xht]
|
||||
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
|||
[counters-order-000.xht]
|
||||
expected: FAIL
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue