mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Review fixes and bindings resync
This commit is contained in:
parent
0d4c5674ec
commit
f72cd7ffbc
6 changed files with 293 additions and 193 deletions
|
@ -24,7 +24,7 @@ use gecko_bindings::bindings::{Gecko_EnsureImageLayersLength, Gecko_CreateGradie
|
|||
use gecko_bindings::bindings::{Gecko_CopyImageValueFrom, Gecko_CopyFontFamilyFrom};
|
||||
use gecko_bindings::bindings::{Gecko_FontFamilyList_AppendGeneric, Gecko_FontFamilyList_AppendNamed};
|
||||
use gecko_bindings::bindings::{Gecko_FontFamilyList_Clear, Gecko_InitializeImageLayer};
|
||||
use gecko_bindings::bindings::ServoComputedValuesMaybeBorrowed;
|
||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||
use gecko_values::{StyleCoordHelpers, GeckoStyleCoordConvertible, convert_nscolor_to_rgba};
|
||||
|
@ -1713,7 +1713,7 @@ fn static_assert() {
|
|||
#[no_mangle]
|
||||
#[allow(non_snake_case, unused_variables)]
|
||||
pub extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed) -> *const ${style_struct.gecko_ffi_name} {
|
||||
ServoComputedValuesBorrowedOrNull) -> *const ${style_struct.gecko_ffi_name} {
|
||||
computed_values.as_arc::<ComputedValues>().get_${style_struct.name_lower}().get_gecko()
|
||||
as *const ${style_struct.gecko_ffi_name}
|
||||
}
|
||||
|
|
|
@ -150,15 +150,14 @@ COMPILATION_TARGETS = {
|
|||
"void_types": [
|
||||
"nsINode", "nsIDocument", "nsIPrincipal", "nsIURI",
|
||||
],
|
||||
"servo_maybe_arc_types": [
|
||||
"servo_nullable_arc_types": [
|
||||
"ServoComputedValues", "RawServoStyleSheet",
|
||||
"ServoDeclarationBlock"
|
||||
],
|
||||
"servo_owned_types": [
|
||||
"RawServoStyleSet",
|
||||
],
|
||||
"servo_maybe_owned_types": [
|
||||
"ServoNodeData",
|
||||
"StyleChildrenIterator",
|
||||
],
|
||||
"servo_immutable_borrow_types": [
|
||||
"RawGeckoNode",
|
||||
|
@ -283,6 +282,22 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
|
|||
|
||||
flags = []
|
||||
|
||||
# This makes an FFI-safe void type that can't be matched on
|
||||
# &VoidType is UB to have, because you can match on it
|
||||
# to produce a reachable unreachable. If it's wrapped in
|
||||
# a struct as a private field it becomes okay again
|
||||
#
|
||||
# Not 100% sure of how safe this is, but it's what we're using
|
||||
# in the XPCOM ffi too
|
||||
# https://github.com/nikomatsakis/rust-memory-model/issues/2
|
||||
def zero_size_type(ty, flags):
|
||||
flags.append("--blacklist-type")
|
||||
flags.append(ty)
|
||||
flags.append("--raw-line")
|
||||
flags.append("enum {0}Void{{ }}".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub struct {0}({0}Void);".format(ty))
|
||||
|
||||
if "flags" in current_target:
|
||||
flags.extend(current_target["flags"])
|
||||
|
||||
|
@ -326,26 +341,32 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
|
|||
for ty in current_target["void_types"]:
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub enum {} {{}}".format(ty))
|
||||
if "servo_maybe_arc_types" in current_target:
|
||||
for ty in current_target["servo_maybe_arc_types"]:
|
||||
if "servo_nullable_arc_types" in current_target:
|
||||
for ty in current_target["servo_nullable_arc_types"]:
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}Strong".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}Strong = ::sugar::ownership::Strong<{0}>;".format(ty))
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}MaybeBorrowed".format(ty))
|
||||
flags.append("-raw-line")
|
||||
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
|
||||
flags.append("{}BorrowedOrNull".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}BorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}Borrowed".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}Borrowed<'a> = &'a {0};".format(ty))
|
||||
zero_size_type(ty, flags)
|
||||
if "servo_immutable_borrow_types" in current_target:
|
||||
for ty in current_target["servo_immutable_borrow_types"]:
|
||||
flags.append("-blacklist-type")
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}Borrowed".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}Borrowed<'a> = &'a {0};".format(ty))
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}MaybeBorrowed".format(ty))
|
||||
flags.append("{}BorrowedOrNull".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
|
||||
flags.append("pub type {0}BorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, {0}>;".format(ty))
|
||||
zero_size_type(ty, flags)
|
||||
if "servo_owned_types" in current_target:
|
||||
for ty in current_target["servo_owned_types"]:
|
||||
flags.append("--blacklist-type")
|
||||
|
@ -360,22 +381,21 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
|
|||
flags.append("{}Owned".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}Owned = ::sugar::ownership::Owned<{0}>;".format(ty))
|
||||
if "servo_maybe_owned_types" in current_target:
|
||||
for ty in current_target["servo_maybe_owned_types"]:
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}MaybeBorrowed".format(ty))
|
||||
flags.append("{}BorrowedOrNull".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}MaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, {0}>;"
|
||||
flags.append("pub type {0}BorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, {0}>;"
|
||||
.format(ty))
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}MaybeBorrowedMut".format(ty))
|
||||
flags.append("{}BorrowedMutOrNull".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}MaybeBorrowedMut<'a> = ::sugar::ownership::BorrowedMut<'a, {0}>;"
|
||||
flags.append("pub type {0}BorrowedMutOrNull<'a> = ::sugar::ownership::BorrowedMut<'a, {0}>;"
|
||||
.format(ty))
|
||||
flags.append("--blacklist-type")
|
||||
flags.append("{}MaybeOwned".format(ty))
|
||||
flags.append("{}OwnedOrNull".format(ty))
|
||||
flags.append("--raw-line")
|
||||
flags.append("pub type {0}MaybeOwned = ::sugar::ownership::MaybeOwned<{0}>;".format(ty))
|
||||
flags.append("pub type {0}OwnedOrNull = ::sugar::ownership::OwnedOrNull<{0}>;".format(ty))
|
||||
zero_size_type(ty, flags)
|
||||
if "structs_types" in current_target:
|
||||
for ty in current_target["structs_types"]:
|
||||
ty_fragments = ty.split("::")
|
||||
|
@ -405,7 +425,7 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
|
|||
|
||||
# TODO: support more files, that's the whole point of this.
|
||||
assert len(current_target["files"]) == 1
|
||||
clang_flags.append(current_target["files"][0].format(objdir))
|
||||
flags.append(current_target["files"][0].format(objdir))
|
||||
|
||||
flags = bindgen + flags + ["--"] + clang_flags
|
||||
|
||||
|
|
|
@ -6,23 +6,56 @@ pub enum nsIDocument {}
|
|||
pub enum nsIPrincipal {}
|
||||
pub enum nsIURI {}
|
||||
pub type ServoComputedValuesStrong = ::sugar::ownership::Strong<ServoComputedValues>;
|
||||
pub type ServoComputedValuesMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, ServoComputedValues>;
|
||||
pub type ServoComputedValuesBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, ServoComputedValues>;
|
||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||
enum ServoComputedValuesVoid{ }
|
||||
pub struct ServoComputedValues(ServoComputedValuesVoid);
|
||||
pub type RawServoStyleSheetStrong = ::sugar::ownership::Strong<RawServoStyleSheet>;
|
||||
pub type RawServoStyleSheetMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, RawServoStyleSheet>;
|
||||
pub type RawServoStyleSheetBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, RawServoStyleSheet>;
|
||||
pub type RawServoStyleSheetBorrowed<'a> = &'a RawServoStyleSheet;
|
||||
enum RawServoStyleSheetVoid{ }
|
||||
pub struct RawServoStyleSheet(RawServoStyleSheetVoid);
|
||||
pub type ServoDeclarationBlockStrong = ::sugar::ownership::Strong<ServoDeclarationBlock>;
|
||||
pub type ServoDeclarationBlockMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, ServoDeclarationBlock>;
|
||||
pub type ServoDeclarationBlockBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, ServoDeclarationBlock>;
|
||||
pub type ServoDeclarationBlockBorrowed<'a> = &'a ServoDeclarationBlock;
|
||||
enum ServoDeclarationBlockVoid{ }
|
||||
pub struct ServoDeclarationBlock(ServoDeclarationBlockVoid);
|
||||
pub type RawGeckoNodeBorrowed<'a> = &'a RawGeckoNode;
|
||||
pub type RawGeckoNodeMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoNode>;
|
||||
pub type RawGeckoNodeBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoNode>;
|
||||
enum RawGeckoNodeVoid{ }
|
||||
pub struct RawGeckoNode(RawGeckoNodeVoid);
|
||||
pub type RawGeckoElementBorrowed<'a> = &'a RawGeckoElement;
|
||||
pub type RawGeckoElementMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoElement>;
|
||||
pub type RawGeckoElementBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoElement>;
|
||||
enum RawGeckoElementVoid{ }
|
||||
pub struct RawGeckoElement(RawGeckoElementVoid);
|
||||
pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument;
|
||||
pub type RawGeckoDocumentMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoDocument>;
|
||||
pub type RawGeckoDocumentBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, RawGeckoDocument>;
|
||||
enum RawGeckoDocumentVoid{ }
|
||||
pub struct RawGeckoDocument(RawGeckoDocumentVoid);
|
||||
pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;
|
||||
pub type RawServoStyleSetBorrowedMut<'a> = &'a mut RawServoStyleSet;
|
||||
pub type RawServoStyleSetOwned = ::sugar::ownership::Owned<RawServoStyleSet>;
|
||||
pub type ServoNodeDataMaybeBorrowed<'a> = ::sugar::ownership::Borrowed<'a, ServoNodeData>;
|
||||
pub type ServoNodeDataMaybeBorrowedMut<'a> = ::sugar::ownership::BorrowedMut<'a, ServoNodeData>;
|
||||
pub type ServoNodeDataMaybeOwned = ::sugar::ownership::MaybeOwned<ServoNodeData>;
|
||||
pub type RawServoStyleSetBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, RawServoStyleSet>;
|
||||
pub type RawServoStyleSetBorrowedMutOrNull<'a> = ::sugar::ownership::BorrowedMut<'a, RawServoStyleSet>;
|
||||
pub type RawServoStyleSetOwnedOrNull = ::sugar::ownership::OwnedOrNull<RawServoStyleSet>;
|
||||
enum RawServoStyleSetVoid{ }
|
||||
pub struct RawServoStyleSet(RawServoStyleSetVoid);
|
||||
pub type ServoNodeDataBorrowed<'a> = &'a ServoNodeData;
|
||||
pub type ServoNodeDataBorrowedMut<'a> = &'a mut ServoNodeData;
|
||||
pub type ServoNodeDataOwned = ::sugar::ownership::Owned<ServoNodeData>;
|
||||
pub type ServoNodeDataBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, ServoNodeData>;
|
||||
pub type ServoNodeDataBorrowedMutOrNull<'a> = ::sugar::ownership::BorrowedMut<'a, ServoNodeData>;
|
||||
pub type ServoNodeDataOwnedOrNull = ::sugar::ownership::OwnedOrNull<ServoNodeData>;
|
||||
enum ServoNodeDataVoid{ }
|
||||
pub struct ServoNodeData(ServoNodeDataVoid);
|
||||
pub type StyleChildrenIteratorBorrowed<'a> = &'a StyleChildrenIterator;
|
||||
pub type StyleChildrenIteratorBorrowedMut<'a> = &'a mut StyleChildrenIterator;
|
||||
pub type StyleChildrenIteratorOwned = ::sugar::ownership::Owned<StyleChildrenIterator>;
|
||||
pub type StyleChildrenIteratorBorrowedOrNull<'a> = ::sugar::ownership::Borrowed<'a, StyleChildrenIterator>;
|
||||
pub type StyleChildrenIteratorBorrowedMutOrNull<'a> = ::sugar::ownership::BorrowedMut<'a, StyleChildrenIterator>;
|
||||
pub type StyleChildrenIteratorOwnedOrNull = ::sugar::ownership::OwnedOrNull<StyleChildrenIterator>;
|
||||
enum StyleChildrenIteratorVoid{ }
|
||||
pub struct StyleChildrenIterator(StyleChildrenIteratorVoid);
|
||||
use structs::nsStyleFont;
|
||||
unsafe impl Send for nsStyleFont {}
|
||||
unsafe impl Sync for nsStyleFont {}
|
||||
|
@ -171,51 +204,42 @@ use structs::StyleBasicShapeType;
|
|||
use structs::StyleBasicShape;
|
||||
use structs::nsCSSShadowArray;
|
||||
|
||||
pub type RawGeckoNode = nsINode;
|
||||
pub enum Element { }
|
||||
pub type RawGeckoElement = Element;
|
||||
pub type RawGeckoDocument = nsIDocument;
|
||||
pub enum ServoNodeData { }
|
||||
pub enum ServoComputedValues { }
|
||||
pub enum RawServoStyleSheet { }
|
||||
pub enum RawServoStyleSet { }
|
||||
pub enum nsHTMLCSSStyleSheet { }
|
||||
pub enum ServoDeclarationBlock { }
|
||||
pub enum StyleChildrenIterator { }
|
||||
pub type ThreadSafePrincipalHolder = nsMainThreadPtrHolder<nsIPrincipal>;
|
||||
pub type ThreadSafeURIHolder = nsMainThreadPtrHolder<nsIURI>;
|
||||
extern "C" {
|
||||
pub fn Gecko_ChildrenCount(node: RawGeckoNodeBorrowed) -> u32;
|
||||
pub fn Gecko_NodeIsElement(node: RawGeckoNodeBorrowed) -> bool;
|
||||
pub fn Gecko_GetParentNode(node: RawGeckoNodeBorrowed)
|
||||
-> RawGeckoNodeMaybeBorrowed;
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_GetFirstChild(node: RawGeckoNodeBorrowed)
|
||||
-> RawGeckoNodeMaybeBorrowed;
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_GetLastChild(node: RawGeckoNodeBorrowed)
|
||||
-> RawGeckoNodeMaybeBorrowed;
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_GetPrevSibling(node: RawGeckoNodeBorrowed)
|
||||
-> RawGeckoNodeMaybeBorrowed;
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_GetNextSibling(node: RawGeckoNodeBorrowed)
|
||||
-> RawGeckoNodeMaybeBorrowed;
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_GetParentElement(element: RawGeckoElementBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_GetFirstChildElement(element: RawGeckoElementBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_GetLastChildElement(element: RawGeckoElementBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_GetPrevSiblingElement(element: RawGeckoElementBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_GetNextSiblingElement(element: RawGeckoElementBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_GetDocumentElement(document: RawGeckoDocumentBorrowed)
|
||||
-> RawGeckoElementMaybeBorrowed;
|
||||
-> RawGeckoElementBorrowedOrNull;
|
||||
pub fn Gecko_MaybeCreateStyleChildrenIterator(node: RawGeckoNodeBorrowed)
|
||||
-> *mut StyleChildrenIterator;
|
||||
pub fn Gecko_DropStyleChildrenIterator(it: *mut StyleChildrenIterator);
|
||||
pub fn Gecko_GetNextStyleChild(it: *mut StyleChildrenIterator)
|
||||
-> *mut RawGeckoNode;
|
||||
pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> u8;
|
||||
pub fn Gecko_IsHTMLElementInHTMLDocument(element: *mut RawGeckoElement)
|
||||
-> StyleChildrenIteratorOwnedOrNull;
|
||||
pub fn Gecko_DropStyleChildrenIterator(it: StyleChildrenIteratorOwned);
|
||||
pub fn Gecko_GetNextStyleChild(it: StyleChildrenIteratorBorrowed)
|
||||
-> RawGeckoNodeBorrowedOrNull;
|
||||
pub fn Gecko_ElementState(element: RawGeckoElementBorrowed) -> u8;
|
||||
pub fn Gecko_IsHTMLElementInHTMLDocument(element: RawGeckoElementBorrowed)
|
||||
-> bool;
|
||||
pub fn Gecko_IsLink(element: RawGeckoElementBorrowed) -> bool;
|
||||
pub fn Gecko_IsTextNode(node: RawGeckoNodeBorrowed) -> bool;
|
||||
|
@ -282,11 +306,11 @@ extern "C" {
|
|||
classList: *mut *mut *mut nsIAtom)
|
||||
-> u32;
|
||||
pub fn Gecko_GetServoDeclarationBlock(element: RawGeckoElementBorrowed)
|
||||
-> ServoDeclarationBlockMaybeBorrowed;
|
||||
-> ServoDeclarationBlockBorrowedOrNull;
|
||||
pub fn Gecko_GetNodeData(node: RawGeckoNodeBorrowed)
|
||||
-> ServoNodeDataMaybeBorrowed;
|
||||
-> ServoNodeDataBorrowedOrNull;
|
||||
pub fn Gecko_SetNodeData(node: RawGeckoNodeBorrowed,
|
||||
data: ServoNodeDataMaybeOwned);
|
||||
data: ServoNodeDataOwned);
|
||||
pub fn Gecko_Atomize(aString: *const ::std::os::raw::c_char, aLength: u32)
|
||||
-> *mut nsIAtom;
|
||||
pub fn Gecko_AddRefAtom(aAtom: *mut nsIAtom);
|
||||
|
@ -337,8 +361,7 @@ extern "C" {
|
|||
aPseudoTagOrNull: *mut nsIAtom)
|
||||
-> *mut nsStyleContext;
|
||||
pub fn Gecko_CalcStyleDifference(oldstyle: *mut nsStyleContext,
|
||||
newstyle:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
newstyle: ServoComputedValuesBorrowed)
|
||||
-> nsChangeHint;
|
||||
pub fn Gecko_StoreStyleDifference(node: RawGeckoNodeBorrowed,
|
||||
change: nsChangeHint);
|
||||
|
@ -477,7 +500,7 @@ extern "C" {
|
|||
pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||
other: *const nsStyleEffects);
|
||||
pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
|
||||
pub fn Servo_NodeData_Drop(data: ServoNodeDataMaybeOwned);
|
||||
pub fn Servo_NodeData_Drop(data: ServoNodeDataOwned);
|
||||
pub fn Servo_StyleSheet_FromUTF8Bytes(bytes: *const u8, length: u32,
|
||||
parsing_mode: SheetParsingMode,
|
||||
base_bytes: *const u8,
|
||||
|
@ -487,143 +510,129 @@ extern "C" {
|
|||
principal:
|
||||
*mut ThreadSafePrincipalHolder)
|
||||
-> RawServoStyleSheetStrong;
|
||||
pub fn Servo_StyleSheet_AddRef(sheet: RawServoStyleSheetMaybeBorrowed);
|
||||
pub fn Servo_StyleSheet_Release(sheet: RawServoStyleSheetMaybeBorrowed);
|
||||
pub fn Servo_StyleSheet_HasRules(sheet: RawServoStyleSheetMaybeBorrowed)
|
||||
pub fn Servo_StyleSheet_AddRef(sheet: RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_StyleSheet_Release(sheet: RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_StyleSheet_HasRules(sheet: RawServoStyleSheetBorrowed)
|
||||
-> bool;
|
||||
pub fn Servo_StyleSet_Init() -> RawServoStyleSetOwned;
|
||||
pub fn Servo_StyleSet_Drop(set: RawServoStyleSetOwned);
|
||||
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowedMut,
|
||||
sheet: RawServoStyleSheetMaybeBorrowed);
|
||||
sheet: RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowedMut,
|
||||
sheet:
|
||||
RawServoStyleSheetMaybeBorrowed);
|
||||
RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_StyleSet_RemoveStyleSheet(set: RawServoStyleSetBorrowedMut,
|
||||
sheet: RawServoStyleSheetMaybeBorrowed);
|
||||
pub fn Servo_StyleSet_InsertStyleSheetBefore(set: RawServoStyleSetBorrowedMut,
|
||||
sheet: RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_StyleSet_InsertStyleSheetBefore(set:
|
||||
RawServoStyleSetBorrowedMut,
|
||||
sheet:
|
||||
RawServoStyleSheetMaybeBorrowed,
|
||||
RawServoStyleSheetBorrowed,
|
||||
reference:
|
||||
RawServoStyleSheetMaybeBorrowed);
|
||||
RawServoStyleSheetBorrowed);
|
||||
pub fn Servo_ParseStyleAttribute(bytes: *const u8, length: u32,
|
||||
cache: *mut nsHTMLCSSStyleSheet)
|
||||
-> ServoDeclarationBlockStrong;
|
||||
pub fn Servo_DeclarationBlock_AddRef(declarations:
|
||||
ServoDeclarationBlockMaybeBorrowed);
|
||||
ServoDeclarationBlockBorrowed);
|
||||
pub fn Servo_DeclarationBlock_Release(declarations:
|
||||
ServoDeclarationBlockMaybeBorrowed);
|
||||
ServoDeclarationBlockBorrowed);
|
||||
pub fn Servo_DeclarationBlock_GetCache(declarations:
|
||||
ServoDeclarationBlockMaybeBorrowed)
|
||||
ServoDeclarationBlockBorrowed)
|
||||
-> *mut nsHTMLCSSStyleSheet;
|
||||
pub fn Servo_DeclarationBlock_SetImmutable(declarations:
|
||||
ServoDeclarationBlockMaybeBorrowed);
|
||||
ServoDeclarationBlockBorrowed);
|
||||
pub fn Servo_DeclarationBlock_ClearCachePointer(declarations:
|
||||
ServoDeclarationBlockMaybeBorrowed);
|
||||
ServoDeclarationBlockBorrowed);
|
||||
pub fn Servo_CSSSupports(name: *const u8, name_length: u32,
|
||||
value: *const u8, value_length: u32) -> bool;
|
||||
pub fn Servo_ComputedValues_Get(node: RawGeckoNodeBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
pub fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||
ServoComputedValuesMaybeBorrowed,
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
pseudoTag: *mut nsIAtom,
|
||||
set: RawServoStyleSetBorrowedMut)
|
||||
set:
|
||||
RawServoStyleSetBorrowedMut)
|
||||
-> ServoComputedValuesStrong;
|
||||
pub fn Servo_ComputedValues_GetForPseudoElement(parent_style:
|
||||
ServoComputedValuesMaybeBorrowed,
|
||||
ServoComputedValuesBorrowed,
|
||||
match_element:
|
||||
*mut RawGeckoElement,
|
||||
RawGeckoElementBorrowed,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
set:
|
||||
RawServoStyleSetBorrowedMut,
|
||||
is_probe: bool)
|
||||
-> ServoComputedValuesStrong;
|
||||
pub fn Servo_ComputedValues_Inherit(parent_style:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> ServoComputedValuesStrong;
|
||||
pub fn Servo_ComputedValues_AddRef(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed);
|
||||
ServoComputedValuesBorrowed);
|
||||
pub fn Servo_ComputedValues_Release(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed);
|
||||
ServoComputedValuesBorrowed);
|
||||
pub fn Servo_Initialize();
|
||||
pub fn Servo_Shutdown();
|
||||
pub fn Servo_ComputeRestyleHint(element: *mut RawGeckoElement,
|
||||
snapshot: *mut ServoElementSnapshot,
|
||||
set: RawServoStyleSetBorrowedMut)
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> nsRestyleHint;
|
||||
pub fn Servo_RestyleDocument(doc: RawGeckoDocumentBorrowed,
|
||||
set: RawServoStyleSetBorrowedMut);
|
||||
pub fn Servo_RestyleSubtree(node: RawGeckoNodeBorrowed,
|
||||
set: RawServoStyleSetBorrowedMut);
|
||||
pub fn Servo_GetStyleFont(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleFont(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleFont;
|
||||
pub fn Servo_GetStyleColor(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleColor(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleColor;
|
||||
pub fn Servo_GetStyleList(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleList(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleList;
|
||||
pub fn Servo_GetStyleText(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleText(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleText;
|
||||
pub fn Servo_GetStyleVisibility(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleVisibility;
|
||||
pub fn Servo_GetStyleUserInterface(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleUserInterface;
|
||||
pub fn Servo_GetStyleTableBorder(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleTableBorder;
|
||||
pub fn Servo_GetStyleSVG(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleSVG(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleSVG;
|
||||
pub fn Servo_GetStyleVariables(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleVariables;
|
||||
pub fn Servo_GetStyleBackground(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleBackground;
|
||||
pub fn Servo_GetStylePosition(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStylePosition;
|
||||
pub fn Servo_GetStyleTextReset(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleTextReset;
|
||||
pub fn Servo_GetStyleDisplay(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleDisplay(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleDisplay;
|
||||
pub fn Servo_GetStyleContent(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleContent(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleContent;
|
||||
pub fn Servo_GetStyleUIReset(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleUIReset(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleUIReset;
|
||||
pub fn Servo_GetStyleTable(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleTable(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleTable;
|
||||
pub fn Servo_GetStyleMargin(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleMargin(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleMargin;
|
||||
pub fn Servo_GetStylePadding(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStylePadding(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStylePadding;
|
||||
pub fn Servo_GetStyleBorder(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleBorder(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleBorder;
|
||||
pub fn Servo_GetStyleOutline(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleOutline(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleOutline;
|
||||
pub fn Servo_GetStyleXUL(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleXUL(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleXUL;
|
||||
pub fn Servo_GetStyleSVGReset(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleSVGReset;
|
||||
pub fn Servo_GetStyleColumn(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleColumn(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleColumn;
|
||||
pub fn Servo_GetStyleEffects(computed_values:
|
||||
ServoComputedValuesMaybeBorrowed)
|
||||
pub fn Servo_GetStyleEffects(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const nsStyleEffects;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::{forget, transmute, transmute_copy};
|
||||
use std::mem::{forget, transmute};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
|
@ -71,20 +71,43 @@ pub unsafe trait HasBoxFFI : HasSimpleFFI {
|
|||
pub unsafe trait HasArcFFI : HasFFI {
|
||||
// these methods can't be on Borrowed because it leads to an unspecified
|
||||
// impl parameter
|
||||
/// Artificially increments the refcount of a borrowed Arc over FFI.
|
||||
unsafe fn addref(ptr: Borrowed<Self::FFIType>) {
|
||||
forget(ptr.as_arc::<Self>().clone())
|
||||
/// Artificially increments the refcount of a (possibly null) borrowed Arc over FFI.
|
||||
unsafe fn addref_opt(ptr: Borrowed<Self::FFIType>) {
|
||||
forget(ptr.as_arc_opt::<Self>().clone())
|
||||
}
|
||||
|
||||
/// Given a (possibly null) borrowed FFI reference, decrements the refcount.
|
||||
/// Unsafe since it doesn't consume the backing Arc. Run it only when you
|
||||
/// know that a strong reference to the backing Arc is disappearing
|
||||
/// (usually on the C++ side) without running the Arc destructor.
|
||||
unsafe fn release(ptr: Borrowed<Self::FFIType>) {
|
||||
unsafe fn release_opt(ptr: Borrowed<Self::FFIType>) {
|
||||
if let Some(arc) = ptr.as_arc_opt::<Self>() {
|
||||
let _: Arc<_> = ptr::read(arc as *const Arc<_>);
|
||||
}
|
||||
}
|
||||
|
||||
/// Artificially increments the refcount of a borrowed Arc over FFI.
|
||||
unsafe fn addref(ptr: &Self::FFIType) {
|
||||
forget(Self::as_arc(&ptr).clone())
|
||||
}
|
||||
|
||||
/// Given a non-null borrowed FFI reference, decrements the refcount.
|
||||
/// Unsafe since it doesn't consume the backing Arc. Run it only when you
|
||||
/// know that a strong reference to the backing Arc is disappearing
|
||||
/// (usually on the C++ side) without running the Arc destructor.
|
||||
unsafe fn release(ptr: &Self::FFIType) {
|
||||
let _: Arc<_> = ptr::read(Self::as_arc(&ptr) as *const Arc<_>);
|
||||
}
|
||||
#[inline]
|
||||
/// Converts a borrowed FFI reference to a borrowed Arc.
|
||||
///
|
||||
/// &GeckoType -> &Arc<ServoType>
|
||||
fn as_arc<'a>(ptr: &'a &Self::FFIType) -> &'a Arc<Self> {
|
||||
debug_assert!(!(ptr as *const _).is_null());
|
||||
unsafe {
|
||||
transmute::<&&Self::FFIType, &Arc<Self>>(ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -113,7 +136,7 @@ impl<'a, T> Clone for Borrowed<'a, T> {
|
|||
|
||||
impl<'a, T> Borrowed<'a, T> {
|
||||
#[inline]
|
||||
pub fn is_null(&self) -> bool {
|
||||
pub fn is_null(self) -> bool {
|
||||
self.ptr == ptr::null()
|
||||
}
|
||||
|
||||
|
@ -150,7 +173,7 @@ impl<'a, T> Borrowed<'a, T> {
|
|||
|
||||
#[inline]
|
||||
/// Borrowed<ServoType> -> Borrowed<GeckoType>
|
||||
pub fn as_ffi(&self) -> Borrowed<<Self as HasFFI>::FFIType> where Self: HasSimpleFFI {
|
||||
pub fn as_ffi(self) -> Borrowed<'a, <Self as HasFFI>::FFIType> where Self: HasSimpleFFI {
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
|
@ -165,6 +188,13 @@ impl<'a, T> Borrowed<'a, T> {
|
|||
pub fn as_servo_ref<U>(self) -> Option<&'a U> where U: HasSimpleFFI<FFIType = T> {
|
||||
self.borrow_opt().map(HasSimpleFFI::from_ffi)
|
||||
}
|
||||
|
||||
pub fn null() -> Borrowed<'static, T> {
|
||||
Borrowed {
|
||||
ptr: ptr::null_mut(),
|
||||
_marker: PhantomData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> BorrowedMut<'a, T> {
|
||||
|
@ -196,9 +226,17 @@ impl<'a, T> BorrowedMut<'a, T> {
|
|||
pub fn as_servo_mut_ref<U>(self) -> Option<&'a mut U> where U: HasSimpleFFI<FFIType = T> {
|
||||
self.borrow_mut_opt().map(HasSimpleFFI::from_ffi_mut)
|
||||
}
|
||||
|
||||
pub fn null_mut() -> BorrowedMut<'static, T> {
|
||||
BorrowedMut {
|
||||
ptr: ptr::null_mut(),
|
||||
_marker: PhantomData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// technically not
|
||||
// technically not how we're supposed to use
|
||||
// Deref, but that's a minor style issue
|
||||
impl<'a, T> Deref for BorrowedMut<'a, T> {
|
||||
type Target = Borrowed<'a, T>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
@ -209,6 +247,8 @@ impl<'a, T> Deref for BorrowedMut<'a, T> {
|
|||
#[repr(C)]
|
||||
/// Gecko-FFI-safe Arc (T is an ArcInner).
|
||||
/// This can be null.
|
||||
/// Leaks on drop. Please don't drop this.
|
||||
/// TODO: Add destructor bomb once drop flags are gone
|
||||
pub struct Strong<T> {
|
||||
ptr: *const T,
|
||||
_marker: PhantomData<T>,
|
||||
|
@ -227,13 +267,26 @@ impl<T> Strong<T> {
|
|||
///
|
||||
/// Strong<GeckoType> -> Arc<ServoType>
|
||||
pub fn into_arc<U>(self) -> Arc<U> where U: HasArcFFI<FFIType = T> {
|
||||
assert!(!self.is_null());
|
||||
unsafe { transmute(self) }
|
||||
self.into_arc_opt().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Given a strong FFI reference,
|
||||
/// converts it into a servo-side Arc
|
||||
/// Returns None on null.
|
||||
///
|
||||
/// Strong<GeckoType> -> Arc<ServoType>
|
||||
pub fn into_arc_opt<U>(self) -> Option<Arc<U>> where U: HasArcFFI<FFIType = T> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
unsafe { Some(transmute(self)) }
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Produces a null strong FFI reference
|
||||
pub fn null_strong() -> Self {
|
||||
pub fn null() -> Self {
|
||||
unsafe { transmute(ptr::null::<T>()) }
|
||||
}
|
||||
}
|
||||
|
@ -244,10 +297,14 @@ pub unsafe trait FFIArcHelpers {
|
|||
///
|
||||
/// Arc<ServoType> -> Strong<GeckoType>
|
||||
fn into_strong(self) -> Strong<<Self::Inner as HasFFI>::FFIType>;
|
||||
/// Produces a borrowed FFI reference by borrowing an Arc.
|
||||
/// Produces a (nullable) borrowed FFI reference by borrowing an Arc.
|
||||
///
|
||||
/// &Arc<ServoType> -> Borrowed<GeckoType>
|
||||
fn as_borrowed(&self) -> Borrowed<<Self::Inner as HasFFI>::FFIType>;
|
||||
fn as_borrowed_opt(&self) -> Borrowed<<Self::Inner as HasFFI>::FFIType>;
|
||||
/// Produces a borrowed FFI reference by borrowing an Arc.
|
||||
///
|
||||
/// &Arc<ServoType> -> &GeckoType
|
||||
fn as_borrowed(&self) -> &<Self::Inner as HasFFI>::FFIType;
|
||||
}
|
||||
|
||||
unsafe impl<T: HasArcFFI> FFIArcHelpers for Arc<T> {
|
||||
|
@ -257,15 +314,21 @@ unsafe impl<T: HasArcFFI> FFIArcHelpers for Arc<T> {
|
|||
unsafe { transmute(self) }
|
||||
}
|
||||
#[inline]
|
||||
fn as_borrowed(&self) -> Borrowed<T::FFIType> {
|
||||
fn as_borrowed_opt(&self) -> Borrowed<T::FFIType> {
|
||||
let borrowedptr = self as *const Arc<T> as *const Borrowed<T::FFIType>;
|
||||
unsafe { ptr::read(borrowedptr) }
|
||||
}
|
||||
#[inline]
|
||||
fn as_borrowed(&self) -> &T::FFIType {
|
||||
let borrowedptr = self as *const Arc<T> as *const & T::FFIType;
|
||||
unsafe { ptr::read(borrowedptr) }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
/// Gecko-FFI-safe owned pointer
|
||||
/// Cannot be null
|
||||
/// Leaks on drop. Please don't drop this.
|
||||
pub struct Owned<T> {
|
||||
ptr: *mut T,
|
||||
_marker: PhantomData<T>,
|
||||
|
@ -276,7 +339,7 @@ impl<T> Owned<T> {
|
|||
pub fn into_box<U>(self) -> Box<T> where U: HasBoxFFI<FFIType = T> {
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
pub fn maybe(self) -> MaybeOwned<T> {
|
||||
pub fn maybe(self) -> OwnedOrNull<T> {
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
}
|
||||
|
@ -297,16 +360,16 @@ impl<T> DerefMut for Owned<T> {
|
|||
#[repr(C)]
|
||||
/// Gecko-FFI-safe owned pointer
|
||||
/// Can be null
|
||||
pub struct MaybeOwned<T> {
|
||||
pub struct OwnedOrNull<T> {
|
||||
ptr: *mut T,
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> MaybeOwned<T> {
|
||||
impl<T> OwnedOrNull<T> {
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.ptr == ptr::null_mut()
|
||||
}
|
||||
/// MaybeOwned<GeckoType> -> Option<Box<ServoType>>
|
||||
/// OwnedOrNull<GeckoType> -> Option<Box<ServoType>>
|
||||
pub fn into_box_opt<U>(self) -> Option<Box<T>> where U: HasBoxFFI<FFIType = T> {
|
||||
if self.is_null() {
|
||||
None
|
||||
|
@ -315,6 +378,15 @@ impl<T> MaybeOwned<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// OwnedOrNull<GeckoType> -> Option<Owned<GeckoType>>
|
||||
pub fn into_owned_opt(self) -> Option<Owned<T>> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { transmute(self) })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn borrow(&self) -> Borrowed<T> {
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
|
|
@ -8,16 +8,16 @@ use app_units::Au;
|
|||
use data::{NUM_THREADS, PerDocumentStyleData};
|
||||
use env_logger;
|
||||
use euclid::Size2D;
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::bindings::RawGeckoDocumentBorrowed;
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoNodeBorrowed};
|
||||
use gecko_bindings::bindings::{RawServoStyleSet, RawServoStyleSetBorrowedMut};
|
||||
use gecko_bindings::bindings::{RawServoStyleSetOwned, ServoNodeDataMaybeOwned};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheetMaybeBorrowed, ServoComputedValuesMaybeBorrowed};
|
||||
use gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned, ServoNodeDataOwned};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
|
||||
use gecko_bindings::bindings::{ServoDeclarationBlock, ThreadSafePrincipalHolder};
|
||||
use gecko_bindings::bindings::{ServoDeclarationBlockMaybeBorrowed, ServoDeclarationBlockStrong};
|
||||
use gecko_bindings::bindings::{ThreadSafeURIHolder, nsHTMLCSSStyleSheet};
|
||||
use gecko_bindings::bindings::{ServoComputedValuesBorrowedOrNull, ServoDeclarationBlock};
|
||||
use gecko_bindings::bindings::{ServoDeclarationBlockBorrowed, ServoDeclarationBlockStrong};
|
||||
use gecko_bindings::bindings::{ThreadSafePrincipalHolder, ThreadSafeURIHolder, nsHTMLCSSStyleSheet};
|
||||
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use gecko_bindings::structs::ServoElementSnapshot;
|
||||
use gecko_bindings::structs::nsRestyleHint;
|
||||
|
@ -138,8 +138,8 @@ pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_NodeData_Drop(data: ServoNodeDataMaybeOwned) -> () {
|
||||
let _ = data.into_box_opt::<NonOpaqueStyleData>();
|
||||
pub extern "C" fn Servo_NodeData_Drop(data: ServoNodeDataOwned) -> () {
|
||||
let _ = data.into_box::<NonOpaqueStyleData>();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -176,9 +176,9 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(bytes: *const u8,
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorrowedMut,
|
||||
raw_sheet: RawServoStyleSheetMaybeBorrowed) {
|
||||
raw_sheet: RawServoStyleSheetBorrowed) {
|
||||
let data = PerDocumentStyleData::from_ffi_mut(raw_data);
|
||||
let sheet = raw_sheet.as_arc();
|
||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
data.stylesheets.push(sheet.clone());
|
||||
data.stylesheets_changed = true;
|
||||
|
@ -186,9 +186,9 @@ pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorr
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBorrowedMut,
|
||||
raw_sheet: RawServoStyleSheetMaybeBorrowed) {
|
||||
raw_sheet: RawServoStyleSheetBorrowed) {
|
||||
let data = PerDocumentStyleData::from_ffi_mut(raw_data);
|
||||
let sheet = raw_sheet.as_arc();
|
||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
data.stylesheets.insert(0, sheet.clone());
|
||||
data.stylesheets_changed = true;
|
||||
|
@ -196,11 +196,11 @@ pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBor
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleSetBorrowedMut,
|
||||
raw_sheet: RawServoStyleSheetMaybeBorrowed,
|
||||
raw_reference: RawServoStyleSheetMaybeBorrowed) {
|
||||
raw_sheet: RawServoStyleSheetBorrowed,
|
||||
raw_reference: RawServoStyleSheetBorrowed) {
|
||||
let data = PerDocumentStyleData::from_ffi_mut(raw_data);
|
||||
let sheet = raw_sheet.as_arc();
|
||||
let reference = raw_reference.as_arc();
|
||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||
let reference = HasArcFFI::as_arc(&raw_reference);
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
let index = data.stylesheets.iter().position(|x| arc_ptr_eq(x, reference)).unwrap();
|
||||
data.stylesheets.insert(index, sheet.clone());
|
||||
|
@ -209,25 +209,25 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleS
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(raw_data: RawServoStyleSetBorrowedMut,
|
||||
raw_sheet: RawServoStyleSheetMaybeBorrowed) {
|
||||
raw_sheet: RawServoStyleSheetBorrowed) {
|
||||
let data = PerDocumentStyleData::from_ffi_mut(raw_data);
|
||||
let sheet = raw_sheet.as_arc();
|
||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
data.stylesheets_changed = true;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_HasRules(raw_sheet: RawServoStyleSheetMaybeBorrowed) -> bool {
|
||||
!raw_sheet.as_arc::<Stylesheet>().rules.is_empty()
|
||||
pub extern "C" fn Servo_StyleSheet_HasRules(raw_sheet: RawServoStyleSheetBorrowed) -> bool {
|
||||
!Stylesheet::as_arc(&raw_sheet).rules.is_empty()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_AddRef(sheet: RawServoStyleSheetMaybeBorrowed) -> () {
|
||||
pub extern "C" fn Servo_StyleSheet_AddRef(sheet: RawServoStyleSheetBorrowed) -> () {
|
||||
unsafe { Stylesheet::addref(sheet) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_Release(sheet: RawServoStyleSheetMaybeBorrowed) -> () {
|
||||
pub extern "C" fn Servo_StyleSheet_Release(sheet: RawServoStyleSheetBorrowed) -> () {
|
||||
unsafe { Stylesheet::release(sheet) };
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ pub extern "C" fn Servo_ComputedValues_Get(node: RawGeckoNodeBorrowed)
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoComputedValuesMaybeBorrowed,
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoComputedValuesBorrowedOrNull,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
raw_data: RawServoStyleSetBorrowedMut)
|
||||
-> ServoComputedValuesStrong {
|
||||
|
@ -264,11 +264,11 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
|||
|
||||
let maybe_parent = parent_style_or_null.as_arc_opt();
|
||||
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent);
|
||||
new_computed.map_or(Strong::null_strong(), |c| c.into_strong())
|
||||
new_computed.map_or(Strong::null(), |c| c.into_strong())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetForPseudoElement(parent_style: ServoComputedValuesMaybeBorrowed,
|
||||
pub extern "C" fn Servo_ComputedValues_GetForPseudoElement(parent_style: ServoComputedValuesBorrowed,
|
||||
match_element: RawGeckoElementBorrowed,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
raw_data: RawServoStyleSetBorrowedMut,
|
||||
|
@ -278,9 +278,9 @@ pub extern "C" fn Servo_ComputedValues_GetForPseudoElement(parent_style: ServoCo
|
|||
|
||||
let parent_or_null = || {
|
||||
if is_probe {
|
||||
Strong::null_strong()
|
||||
Strong::null()
|
||||
} else {
|
||||
parent_style.as_arc::<ComputedValues>().clone().into_strong()
|
||||
ComputedValues::as_arc(&parent_style).clone().into_strong()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -304,7 +304,7 @@ pub extern "C" fn Servo_ComputedValues_GetForPseudoElement(parent_style: ServoCo
|
|||
maybe_computed.map_or_else(parent_or_null, FFIArcHelpers::into_strong)
|
||||
}
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
let parent = parent_style.as_arc::<ComputedValues>();
|
||||
let parent = ComputedValues::as_arc(&parent_style);
|
||||
data.stylist
|
||||
.lazily_compute_pseudo_element_style(&element, &pseudo, parent)
|
||||
.map_or_else(parent_or_null, FFIArcHelpers::into_strong)
|
||||
|
@ -317,7 +317,7 @@ pub extern "C" fn Servo_ComputedValues_GetForPseudoElement(parent_style: ServoCo
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValuesMaybeBorrowed)
|
||||
pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValuesBorrowedOrNull)
|
||||
-> ServoComputedValuesStrong {
|
||||
let style = if parent_style.is_null() {
|
||||
Arc::new(ComputedValues::initial_values().clone())
|
||||
|
@ -328,12 +328,12 @@ pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValues
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_AddRef(ptr: ServoComputedValuesMaybeBorrowed) -> () {
|
||||
pub extern "C" fn Servo_ComputedValues_AddRef(ptr: ServoComputedValuesBorrowed) -> () {
|
||||
unsafe { ComputedValues::addref(ptr) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_Release(ptr: ServoComputedValuesMaybeBorrowed) -> () {
|
||||
pub extern "C" fn Servo_ComputedValues_Release(ptr: ServoComputedValuesBorrowed) -> () {
|
||||
unsafe { ComputedValues::release(ptr) };
|
||||
}
|
||||
|
||||
|
@ -378,29 +378,29 @@ pub extern "C" fn Servo_ParseStyleAttribute(bytes: *const u8, length: u32,
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_AddRef(declarations: ServoDeclarationBlockMaybeBorrowed) {
|
||||
pub extern "C" fn Servo_DeclarationBlock_AddRef(declarations: ServoDeclarationBlockBorrowed) {
|
||||
unsafe { GeckoDeclarationBlock::addref(declarations) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_Release(declarations: ServoDeclarationBlockMaybeBorrowed) {
|
||||
pub extern "C" fn Servo_DeclarationBlock_Release(declarations: ServoDeclarationBlockBorrowed) {
|
||||
unsafe { GeckoDeclarationBlock::release(declarations) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_GetCache(declarations: ServoDeclarationBlockMaybeBorrowed)
|
||||
pub extern "C" fn Servo_DeclarationBlock_GetCache(declarations: ServoDeclarationBlockBorrowed)
|
||||
-> *mut nsHTMLCSSStyleSheet {
|
||||
declarations.as_arc::<GeckoDeclarationBlock>().cache.load(Ordering::Relaxed)
|
||||
GeckoDeclarationBlock::as_arc(&declarations).cache.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_SetImmutable(declarations: ServoDeclarationBlockMaybeBorrowed) {
|
||||
declarations.as_arc::<GeckoDeclarationBlock>().immutable.store(true, Ordering::Relaxed)
|
||||
pub extern "C" fn Servo_DeclarationBlock_SetImmutable(declarations: ServoDeclarationBlockBorrowed) {
|
||||
GeckoDeclarationBlock::as_arc(&declarations).immutable.store(true, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_ClearCachePointer(declarations: ServoDeclarationBlockMaybeBorrowed) {
|
||||
declarations.as_arc::<GeckoDeclarationBlock>().cache.store(ptr::null_mut(), Ordering::Relaxed)
|
||||
pub extern "C" fn Servo_DeclarationBlock_ClearCachePointer(declarations: ServoDeclarationBlockBorrowed) {
|
||||
GeckoDeclarationBlock::as_arc(&declarations).cache.store(ptr::null_mut(), Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -421,8 +421,8 @@ pub extern "C" fn Servo_CSSSupports(property: *const u8, property_length: u32,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputeRestyleHint(element: RawGeckoElementBorrowed,
|
||||
snapshot: *mut ServoElementSnapshot,
|
||||
raw_data: RawServoStyleSetBorrowedMut) -> nsRestyleHint {
|
||||
let per_doc_data = PerDocumentStyleData::from_ffi_mut(raw_data);
|
||||
raw_data: RawServoStyleSetBorrowed) -> nsRestyleHint {
|
||||
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data);
|
||||
let snapshot = unsafe { GeckoElementSnapshot::from_raw(snapshot) };
|
||||
let element = unsafe { GeckoElement(element) };
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement, Gecko_IsTextNo
|
|||
use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink};
|
||||
use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetNodeData};
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::bindings::RawGeckoDocumentBorrowed;
|
||||
use gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoNodeBorrowed};
|
||||
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
||||
use gecko_bindings::structs::{nsIAtom, nsChangeHint, nsStyleContext};
|
||||
|
@ -89,7 +88,7 @@ impl<'ln> GeckoNode<'ln> {
|
|||
unsafe {
|
||||
if self.get_node_data().is_null() {
|
||||
let ptr = Box::new(NonOpaqueStyleData::new());
|
||||
Gecko_SetNodeData(self.0, ptr.into_ffi().maybe());
|
||||
Gecko_SetNodeData(self.0, ptr.into_ffi());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +164,8 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
|
||||
fn children(self) -> GeckoChildrenIterator<'ln> {
|
||||
let maybe_iter = unsafe { Gecko_MaybeCreateStyleChildrenIterator(self.0) };
|
||||
if !maybe_iter.is_null() {
|
||||
GeckoChildrenIterator::GeckoIterator(maybe_iter)
|
||||
if let Some(iter) = maybe_iter.into_owned_opt() {
|
||||
GeckoChildrenIterator::GeckoIterator(iter)
|
||||
} else {
|
||||
GeckoChildrenIterator::Current(self.first_child())
|
||||
}
|
||||
|
@ -346,14 +345,14 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
// (heavier-weight) Gecko-implemented iterator.
|
||||
pub enum GeckoChildrenIterator<'a> {
|
||||
Current(Option<GeckoNode<'a>>),
|
||||
GeckoIterator(*mut bindings::StyleChildrenIterator),
|
||||
GeckoIterator(bindings::StyleChildrenIteratorOwned),
|
||||
}
|
||||
|
||||
impl<'a> Drop for GeckoChildrenIterator<'a> {
|
||||
fn drop(&mut self) {
|
||||
if let GeckoChildrenIterator::GeckoIterator(it) = *self {
|
||||
if let GeckoChildrenIterator::GeckoIterator(ref it) = *self {
|
||||
unsafe {
|
||||
Gecko_DropStyleChildrenIterator(it);
|
||||
Gecko_DropStyleChildrenIterator(ptr::read(it as *const _));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,8 +367,8 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> {
|
|||
*self = GeckoChildrenIterator::Current(next);
|
||||
curr
|
||||
},
|
||||
GeckoChildrenIterator::GeckoIterator(it) => unsafe {
|
||||
Gecko_GetNextStyleChild(it).as_ref().map(|n| GeckoNode::from_ref(n))
|
||||
GeckoChildrenIterator::GeckoIterator(ref it) => unsafe {
|
||||
Gecko_GetNextStyleChild(&it).borrow_opt().map(GeckoNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue