mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Auto merge of #12991 - Manishearth:more-arc-safety, r=mystor,emilio
Add sugar for handling borrowed and owned types Implements the changes outlined in https://github.com/servo/servo/pull/12826#discussion_r75074985 <s>Also gets things ready for the Unique/Borrowed bindings</s> WIP for borrowed and unique in the same PR. Still need to convert all the rest of the gecko types to use the new wrappers. r? @emilio <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12991) <!-- Reviewable:end -->
This commit is contained in:
commit
927cd8ebf7
10 changed files with 805 additions and 449 deletions
|
@ -11,17 +11,19 @@
|
|||
use app_units::Au;
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, ServoComputedValues};
|
||||
use gecko_bindings::structs::nsStyleCoord_CalcValue;
|
||||
use gecko_bindings::sugar::refptr::HasArcFFI;
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use properties::ComputedValues;
|
||||
use stylesheets::Stylesheet;
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
|
||||
|
||||
unsafe impl HasArcFFI for Stylesheet {
|
||||
unsafe impl HasFFI for Stylesheet {
|
||||
type FFIType = RawServoStyleSheet;
|
||||
}
|
||||
unsafe impl HasArcFFI for ComputedValues {
|
||||
unsafe impl HasArcFFI for Stylesheet {}
|
||||
unsafe impl HasFFI for ComputedValues {
|
||||
type FFIType = ServoComputedValues;
|
||||
}
|
||||
unsafe impl HasArcFFI for ComputedValues {}
|
||||
|
||||
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
|
|
|
@ -24,10 +24,9 @@ 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::ServoComputedValuesBorrowed;
|
||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||
use gecko_bindings::sugar::refptr::HasArcFFI;
|
||||
use gecko_values::{StyleCoordHelpers, GeckoStyleCoordConvertible, convert_nscolor_to_rgba};
|
||||
use gecko_values::convert_rgba_to_nscolor;
|
||||
use gecko_values::round_border_to_device_pixels;
|
||||
|
@ -1744,10 +1743,10 @@ fn static_assert() {
|
|||
<%def name="define_ffi_struct_accessor(style_struct)">
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case, unused_variables)]
|
||||
pub extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values: ServoComputedValuesBorrowed)
|
||||
-> *const ${style_struct.gecko_ffi_name} {
|
||||
ComputedValues::with(computed_values, |values| values.get_${style_struct.name_lower}().get_gecko()
|
||||
as *const ${style_struct.gecko_ffi_name})
|
||||
pub extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values:
|
||||
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}
|
||||
}
|
||||
</%def>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue