mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add binding functions for length and item getter of DeclarationBlock
This commit is contained in:
parent
0b0ff2b152
commit
1af2edf190
3 changed files with 38 additions and 2 deletions
|
@ -236,10 +236,12 @@ COMPILATION_TARGETS = {
|
||||||
"target_dir": "../gecko_bindings",
|
"target_dir": "../gecko_bindings",
|
||||||
"blacklist_types": [
|
"blacklist_types": [
|
||||||
"nsACString_internal",
|
"nsACString_internal",
|
||||||
|
"nsAString_internal",
|
||||||
],
|
],
|
||||||
"raw_lines": [
|
"raw_lines": [
|
||||||
"pub use nsstring::nsACString;",
|
"pub use nsstring::{nsACString, nsAString};",
|
||||||
"type nsACString_internal = nsACString;",
|
"type nsACString_internal = nsACString;",
|
||||||
|
"type nsAString_internal = nsAString;"
|
||||||
],
|
],
|
||||||
"flags": [
|
"flags": [
|
||||||
"--ignore-methods",
|
"--ignore-methods",
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* automatically generated by rust-bindgen */
|
/* automatically generated by rust-bindgen */
|
||||||
|
|
||||||
pub use nsstring::nsACString;
|
pub use nsstring::{nsACString, nsAString};
|
||||||
type nsACString_internal = nsACString;
|
type nsACString_internal = nsACString;
|
||||||
|
type nsAString_internal = nsAString;
|
||||||
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
||||||
pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;
|
pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;
|
||||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||||
|
@ -936,6 +937,19 @@ extern "C" {
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
buffer: *mut nsString);
|
buffer: *mut nsString);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_DeclarationBlock_Count(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed)
|
||||||
|
-> u32;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_DeclarationBlock_GetNthProperty(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
index: u32,
|
||||||
|
result:
|
||||||
|
*mut nsAString_internal)
|
||||||
|
-> bool;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_CSSSupports(name: *const nsACString_internal,
|
pub fn Servo_CSSSupports(name: *const nsACString_internal,
|
||||||
value: *const nsACString_internal) -> bool;
|
value: *const nsACString_internal) -> bool;
|
||||||
|
|
|
@ -7,6 +7,7 @@ use cssparser::{Parser, ToCss};
|
||||||
use env_logger;
|
use env_logger;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
use std::fmt::Write;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use style::arc_ptr_eq;
|
use style::arc_ptr_eq;
|
||||||
|
@ -474,6 +475,25 @@ pub extern "C" fn Servo_DeclarationBlock_SerializeOneValue(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_Count(declarations: RawServoDeclarationBlockBorrowed) -> u32 {
|
||||||
|
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
declarations.read().declarations.len() as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_GetNthProperty(declarations: RawServoDeclarationBlockBorrowed,
|
||||||
|
index: u32, result: *mut nsAString) -> bool {
|
||||||
|
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
if let Some(&(ref decl, _)) = declarations.read().declarations.get(index as usize) {
|
||||||
|
let result = unsafe { result.as_mut().unwrap() };
|
||||||
|
write!(result, "{}", decl.name()).unwrap();
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_CSSSupports(property: *const nsACString, value: *const nsACString) -> bool {
|
pub extern "C" fn Servo_CSSSupports(property: *const nsACString, value: *const nsACString) -> bool {
|
||||||
let property = unsafe { property.as_ref().unwrap().as_str_unchecked() };
|
let property = unsafe { property.as_ref().unwrap().as_str_unchecked() };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue