mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
stylo: Support URL filters
MozReview-Commit-ID: 4QKKzJ1DVYP
This commit is contained in:
parent
e965b4e345
commit
2942e3b2ea
4 changed files with 43 additions and 3 deletions
|
@ -552,6 +552,7 @@ mod bindings {
|
|||
"nsStyleCoord_CalcValue",
|
||||
"nsStyleDisplay",
|
||||
"nsStyleEffects",
|
||||
"nsStyleFilter",
|
||||
"nsStyleFont",
|
||||
"nsStyleGradient",
|
||||
"nsStyleGradientStop",
|
||||
|
|
|
@ -70,6 +70,9 @@ unsafe impl Sync for nsStyleDisplay {}
|
|||
use gecko_bindings::structs::nsStyleEffects;
|
||||
unsafe impl Send for nsStyleEffects {}
|
||||
unsafe impl Sync for nsStyleEffects {}
|
||||
use gecko_bindings::structs::nsStyleFilter;
|
||||
unsafe impl Send for nsStyleFilter {}
|
||||
unsafe impl Sync for nsStyleFilter {}
|
||||
use gecko_bindings::structs::nsStyleFont;
|
||||
unsafe impl Send for nsStyleFont {}
|
||||
unsafe impl Sync for nsStyleFont {}
|
||||
|
@ -708,6 +711,10 @@ extern "C" {
|
|||
pub fn Gecko_CopyFiltersFrom(aSrc: *mut nsStyleEffects,
|
||||
aDest: *mut nsStyleEffects);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_nsStyleFilter_SetURLValue(effects: *mut nsStyleFilter,
|
||||
uri: ServoBundledURI);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_FillAllBackgroundLists(layers: *mut nsStyleImageLayers,
|
||||
max_len: u32);
|
||||
|
|
|
@ -2262,6 +2262,11 @@ fn static_assert() {
|
|||
Color::CurrentColor => 0,
|
||||
};
|
||||
}
|
||||
Url(ref url) => {
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleFilter_SetURLValue(gecko_filter, url.for_ffi());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ ${helpers.predefined_type("clip",
|
|||
use style_traits::{self, ToCss};
|
||||
use values::{CSSFloat, HasViewportPercentage};
|
||||
use values::specified::{Angle, CSSColor, Length, Shadow};
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
|
@ -129,6 +130,7 @@ ${helpers.predefined_type("clip",
|
|||
Sepia(CSSFloat),
|
||||
% if product == "gecko":
|
||||
DropShadow(Shadow),
|
||||
Url(SpecifiedUrl),
|
||||
% endif
|
||||
}
|
||||
|
||||
|
@ -136,7 +138,8 @@ ${helpers.predefined_type("clip",
|
|||
use app_units::Au;
|
||||
use values::CSSFloat;
|
||||
use values::computed::{CSSColor, Shadow};
|
||||
use values::specified::{Angle};
|
||||
use values::specified::Angle;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
|
@ -152,6 +155,7 @@ ${helpers.predefined_type("clip",
|
|||
Sepia(CSSFloat),
|
||||
% if product == "gecko":
|
||||
DropShadow(Shadow),
|
||||
Url(SpecifiedUrl),
|
||||
% endif
|
||||
}
|
||||
|
||||
|
@ -262,6 +266,11 @@ ${helpers.predefined_type("clip",
|
|||
try!(shadow.color.to_css(dest));
|
||||
try!(dest.write_str(")"));
|
||||
}
|
||||
computed_value::Filter::Url(ref url) => {
|
||||
dest.write_str("url(")?;
|
||||
url.to_css(dest)?;
|
||||
dest.write_str(")")?;
|
||||
}
|
||||
% endif
|
||||
}
|
||||
Ok(())
|
||||
|
@ -302,6 +311,11 @@ ${helpers.predefined_type("clip",
|
|||
}
|
||||
try!(dest.write_str(")"));
|
||||
}
|
||||
SpecifiedFilter::Url(ref url) => {
|
||||
dest.write_str("url(")?;
|
||||
url.to_css(dest)?;
|
||||
dest.write_str(")")?;
|
||||
}
|
||||
% endif
|
||||
}
|
||||
Ok(())
|
||||
|
@ -319,6 +333,11 @@ ${helpers.predefined_type("clip",
|
|||
return Ok(SpecifiedValue(filters))
|
||||
}
|
||||
loop {
|
||||
% if product == "gecko":
|
||||
if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) {
|
||||
filters.push(SpecifiedFilter::Url(url));
|
||||
} else
|
||||
% endif
|
||||
if let Ok(function_name) = input.try(|input| input.expect_function()) {
|
||||
filters.push(try!(input.parse_nested_block(|input| {
|
||||
match_ignore_ascii_case! { function_name,
|
||||
|
@ -375,6 +394,9 @@ ${helpers.predefined_type("clip",
|
|||
SpecifiedFilter::DropShadow(ref shadow) => {
|
||||
computed_value::Filter::DropShadow(shadow.to_computed_value(context))
|
||||
},
|
||||
SpecifiedFilter::Url(ref url) => {
|
||||
computed_value::Filter::Url(url.to_computed_value(context))
|
||||
}
|
||||
% endif
|
||||
}
|
||||
}).collect() }
|
||||
|
@ -394,9 +416,14 @@ ${helpers.predefined_type("clip",
|
|||
computed_value::Filter::Saturate(factor) => SpecifiedFilter::Saturate(factor),
|
||||
computed_value::Filter::Sepia(factor) => SpecifiedFilter::Sepia(factor),
|
||||
% if product == "gecko":
|
||||
computed_value::Filter::DropShadow(shadow) => {
|
||||
computed_value::Filter::DropShadow(ref shadow) => {
|
||||
SpecifiedFilter::DropShadow(
|
||||
ToComputedValue::from_computed_value(&shadow),
|
||||
ToComputedValue::from_computed_value(shadow),
|
||||
)
|
||||
}
|
||||
computed_value::Filter::Url(ref url) => {
|
||||
SpecifiedFilter::Url(
|
||||
ToComputedValue::from_computed_value(url),
|
||||
)
|
||||
}
|
||||
% endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue