mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
Add FFI glue for Gecko to implement 1-arg CSS.supports() with stylo.
This commit is contained in:
parent
d87ea67bf2
commit
64c47ed720
2 changed files with 19 additions and 2 deletions
|
@ -288,6 +288,8 @@ extern "C" {
|
|||
*mut ServoDeclarationBlock);
|
||||
pub fn Servo_ClearDeclarationBlockCachePointer(declarations:
|
||||
*mut ServoDeclarationBlock);
|
||||
pub fn Servo_CSSSupports(property: *const u8, property_length: u32,
|
||||
value: *const u8, value_length: u32) -> bool;
|
||||
pub fn Servo_GetComputedValues(node: *mut RawGeckoNode)
|
||||
-> *mut ServoComputedValues;
|
||||
pub fn Servo_GetComputedValuesForAnonymousBox(parentStyleOrNull:
|
||||
|
|
|
@ -28,13 +28,13 @@ use style::dom::{TDocument, TElement, TNode};
|
|||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::parallel;
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use style::properties::{ComputedValues, PropertyDeclarationBlock, parse_one_declaration};
|
||||
use style::selector_impl::{SelectorImplExt, PseudoElementCascadeType};
|
||||
use style::sequential;
|
||||
use style::stylesheets::Origin;
|
||||
use traversal::RecalcStyleOnly;
|
||||
use url::Url;
|
||||
use wrapper::{GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData};
|
||||
use wrapper::{DUMMY_BASE_URL, GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData};
|
||||
|
||||
// TODO: This is ugly and should go away once we get an atom back-end.
|
||||
pub fn pseudo_element_from_atom(pseudo: *mut nsIAtom,
|
||||
|
@ -471,3 +471,18 @@ pub extern "C" fn Servo_ClearDeclarationBlockCachePointer(declarations: *mut Ser
|
|||
let declarations = unsafe { (declarations as *mut GeckoDeclarationBlock).as_mut().unwrap() };
|
||||
declarations.cache = ptr::null_mut();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CSSSupports(property: *const u8, property_length: u32,
|
||||
value: *const u8, value_length: u32) -> bool {
|
||||
let property = unsafe { from_utf8_unchecked(slice::from_raw_parts(property, property_length as usize)) };
|
||||
let value = unsafe { from_utf8_unchecked(slice::from_raw_parts(value, value_length as usize)) };
|
||||
|
||||
let base_url = &*DUMMY_BASE_URL;
|
||||
let extra_data = ParserContextExtraData::default();
|
||||
|
||||
match parse_one_declaration(&property, &value, &base_url, Box::new(StdoutErrorReporter), extra_data) {
|
||||
Ok(decls) => !decls.is_empty(),
|
||||
Err(()) => false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue