Attachment #8822398: part 11. Pass through useful default styles to CascadePropertyFn for bug #1298588

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

(-)a/servo/components/style/properties/helpers.mako.rs (-1 / +2 lines)
Line     Link Here 
 Lines 196-211    Link Here 
196
        use std::sync::Arc;
196
        use std::sync::Arc;
197
        use values::computed::{Context, ToComputedValue};
197
        use values::computed::{Context, ToComputedValue};
198
        use values::{computed, specified};
198
        use values::{computed, specified};
199
        use Atom;
199
        use Atom;
200
        ${caller.body()}
200
        ${caller.body()}
201
        #[allow(unused_variables)]
201
        #[allow(unused_variables)]
202
        pub fn cascade_property(declaration: &PropertyDeclaration,
202
        pub fn cascade_property(declaration: &PropertyDeclaration,
203
                                inherited_style: &ComputedValues,
203
                                inherited_style: &ComputedValues,
204
                                default_style: &Arc<ComputedValues>,
204
                                context: &mut computed::Context,
205
                                context: &mut computed::Context,
205
                                seen: &mut PropertyBitField,
206
                                seen: &mut PropertyBitField,
206
                                cacheable: &mut bool,
207
                                cacheable: &mut bool,
207
                                cascade_info: &mut Option<<&mut CascadeInfo>,
208
                                cascade_info: &mut Option<<&mut CascadeInfo>,
208
                                error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
209
                                error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
209
            let declared_value = match *declaration {
210
            let declared_value = match *declaration {
210
                PropertyDeclaration::${property.camel_case}(ref declared_value) => {
211
                PropertyDeclaration::${property.camel_case}(ref declared_value) => {
211
                    declared_value
212
                    declared_value
 Lines 246-262    Link Here 
246
                            }
247
                            }
247
                            DeclaredValue::WithVariables { .. } => unreachable!(),
248
                            DeclaredValue::WithVariables { .. } => unreachable!(),
248
                            % if not data.current_style_struct.inherited:
249
                            % if not data.current_style_struct.inherited:
249
                            DeclaredValue::Unset |
250
                            DeclaredValue::Unset |
250
                            % endif
251
                            % endif
251
                            DeclaredValue::Initial => {
252
                            DeclaredValue::Initial => {
252
                                // We assume that it's faster to use copy_*_from rather than
253
                                // We assume that it's faster to use copy_*_from rather than
253
                                // set_*(get_initial_value());
254
                                // set_*(get_initial_value());
254
                                let initial_struct = ComputedValues::initial_values()
255
                                let initial_struct = default_style
255
                                                      .get_${data.current_style_struct.name_lower}();
256
                                                      .get_${data.current_style_struct.name_lower}();
256
                                context.mutate_style().mutate_${data.current_style_struct.name_lower}()
257
                                context.mutate_style().mutate_${data.current_style_struct.name_lower}()
257
                                                      .copy_${property.ident}_from(initial_struct ${maybe_wm});
258
                                                      .copy_${property.ident}_from(initial_struct ${maybe_wm});
258
                            },
259
                            },
259
                            % if data.current_style_struct.inherited:
260
                            % if data.current_style_struct.inherited:
260
                            DeclaredValue::Unset |
261
                            DeclaredValue::Unset |
261
                            % endif
262
                            % endif
262
                            DeclaredValue::Inherit => {
263
                            DeclaredValue::Inherit => {
(-)a/servo/components/style/properties/properties.mako.rs (+2 lines)
Line     Link Here 
 Lines 1480-1495   mod lazy_static_module { Link Here 
1480
            root_font_size: longhands::font_size::get_initial_value(),
1480
            root_font_size: longhands::font_size::get_initial_value(),
1481
        };
1481
        };
1482
    }
1482
    }
1483
}
1483
}
1484
1484
1485
pub type CascadePropertyFn =
1485
pub type CascadePropertyFn =
1486
    extern "Rust" fn(declaration: &PropertyDeclaration,
1486
    extern "Rust" fn(declaration: &PropertyDeclaration,
1487
                     inherited_style: &ComputedValues,
1487
                     inherited_style: &ComputedValues,
1488
                     default_style: &Arc<ComputedValues>,
1488
                     context: &mut computed::Context,
1489
                     context: &mut computed::Context,
1489
                     seen: &mut PropertyBitField,
1490
                     seen: &mut PropertyBitField,
1490
                     cacheable: &mut bool,
1491
                     cacheable: &mut bool,
1491
                     cascade_info: &mut Option<<&mut CascadeInfo>,
1492
                     cascade_info: &mut Option<<&mut CascadeInfo>,
1492
                     error_reporter: &mut StdBox<ParseErrorReporter + Send>);
1493
                     error_reporter: &mut StdBox<ParseErrorReporter + Send>);
1493
1494
1494
#[cfg(feature = "servo")]
1495
#[cfg(feature = "servo")]
1495
static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
1496
static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
 Lines 1681-1696   pub fn apply_declarations<'a, F, I>(view Link Here 
1681
                    is_early_property
1682
                    is_early_property
1682
                {
1683
                {
1683
                    continue
1684
                    continue
1684
                }
1685
                }
1685
1686
1686
                let discriminant = longhand_id as usize;
1687
                let discriminant = longhand_id as usize;
1687
                (cascade_property[discriminant])(declaration,
1688
                (cascade_property[discriminant])(declaration,
1688
                                                 inherited_style,
1689
                                                 inherited_style,
1690
                                                 default_style,
1689
                                                 &mut context,
1691
                                                 &mut context,
1690
                                                 &mut seen,
1692
                                                 &mut seen,
1691
                                                 &mut cacheable,
1693
                                                 &mut cacheable,
1692
                                                 &mut cascade_info,
1694
                                                 &mut cascade_info,
1693
                                                 &mut error_reporter);
1695
                                                 &mut error_reporter);
1694
            }
1696
            }
1695
            % if category_to_cascade_now == "early":
1697
            % if category_to_cascade_now == "early":
1696
                let mode = get_writing_mode(context.style.get_inheritedbox());
1698
                let mode = get_writing_mode(context.style.get_inheritedbox());

Return to bug 1298588