diff --git a/ports/geckolib/bindings.rs b/ports/geckolib/bindings.rs index 845cca32e13..d441f44c8e5 100644 --- a/ports/geckolib/bindings.rs +++ b/ports/geckolib/bindings.rs @@ -1,25 +1,25 @@ /* automatically generated by rust-bindgen */ -pub type int64_t = ::libc::c_longlong; -pub type uint64_t = ::libc::c_ulonglong; +pub type int64_t = i64; +pub type uint64_t = u64; pub type int_least64_t = int64_t; pub type uint_least64_t = uint64_t; pub type int_fast64_t = int64_t; pub type uint_fast64_t = uint64_t; -pub type int32_t = ::libc::c_int; -pub type uint32_t = ::libc::c_uint; +pub type int32_t = i32; +pub type uint32_t = u32; pub type int_least32_t = int32_t; pub type uint_least32_t = uint32_t; pub type int_fast32_t = int32_t; pub type uint_fast32_t = uint32_t; -pub type int16_t = ::libc::c_short; -pub type uint16_t = ::libc::c_ushort; +pub type int16_t = i16; +pub type uint16_t = u16; pub type int_least16_t = int16_t; pub type uint_least16_t = uint16_t; pub type int_fast16_t = int16_t; pub type uint_fast16_t = uint16_t; pub type int8_t = ::libc::c_char; -pub type uint8_t = ::libc::c_uchar; +pub type uint8_t = u8; pub type int_least8_t = int8_t; pub type uint_least8_t = uint8_t; pub type int_fast8_t = int8_t; @@ -28,43 +28,16 @@ pub type intptr_t = int64_t; pub type uintptr_t = uint64_t; pub type intmax_t = ::libc::c_long; pub type uintmax_t = ::libc::c_ulong; -#[derive(Clone, Copy)] -#[repr(u32)] -pub enum Enum_NodeType { - ELEMENT_NODE = 1, - ATTRIBUTE_NODE = 2, - TEXT_NODE = 3, - CDATA_SECTION_NODE = 4, - ENTITY_REFERENCE_NODE = 5, - ENTITY_NODE = 6, - PROCESSING_INSTRUCTION_NODE = 7, - COMMENT_NODE = 8, - DOCUMENT_NODE = 9, - DOCUMENT_TYPE_NODE = 10, - DOCUMENT_FRAGMENT_NODE = 11, - NOTATION_NODE = 12, -} -pub enum Struct_RawGeckoNode { } -pub type RawGeckoNode = Struct_RawGeckoNode; -pub enum Struct_RawGeckoElement { } -pub type RawGeckoElement = Struct_RawGeckoElement; -pub enum Struct_RawGeckoDocument { } -pub type RawGeckoDocument = Struct_RawGeckoDocument; -pub enum Struct_ServoNodeData { } -pub type ServoNodeData = Struct_ServoNodeData; -pub enum Struct_ServoArcStyleSheet { } -pub type ServoArcStyleSheet = Struct_ServoArcStyleSheet; -pub enum Struct_ServoStyleSetData { } -pub type ServoStyleSetData = Struct_ServoStyleSetData; +pub enum RawGeckoNode { } +pub enum RawGeckoElement { } +pub enum RawGeckoDocument { } +pub enum ServoNodeData { } +pub enum RawServoStyleSheet { } +pub enum RawServoStyleSet { } extern "C" { - pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t; - pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, - ns: *const uint8_t, name: *const uint8_t, - length: *mut uint32_t) - -> *const ::libc::c_char; pub fn Gecko_ChildrenCount(node: *mut RawGeckoNode) -> uint32_t; - pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument) - -> *mut RawGeckoElement; + pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> i32; + pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetFirstChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetLastChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetPrevSibling(node: *mut RawGeckoNode) -> *mut RawGeckoNode; @@ -79,40 +52,41 @@ extern "C" { -> *mut RawGeckoElement; pub fn Gecko_GetNextSiblingElement(element: *mut RawGeckoElement) -> *mut RawGeckoElement; - pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData; - pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode; - pub fn Gecko_LocalName(element: *mut RawGeckoElement, - length: *mut uint32_t) -> *const uint16_t; + pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument) + -> *mut RawGeckoElement; + pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t; pub fn Gecko_IsHTMLElementInHTMLDocument(element: *mut RawGeckoElement) - -> ::libc::c_int; - pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> ::libc::c_int; - pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> ::libc::c_int; - pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement) - -> ::libc::c_int; - pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement) - -> ::libc::c_int; - pub fn Gecko_IsRootElement(element: *mut RawGeckoElement) - -> ::libc::c_int; - pub fn Gecko_Namespace(element: *mut RawGeckoElement, - length: *mut uint32_t) -> *const uint16_t; - pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> ::libc::c_int; + -> i32; + pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> i32; + pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> i32; + pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement) -> i32; + pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement) -> i32; + pub fn Gecko_IsRootElement(element: *mut RawGeckoElement) -> i32; + pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData; pub fn Gecko_SetNodeData(node: *mut RawGeckoNode, data: *mut ServoNodeData); - pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, - data: *mut ServoStyleSetData); pub fn Servo_DropNodeData(data: *mut ServoNodeData); pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t, length: uint32_t) - -> *mut ServoArcStyleSheet; - pub fn Servo_AppendStyleSheet(sheet: *mut ServoArcStyleSheet, - data: *mut ServoStyleSetData); - pub fn Servo_PrependStyleSheet(sheet: *mut ServoArcStyleSheet, - data: *mut ServoStyleSetData); - pub fn Servo_RemoveStyleSheet(sheet: *mut ServoArcStyleSheet, - data: *mut ServoStyleSetData); - pub fn Servo_StyleSheetHasRules(sheet: *mut ServoArcStyleSheet) - -> ::libc::c_int; - pub fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet); - pub fn Servo_InitStyleSetData() -> *mut ServoStyleSetData; - pub fn Servo_DropStyleSetData(data: *mut ServoStyleSetData); + -> *mut RawServoStyleSheet; + pub fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet); + pub fn Servo_AppendStyleSheet(sheet: *mut RawServoStyleSheet, + set: *mut RawServoStyleSet); + pub fn Servo_PrependStyleSheet(sheet: *mut RawServoStyleSheet, + set: *mut RawServoStyleSet); + pub fn Servo_RemoveStyleSheet(sheet: *mut RawServoStyleSheet, + set: *mut RawServoStyleSet); + pub fn Servo_StyleSheetHasRules(sheet: *mut RawServoStyleSheet) -> i32; + pub fn Servo_InitStyleSet() -> *mut RawServoStyleSet; + pub fn Servo_DropStyleSet(set: *mut RawServoStyleSet); + pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, + ns: *const uint8_t, name: *const uint8_t, + length: *mut uint32_t) + -> *const ::libc::c_char; + pub fn Gecko_LocalName(element: *mut RawGeckoElement, + length: *mut uint32_t) -> *const uint16_t; + pub fn Gecko_Namespace(element: *mut RawGeckoElement, + length: *mut uint32_t) -> *const uint16_t; + pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, + set: *mut RawServoStyleSet); } diff --git a/ports/geckolib/data.rs b/ports/geckolib/data.rs index 38351d70e2a..bc1c398e6c0 100644 --- a/ports/geckolib/data.rs +++ b/ports/geckolib/data.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use bindings::ServoStyleSetData; +use bindings::RawServoStyleSet; use euclid::Size2D; use euclid::size::TypedSize2D; use num_cpus; @@ -61,7 +61,7 @@ impl PerDocumentStyleData { } } - pub fn borrow_mut_from_raw<'a>(data: *mut ServoStyleSetData) -> &'a mut Self { + pub fn borrow_mut_from_raw<'a>(data: *mut RawServoStyleSet) -> &'a mut Self { unsafe { &mut *(data as *mut PerDocumentStyleData) } } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index d536a65bcb0..b63453f9559 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -6,7 +6,7 @@ use app_units::Au; use bindings::RawGeckoDocument; -use bindings::{ServoArcStyleSheet, ServoNodeData, ServoStyleSetData, uint8_t, uint32_t}; +use bindings::{ServoNodeData, RawServoStyleSet, RawServoStyleSheet, uint8_t, uint32_t}; use data::PerDocumentStyleData; use euclid::Size2D; use selector_impl::{SharedStyleContext, Stylesheet}; @@ -34,7 +34,7 @@ use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData}; */ #[no_mangle] -pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut ServoStyleSetData) -> () { +pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () { let document = unsafe { GeckoDocument::from_raw(doc) }; let node = match document.root_node() { Some(x) => x, @@ -75,7 +75,7 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () { #[no_mangle] pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t, - length: uint32_t) -> *mut ServoArcStyleSheet { + length: uint32_t) -> *mut RawServoStyleSheet { let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) }; @@ -87,7 +87,7 @@ pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t, } } -fn with_arc_stylesheet(raw: *mut ServoArcStyleSheet, cb: F) -> Output +fn with_arc_stylesheet(raw: *mut RawServoStyleSheet, cb: F) -> Output where F: FnOnce(&Arc) -> Output { let owned = unsafe { consume_arc_stylesheet(raw) }; let result = cb(&owned); @@ -95,13 +95,13 @@ fn with_arc_stylesheet(raw: *mut ServoArcStyleSheet, cb: F) -> Output result } -unsafe fn consume_arc_stylesheet(raw: *mut ServoArcStyleSheet) -> Arc { +unsafe fn consume_arc_stylesheet(raw: *mut RawServoStyleSheet) -> Arc { transmute(raw) } #[no_mangle] -pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet, - raw_data: *mut ServoStyleSetData) { +pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut RawServoStyleSheet, + raw_data: *mut RawServoStyleSet) { let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); with_arc_stylesheet(raw_sheet, |sheet| { data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); @@ -111,8 +111,8 @@ pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet, } #[no_mangle] -pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet, - raw_data: *mut ServoStyleSetData) { +pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut RawServoStyleSheet, + raw_data: *mut RawServoStyleSet) { let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); with_arc_stylesheet(raw_sheet, |sheet| { data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); @@ -122,8 +122,8 @@ pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet, } #[no_mangle] -pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet, - raw_data: *mut ServoStyleSetData) { +pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut RawServoStyleSheet, + raw_data: *mut RawServoStyleSet) { let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); with_arc_stylesheet(raw_sheet, |sheet| { data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); @@ -132,27 +132,27 @@ pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet, } #[no_mangle] -pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut ServoArcStyleSheet) -> ::libc::c_int { +pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut RawServoStyleSheet) -> ::libc::c_int { with_arc_stylesheet(raw_sheet, |sheet| if sheet.rules.is_empty() { 0 } else { 1 }) } #[no_mangle] -pub extern "C" fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet) -> () { +pub extern "C" fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet) -> () { unsafe { let _ = consume_arc_stylesheet(sheet); } } #[no_mangle] -pub extern "C" fn Servo_InitStyleSetData() -> *mut ServoStyleSetData { +pub extern "C" fn Servo_InitStyleSet() -> *mut RawServoStyleSet { let data = Box::new(PerDocumentStyleData::new()); - Box::into_raw(data) as *mut ServoStyleSetData + Box::into_raw(data) as *mut RawServoStyleSet } #[no_mangle] -pub extern "C" fn Servo_DropStyleSetData(data: *mut ServoStyleSetData) -> () { +pub extern "C" fn Servo_DropStyleSet(data: *mut RawServoStyleSet) -> () { unsafe { let _ = Box::::from_raw(data as *mut PerDocumentStyleData); }