mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #12895 - emilio:stylo-pseudos, r=bholley
stylo: Improve pseudo element restyling and support the content property. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because geckolib. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12895) <!-- Reviewable:end -->
This commit is contained in:
commit
94152523ae
8 changed files with 204 additions and 71 deletions
|
@ -34,7 +34,7 @@ pub struct PseudoElement(Atom, bool);
|
||||||
|
|
||||||
impl PseudoElement {
|
impl PseudoElement {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_atom(&self) -> &Atom {
|
pub fn as_atom(&self) -> &Atom {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
||||||
impl Debug for ${style_struct.gecko_struct_name} {
|
impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
// FIXME(bholley): Generate this.
|
// FIXME(bholley): Generate this.
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "GECKO STYLE STRUCT")
|
write!(f, "Gecko style struct: ${style_struct.gecko_struct_name}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%else:
|
%else:
|
||||||
|
@ -1355,6 +1355,93 @@ fn static_assert() {
|
||||||
${impl_coord_copy('column_width', 'mColumnWidth')}
|
${impl_coord_copy('column_width', 'mColumnWidth')}
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
<%self:impl_trait style_struct_name="Counters"
|
||||||
|
skip_longhands="content">
|
||||||
|
pub fn set_content(&mut self, v: longhands::content::computed_value::T) {
|
||||||
|
use properties::longhands::content::computed_value::T;
|
||||||
|
use properties::longhands::content::computed_value::ContentItem;
|
||||||
|
use gecko_bindings::structs::nsStyleContentData;
|
||||||
|
use gecko_bindings::structs::nsStyleContentType::*;
|
||||||
|
use gecko_bindings::bindings::Gecko_ClearStyleContents;
|
||||||
|
|
||||||
|
// Converts a string as utf16, and returns an owned, zero-terminated raw buffer.
|
||||||
|
fn as_utf16_and_forget(s: &str) -> *mut u16 {
|
||||||
|
use std::mem;
|
||||||
|
let mut vec = s.encode_utf16().collect::<Vec<_>>();
|
||||||
|
vec.push(0u16);
|
||||||
|
let ptr = vec.as_mut_ptr();
|
||||||
|
mem::forget(vec);
|
||||||
|
ptr
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
fn set_image_tracked(contents: &mut nsStyleContentData, val: bool) {
|
||||||
|
contents.mImageTracked = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
fn set_image_tracked(_contents: &mut nsStyleContentData, _val: bool) {}
|
||||||
|
|
||||||
|
// Ensure destructors run, otherwise we could leak.
|
||||||
|
if !self.gecko.mContents.is_empty() {
|
||||||
|
unsafe {
|
||||||
|
Gecko_ClearStyleContents(&mut self.gecko);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match v {
|
||||||
|
T::none |
|
||||||
|
T::normal => {}, // Do nothing, already cleared.
|
||||||
|
T::Content(items) => {
|
||||||
|
// NB: set_len also reserves the appropriate space.
|
||||||
|
unsafe { self.gecko.mContents.set_len(items.len() as u32) }
|
||||||
|
for (i, item) in items.into_iter().enumerate() {
|
||||||
|
// TODO: Servo lacks support for attr(), and URIs,
|
||||||
|
// We don't support images, but need to remember to
|
||||||
|
// explicitly initialize mImageTracked in debug builds.
|
||||||
|
set_image_tracked(&mut self.gecko.mContents[i], false);
|
||||||
|
// NB: Gecko compares the mString value if type is not image
|
||||||
|
// or URI independently of whatever gets there. In the quote
|
||||||
|
// cases, they set it to null, so do the same here.
|
||||||
|
unsafe {
|
||||||
|
*self.gecko.mContents[i].mContent.mString.as_mut() = ptr::null_mut();
|
||||||
|
}
|
||||||
|
match item {
|
||||||
|
ContentItem::String(value) => {
|
||||||
|
self.gecko.mContents[i].mType = eStyleContentType_String;
|
||||||
|
unsafe {
|
||||||
|
// NB: we share allocators, so doing this is fine.
|
||||||
|
*self.gecko.mContents[i].mContent.mString.as_mut() =
|
||||||
|
as_utf16_and_forget(&value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ContentItem::OpenQuote
|
||||||
|
=> self.gecko.mContents[i].mType = eStyleContentType_OpenQuote,
|
||||||
|
ContentItem::CloseQuote
|
||||||
|
=> self.gecko.mContents[i].mType = eStyleContentType_CloseQuote,
|
||||||
|
ContentItem::NoOpenQuote
|
||||||
|
=> self.gecko.mContents[i].mType = eStyleContentType_NoOpenQuote,
|
||||||
|
ContentItem::NoCloseQuote
|
||||||
|
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
|
||||||
|
ContentItem::Counter(..) |
|
||||||
|
ContentItem::Counters(..)
|
||||||
|
=> self.gecko.mContents[i].mType = eStyleContentType_Uninitialized,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_content_from(&mut self, other: &Self) {
|
||||||
|
use gecko_bindings::bindings::Gecko_CopyStyleContentsFrom;
|
||||||
|
unsafe {
|
||||||
|
Gecko_CopyStyleContentsFrom(&mut self.gecko, &other.gecko)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%def name="define_ffi_struct_accessor(style_struct)">
|
<%def name="define_ffi_struct_accessor(style_struct)">
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_snake_case, unused_variables)]
|
#[allow(non_snake_case, unused_variables)]
|
||||||
|
|
|
@ -106,8 +106,6 @@ COMPILATION_TARGETS = {
|
||||||
"Maybe", # <- AlignedStorage, which means templated union, which
|
"Maybe", # <- AlignedStorage, which means templated union, which
|
||||||
# means impossible to represent in stable rust as of
|
# means impossible to represent in stable rust as of
|
||||||
# right now.
|
# right now.
|
||||||
# Union handling falls over for templated types.
|
|
||||||
"StyleShapeSource", "StyleClipPath", "StyleShapeOutside",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
# Generation of the ffi bindings.
|
# Generation of the ffi bindings.
|
||||||
|
@ -212,7 +210,7 @@ def extend_object(obj, other):
|
||||||
obj[key] = copy.deepcopy(other[key])
|
obj[key] = copy.deepcopy(other[key])
|
||||||
|
|
||||||
|
|
||||||
def build(objdir, target_name, kind_name=None,
|
def build(objdir, target_name, debug, debugger, kind_name=None,
|
||||||
output_filename=None, bindgen=None, skip_test=False,
|
output_filename=None, bindgen=None, skip_test=False,
|
||||||
verbose=False):
|
verbose=False):
|
||||||
assert target_name in COMPILATION_TARGETS
|
assert target_name in COMPILATION_TARGETS
|
||||||
|
@ -346,10 +344,15 @@ def build(objdir, target_name, kind_name=None,
|
||||||
flags.append(current_target["files"][0].format(objdir))
|
flags.append(current_target["files"][0].format(objdir))
|
||||||
|
|
||||||
flags = bindgen + flags
|
flags = bindgen + flags
|
||||||
output = None
|
|
||||||
|
output = ""
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(flags, stderr=subprocess.STDOUT)
|
if debug:
|
||||||
output = output.decode('utf8')
|
flags = [debugger, "--args"] + flags
|
||||||
|
subprocess.check_call(flags)
|
||||||
|
else:
|
||||||
|
output = subprocess.check_output(flags, stderr=subprocess.STDOUT)
|
||||||
|
output = output.decode('utf8')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("FAIL\n", e.output.decode('utf8'))
|
print("FAIL\n", e.output.decode('utf8'))
|
||||||
return 1
|
return 1
|
||||||
|
@ -428,7 +431,7 @@ def builds_for(target_name, kind):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description=DESCRIPTION)
|
parser = argparse.ArgumentParser(description=DESCRIPTION)
|
||||||
parser.add_argument('--target', default="all",
|
parser.add_argument('--target', default='all',
|
||||||
help='The target to build, either "structs" or "bindings"')
|
help='The target to build, either "structs" or "bindings"')
|
||||||
parser.add_argument('--kind',
|
parser.add_argument('--kind',
|
||||||
help='Kind of build')
|
help='Kind of build')
|
||||||
|
@ -442,6 +445,11 @@ def main():
|
||||||
parser.add_argument('--verbose', '-v',
|
parser.add_argument('--verbose', '-v',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Be... verbose')
|
help='Be... verbose')
|
||||||
|
parser.add_argument('--debug',
|
||||||
|
action='store_true',
|
||||||
|
help='Try to use a debugger to debug bindgen commands (default: gdb)')
|
||||||
|
parser.add_argument('--debugger', default='gdb',
|
||||||
|
help='Debugger to use. Only used if --debug is passed.')
|
||||||
parser.add_argument('objdir')
|
parser.add_argument('objdir')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -467,7 +475,8 @@ def main():
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for target, kind in builds_for(args.target, args.kind):
|
for target, kind in builds_for(args.target, args.kind):
|
||||||
ret = build(args.objdir, target, kind,
|
ret = build(args.objdir, target, kind_name=kind,
|
||||||
|
debug=args.debug, debugger=args.debugger,
|
||||||
bindgen=args.bindgen, skip_test=args.skip_test,
|
bindgen=args.bindgen, skip_test=args.skip_test,
|
||||||
output_filename=args.output,
|
output_filename=args.output,
|
||||||
verbose=args.verbose)
|
verbose=args.verbose)
|
||||||
|
|
|
@ -302,7 +302,8 @@ extern "C" {
|
||||||
pub fn Gecko_GetNodeFlags(node: *mut RawGeckoNode) -> u32;
|
pub fn Gecko_GetNodeFlags(node: *mut RawGeckoNode) -> u32;
|
||||||
pub fn Gecko_SetNodeFlags(node: *mut RawGeckoNode, flags: u32);
|
pub fn Gecko_SetNodeFlags(node: *mut RawGeckoNode, flags: u32);
|
||||||
pub fn Gecko_UnsetNodeFlags(node: *mut RawGeckoNode, flags: u32);
|
pub fn Gecko_UnsetNodeFlags(node: *mut RawGeckoNode, flags: u32);
|
||||||
pub fn Gecko_GetStyleContext(node: *mut RawGeckoNode)
|
pub fn Gecko_GetStyleContext(node: *mut RawGeckoNode,
|
||||||
|
aPseudoTagOrNull: *mut nsIAtom)
|
||||||
-> *mut nsStyleContext;
|
-> *mut nsStyleContext;
|
||||||
pub fn Gecko_CalcStyleDifference(oldstyle: *mut nsStyleContext,
|
pub fn Gecko_CalcStyleDifference(oldstyle: *mut nsStyleContext,
|
||||||
newstyle: ServoComputedValuesBorrowed)
|
newstyle: ServoComputedValuesBorrowed)
|
||||||
|
@ -311,6 +312,11 @@ extern "C" {
|
||||||
change: nsChangeHint);
|
change: nsChangeHint);
|
||||||
pub fn Gecko_EnsureTArrayCapacity(array: *mut ::std::os::raw::c_void,
|
pub fn Gecko_EnsureTArrayCapacity(array: *mut ::std::os::raw::c_void,
|
||||||
capacity: usize, elem_size: usize);
|
capacity: usize, elem_size: usize);
|
||||||
|
pub fn Gecko_ClearPODTArray(array: *mut ::std::os::raw::c_void,
|
||||||
|
elem_size: usize, elem_align: usize);
|
||||||
|
pub fn Gecko_ClearStyleContents(content: *mut nsStyleContent);
|
||||||
|
pub fn Gecko_CopyStyleContentsFrom(content: *mut nsStyleContent,
|
||||||
|
other: *const nsStyleContent);
|
||||||
pub fn Gecko_EnsureImageLayersLength(layers: *mut nsStyleImageLayers,
|
pub fn Gecko_EnsureImageLayersLength(layers: *mut nsStyleImageLayers,
|
||||||
len: usize);
|
len: usize);
|
||||||
pub fn Gecko_InitializeImageLayer(layer: *mut Layer,
|
pub fn Gecko_InitializeImageLayer(layer: *mut Layer,
|
||||||
|
|
|
@ -6389,25 +6389,33 @@ fn bindgen_test_layout_StyleBasicShape() {
|
||||||
assert_eq!(::std::mem::align_of::<StyleBasicShape>() , 8usize);
|
assert_eq!(::std::mem::align_of::<StyleBasicShape>() , 8usize);
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct StyleShapeSource;
|
#[derive(Debug)]
|
||||||
#[repr(C)]
|
pub struct StyleShapeSource<ReferenceBox> {
|
||||||
pub struct StyleClipPath {
|
pub StyleShapeSource_nsStyleStruct_h_unnamed_26: StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox>,
|
||||||
pub _bindgen_opaque_blob: [u64; 2usize],
|
pub mType: StyleShapeSourceType,
|
||||||
}
|
pub mReferenceBox: ReferenceBox,
|
||||||
#[test]
|
|
||||||
fn bindgen_test_layout_StyleClipPath() {
|
|
||||||
assert_eq!(::std::mem::size_of::<StyleClipPath>() , 16usize);
|
|
||||||
assert_eq!(::std::mem::align_of::<StyleClipPath>() , 8usize);
|
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct StyleShapeOutside {
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub _bindgen_opaque_blob: [u64; 2usize],
|
pub struct StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox> {
|
||||||
|
pub mBasicShape: __BindgenUnionField<*mut StyleBasicShape>,
|
||||||
|
pub mURL: __BindgenUnionField<*mut FragmentOrURL>,
|
||||||
|
pub _bindgen_data_: u64,
|
||||||
|
pub _phantom0: ::std::marker::PhantomData<ReferenceBox>,
|
||||||
}
|
}
|
||||||
#[test]
|
impl <ReferenceBox> StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox>
|
||||||
fn bindgen_test_layout_StyleShapeOutside() {
|
{
|
||||||
assert_eq!(::std::mem::size_of::<StyleShapeOutside>() , 16usize);
|
pub unsafe fn mBasicShape(&mut self) -> *mut *mut StyleBasicShape {
|
||||||
assert_eq!(::std::mem::align_of::<StyleShapeOutside>() , 8usize);
|
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
|
||||||
|
::std::mem::transmute(raw.offset(0))
|
||||||
|
}
|
||||||
|
pub unsafe fn mURL(&mut self) -> *mut *mut FragmentOrURL {
|
||||||
|
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
|
||||||
|
::std::mem::transmute(raw.offset(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pub type StyleClipPath = StyleShapeSource<StyleClipPathGeometryBox>;
|
||||||
|
pub type StyleShapeOutside = StyleShapeSource<StyleShapeOutsideShapeBox>;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct nsStyleDisplay {
|
pub struct nsStyleDisplay {
|
||||||
pub mBinding: RefPtr<URLValue>,
|
pub mBinding: RefPtr<URLValue>,
|
||||||
|
@ -6461,7 +6469,7 @@ pub struct nsStyleDisplay {
|
||||||
pub mAnimationFillModeCount: u32,
|
pub mAnimationFillModeCount: u32,
|
||||||
pub mAnimationPlayStateCount: u32,
|
pub mAnimationPlayStateCount: u32,
|
||||||
pub mAnimationIterationCountCount: u32,
|
pub mAnimationIterationCountCount: u32,
|
||||||
pub mShapeOutside: [u64; 2usize],
|
pub mShapeOutside: StyleShapeOutside,
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_nsStyleDisplay() {
|
fn bindgen_test_layout_nsStyleDisplay() {
|
||||||
|
@ -6567,16 +6575,13 @@ fn bindgen_test_layout_nsStyleCounterData() {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct nsStyleContent {
|
pub struct nsStyleContent {
|
||||||
pub mMarkerOffset: nsStyleCoord,
|
pub mMarkerOffset: nsStyleCoord,
|
||||||
pub mContents: *mut nsStyleContentData,
|
pub mContents: nsTArray<nsStyleContentData>,
|
||||||
pub mIncrements: *mut nsStyleCounterData,
|
pub mIncrements: nsTArray<nsStyleCounterData>,
|
||||||
pub mResets: *mut nsStyleCounterData,
|
pub mResets: nsTArray<nsStyleCounterData>,
|
||||||
pub mContentCount: u32,
|
|
||||||
pub mIncrementCount: u32,
|
|
||||||
pub mResetCount: u32,
|
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_nsStyleContent() {
|
fn bindgen_test_layout_nsStyleContent() {
|
||||||
assert_eq!(::std::mem::size_of::<nsStyleContent>() , 56usize);
|
assert_eq!(::std::mem::size_of::<nsStyleContent>() , 40usize);
|
||||||
assert_eq!(::std::mem::align_of::<nsStyleContent>() , 8usize);
|
assert_eq!(::std::mem::align_of::<nsStyleContent>() , 8usize);
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -6797,7 +6802,7 @@ fn bindgen_test_layout_nsStyleFilter() {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct nsStyleSVGReset {
|
pub struct nsStyleSVGReset {
|
||||||
pub mMask: nsStyleImageLayers,
|
pub mMask: nsStyleImageLayers,
|
||||||
pub mClipPath: [u64; 2usize],
|
pub mClipPath: StyleClipPath,
|
||||||
pub mStopColor: nscolor,
|
pub mStopColor: nscolor,
|
||||||
pub mFloodColor: nscolor,
|
pub mFloodColor: nscolor,
|
||||||
pub mLightingColor: nscolor,
|
pub mLightingColor: nscolor,
|
||||||
|
|
|
@ -6367,25 +6367,33 @@ fn bindgen_test_layout_StyleBasicShape() {
|
||||||
assert_eq!(::std::mem::align_of::<StyleBasicShape>() , 8usize);
|
assert_eq!(::std::mem::align_of::<StyleBasicShape>() , 8usize);
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct StyleShapeSource;
|
#[derive(Debug)]
|
||||||
#[repr(C)]
|
pub struct StyleShapeSource<ReferenceBox> {
|
||||||
pub struct StyleClipPath {
|
pub StyleShapeSource_nsStyleStruct_h_unnamed_26: StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox>,
|
||||||
pub _bindgen_opaque_blob: [u64; 2usize],
|
pub mType: StyleShapeSourceType,
|
||||||
}
|
pub mReferenceBox: ReferenceBox,
|
||||||
#[test]
|
|
||||||
fn bindgen_test_layout_StyleClipPath() {
|
|
||||||
assert_eq!(::std::mem::size_of::<StyleClipPath>() , 16usize);
|
|
||||||
assert_eq!(::std::mem::align_of::<StyleClipPath>() , 8usize);
|
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct StyleShapeOutside {
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub _bindgen_opaque_blob: [u64; 2usize],
|
pub struct StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox> {
|
||||||
|
pub mBasicShape: __BindgenUnionField<*mut StyleBasicShape>,
|
||||||
|
pub mURL: __BindgenUnionField<*mut FragmentOrURL>,
|
||||||
|
pub _bindgen_data_: u64,
|
||||||
|
pub _phantom0: ::std::marker::PhantomData<ReferenceBox>,
|
||||||
}
|
}
|
||||||
#[test]
|
impl <ReferenceBox> StyleShapeSource_nsStyleStruct_h_unnamed_26<ReferenceBox>
|
||||||
fn bindgen_test_layout_StyleShapeOutside() {
|
{
|
||||||
assert_eq!(::std::mem::size_of::<StyleShapeOutside>() , 16usize);
|
pub unsafe fn mBasicShape(&mut self) -> *mut *mut StyleBasicShape {
|
||||||
assert_eq!(::std::mem::align_of::<StyleShapeOutside>() , 8usize);
|
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
|
||||||
|
::std::mem::transmute(raw.offset(0))
|
||||||
|
}
|
||||||
|
pub unsafe fn mURL(&mut self) -> *mut *mut FragmentOrURL {
|
||||||
|
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
|
||||||
|
::std::mem::transmute(raw.offset(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pub type StyleClipPath = StyleShapeSource<StyleClipPathGeometryBox>;
|
||||||
|
pub type StyleShapeOutside = StyleShapeSource<StyleShapeOutsideShapeBox>;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct nsStyleDisplay {
|
pub struct nsStyleDisplay {
|
||||||
pub mBinding: RefPtr<URLValue>,
|
pub mBinding: RefPtr<URLValue>,
|
||||||
|
@ -6439,7 +6447,7 @@ pub struct nsStyleDisplay {
|
||||||
pub mAnimationFillModeCount: u32,
|
pub mAnimationFillModeCount: u32,
|
||||||
pub mAnimationPlayStateCount: u32,
|
pub mAnimationPlayStateCount: u32,
|
||||||
pub mAnimationIterationCountCount: u32,
|
pub mAnimationIterationCountCount: u32,
|
||||||
pub mShapeOutside: [u64; 2usize],
|
pub mShapeOutside: StyleShapeOutside,
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_nsStyleDisplay() {
|
fn bindgen_test_layout_nsStyleDisplay() {
|
||||||
|
@ -6544,16 +6552,13 @@ fn bindgen_test_layout_nsStyleCounterData() {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct nsStyleContent {
|
pub struct nsStyleContent {
|
||||||
pub mMarkerOffset: nsStyleCoord,
|
pub mMarkerOffset: nsStyleCoord,
|
||||||
pub mContents: *mut nsStyleContentData,
|
pub mContents: nsTArray<nsStyleContentData>,
|
||||||
pub mIncrements: *mut nsStyleCounterData,
|
pub mIncrements: nsTArray<nsStyleCounterData>,
|
||||||
pub mResets: *mut nsStyleCounterData,
|
pub mResets: nsTArray<nsStyleCounterData>,
|
||||||
pub mContentCount: u32,
|
|
||||||
pub mIncrementCount: u32,
|
|
||||||
pub mResetCount: u32,
|
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_nsStyleContent() {
|
fn bindgen_test_layout_nsStyleContent() {
|
||||||
assert_eq!(::std::mem::size_of::<nsStyleContent>() , 56usize);
|
assert_eq!(::std::mem::size_of::<nsStyleContent>() , 40usize);
|
||||||
assert_eq!(::std::mem::align_of::<nsStyleContent>() , 8usize);
|
assert_eq!(::std::mem::align_of::<nsStyleContent>() , 8usize);
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -6774,7 +6779,7 @@ fn bindgen_test_layout_nsStyleFilter() {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct nsStyleSVGReset {
|
pub struct nsStyleSVGReset {
|
||||||
pub mMask: nsStyleImageLayers,
|
pub mMask: nsStyleImageLayers,
|
||||||
pub mClipPath: [u64; 2usize],
|
pub mClipPath: StyleClipPath,
|
||||||
pub mStopColor: nscolor,
|
pub mStopColor: nscolor,
|
||||||
pub mFloodColor: nscolor,
|
pub mFloodColor: nscolor,
|
||||||
pub mLightingColor: nscolor,
|
pub mLightingColor: nscolor,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use bindings::Gecko_EnsureTArrayCapacity;
|
use bindings;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
@ -38,6 +38,7 @@ impl<T> nsTArray<T> {
|
||||||
// unsafe, since header may be in shared static or something
|
// unsafe, since header may be in shared static or something
|
||||||
unsafe fn header_mut<'a>(&'a mut self) -> &'a mut nsTArrayHeader {
|
unsafe fn header_mut<'a>(&'a mut self) -> &'a mut nsTArrayHeader {
|
||||||
debug_assert!(!self.mBuffer.is_null());
|
debug_assert!(!self.mBuffer.is_null());
|
||||||
|
|
||||||
mem::transmute(self.mBuffer)
|
mem::transmute(self.mBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +48,37 @@ impl<T> nsTArray<T> {
|
||||||
(self.mBuffer as *const nsTArrayHeader).offset(1) as *mut _
|
(self.mBuffer as *const nsTArrayHeader).offset(1) as *mut _
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_capacity(&mut self, cap: usize) {
|
/// Ensures the array has enough capacity at least to hold `cap` elements.
|
||||||
unsafe {
|
///
|
||||||
Gecko_EnsureTArrayCapacity(self as *mut nsTArray<T> as *mut c_void, cap, mem::size_of::<T>())
|
/// NOTE: This doesn't call the constructor on the values!
|
||||||
|
pub fn ensure_capacity(&mut self, cap: usize) {
|
||||||
|
if cap >= self.len() {
|
||||||
|
unsafe {
|
||||||
|
bindings::Gecko_EnsureTArrayCapacity(self as *mut nsTArray<T> as *mut _,
|
||||||
|
cap, mem::size_of::<T>())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clears the array storage without calling the destructor on the values.
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn clear(&mut self) {
|
||||||
|
if self.len() != 0 {
|
||||||
|
bindings::Gecko_ClearPODTArray(self as *mut nsTArray<T> as *mut _,
|
||||||
|
mem::size_of::<T>(),
|
||||||
|
mem::align_of::<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Clears a POD array. This is safe since copy types are memcopyable.
|
||||||
|
#[inline]
|
||||||
|
pub fn clear_pod(&mut self)
|
||||||
|
where T: Copy
|
||||||
|
{
|
||||||
|
unsafe { self.clear() }
|
||||||
|
}
|
||||||
|
|
||||||
// unsafe because the array may contain uninits
|
// unsafe because the array may contain uninits
|
||||||
// This will not call constructors, either manually
|
// This will not call constructors, either manually
|
||||||
// add bindings or run the typed ensurecapacity call
|
// add bindings or run the typed ensurecapacity call
|
||||||
|
|
|
@ -319,15 +319,10 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if pseudo.is_some() {
|
|
||||||
// FIXME(emilio): This makes us reconstruct frame for pseudos every
|
|
||||||
// restyle, add a FFI call to get the style context associated with
|
|
||||||
// a PE.
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let context_ptr = Gecko_GetStyleContext(self.node);
|
let atom_ptr = pseudo.map(|p| p.as_atom().as_ptr())
|
||||||
|
.unwrap_or(ptr::null_mut());
|
||||||
|
let context_ptr = Gecko_GetStyleContext(self.node, atom_ptr);
|
||||||
context_ptr.as_ref()
|
context_ptr.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue