Add an extra data field to ParserContext.

This will be used for passing Gecko-specific information through
the CSS parser in stylo.
This commit is contained in:
Cameron McCormack 2016-05-19 11:58:31 +10:00
parent a636b7127e
commit bb85f5faf0
10 changed files with 91 additions and 27 deletions

View file

@ -24,6 +24,7 @@ use style::context::{ReflowGoal};
use style::dom::{TDocument, TElement, TNode};
use style::error_reporting::StdoutErrorReporter;
use style::parallel;
use style::parser::ParserContextExtraData;
use style::properties::ComputedValues;
use style::selector_impl::{SelectorImplExt, PseudoElementCascadeType};
use style::stylesheets::Origin;
@ -132,7 +133,9 @@ pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8,
// FIXME(heycam): Pass in the real base URL.
let url = Url::parse("about:none").unwrap();
let sheet = Arc::new(Stylesheet::from_str(input, url, origin, Box::new(StdoutErrorReporter)));
let extra_data = ParserContextExtraData { };
let sheet = Arc::new(Stylesheet::from_str(input, url, origin, Box::new(StdoutErrorReporter),
extra_data));
unsafe {
transmute(sheet)
}

View file

@ -37,6 +37,7 @@ use style::dom::{TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
use style::element_state::ElementState;
#[allow(unused_imports)] // Used in commented-out code.
use style::error_reporting::StdoutErrorReporter;
use style::parser::ParserContextExtraData;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
#[allow(unused_imports)] // Used in commented-out code.
use style::properties::{parse_style_attribute};
@ -330,7 +331,11 @@ impl<'le> TElement for GeckoElement<'le> {
let attr = self.get_attr(&ns!(), &atom!("style"));
// FIXME(bholley): Real base URL and error reporter.
let base_url = Url::parse("http://www.example.org").unwrap();
attr.map(|v| parse_style_attribute(&v, &base_url, Box::new(StdoutErrorReporter)))
// FIXME(heycam): Needs real ParserContextExtraData so that URLs parse
// properly.
let extra_data = ParserContextExtraData::default();
attr.map(|v| parse_style_attribute(&v, &base_url, Box::new(StdoutErrorReporter),
extra_data))
*/
}