Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ::before and ::after content for layout_2020 #25817

Merged
merged 5 commits into from Feb 25, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Some generated files are not rendered by default. Learn more.

@@ -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
None
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")]
This conversation was marked as resolved by SimonSapin

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Feb 20, 2020

Member

This and other cfgs changed here should probably be something like #[cfg(any(feature = "gecko", feature = "servo-layout-2020"))], since layout 2013 still doesn’t support this.

#[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]
This conversation was marked as resolved by SimonSapin

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Feb 20, 2020

Member

Let’s also enable web-platform-tests/css/css-content here, even if we don’t yet implement anything from https://drafts.csswg.org/css-content/. It’s possible that some of those tests cover some of the functionality from CSS2.

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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.