Attachment #8822388: part 4. Recreate the default computed values for a document as needed for bug #1298588

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

(-)a/layout/base/ServoRestyleManager.cpp (+12 lines)
Line     Link Here 
 Lines 82-97   ServoRestyleManager::PostRestyleEventFor Link Here 
82
  PostRestyleEventInternal(true);
82
  PostRestyleEventInternal(true);
83
}
83
}
84
84
85
void
85
void
86
ServoRestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
86
ServoRestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
87
                                         nsRestyleHint aRestyleHint)
87
                                         nsRestyleHint aRestyleHint)
88
{
88
{
89
  NS_WARNING("stylo: ServoRestyleManager::RebuildAllStyleData not implemented");
89
  NS_WARNING("stylo: ServoRestyleManager::RebuildAllStyleData not implemented");
90
  // That said, we do know that rebuilding all style data in Gecko would get rid
91
  // of the old ruletree, and hence of the cached-on-the-root default computed
92
  // styles.  So we know we need to clear them here.  I think this is the only
93
  // way they could get cleared, in fact, though not _all_ calls that come
94
  // through here may need to clear them in practice.
95
  //
96
  // We probably need to do some actual restyling here too, though.  And figure
97
  // out whether it actually matters that we may be recomputing the default
98
  // styles in too many cases.  For one thing, we do a bunch of eager work here,
99
  // whereas we should really just set a bit that says to recompute the default
100
  // computed styles before the next time we restyle anything!
101
  StyleSet()->RecomputeDefaultComputedStyles();
90
}
102
}
91
103
92
void
104
void
93
ServoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
105
ServoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
94
                                                  nsRestyleHint aRestyleHint)
106
                                                  nsRestyleHint aRestyleHint)
95
{
107
{
96
  NS_WARNING("stylo: ServoRestyleManager::PostRebuildAllStyleDataEvent not implemented");
108
  NS_WARNING("stylo: ServoRestyleManager::PostRebuildAllStyleDataEvent not implemented");
97
}
109
}
(-)a/layout/style/ServoBindingList.h (+3 lines)
Line     Link Here 
 Lines 32-47   SERVO_BINDING_FUNC(Servo_StyleSheet_From Link Here 
32
                   ThreadSafeURIHolder* base,
32
                   ThreadSafeURIHolder* base,
33
                   ThreadSafeURIHolder* referrer,
33
                   ThreadSafeURIHolder* referrer,
34
                   ThreadSafePrincipalHolder* principal)
34
                   ThreadSafePrincipalHolder* principal)
35
SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
35
SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
36
                   RawServoStyleSheetBorrowed sheet)
36
                   RawServoStyleSheetBorrowed sheet)
37
SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
37
SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
38
                   RawServoStyleSheetBorrowed sheet)
38
                   RawServoStyleSheetBorrowed sheet)
39
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextBorrowed pres_context)
39
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextBorrowed pres_context)
40
SERVO_BINDING_FUNC(Servo_StyleSet_RecomputeDefaultStyles, void,
41
                   RawServoStyleSetBorrowed set,
42
                   RawGeckoPresContextBorrowed pres_context)
40
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
43
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
41
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
44
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
42
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
45
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
43
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
46
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
44
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
47
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
45
SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
48
SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
46
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
49
                   RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush)
47
SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
50
SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
(-)a/layout/style/ServoStyleSet.cpp (+6 lines)
Line     Link Here 
 Lines 520-527   ServoStyleSet::NoteStyleSheetsChanged() Link Here 
520
void
520
void
521
ServoStyleSet::AssertTreeIsClean()
521
ServoStyleSet::AssertTreeIsClean()
522
{
522
{
523
  if (Element* root = mPresContext->Document()->GetRootElement()) {
523
  if (Element* root = mPresContext->Document()->GetRootElement()) {
524
    Servo_AssertTreeIsClean(root);
524
    Servo_AssertTreeIsClean(root);
525
  }
525
  }
526
}
526
}
527
#endif
527
#endif
528
529
void
530
ServoStyleSet::RecomputeDefaultComputedStyles()
531
{
532
  Servo_StyleSet_RecomputeDefaultStyles(mRawSet.get(), mPresContext);
533
}
(-)a/layout/style/ServoStyleSet.h (+6 lines)
Line     Link Here 
 Lines 150-165   public: Link Here 
150
  void NoteStyleSheetsChanged();
150
  void NoteStyleSheetsChanged();
151
151
152
#ifdef DEBUG
152
#ifdef DEBUG
153
  void AssertTreeIsClean();
153
  void AssertTreeIsClean();
154
#else
154
#else
155
  void AssertTreeIsClean() {}
155
  void AssertTreeIsClean() {}
156
#endif
156
#endif
157
157
158
  /**
159
   * Recompute our default computed styles.  This will eagerly create a new set
160
   * of default computed style structs.
161
   */
162
  void RecomputeDefaultComputedStyles();
163
158
private:
164
private:
159
  already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
165
  already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
160
                                              nsStyleContext* aParentContext,
166
                                              nsStyleContext* aParentContext,
161
                                              nsIAtom* aPseudoTag,
167
                                              nsIAtom* aPseudoTag,
162
                                              CSSPseudoElementType aPseudoType);
168
                                              CSSPseudoElementType aPseudoType);
163
169
164
  already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,
170
  already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,
165
                                              nsStyleContext* aParentContext,
171
                                              nsStyleContext* aParentContext,
(-)a/servo/components/style/gecko_bindings/bindings.rs (+6 lines)
Line     Link Here 
 Lines 1115-1130   extern "C" { Link Here 
1115
    pub fn Servo_StyleSheet_GetRules(sheet: RawServoStyleSheetBorrowed)
1115
    pub fn Servo_StyleSheet_GetRules(sheet: RawServoStyleSheetBorrowed)
1116
     -> ServoCssRulesStrong;
1116
     -> ServoCssRulesStrong;
1117
}
1117
}
1118
extern "C" {
1118
extern "C" {
1119
    pub fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
1119
    pub fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
1120
     -> RawServoStyleSetOwned;
1120
     -> RawServoStyleSetOwned;
1121
}
1121
}
1122
extern "C" {
1122
extern "C" {
1123
    pub fn Servo_StyleSet_RecomputeDefaultStyles(set:
1124
                                                     RawServoStyleSetBorrowed,
1125
                                                 pres_context:
1126
                                                     RawGeckoPresContextBorrowed);
1127
}
1128
extern "C" {
1123
    pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
1129
    pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
1124
                                           sheet: RawServoStyleSheetBorrowed,
1130
                                           sheet: RawServoStyleSheetBorrowed,
1125
                                           flush: bool);
1131
                                           flush: bool);
1126
}
1132
}
1127
extern "C" {
1133
extern "C" {
1128
    pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed,
1134
    pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed,
1129
                                            sheet: RawServoStyleSheetBorrowed,
1135
                                            sheet: RawServoStyleSheetBorrowed,
1130
                                            flush: bool);
1136
                                            flush: bool);
(-)a/servo/ports/geckolib/glue.rs (+8 lines)
Line     Link Here 
 Lines 543-558   pub extern "C" fn Servo_ComputedValues_R Link Here 
543
#[no_mangle]
543
#[no_mangle]
544
pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
544
pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
545
  -> RawServoStyleSetOwned {
545
  -> RawServoStyleSetOwned {
546
    let data = Box::new(PerDocumentStyleData::new(pres_context));
546
    let data = Box::new(PerDocumentStyleData::new(pres_context));
547
    data.into_ffi()
547
    data.into_ffi()
548
}
548
}
549
549
550
#[no_mangle]
550
#[no_mangle]
551
pub extern "C" fn Servo_StyleSet_RecomputeDefaultStyles(
552
  raw_data: RawServoStyleSetBorrowed,
553
  pres_context: RawGeckoPresContextBorrowed) {
554
    let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
555
    data.default_computed_values = ComputedValues::default_values(pres_context);
556
}
557
558
#[no_mangle]
551
pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
559
pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
552
    let _ = data.into_box::<PerDocumentStyleData>();
560
    let _ = data.into_box::<PerDocumentStyleData>();
553
}
561
}
554
562
555
563
556
#[no_mangle]
564
#[no_mangle]
557
pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const nsACString,
565
pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const nsACString,
558
                                      base_url: *const nsACString, base: *mut ThreadSafeURIHolder,
566
                                      base_url: *const nsACString, base: *mut ThreadSafeURIHolder,

Return to bug 1298588