Attachment #8822387: part 3. Add a default ComputedValues member to PerDocumentStyleData for bug #1298588

View | Details | Raw Unified | Return to bug 1298588
Collapse All | Expand All

(-)a/layout/style/ServoBindings.cpp (+7 lines)
Line     Link Here 
 Lines 1027-1042   NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSS Link Here 
1027
                                                                              \
1027
                                                                              \
1028
void                                                                          \
1028
void                                                                          \
1029
Gecko_Construct_nsStyle##name(nsStyle##name* ptr)                             \
1029
Gecko_Construct_nsStyle##name(nsStyle##name* ptr)                             \
1030
{                                                                             \
1030
{                                                                             \
1031
  new (ptr) nsStyle##name(StyleStructContext::ServoContext());                \
1031
  new (ptr) nsStyle##name(StyleStructContext::ServoContext());                \
1032
}                                                                             \
1032
}                                                                             \
1033
                                                                              \
1033
                                                                              \
1034
void                                                                          \
1034
void                                                                          \
1035
Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr,                     \
1036
                                      const nsPresContext* pres_context)      \
1037
{                                                                             \
1038
  new (ptr) nsStyle##name(pres_context);                                      \
1039
}                                                                             \
1040
                                                                              \
1041
void                                                                          \
1035
Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                         \
1042
Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                         \
1036
                                  const nsStyle##name* other)                 \
1043
                                  const nsStyle##name* other)                 \
1037
{                                                                             \
1044
{                                                                             \
1038
  new (ptr) nsStyle##name(*other);                                            \
1045
  new (ptr) nsStyle##name(*other);                                            \
1039
}                                                                             \
1046
}                                                                             \
1040
                                                                              \
1047
                                                                              \
1041
void                                                                          \
1048
void                                                                          \
1042
Gecko_Destroy_nsStyle##name(nsStyle##name* ptr)                               \
1049
Gecko_Destroy_nsStyle##name(nsStyle##name* ptr)                               \
(-)a/layout/style/ServoBindings.h (+3 lines)
Line     Link Here 
 Lines 279-294   void Gecko_CSSValue_SetAngle(nsCSSValueB Link Here 
279
void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
279
void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
280
void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
280
void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
281
nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
281
nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
282
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
282
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
283
283
284
// Style-struct management.
284
// Style-struct management.
285
#define STYLE_STRUCT(name, checkdata_cb)                                       \
285
#define STYLE_STRUCT(name, checkdata_cb)                                       \
286
  void Gecko_Construct_nsStyle##name(nsStyle##name* ptr);                      \
286
  void Gecko_Construct_nsStyle##name(nsStyle##name* ptr);                      \
287
  void Gecko_Construct_Default_nsStyle##name(                                  \
288
    nsStyle##name* ptr,                                                        \
289
    RawGeckoPresContextBorrowed pres_context);                                 \
287
  void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                   \
290
  void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                   \
288
                                         const nsStyle##name* other);          \
291
                                         const nsStyle##name* other);          \
289
  void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
292
  void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
290
#include "nsStyleStructList.h"
293
#include "nsStyleStructList.h"
291
#undef STYLE_STRUCT
294
#undef STYLE_STRUCT
292
295
293
#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
296
#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
294
#include "mozilla/ServoBindingList.h"
297
#include "mozilla/ServoBindingList.h"
(-)a/servo/components/style/gecko/data.rs (-1 / +5 lines)
Line     Link Here 
 Lines 16-31   use rayon; Link Here 
16
use std::cmp;
16
use std::cmp;
17
use std::collections::HashMap;
17
use std::collections::HashMap;
18
use std::env;
18
use std::env;
19
use std::sync::Arc;
19
use std::sync::Arc;
20
use std::sync::mpsc::{Receiver, Sender, channel};
20
use std::sync::mpsc::{Receiver, Sender, channel};
21
use style_traits::ViewportPx;
21
use style_traits::ViewportPx;
22
use stylesheets::Stylesheet;
22
use stylesheets::Stylesheet;
23
use stylist::Stylist;
23
use stylist::Stylist;
24
use properties::ComputedValues;
24
25
25
pub struct PerDocumentStyleDataImpl {
26
pub struct PerDocumentStyleDataImpl {
26
    /// Rule processor.
27
    /// Rule processor.
27
    pub stylist: Arc<Stylist>,
28
    pub stylist: Arc<Stylist>,
28
29
29
    /// List of stylesheets, mirrored from Gecko.
30
    /// List of stylesheets, mirrored from Gecko.
30
    pub stylesheets: Vec<Arc<Stylesheet>>,
31
    pub stylesheets: Vec<Arc<Stylesheet>>,
31
32
 Lines 37-67   pub struct PerDocumentStyleDataImpl { Link Here 
37
    pub new_animations_receiver: Receiver<Animation>,
38
    pub new_animations_receiver: Receiver<Animation>,
38
    pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
39
    pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
39
    pub expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
40
    pub expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
40
41
41
    // FIXME(bholley): This shouldn't be per-document.
42
    // FIXME(bholley): This shouldn't be per-document.
42
    pub work_queue: Option<rayon::ThreadPool>,
43
    pub work_queue: Option<rayon::ThreadPool>,
43
44
44
    pub num_threads: usize,
45
    pub num_threads: usize,
46
47
    // Default computed values.
48
    pub default_computed_values: Arc<ComputedValues>
45
}
49
}
46
50
47
pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
51
pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
48
52
49
lazy_static! {
53
lazy_static! {
50
    pub static ref NUM_THREADS: usize = {
54
    pub static ref NUM_THREADS: usize = {
51
        match env::var("STYLO_THREADS").map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS")) {
55
        match env::var("STYLO_THREADS").map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS")) {
52
            Ok(num) => num,
56
            Ok(num) => num,
53
            _ => cmp::max(num_cpus::get() * 3 / 4, 1),
57
            _ => cmp::max(num_cpus::get() * 3 / 4, 1),
54
        }
58
        }
55
    };
59
    };
56
}
60
}
57
61
58
impl PerDocumentStyleData {
62
impl PerDocumentStyleData {
59
    #[allow(unused_variables)] // temporary until we make use of the ctor arg.
60
    pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
63
    pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
61
        // FIXME(bholley): Real window size.
64
        // FIXME(bholley): Real window size.
62
        let window_size: TypedSize2D<f32, ViewportPx> = TypedSize2D::new(800.0, 600.0);
65
        let window_size: TypedSize2D<f32, ViewportPx> = TypedSize2D::new(800.0, 600.0);
63
        let device = Device::new(MediaType::Screen, window_size);
66
        let device = Device::new(MediaType::Screen, window_size);
64
67
65
        let (new_anims_sender, new_anims_receiver) = channel();
68
        let (new_anims_sender, new_anims_receiver) = channel();
66
69
67
        PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
70
        PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
 Lines 75-90   impl PerDocumentStyleData { Link Here 
75
            work_queue: if *NUM_THREADS <= 1 {
78
            work_queue: if *NUM_THREADS <= 1 {
76
                None
79
                None
77
            } else {
80
            } else {
78
                let configuration =
81
                let configuration =
79
                    rayon::Configuration::new().set_num_threads(*NUM_THREADS);
82
                    rayon::Configuration::new().set_num_threads(*NUM_THREADS);
80
                rayon::ThreadPool::new(configuration).ok()
83
                rayon::ThreadPool::new(configuration).ok()
81
            },
84
            },
82
            num_threads: *NUM_THREADS,
85
            num_threads: *NUM_THREADS,
86
            default_computed_values: ComputedValues::default_values(pres_context),
83
        }))
87
        }))
84
    }
88
    }
85
89
86
    pub fn borrow(&self) -> AtomicRef<PerDocumentStyleDataImpl> {
90
    pub fn borrow(&self) -> AtomicRef<PerDocumentStyleDataImpl> {
87
        self.0.borrow()
91
        self.0.borrow()
88
    }
92
    }
89
93
90
    pub fn borrow_mut(&self) -> AtomicRefMut<PerDocumentStyleDataImpl> {
94
    pub fn borrow_mut(&self) -> AtomicRefMut<PerDocumentStyleDataImpl> {
(-)a/servo/components/style/gecko_bindings/bindings.rs (+126 lines)
Line     Link Here 
 Lines 709-963   extern "C" { Link Here 
709
extern "C" {
709
extern "C" {
710
    pub fn Gecko_ReleaseCSSValueSharedListArbitraryThread(aPtr:
710
    pub fn Gecko_ReleaseCSSValueSharedListArbitraryThread(aPtr:
711
                                                              *mut nsCSSValueSharedList);
711
                                                              *mut nsCSSValueSharedList);
712
}
712
}
713
extern "C" {
713
extern "C" {
714
    pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);
714
    pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);
715
}
715
}
716
extern "C" {
716
extern "C" {
717
    pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
718
                                               pres_context:
719
                                                   RawGeckoPresContextBorrowed);
720
}
721
extern "C" {
717
    pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
722
    pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
718
                                           other: *const nsStyleFont);
723
                                           other: *const nsStyleFont);
719
}
724
}
720
extern "C" {
725
extern "C" {
721
    pub fn Gecko_Destroy_nsStyleFont(ptr: *mut nsStyleFont);
726
    pub fn Gecko_Destroy_nsStyleFont(ptr: *mut nsStyleFont);
722
}
727
}
723
extern "C" {
728
extern "C" {
724
    pub fn Gecko_Construct_nsStyleColor(ptr: *mut nsStyleColor);
729
    pub fn Gecko_Construct_nsStyleColor(ptr: *mut nsStyleColor);
725
}
730
}
726
extern "C" {
731
extern "C" {
732
    pub fn Gecko_Construct_Default_nsStyleColor(ptr: *mut nsStyleColor,
733
                                                pres_context:
734
                                                    RawGeckoPresContextBorrowed);
735
}
736
extern "C" {
727
    pub fn Gecko_CopyConstruct_nsStyleColor(ptr: *mut nsStyleColor,
737
    pub fn Gecko_CopyConstruct_nsStyleColor(ptr: *mut nsStyleColor,
728
                                            other: *const nsStyleColor);
738
                                            other: *const nsStyleColor);
729
}
739
}
730
extern "C" {
740
extern "C" {
731
    pub fn Gecko_Destroy_nsStyleColor(ptr: *mut nsStyleColor);
741
    pub fn Gecko_Destroy_nsStyleColor(ptr: *mut nsStyleColor);
732
}
742
}
733
extern "C" {
743
extern "C" {
734
    pub fn Gecko_Construct_nsStyleList(ptr: *mut nsStyleList);
744
    pub fn Gecko_Construct_nsStyleList(ptr: *mut nsStyleList);
735
}
745
}
736
extern "C" {
746
extern "C" {
747
    pub fn Gecko_Construct_Default_nsStyleList(ptr: *mut nsStyleList,
748
                                               pres_context:
749
                                                   RawGeckoPresContextBorrowed);
750
}
751
extern "C" {
737
    pub fn Gecko_CopyConstruct_nsStyleList(ptr: *mut nsStyleList,
752
    pub fn Gecko_CopyConstruct_nsStyleList(ptr: *mut nsStyleList,
738
                                           other: *const nsStyleList);
753
                                           other: *const nsStyleList);
739
}
754
}
740
extern "C" {
755
extern "C" {
741
    pub fn Gecko_Destroy_nsStyleList(ptr: *mut nsStyleList);
756
    pub fn Gecko_Destroy_nsStyleList(ptr: *mut nsStyleList);
742
}
757
}
743
extern "C" {
758
extern "C" {
744
    pub fn Gecko_Construct_nsStyleText(ptr: *mut nsStyleText);
759
    pub fn Gecko_Construct_nsStyleText(ptr: *mut nsStyleText);
745
}
760
}
746
extern "C" {
761
extern "C" {
762
    pub fn Gecko_Construct_Default_nsStyleText(ptr: *mut nsStyleText,
763
                                               pres_context:
764
                                                   RawGeckoPresContextBorrowed);
765
}
766
extern "C" {
747
    pub fn Gecko_CopyConstruct_nsStyleText(ptr: *mut nsStyleText,
767
    pub fn Gecko_CopyConstruct_nsStyleText(ptr: *mut nsStyleText,
748
                                           other: *const nsStyleText);
768
                                           other: *const nsStyleText);
749
}
769
}
750
extern "C" {
770
extern "C" {
751
    pub fn Gecko_Destroy_nsStyleText(ptr: *mut nsStyleText);
771
    pub fn Gecko_Destroy_nsStyleText(ptr: *mut nsStyleText);
752
}
772
}
753
extern "C" {
773
extern "C" {
754
    pub fn Gecko_Construct_nsStyleVisibility(ptr: *mut nsStyleVisibility);
774
    pub fn Gecko_Construct_nsStyleVisibility(ptr: *mut nsStyleVisibility);
755
}
775
}
756
extern "C" {
776
extern "C" {
777
    pub fn Gecko_Construct_Default_nsStyleVisibility(ptr:
778
                                                         *mut nsStyleVisibility,
779
                                                     pres_context:
780
                                                         RawGeckoPresContextBorrowed);
781
}
782
extern "C" {
757
    pub fn Gecko_CopyConstruct_nsStyleVisibility(ptr: *mut nsStyleVisibility,
783
    pub fn Gecko_CopyConstruct_nsStyleVisibility(ptr: *mut nsStyleVisibility,
758
                                                 other:
784
                                                 other:
759
                                                     *const nsStyleVisibility);
785
                                                     *const nsStyleVisibility);
760
}
786
}
761
extern "C" {
787
extern "C" {
762
    pub fn Gecko_Destroy_nsStyleVisibility(ptr: *mut nsStyleVisibility);
788
    pub fn Gecko_Destroy_nsStyleVisibility(ptr: *mut nsStyleVisibility);
763
}
789
}
764
extern "C" {
790
extern "C" {
765
    pub fn Gecko_Construct_nsStyleUserInterface(ptr:
791
    pub fn Gecko_Construct_nsStyleUserInterface(ptr:
766
                                                    *mut nsStyleUserInterface);
792
                                                    *mut nsStyleUserInterface);
767
}
793
}
768
extern "C" {
794
extern "C" {
795
    pub fn Gecko_Construct_Default_nsStyleUserInterface(ptr:
796
                                                            *mut nsStyleUserInterface,
797
                                                        pres_context:
798
                                                            RawGeckoPresContextBorrowed);
799
}
800
extern "C" {
769
    pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
801
    pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
770
                                                        *mut nsStyleUserInterface,
802
                                                        *mut nsStyleUserInterface,
771
                                                    other:
803
                                                    other:
772
                                                        *const nsStyleUserInterface);
804
                                                        *const nsStyleUserInterface);
773
}
805
}
774
extern "C" {
806
extern "C" {
775
    pub fn Gecko_Destroy_nsStyleUserInterface(ptr: *mut nsStyleUserInterface);
807
    pub fn Gecko_Destroy_nsStyleUserInterface(ptr: *mut nsStyleUserInterface);
776
}
808
}
777
extern "C" {
809
extern "C" {
778
    pub fn Gecko_Construct_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
810
    pub fn Gecko_Construct_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
779
}
811
}
780
extern "C" {
812
extern "C" {
813
    pub fn Gecko_Construct_Default_nsStyleTableBorder(ptr:
814
                                                          *mut nsStyleTableBorder,
815
                                                      pres_context:
816
                                                          RawGeckoPresContextBorrowed);
817
}
818
extern "C" {
781
    pub fn Gecko_CopyConstruct_nsStyleTableBorder(ptr:
819
    pub fn Gecko_CopyConstruct_nsStyleTableBorder(ptr:
782
                                                      *mut nsStyleTableBorder,
820
                                                      *mut nsStyleTableBorder,
783
                                                  other:
821
                                                  other:
784
                                                      *const nsStyleTableBorder);
822
                                                      *const nsStyleTableBorder);
785
}
823
}
786
extern "C" {
824
extern "C" {
787
    pub fn Gecko_Destroy_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
825
    pub fn Gecko_Destroy_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
788
}
826
}
789
extern "C" {
827
extern "C" {
790
    pub fn Gecko_Construct_nsStyleSVG(ptr: *mut nsStyleSVG);
828
    pub fn Gecko_Construct_nsStyleSVG(ptr: *mut nsStyleSVG);
791
}
829
}
792
extern "C" {
830
extern "C" {
831
    pub fn Gecko_Construct_Default_nsStyleSVG(ptr: *mut nsStyleSVG,
832
                                              pres_context:
833
                                                  RawGeckoPresContextBorrowed);
834
}
835
extern "C" {
793
    pub fn Gecko_CopyConstruct_nsStyleSVG(ptr: *mut nsStyleSVG,
836
    pub fn Gecko_CopyConstruct_nsStyleSVG(ptr: *mut nsStyleSVG,
794
                                          other: *const nsStyleSVG);
837
                                          other: *const nsStyleSVG);
795
}
838
}
796
extern "C" {
839
extern "C" {
797
    pub fn Gecko_Destroy_nsStyleSVG(ptr: *mut nsStyleSVG);
840
    pub fn Gecko_Destroy_nsStyleSVG(ptr: *mut nsStyleSVG);
798
}
841
}
799
extern "C" {
842
extern "C" {
800
    pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables);
843
    pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables);
801
}
844
}
802
extern "C" {
845
extern "C" {
846
    pub fn Gecko_Construct_Default_nsStyleVariables(ptr:
847
                                                        *mut nsStyleVariables,
848
                                                    pres_context:
849
                                                        RawGeckoPresContextBorrowed);
850
}
851
extern "C" {
803
    pub fn Gecko_CopyConstruct_nsStyleVariables(ptr: *mut nsStyleVariables,
852
    pub fn Gecko_CopyConstruct_nsStyleVariables(ptr: *mut nsStyleVariables,
804
                                                other:
853
                                                other:
805
                                                    *const nsStyleVariables);
854
                                                    *const nsStyleVariables);
806
}
855
}
807
extern "C" {
856
extern "C" {
808
    pub fn Gecko_Destroy_nsStyleVariables(ptr: *mut nsStyleVariables);
857
    pub fn Gecko_Destroy_nsStyleVariables(ptr: *mut nsStyleVariables);
809
}
858
}
810
extern "C" {
859
extern "C" {
811
    pub fn Gecko_Construct_nsStyleBackground(ptr: *mut nsStyleBackground);
860
    pub fn Gecko_Construct_nsStyleBackground(ptr: *mut nsStyleBackground);
812
}
861
}
813
extern "C" {
862
extern "C" {
863
    pub fn Gecko_Construct_Default_nsStyleBackground(ptr:
864
                                                         *mut nsStyleBackground,
865
                                                     pres_context:
866
                                                         RawGeckoPresContextBorrowed);
867
}
868
extern "C" {
814
    pub fn Gecko_CopyConstruct_nsStyleBackground(ptr: *mut nsStyleBackground,
869
    pub fn Gecko_CopyConstruct_nsStyleBackground(ptr: *mut nsStyleBackground,
815
                                                 other:
870
                                                 other:
816
                                                     *const nsStyleBackground);
871
                                                     *const nsStyleBackground);
817
}
872
}
818
extern "C" {
873
extern "C" {
819
    pub fn Gecko_Destroy_nsStyleBackground(ptr: *mut nsStyleBackground);
874
    pub fn Gecko_Destroy_nsStyleBackground(ptr: *mut nsStyleBackground);
820
}
875
}
821
extern "C" {
876
extern "C" {
822
    pub fn Gecko_Construct_nsStylePosition(ptr: *mut nsStylePosition);
877
    pub fn Gecko_Construct_nsStylePosition(ptr: *mut nsStylePosition);
823
}
878
}
824
extern "C" {
879
extern "C" {
880
    pub fn Gecko_Construct_Default_nsStylePosition(ptr: *mut nsStylePosition,
881
                                                   pres_context:
882
                                                       RawGeckoPresContextBorrowed);
883
}
884
extern "C" {
825
    pub fn Gecko_CopyConstruct_nsStylePosition(ptr: *mut nsStylePosition,
885
    pub fn Gecko_CopyConstruct_nsStylePosition(ptr: *mut nsStylePosition,
826
                                               other: *const nsStylePosition);
886
                                               other: *const nsStylePosition);
827
}
887
}
828
extern "C" {
888
extern "C" {
829
    pub fn Gecko_Destroy_nsStylePosition(ptr: *mut nsStylePosition);
889
    pub fn Gecko_Destroy_nsStylePosition(ptr: *mut nsStylePosition);
830
}
890
}
831
extern "C" {
891
extern "C" {
832
    pub fn Gecko_Construct_nsStyleTextReset(ptr: *mut nsStyleTextReset);
892
    pub fn Gecko_Construct_nsStyleTextReset(ptr: *mut nsStyleTextReset);
833
}
893
}
834
extern "C" {
894
extern "C" {
895
    pub fn Gecko_Construct_Default_nsStyleTextReset(ptr:
896
                                                        *mut nsStyleTextReset,
897
                                                    pres_context:
898
                                                        RawGeckoPresContextBorrowed);
899
}
900
extern "C" {
835
    pub fn Gecko_CopyConstruct_nsStyleTextReset(ptr: *mut nsStyleTextReset,
901
    pub fn Gecko_CopyConstruct_nsStyleTextReset(ptr: *mut nsStyleTextReset,
836
                                                other:
902
                                                other:
837
                                                    *const nsStyleTextReset);
903
                                                    *const nsStyleTextReset);
838
}
904
}
839
extern "C" {
905
extern "C" {
840
    pub fn Gecko_Destroy_nsStyleTextReset(ptr: *mut nsStyleTextReset);
906
    pub fn Gecko_Destroy_nsStyleTextReset(ptr: *mut nsStyleTextReset);
841
}
907
}
842
extern "C" {
908
extern "C" {
843
    pub fn Gecko_Construct_nsStyleDisplay(ptr: *mut nsStyleDisplay);
909
    pub fn Gecko_Construct_nsStyleDisplay(ptr: *mut nsStyleDisplay);
844
}
910
}
845
extern "C" {
911
extern "C" {
912
    pub fn Gecko_Construct_Default_nsStyleDisplay(ptr: *mut nsStyleDisplay,
913
                                                  pres_context:
914
                                                      RawGeckoPresContextBorrowed);
915
}
916
extern "C" {
846
    pub fn Gecko_CopyConstruct_nsStyleDisplay(ptr: *mut nsStyleDisplay,
917
    pub fn Gecko_CopyConstruct_nsStyleDisplay(ptr: *mut nsStyleDisplay,
847
                                              other: *const nsStyleDisplay);
918
                                              other: *const nsStyleDisplay);
848
}
919
}
849
extern "C" {
920
extern "C" {
850
    pub fn Gecko_Destroy_nsStyleDisplay(ptr: *mut nsStyleDisplay);
921
    pub fn Gecko_Destroy_nsStyleDisplay(ptr: *mut nsStyleDisplay);
851
}
922
}
852
extern "C" {
923
extern "C" {
853
    pub fn Gecko_Construct_nsStyleContent(ptr: *mut nsStyleContent);
924
    pub fn Gecko_Construct_nsStyleContent(ptr: *mut nsStyleContent);
854
}
925
}
855
extern "C" {
926
extern "C" {
927
    pub fn Gecko_Construct_Default_nsStyleContent(ptr: *mut nsStyleContent,
928
                                                  pres_context:
929
                                                      RawGeckoPresContextBorrowed);
930
}
931
extern "C" {
856
    pub fn Gecko_CopyConstruct_nsStyleContent(ptr: *mut nsStyleContent,
932
    pub fn Gecko_CopyConstruct_nsStyleContent(ptr: *mut nsStyleContent,
857
                                              other: *const nsStyleContent);
933
                                              other: *const nsStyleContent);
858
}
934
}
859
extern "C" {
935
extern "C" {
860
    pub fn Gecko_Destroy_nsStyleContent(ptr: *mut nsStyleContent);
936
    pub fn Gecko_Destroy_nsStyleContent(ptr: *mut nsStyleContent);
861
}
937
}
862
extern "C" {
938
extern "C" {
863
    pub fn Gecko_Construct_nsStyleUIReset(ptr: *mut nsStyleUIReset);
939
    pub fn Gecko_Construct_nsStyleUIReset(ptr: *mut nsStyleUIReset);
864
}
940
}
865
extern "C" {
941
extern "C" {
942
    pub fn Gecko_Construct_Default_nsStyleUIReset(ptr: *mut nsStyleUIReset,
943
                                                  pres_context:
944
                                                      RawGeckoPresContextBorrowed);
945
}
946
extern "C" {
866
    pub fn Gecko_CopyConstruct_nsStyleUIReset(ptr: *mut nsStyleUIReset,
947
    pub fn Gecko_CopyConstruct_nsStyleUIReset(ptr: *mut nsStyleUIReset,
867
                                              other: *const nsStyleUIReset);
948
                                              other: *const nsStyleUIReset);
868
}
949
}
869
extern "C" {
950
extern "C" {
870
    pub fn Gecko_Destroy_nsStyleUIReset(ptr: *mut nsStyleUIReset);
951
    pub fn Gecko_Destroy_nsStyleUIReset(ptr: *mut nsStyleUIReset);
871
}
952
}
872
extern "C" {
953
extern "C" {
873
    pub fn Gecko_Construct_nsStyleTable(ptr: *mut nsStyleTable);
954
    pub fn Gecko_Construct_nsStyleTable(ptr: *mut nsStyleTable);
874
}
955
}
875
extern "C" {
956
extern "C" {
957
    pub fn Gecko_Construct_Default_nsStyleTable(ptr: *mut nsStyleTable,
958
                                                pres_context:
959
                                                    RawGeckoPresContextBorrowed);
960
}
961
extern "C" {
876
    pub fn Gecko_CopyConstruct_nsStyleTable(ptr: *mut nsStyleTable,
962
    pub fn Gecko_CopyConstruct_nsStyleTable(ptr: *mut nsStyleTable,
877
                                            other: *const nsStyleTable);
963
                                            other: *const nsStyleTable);
878
}
964
}
879
extern "C" {
965
extern "C" {
880
    pub fn Gecko_Destroy_nsStyleTable(ptr: *mut nsStyleTable);
966
    pub fn Gecko_Destroy_nsStyleTable(ptr: *mut nsStyleTable);
881
}
967
}
882
extern "C" {
968
extern "C" {
883
    pub fn Gecko_Construct_nsStyleMargin(ptr: *mut nsStyleMargin);
969
    pub fn Gecko_Construct_nsStyleMargin(ptr: *mut nsStyleMargin);
884
}
970
}
885
extern "C" {
971
extern "C" {
972
    pub fn Gecko_Construct_Default_nsStyleMargin(ptr: *mut nsStyleMargin,
973
                                                 pres_context:
974
                                                     RawGeckoPresContextBorrowed);
975
}
976
extern "C" {
886
    pub fn Gecko_CopyConstruct_nsStyleMargin(ptr: *mut nsStyleMargin,
977
    pub fn Gecko_CopyConstruct_nsStyleMargin(ptr: *mut nsStyleMargin,
887
                                             other: *const nsStyleMargin);
978
                                             other: *const nsStyleMargin);
888
}
979
}
889
extern "C" {
980
extern "C" {
890
    pub fn Gecko_Destroy_nsStyleMargin(ptr: *mut nsStyleMargin);
981
    pub fn Gecko_Destroy_nsStyleMargin(ptr: *mut nsStyleMargin);
891
}
982
}
892
extern "C" {
983
extern "C" {
893
    pub fn Gecko_Construct_nsStylePadding(ptr: *mut nsStylePadding);
984
    pub fn Gecko_Construct_nsStylePadding(ptr: *mut nsStylePadding);
894
}
985
}
895
extern "C" {
986
extern "C" {
987
    pub fn Gecko_Construct_Default_nsStylePadding(ptr: *mut nsStylePadding,
988
                                                  pres_context:
989
                                                      RawGeckoPresContextBorrowed);
990
}
991
extern "C" {
896
    pub fn Gecko_CopyConstruct_nsStylePadding(ptr: *mut nsStylePadding,
992
    pub fn Gecko_CopyConstruct_nsStylePadding(ptr: *mut nsStylePadding,
897
                                              other: *const nsStylePadding);
993
                                              other: *const nsStylePadding);
898
}
994
}
899
extern "C" {
995
extern "C" {
900
    pub fn Gecko_Destroy_nsStylePadding(ptr: *mut nsStylePadding);
996
    pub fn Gecko_Destroy_nsStylePadding(ptr: *mut nsStylePadding);
901
}
997
}
902
extern "C" {
998
extern "C" {
903
    pub fn Gecko_Construct_nsStyleBorder(ptr: *mut nsStyleBorder);
999
    pub fn Gecko_Construct_nsStyleBorder(ptr: *mut nsStyleBorder);
904
}
1000
}
905
extern "C" {
1001
extern "C" {
1002
    pub fn Gecko_Construct_Default_nsStyleBorder(ptr: *mut nsStyleBorder,
1003
                                                 pres_context:
1004
                                                     RawGeckoPresContextBorrowed);
1005
}
1006
extern "C" {
906
    pub fn Gecko_CopyConstruct_nsStyleBorder(ptr: *mut nsStyleBorder,
1007
    pub fn Gecko_CopyConstruct_nsStyleBorder(ptr: *mut nsStyleBorder,
907
                                             other: *const nsStyleBorder);
1008
                                             other: *const nsStyleBorder);
908
}
1009
}
909
extern "C" {
1010
extern "C" {
910
    pub fn Gecko_Destroy_nsStyleBorder(ptr: *mut nsStyleBorder);
1011
    pub fn Gecko_Destroy_nsStyleBorder(ptr: *mut nsStyleBorder);
911
}
1012
}
912
extern "C" {
1013
extern "C" {
913
    pub fn Gecko_Construct_nsStyleOutline(ptr: *mut nsStyleOutline);
1014
    pub fn Gecko_Construct_nsStyleOutline(ptr: *mut nsStyleOutline);
914
}
1015
}
915
extern "C" {
1016
extern "C" {
1017
    pub fn Gecko_Construct_Default_nsStyleOutline(ptr: *mut nsStyleOutline,
1018
                                                  pres_context:
1019
                                                      RawGeckoPresContextBorrowed);
1020
}
1021
extern "C" {
916
    pub fn Gecko_CopyConstruct_nsStyleOutline(ptr: *mut nsStyleOutline,
1022
    pub fn Gecko_CopyConstruct_nsStyleOutline(ptr: *mut nsStyleOutline,
917
                                              other: *const nsStyleOutline);
1023
                                              other: *const nsStyleOutline);
918
}
1024
}
919
extern "C" {
1025
extern "C" {
920
    pub fn Gecko_Destroy_nsStyleOutline(ptr: *mut nsStyleOutline);
1026
    pub fn Gecko_Destroy_nsStyleOutline(ptr: *mut nsStyleOutline);
921
}
1027
}
922
extern "C" {
1028
extern "C" {
923
    pub fn Gecko_Construct_nsStyleXUL(ptr: *mut nsStyleXUL);
1029
    pub fn Gecko_Construct_nsStyleXUL(ptr: *mut nsStyleXUL);
924
}
1030
}
925
extern "C" {
1031
extern "C" {
1032
    pub fn Gecko_Construct_Default_nsStyleXUL(ptr: *mut nsStyleXUL,
1033
                                              pres_context:
1034
                                                  RawGeckoPresContextBorrowed);
1035
}
1036
extern "C" {
926
    pub fn Gecko_CopyConstruct_nsStyleXUL(ptr: *mut nsStyleXUL,
1037
    pub fn Gecko_CopyConstruct_nsStyleXUL(ptr: *mut nsStyleXUL,
927
                                          other: *const nsStyleXUL);
1038
                                          other: *const nsStyleXUL);
928
}
1039
}
929
extern "C" {
1040
extern "C" {
930
    pub fn Gecko_Destroy_nsStyleXUL(ptr: *mut nsStyleXUL);
1041
    pub fn Gecko_Destroy_nsStyleXUL(ptr: *mut nsStyleXUL);
931
}
1042
}
932
extern "C" {
1043
extern "C" {
933
    pub fn Gecko_Construct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
1044
    pub fn Gecko_Construct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
934
}
1045
}
935
extern "C" {
1046
extern "C" {
1047
    pub fn Gecko_Construct_Default_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
1048
                                                   pres_context:
1049
                                                       RawGeckoPresContextBorrowed);
1050
}
1051
extern "C" {
936
    pub fn Gecko_CopyConstruct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
1052
    pub fn Gecko_CopyConstruct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
937
                                               other: *const nsStyleSVGReset);
1053
                                               other: *const nsStyleSVGReset);
938
}
1054
}
939
extern "C" {
1055
extern "C" {
940
    pub fn Gecko_Destroy_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
1056
    pub fn Gecko_Destroy_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
941
}
1057
}
942
extern "C" {
1058
extern "C" {
943
    pub fn Gecko_Construct_nsStyleColumn(ptr: *mut nsStyleColumn);
1059
    pub fn Gecko_Construct_nsStyleColumn(ptr: *mut nsStyleColumn);
944
}
1060
}
945
extern "C" {
1061
extern "C" {
1062
    pub fn Gecko_Construct_Default_nsStyleColumn(ptr: *mut nsStyleColumn,
1063
                                                 pres_context:
1064
                                                     RawGeckoPresContextBorrowed);
1065
}
1066
extern "C" {
946
    pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
1067
    pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
947
                                             other: *const nsStyleColumn);
1068
                                             other: *const nsStyleColumn);
948
}
1069
}
949
extern "C" {
1070
extern "C" {
950
    pub fn Gecko_Destroy_nsStyleColumn(ptr: *mut nsStyleColumn);
1071
    pub fn Gecko_Destroy_nsStyleColumn(ptr: *mut nsStyleColumn);
951
}
1072
}
952
extern "C" {
1073
extern "C" {
953
    pub fn Gecko_Construct_nsStyleEffects(ptr: *mut nsStyleEffects);
1074
    pub fn Gecko_Construct_nsStyleEffects(ptr: *mut nsStyleEffects);
954
}
1075
}
955
extern "C" {
1076
extern "C" {
1077
    pub fn Gecko_Construct_Default_nsStyleEffects(ptr: *mut nsStyleEffects,
1078
                                                  pres_context:
1079
                                                      RawGeckoPresContextBorrowed);
1080
}
1081
extern "C" {
956
    pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
1082
    pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
957
                                              other: *const nsStyleEffects);
1083
                                              other: *const nsStyleEffects);
958
}
1084
}
959
extern "C" {
1085
extern "C" {
960
    pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
1086
    pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
961
}
1087
}
962
extern "C" {
1088
extern "C" {
963
    pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
1089
    pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
(-)a/servo/components/style/properties/gecko.mako.rs (+22 lines)
Line     Link Here 
 Lines 11-26    Link Here 
11
<%namespace name="helpers" file="/helpers.mako.rs" />
11
<%namespace name="helpers" file="/helpers.mako.rs" />
12
12
13
use app_units::Au;
13
use app_units::Au;
14
use custom_properties::ComputedValuesMap;
14
use custom_properties::ComputedValuesMap;
15
use gecko_bindings::bindings;
15
use gecko_bindings::bindings;
16
% for style_struct in data.style_structs:
16
% for style_struct in data.style_structs:
17
use gecko_bindings::structs::${style_struct.gecko_ffi_name};
17
use gecko_bindings::structs::${style_struct.gecko_ffi_name};
18
use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
18
use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
19
use gecko_bindings::bindings::Gecko_Construct_Default_${style_struct.gecko_ffi_name};
19
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
20
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
20
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
21
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
21
% endfor
22
% endfor
22
use gecko_bindings::bindings::Gecko_Construct_nsStyleVariables;
23
use gecko_bindings::bindings::Gecko_Construct_nsStyleVariables;
23
use gecko_bindings::bindings::Gecko_CopyCursorArrayFrom;
24
use gecko_bindings::bindings::Gecko_CopyCursorArrayFrom;
24
use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
25
use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
25
use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
26
use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
26
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
27
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
 Lines 35-50   use gecko_bindings::bindings::Gecko_SetC Link Here 
35
use gecko_bindings::bindings::Gecko_NewCSSShadowArray;
36
use gecko_bindings::bindings::Gecko_NewCSSShadowArray;
36
use gecko_bindings::bindings::Gecko_SetListStyleImage;
37
use gecko_bindings::bindings::Gecko_SetListStyleImage;
37
use gecko_bindings::bindings::Gecko_SetListStyleImageNone;
38
use gecko_bindings::bindings::Gecko_SetListStyleImageNone;
38
use gecko_bindings::bindings::Gecko_SetListStyleType;
39
use gecko_bindings::bindings::Gecko_SetListStyleType;
39
use gecko_bindings::bindings::Gecko_SetMozBinding;
40
use gecko_bindings::bindings::Gecko_SetMozBinding;
40
use gecko_bindings::bindings::Gecko_SetNullImageValue;
41
use gecko_bindings::bindings::Gecko_SetNullImageValue;
41
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
42
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
42
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
43
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
44
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
43
use gecko_bindings::structs;
45
use gecko_bindings::structs;
44
use gecko_bindings::structs::nsStyleVariables;
46
use gecko_bindings::structs::nsStyleVariables;
45
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
47
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
46
use gecko_bindings::sugar::ownership::HasArcFFI;
48
use gecko_bindings::sugar::ownership::HasArcFFI;
47
use gecko::values::convert_nscolor_to_rgba;
49
use gecko::values::convert_nscolor_to_rgba;
48
use gecko::values::convert_rgba_to_nscolor;
50
use gecko::values::convert_rgba_to_nscolor;
49
use gecko::values::GeckoStyleCoordConvertible;
51
use gecko::values::GeckoStyleCoordConvertible;
50
use gecko::values::round_border_to_device_pixels;
52
use gecko::values::round_border_to_device_pixels;
 Lines 122-137   impl ComputedValues { Link Here 
122
124
123
    pub fn initial_values() -> &'static Self {
125
    pub fn initial_values() -> &'static Self {
124
        unsafe {
126
        unsafe {
125
            debug_assert!(!raw_initial_values().is_null());
127
            debug_assert!(!raw_initial_values().is_null());
126
            &*raw_initial_values()
128
            &*raw_initial_values()
127
        }
129
        }
128
    }
130
    }
129
131
132
    pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
133
        Arc::new(ComputedValues {
134
            custom_properties: None,
135
            shareable: true,
136
            writing_mode: WritingMode::empty(), // This seems dubious
137
            root_font_size: longhands::font_size::get_initial_value(), // Also seems dubious?
138
            % for style_struct in data.style_structs:
139
                ${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
140
            % endfor
141
        })
142
    }
143
130
    pub unsafe fn initialize() {
144
    pub unsafe fn initialize() {
131
        debug_assert!(raw_initial_values().is_null());
145
        debug_assert!(raw_initial_values().is_null());
132
        set_raw_initial_values(Box::into_raw(Box::new(ComputedValues {
146
        set_raw_initial_values(Box::into_raw(Box::new(ComputedValues {
133
            % for style_struct in data.style_structs:
147
            % for style_struct in data.style_structs:
134
               ${style_struct.ident}: style_structs::${style_struct.name}::initial(),
148
               ${style_struct.ident}: style_structs::${style_struct.name}::initial(),
135
            % endfor
149
            % endfor
136
            custom_properties: None,
150
            custom_properties: None,
137
            shareable: true,
151
            shareable: true,
 Lines 424-439   impl ${style_struct.gecko_struct_name} { Link Here 
424
    #[allow(dead_code, unused_variables)]
438
    #[allow(dead_code, unused_variables)]
425
    pub fn initial() -> Arc<Self> {
439
    pub fn initial() -> Arc<Self> {
426
        let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
440
        let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
427
        unsafe {
441
        unsafe {
428
            Gecko_Construct_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko);
442
            Gecko_Construct_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko);
429
        }
443
        }
430
        result
444
        result
431
    }
445
    }
446
    #[allow(dead_code, unused_variables)]
447
    pub fn default(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
448
        let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
449
        unsafe {
450
            Gecko_Construct_Default_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko, pres_context);
451
        }
452
        result
453
    }
432
    pub fn get_gecko(&self) -> &${style_struct.gecko_ffi_name} {
454
    pub fn get_gecko(&self) -> &${style_struct.gecko_ffi_name} {
433
        &self.gecko
455
        &self.gecko
434
    }
456
    }
435
}
457
}
436
impl Drop for ${style_struct.gecko_struct_name} {
458
impl Drop for ${style_struct.gecko_struct_name} {
437
    fn drop(&mut self) {
459
    fn drop(&mut self) {
438
        unsafe {
460
        unsafe {
439
            Gecko_Destroy_${style_struct.gecko_ffi_name}(&mut self.gecko);
461
            Gecko_Destroy_${style_struct.gecko_ffi_name}(&mut self.gecko);

Return to bug 1298588