mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Hoist gecko bindings into their own crate.
This will be helpful for leveraging the bindings with our nsIAtom-backed string_cache replacement.
This commit is contained in:
parent
7f76e3ba74
commit
d6a6f2c7e0
18 changed files with 215 additions and 106 deletions
8
ports/geckolib/Cargo.lock
generated
8
ports/geckolib/Cargo.lock
generated
|
@ -6,6 +6,7 @@ dependencies = [
|
|||
"cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gecko_bindings 0.0.1",
|
||||
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize_plugin 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -223,6 +224,13 @@ name = "gcc"
|
|||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "gecko_bindings"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.14"
|
||||
|
|
|
@ -14,6 +14,7 @@ crate-type = ["staticlib"]
|
|||
app_units = "0.2.3"
|
||||
cssparser = "0.5.4"
|
||||
euclid = "0.6.4"
|
||||
gecko_bindings = {version = "0.0.1", path = "gecko_bindings"}
|
||||
heapsize = "0.3.0"
|
||||
heapsize_plugin = "0.1.2"
|
||||
lazy_static = "0.2"
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* 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::RawServoStyleSet;
|
||||
use euclid::Size2D;
|
||||
use euclid::size::TypedSize2D;
|
||||
use gecko_bindings::bindings::RawServoStyleSet;
|
||||
use num_cpus;
|
||||
use selector_impl::{Stylist, Stylesheet, SharedStyleContext};
|
||||
use std::cmp;
|
||||
|
|
12
ports/geckolib/gecko_bindings/Cargo.toml
Normal file
12
ports/geckolib/gecko_bindings/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "gecko_bindings"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "gecko_bindings"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
heapsize = "0.3.0"
|
|
@ -1,30 +1,103 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
use gecko_style_structs::SheetParsingMode;
|
||||
use gecko_style_structs::nsStyleFont;
|
||||
use gecko_style_structs::nsStyleColor;
|
||||
use gecko_style_structs::nsStyleList;
|
||||
use gecko_style_structs::nsStyleText;
|
||||
use gecko_style_structs::nsStyleVisibility;
|
||||
use gecko_style_structs::nsStyleUserInterface;
|
||||
use gecko_style_structs::nsStyleTableBorder;
|
||||
use gecko_style_structs::nsStyleSVG;
|
||||
use gecko_style_structs::nsStyleVariables;
|
||||
use gecko_style_structs::nsStyleBackground;
|
||||
use gecko_style_structs::nsStylePosition;
|
||||
use gecko_style_structs::nsStyleTextReset;
|
||||
use gecko_style_structs::nsStyleDisplay;
|
||||
use gecko_style_structs::nsStyleContent;
|
||||
use gecko_style_structs::nsStyleUIReset;
|
||||
use gecko_style_structs::nsStyleTable;
|
||||
use gecko_style_structs::nsStyleMargin;
|
||||
use gecko_style_structs::nsStylePadding;
|
||||
use gecko_style_structs::nsStyleBorder;
|
||||
use gecko_style_structs::nsStyleOutline;
|
||||
use gecko_style_structs::nsStyleXUL;
|
||||
use gecko_style_structs::nsStyleSVGReset;
|
||||
use gecko_style_structs::nsStyleColumn;
|
||||
use gecko_style_structs::nsStyleEffects;
|
||||
use structs::nsStyleFont;
|
||||
use structs::nsStyleColor;
|
||||
use structs::nsStyleList;
|
||||
use structs::nsStyleText;
|
||||
use structs::nsStyleVisibility;
|
||||
use structs::nsStyleUserInterface;
|
||||
use structs::nsStyleTableBorder;
|
||||
use structs::nsStyleSVG;
|
||||
use structs::nsStyleVariables;
|
||||
use structs::nsStyleBackground;
|
||||
use structs::nsStylePosition;
|
||||
use structs::nsStyleTextReset;
|
||||
use structs::nsStyleDisplay;
|
||||
use structs::nsStyleContent;
|
||||
use structs::nsStyleUIReset;
|
||||
use structs::nsStyleTable;
|
||||
use structs::nsStyleMargin;
|
||||
use structs::nsStylePadding;
|
||||
use structs::nsStyleBorder;
|
||||
use structs::nsStyleOutline;
|
||||
use structs::nsStyleXUL;
|
||||
use structs::nsStyleSVGReset;
|
||||
use structs::nsStyleColumn;
|
||||
use structs::nsStyleEffects;
|
||||
use structs::SheetParsingMode;
|
||||
use heapsize::HeapSizeOf;
|
||||
unsafe impl Send for nsStyleFont {}
|
||||
unsafe impl Sync for nsStyleFont {}
|
||||
impl HeapSizeOf for nsStyleFont { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleColor {}
|
||||
unsafe impl Sync for nsStyleColor {}
|
||||
impl HeapSizeOf for nsStyleColor { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleList {}
|
||||
unsafe impl Sync for nsStyleList {}
|
||||
impl HeapSizeOf for nsStyleList { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleText {}
|
||||
unsafe impl Sync for nsStyleText {}
|
||||
impl HeapSizeOf for nsStyleText { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleVisibility {}
|
||||
unsafe impl Sync for nsStyleVisibility {}
|
||||
impl HeapSizeOf for nsStyleVisibility { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleUserInterface {}
|
||||
unsafe impl Sync for nsStyleUserInterface {}
|
||||
impl HeapSizeOf for nsStyleUserInterface { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleTableBorder {}
|
||||
unsafe impl Sync for nsStyleTableBorder {}
|
||||
impl HeapSizeOf for nsStyleTableBorder { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleSVG {}
|
||||
unsafe impl Sync for nsStyleSVG {}
|
||||
impl HeapSizeOf for nsStyleSVG { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleVariables {}
|
||||
unsafe impl Sync for nsStyleVariables {}
|
||||
impl HeapSizeOf for nsStyleVariables { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleBackground {}
|
||||
unsafe impl Sync for nsStyleBackground {}
|
||||
impl HeapSizeOf for nsStyleBackground { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStylePosition {}
|
||||
unsafe impl Sync for nsStylePosition {}
|
||||
impl HeapSizeOf for nsStylePosition { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleTextReset {}
|
||||
unsafe impl Sync for nsStyleTextReset {}
|
||||
impl HeapSizeOf for nsStyleTextReset { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleDisplay {}
|
||||
unsafe impl Sync for nsStyleDisplay {}
|
||||
impl HeapSizeOf for nsStyleDisplay { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleContent {}
|
||||
unsafe impl Sync for nsStyleContent {}
|
||||
impl HeapSizeOf for nsStyleContent { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleUIReset {}
|
||||
unsafe impl Sync for nsStyleUIReset {}
|
||||
impl HeapSizeOf for nsStyleUIReset { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleTable {}
|
||||
unsafe impl Sync for nsStyleTable {}
|
||||
impl HeapSizeOf for nsStyleTable { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleMargin {}
|
||||
unsafe impl Sync for nsStyleMargin {}
|
||||
impl HeapSizeOf for nsStyleMargin { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStylePadding {}
|
||||
unsafe impl Sync for nsStylePadding {}
|
||||
impl HeapSizeOf for nsStylePadding { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleBorder {}
|
||||
unsafe impl Sync for nsStyleBorder {}
|
||||
impl HeapSizeOf for nsStyleBorder { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleOutline {}
|
||||
unsafe impl Sync for nsStyleOutline {}
|
||||
impl HeapSizeOf for nsStyleOutline { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleXUL {}
|
||||
unsafe impl Sync for nsStyleXUL {}
|
||||
impl HeapSizeOf for nsStyleXUL { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleSVGReset {}
|
||||
unsafe impl Sync for nsStyleSVGReset {}
|
||||
impl HeapSizeOf for nsStyleSVGReset { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleColumn {}
|
||||
unsafe impl Sync for nsStyleColumn {}
|
||||
impl HeapSizeOf for nsStyleColumn { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
unsafe impl Send for nsStyleEffects {}
|
||||
unsafe impl Sync for nsStyleEffects {}
|
||||
impl HeapSizeOf for nsStyleEffects { fn heap_size_of_children(&self) -> usize { 0 } }
|
||||
|
||||
pub enum nsIAtom { }
|
||||
pub enum nsINode { }
|
10
ports/geckolib/gecko_bindings/lib.rs
Normal file
10
ports/geckolib/gecko_bindings/lib.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
extern crate heapsize;
|
||||
|
||||
#[allow(dead_code, non_camel_case_types)]
|
||||
pub mod bindings;
|
||||
#[allow(dead_code, non_camel_case_types, non_snake_case, non_upper_case_globals)]
|
||||
pub mod structs;
|
|
@ -23,4 +23,4 @@ build (which are in `ports/geckolib/bindings.rs`).
|
|||
## `regen_style_structs.sh`
|
||||
|
||||
This will generate the bindings for Gecko's style structs. Current bindings are
|
||||
actually in `ports/geckolib/gecko_style_structs.rs`.
|
||||
actually in `ports/geckolib/structs.rs`.
|
|
@ -28,9 +28,14 @@ else
|
|||
LIBCLANG_PATH=`brew --prefix llvm38`/lib/llvm-3.8/lib;
|
||||
fi
|
||||
|
||||
# Prevent bindgen from generating opaque types for common gecko types
|
||||
# Prevent bindgen from generating opaque types for common gecko types.
|
||||
export MAP_GECKO_TYPES=""
|
||||
for STRUCT in SheetParsingMode nsStyleFont nsStyleColor nsStyleList nsStyleText \
|
||||
|
||||
# Extra code we want to generate.
|
||||
export EXTRA_CODE="-raw-line 'use heapsize::HeapSizeOf;' "
|
||||
|
||||
# Style structs.
|
||||
for STRUCT in nsStyleFont nsStyleColor nsStyleList nsStyleText \
|
||||
nsStyleVisibility nsStyleUserInterface nsStyleTableBorder \
|
||||
nsStyleSVG nsStyleVariables nsStyleBackground nsStylePosition \
|
||||
nsStyleTextReset nsStyleDisplay nsStyleContent nsStyleUIReset \
|
||||
|
@ -38,9 +43,21 @@ for STRUCT in SheetParsingMode nsStyleFont nsStyleColor nsStyleList nsStyleText
|
|||
nsStyleOutline nsStyleXUL nsStyleSVGReset nsStyleColumn nsStyleEffects
|
||||
do
|
||||
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-blacklist-type $STRUCT "
|
||||
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-raw-line 'use gecko_style_structs::$STRUCT;' "
|
||||
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-raw-line 'use structs::$STRUCT;' "
|
||||
EXTRA_CODE=$EXTRA_CODE"-raw-line 'unsafe impl Send for $STRUCT {}' "
|
||||
EXTRA_CODE=$EXTRA_CODE"-raw-line 'unsafe impl Sync for $STRUCT {}' "
|
||||
EXTRA_CODE=$EXTRA_CODE"-raw-line 'impl HeapSizeOf for $STRUCT { fn heap_size_of_children(&self) -> usize { 0 } }' "
|
||||
done
|
||||
|
||||
# Other mapped types.
|
||||
for TYPE in SheetParsingMode
|
||||
do
|
||||
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-blacklist-type $TYPE "
|
||||
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-raw-line 'use structs::$TYPE;' "
|
||||
done
|
||||
|
||||
|
||||
|
||||
# Check for the include directory.
|
||||
export DIST_INCLUDE="$1/dist/include"
|
||||
if [ ! -d "$DIST_INCLUDE" ]; then
|
||||
|
@ -61,4 +78,5 @@ eval ./rust-bindgen/target/debug/bindgen \
|
|||
"$DIST_INCLUDE/mozilla/ServoBindings.h" \
|
||||
-match "ServoBindings.h" \
|
||||
-match "nsStyleStructList.h" \
|
||||
$MAP_GECKO_TYPES
|
||||
$MAP_GECKO_TYPES \
|
||||
$EXTRA_CODE
|
|
@ -39,7 +39,7 @@ fi
|
|||
export RUST_BACKTRACE=1
|
||||
|
||||
./rust-bindgen/target/debug/bindgen \
|
||||
-o ../gecko_style_structs.rs \
|
||||
-o ../structs.rs \
|
||||
-x c++ -std=gnu++0x \
|
||||
-allow-unknown-types \
|
||||
"-I$DIST_INCLUDE" "-I$DIST_INCLUDE/nspr" \
|
||||
|
@ -123,7 +123,7 @@ if [ $? -ne 0 ]; then
|
|||
else
|
||||
echo -e "\e[34minfo:\e[0m bindgen exited successfully, running tests"
|
||||
TESTS_FILE=$(mktemp)
|
||||
rustc ../gecko_style_structs.rs --test -o $TESTS_FILE
|
||||
rustc ../structs.rs --test -o $TESTS_FILE
|
||||
$TESTS_FILE
|
||||
rm $TESTS_FILE
|
||||
fi
|
|
@ -5,13 +5,13 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use app_units::Au;
|
||||
use bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use bindings::{RawServoStyleSet, RawServoStyleSheet, ServoComputedValues, ServoNodeData};
|
||||
use bindings::{nsIAtom};
|
||||
use data::PerDocumentStyleData;
|
||||
use env_logger;
|
||||
use euclid::Size2D;
|
||||
use gecko_style_structs::SheetParsingMode;
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::bindings::{RawServoStyleSet, RawServoStyleSheet, ServoComputedValues, ServoNodeData};
|
||||
use gecko_bindings::bindings::{nsIAtom};
|
||||
use gecko_bindings::structs::SheetParsingMode;
|
||||
use properties::GeckoComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
|
||||
use std::marker::PhantomData;
|
||||
|
@ -35,7 +35,7 @@ use wrapper::{GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData};
|
|||
// TODO: This is ugly and should go away once we get an atom back-end.
|
||||
pub fn pseudo_element_from_atom(pseudo: *mut nsIAtom,
|
||||
in_ua_stylesheet: bool) -> Result<PseudoElement, String> {
|
||||
use bindings::Gecko_GetAtomAsUTF16;
|
||||
use gecko_bindings::bindings::Gecko_GetAtomAsUTF16;
|
||||
use selectors::parser::{ParserContext, SelectorImpl};
|
||||
|
||||
let pseudo_string = unsafe {
|
||||
|
@ -258,7 +258,6 @@ pub extern "C" fn Servo_ReleaseStyleSheet(sheet: *mut RawServoStyleSheet) -> ()
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_GetComputedValues(node: *mut RawGeckoNode)
|
||||
-> *mut ServoComputedValues {
|
||||
use selectors::Element;
|
||||
let node = unsafe { GeckoNode::from_raw(node) };
|
||||
let arc_cv = match node.borrow_data().map_or(None, |data| data.style.clone()) {
|
||||
Some(style) => style,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#![feature(as_unsafe_cell)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(ptr_as_ref)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(custom_derive)]
|
||||
#![feature(plugin)]
|
||||
|
@ -17,6 +16,7 @@ extern crate app_units;
|
|||
extern crate cssparser;
|
||||
extern crate env_logger;
|
||||
extern crate euclid;
|
||||
extern crate gecko_bindings;
|
||||
extern crate heapsize;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
@ -32,11 +32,7 @@ extern crate style;
|
|||
extern crate url;
|
||||
extern crate util;
|
||||
|
||||
#[allow(dead_code, non_camel_case_types)]
|
||||
mod bindings;
|
||||
mod data;
|
||||
#[allow(dead_code, non_camel_case_types, non_snake_case, non_upper_case_globals)]
|
||||
mod gecko_style_structs;
|
||||
#[allow(non_snake_case)]
|
||||
pub mod glue;
|
||||
mod selector_impl;
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
use app_units::Au;
|
||||
% for style_struct in data.style_structs:
|
||||
use gecko_style_structs::${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
||||
use bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
||||
use gecko_bindings::structs::${style_struct.gecko_ffi_name};
|
||||
use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
|
||||
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
||||
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
||||
% endfor
|
||||
use bindings::{Gecko_CopyListStyleTypeFrom, Gecko_SetListStyleType};
|
||||
use gecko_style_structs;
|
||||
use gecko_bindings::bindings::{Gecko_CopyListStyleTypeFrom, Gecko_SetListStyleType};
|
||||
use gecko_bindings::structs;
|
||||
use glue::ArcHelpers;
|
||||
use heapsize::HeapSizeOf;
|
||||
use std::fmt::{self, Debug};
|
||||
|
@ -29,7 +29,6 @@ use style::properties::{CascadePropertyFn, ServoComputedValues, ComputedValues};
|
|||
use style::properties::longhands;
|
||||
use style::properties::make_cascade_vec;
|
||||
use style::properties::style_struct_traits::*;
|
||||
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
|
||||
use values::{ToGeckoStyleCoord, convert_rgba_to_nscolor, convert_nscolor_to_rgba};
|
||||
use values::round_border_to_device_pixels;
|
||||
|
||||
|
@ -130,7 +129,7 @@ impl ComputedValues for GeckoComputedValues {
|
|||
}
|
||||
|
||||
<%def name="declare_style_struct(style_struct)">
|
||||
#[derive(Clone, HeapSizeOf, Debug)]
|
||||
#[derive(HeapSizeOf)]
|
||||
pub struct ${style_struct.gecko_struct_name} {
|
||||
gecko: ${style_struct.gecko_ffi_name},
|
||||
}
|
||||
|
@ -154,12 +153,12 @@ def is_border_style_masked(ffi_name):
|
|||
|
||||
def get_gecko_property(ffi_name):
|
||||
if is_border_style_masked(ffi_name):
|
||||
return "(self.gecko.%s & (gecko_style_structs::BORDER_STYLE_MASK as u8))" % ffi_name
|
||||
return "(self.gecko.%s & (structs::BORDER_STYLE_MASK as u8))" % ffi_name
|
||||
return "self.gecko.%s" % ffi_name
|
||||
|
||||
def set_gecko_property(ffi_name, expr):
|
||||
if is_border_style_masked(ffi_name):
|
||||
return "self.gecko.%s &= !(gecko_style_structs::BORDER_STYLE_MASK as u8);" % ffi_name + \
|
||||
return "self.gecko.%s &= !(structs::BORDER_STYLE_MASK as u8);" % ffi_name + \
|
||||
"self.gecko.%s |= %s as u8;" % (ffi_name, expr)
|
||||
elif ffi_name == "__LIST_STYLE_TYPE__":
|
||||
return "unsafe { Gecko_SetListStyleType(&mut self.gecko, %s as u32); }" % expr
|
||||
|
@ -168,12 +167,11 @@ def set_gecko_property(ffi_name, expr):
|
|||
|
||||
<%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword)">
|
||||
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
use gecko_style_structs as gss;
|
||||
use style::properties::longhands::${ident}::computed_value::T as Keyword;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} => gss::${keyword.gecko_constant(value)} as u8,
|
||||
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
|
||||
% endfor
|
||||
};
|
||||
${set_gecko_property(gecko_ffi_name, "result")}
|
||||
|
@ -182,12 +180,11 @@ def set_gecko_property(ffi_name, expr):
|
|||
|
||||
<%def name="impl_keyword_clone(ident, gecko_ffi_name, keyword)">
|
||||
fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use gecko_style_structs as gss;
|
||||
use style::properties::longhands::${ident}::computed_value::T as Keyword;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
match ${get_gecko_property(gecko_ffi_name)} as u32 {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
gss::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {}", x),
|
||||
}
|
||||
|
@ -196,13 +193,13 @@ def set_gecko_property(ffi_name, expr):
|
|||
|
||||
<%def name="clear_color_flags(color_flags_ffi_name)">
|
||||
% if color_flags_ffi_name:
|
||||
self.gecko.${color_flags_ffi_name} &= !(gecko_style_structs::BORDER_COLOR_SPECIAL as u8);
|
||||
self.gecko.${color_flags_ffi_name} &= !(structs::BORDER_COLOR_SPECIAL as u8);
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="set_current_color_flag(color_flags_ffi_name)">
|
||||
% if color_flags_ffi_name:
|
||||
self.gecko.${color_flags_ffi_name} |= gecko_style_structs::BORDER_COLOR_FOREGROUND as u8;
|
||||
self.gecko.${color_flags_ffi_name} |= structs::BORDER_COLOR_FOREGROUND as u8;
|
||||
% else:
|
||||
// FIXME(heycam): This is a Gecko property that doesn't store currentColor
|
||||
// as a computed value. These are currently handled by converting
|
||||
|
@ -216,7 +213,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
</%def>
|
||||
|
||||
<%def name="get_current_color_flag_from(field)">
|
||||
(${field} & (gecko_style_structs::BORDER_COLOR_FOREGROUND as u8)) != 0
|
||||
(${field} & (structs::BORDER_COLOR_FOREGROUND as u8)) != 0
|
||||
</%def>
|
||||
|
||||
<%def name="impl_color_setter(ident, gecko_ffi_name, color_flags_ffi_name=None)">
|
||||
|
@ -288,7 +285,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
&mut self.gecko.${union_ffi_name});
|
||||
}
|
||||
fn copy_${ident}_from(&mut self, other: &Self) {
|
||||
use gecko_style_structs::nsStyleUnit::eStyleUnit_Calc;
|
||||
use gecko_bindings::structs::nsStyleUnit::eStyleUnit_Calc;
|
||||
debug_assert!(self.gecko.${unit_ffi_name} != eStyleUnit_Calc,
|
||||
"stylo: Can't yet handle refcounted Calc");
|
||||
self.gecko.${unit_ffi_name} = other.gecko.${unit_ffi_name};
|
||||
|
@ -308,7 +305,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
&mut self.gecko.${y_union_ffi_name});
|
||||
}
|
||||
fn copy_${ident}_from(&mut self, other: &Self) {
|
||||
use gecko_style_structs::nsStyleUnit::eStyleUnit_Calc;
|
||||
use gecko_bindings::structs::nsStyleUnit::eStyleUnit_Calc;
|
||||
debug_assert!(self.gecko.${x_unit_ffi_name} != eStyleUnit_Calc &&
|
||||
self.gecko.${y_unit_ffi_name} != eStyleUnit_Calc,
|
||||
"stylo: Can't yet handle refcounted Calc");
|
||||
|
@ -340,31 +337,30 @@ impl Drop for ${style_struct.gecko_struct_name} {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl Clone for ${style_struct.gecko_ffi_name} {
|
||||
impl Clone for ${style_struct.gecko_struct_name} {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let mut result: Self = zeroed();
|
||||
Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(&mut result, self);
|
||||
Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(&mut result.gecko, &self.gecko);
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe impl Send for ${style_struct.gecko_ffi_name} {}
|
||||
unsafe impl Sync for ${style_struct.gecko_ffi_name} {}
|
||||
impl HeapSizeOf for ${style_struct.gecko_ffi_name} {
|
||||
// Not entirely accurate, but good enough for now.
|
||||
fn heap_size_of_children(&self) -> usize { 0 }
|
||||
}
|
||||
|
||||
// FIXME(bholley): Make bindgen generate Debug for all types.
|
||||
%if style_struct.gecko_ffi_name in "nsStyleBorder nsStyleDisplay nsStyleList nsStyleBackground "\
|
||||
"nsStyleFont nsStyleSVGReset".split():
|
||||
impl Debug for ${style_struct.gecko_ffi_name} {
|
||||
impl Debug for ${style_struct.gecko_struct_name} {
|
||||
// FIXME(bholley): Generate this.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "GECKO STYLE STRUCT")
|
||||
}
|
||||
}
|
||||
%else:
|
||||
impl Debug for ${style_struct.gecko_struct_name} {
|
||||
// FIXME(bholley): Generate this.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.gecko.fmt(f) }
|
||||
}
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
|
@ -476,14 +472,15 @@ CORNERS = [Corner("TOP_LEFT", 0), Corner("TOP_RIGHT", 1), Corner("BOTTOM_RIGHT",
|
|||
#[allow(dead_code)]
|
||||
fn static_assert() {
|
||||
unsafe {
|
||||
% for side in SIDES:
|
||||
transmute::<_, [u32; ${side.index}]>([1; gecko_style_structs::Side::eSide${side.name} as usize]);
|
||||
% endfor
|
||||
% for corner in CORNERS:
|
||||
transmute::<_, [u32; ${corner.x_index}]>([1; gecko_style_structs::${corner.x_name} as usize]);
|
||||
transmute::<_, [u32; ${corner.y_index}]>([1; gecko_style_structs::${corner.y_name} as usize]);
|
||||
% endfor
|
||||
% for corner in CORNERS:
|
||||
transmute::<_, [u32; ${corner.x_index}]>([1; structs::${corner.x_name} as usize]);
|
||||
transmute::<_, [u32; ${corner.y_index}]>([1; structs::${corner.y_name} as usize]);
|
||||
% endfor
|
||||
}
|
||||
// Note: using the above technique with an enum hits a rust bug when |structs| is in a different crate.
|
||||
% for side in SIDES:
|
||||
{ const DETAIL: u32 = [0][(structs::Side::eSide${side.name} as usize != ${side.index}) as usize]; let _ = DETAIL; }
|
||||
% endfor
|
||||
}
|
||||
|
||||
<% border_style_keyword = Keyword("border-style",
|
||||
|
@ -629,24 +626,22 @@ fn static_assert() {
|
|||
// We could generalize this if we run into other newtype keywords.
|
||||
<% overflow_x = data.longhands_by_name["overflow-x"] %>
|
||||
fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) {
|
||||
use gecko_style_structs as gss;
|
||||
use style::properties::longhands::overflow_x::computed_value::T as BaseType;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
self.gecko.mOverflowY = match v.0 {
|
||||
% for value in overflow_x.keyword.values_for('gecko'):
|
||||
BaseType::${to_rust_ident(value)} => gss::${overflow_x.keyword.gecko_constant(value)} as u8,
|
||||
BaseType::${to_rust_ident(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8,
|
||||
% endfor
|
||||
};
|
||||
}
|
||||
<%call expr="impl_simple_copy('overflow_y', 'mOverflowY')"></%call>
|
||||
fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T {
|
||||
use gecko_style_structs as gss;
|
||||
use style::properties::longhands::overflow_x::computed_value::T as BaseType;
|
||||
use style::properties::longhands::overflow_y::computed_value::T as NewType;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
match self.gecko.mOverflowY as u32 {
|
||||
% for value in overflow_x.keyword.values_for('gecko'):
|
||||
gss::${overflow_x.keyword.gecko_constant(value)} => NewType(BaseType::${to_rust_ident(value)}),
|
||||
structs::${overflow_x.keyword.gecko_constant(value)} => NewType(BaseType::${to_rust_ident(value)}),
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for overflow_y property: {}", x),
|
||||
}
|
||||
|
@ -680,16 +675,13 @@ fn static_assert() {
|
|||
color_flags_ffi_name="mTextDecorationStyle") %>
|
||||
|
||||
fn has_underline(&self) -> bool {
|
||||
use gecko_style_structs as gss;
|
||||
(self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0
|
||||
}
|
||||
fn has_overline(&self) -> bool {
|
||||
use gecko_style_structs as gss;
|
||||
(self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0
|
||||
}
|
||||
fn has_line_through(&self) -> bool {
|
||||
use gecko_style_structs as gss;
|
||||
(self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0
|
||||
}
|
||||
</%self:impl_trait>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use cssparser::RGBA;
|
||||
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
|
||||
use gecko_bindings::structs::{nsStyleUnion, nsStyleUnit};
|
||||
use std::cmp::max;
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use bindings::{Gecko_ChildrenCount};
|
||||
use bindings::{Gecko_ElementState, Gecko_GetAttrAsUTF8, Gecko_GetDocumentElement};
|
||||
use bindings::{Gecko_GetFirstChild, Gecko_GetFirstChildElement};
|
||||
use bindings::{Gecko_GetLastChild, Gecko_GetLastChildElement};
|
||||
use bindings::{Gecko_GetNextSibling, Gecko_GetNextSiblingElement};
|
||||
use bindings::{Gecko_GetNodeData};
|
||||
use bindings::{Gecko_GetParentElement, Gecko_GetParentNode};
|
||||
use bindings::{Gecko_GetPrevSibling, Gecko_GetPrevSiblingElement};
|
||||
use bindings::{Gecko_IsHTMLElementInHTMLDocument, Gecko_IsLink, Gecko_IsRootElement, Gecko_IsTextNode};
|
||||
use bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink};
|
||||
use gecko_bindings::bindings::{Gecko_ChildrenCount};
|
||||
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetAttrAsUTF8, Gecko_GetDocumentElement};
|
||||
use gecko_bindings::bindings::{Gecko_GetFirstChild, Gecko_GetFirstChildElement};
|
||||
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetLastChildElement};
|
||||
use gecko_bindings::bindings::{Gecko_GetNextSibling, Gecko_GetNextSiblingElement};
|
||||
use gecko_bindings::bindings::{Gecko_GetNodeData};
|
||||
use gecko_bindings::bindings::{Gecko_GetParentElement, Gecko_GetParentNode};
|
||||
use gecko_bindings::bindings::{Gecko_GetPrevSibling, Gecko_GetPrevSiblingElement};
|
||||
use gecko_bindings::bindings::{Gecko_IsHTMLElementInHTMLDocument, Gecko_IsLink, Gecko_IsRootElement, Gecko_IsTextNode};
|
||||
use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink};
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetNodeData};
|
||||
use bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use bindings::{ServoNodeData};
|
||||
use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetNodeData};
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::bindings::{ServoNodeData};
|
||||
use libc::uintptr_t;
|
||||
use properties::GeckoComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};
|
||||
|
|
|
@ -34,8 +34,8 @@ file_patterns_to_ignore = [
|
|||
ignored_files = [
|
||||
# Generated and upstream code combined with our own. Could use cleanup
|
||||
os.path.join(".", "ports", "gonk", "src", "native_window_glue.cpp"),
|
||||
os.path.join(".", "ports", "geckolib", "bindings.rs"),
|
||||
os.path.join(".", "ports", "geckolib", "gecko_style_structs.rs"),
|
||||
os.path.join(".", "ports", "geckolib", "gecko_bindings", "bindings.rs"),
|
||||
os.path.join(".", "ports", "geckolib", "gecko_bindings", "structs.rs"),
|
||||
os.path.join(".", "resources", "hsts_preload.json"),
|
||||
os.path.join(".", "tests", "wpt", "metadata", "MANIFEST.json"),
|
||||
os.path.join(".", "tests", "wpt", "metadata-css", "MANIFEST.json"),
|
||||
|
@ -64,7 +64,7 @@ ignored_dirs = [
|
|||
os.path.join(".", "target"),
|
||||
os.path.join(".", "ports", "cef"),
|
||||
# Tooling, generated locally from external repos.
|
||||
os.path.join(".", "ports", "geckolib", "tools"),
|
||||
os.path.join(".", "ports", "geckolib", "gecko_bindings", "tools"),
|
||||
# Hidden directories
|
||||
os.path.join(".", "."),
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue