mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Support -moz-binding in geckolib.
This commit is contained in:
parent
6d67aa8a01
commit
44bdbed989
3 changed files with 98 additions and 3 deletions
|
@ -43,7 +43,7 @@
|
|||
#![allow(unused_imports)]
|
||||
% if not property.derived_from:
|
||||
use cssparser::Parser;
|
||||
use parser::ParserContext;
|
||||
use parser::{ParserContext, ParserContextExtraData};
|
||||
use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
|
||||
% endif
|
||||
use error_reporting::ParseErrorReporter;
|
||||
|
|
|
@ -851,3 +851,78 @@ ${helpers.single_keyword("-moz-appearance",
|
|||
gecko_ffi_name="mAppearance",
|
||||
gecko_constant_prefix="NS_THEME",
|
||||
products="gecko")}
|
||||
|
||||
// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding
|
||||
<%helpers:longhand name="-moz-binding" products="gecko">
|
||||
use cssparser::{CssStringWriter, ToCss};
|
||||
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use std::fmt::{self, Write};
|
||||
use url::Url;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
#[derive(PartialEq, Clone, Debug, HeapSizeOf)]
|
||||
pub struct UrlExtraData {
|
||||
pub base: GeckoArcURI,
|
||||
pub referrer: GeckoArcURI,
|
||||
pub principal: GeckoArcPrincipal,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Debug, HeapSizeOf)]
|
||||
pub enum SpecifiedValue {
|
||||
Url(Url, UrlExtraData),
|
||||
None,
|
||||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use values::LocalToCss;
|
||||
match *self {
|
||||
SpecifiedValue::Url(ref url, _) => {
|
||||
url.to_css(dest)
|
||||
}
|
||||
SpecifiedValue::None => {
|
||||
try!(dest.write_str("none"));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
}
|
||||
|
||||
#[inline] pub fn get_initial_value() -> SpecifiedValue {
|
||||
SpecifiedValue::None
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(SpecifiedValue::None);
|
||||
}
|
||||
|
||||
let url = context.parse_url(&*try!(input.expect_url()));
|
||||
match context.extra_data {
|
||||
ParserContextExtraData {
|
||||
base: Some(ref base),
|
||||
referrer: Some(ref referrer),
|
||||
principal: Some(ref principal),
|
||||
} => {
|
||||
let extra_data = UrlExtraData {
|
||||
base: base.clone(),
|
||||
referrer: referrer.clone(),
|
||||
principal: principal.clone(),
|
||||
};
|
||||
Ok(SpecifiedValue::Url(url, extra_data))
|
||||
},
|
||||
_ => {
|
||||
// FIXME(heycam) should ensure we always have a principal, etc., when parsing
|
||||
// style attributes and re-parsing due to CSS Variables.
|
||||
println!("stylo: skipping -moz-binding declaration without ParserContextExtraData");
|
||||
Err(())
|
||||
},
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue