зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #12487 - Add FFI glue for Gecko to implement 1-arg CSS.supports() with stylo (from heycam:supports-ffi); r=emilio
<!-- Please describe your changes on the following line: --> This adds an FFI function for Gecko to call to implement the 1-arg version of `CSS.supports()`. This will be useful for producing an automated analysis of CSS properties we lack support for in geckolib. Corresponding Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1287382 r? @emilio --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because this is a geckolib-only change, and we don't have testing for that yet :( <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: f88ecda3628ec2af3a4e4c7fdebeda47b4008d6f
This commit is contained in:
Родитель
9d9fa28d20
Коммит
b4e35e0e34
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче