|
|
|
Lines 75-101
pub struct ComputedValues {
|
Link Here
|
|---|
|
| 75 |
|
75 |
|
| 76 |
custom_properties: Option<Arc<ComputedValuesMap>>, |
76 |
custom_properties: Option<Arc<ComputedValuesMap>>, |
| 77 |
shareable: bool, |
77 |
shareable: bool, |
| 78 |
pub writing_mode: WritingMode, |
78 |
pub writing_mode: WritingMode, |
| 79 |
pub root_font_size: Au, |
79 |
pub root_font_size: Au, |
| 80 |
} |
80 |
} |
| 81 |
|
81 |
|
| 82 |
impl ComputedValues { |
82 |
impl ComputedValues { |
| 83 |
pub fn inherit_from(parent: &Arc<Self>) -> Arc<Self> { |
83 |
pub fn inherit_from(parent: &Arc<Self>, default: &Arc<Self>) -> Arc<Self> { |
| 84 |
Arc::new(ComputedValues { |
84 |
Arc::new(ComputedValues { |
| 85 |
custom_properties: parent.custom_properties.clone(), |
85 |
custom_properties: parent.custom_properties.clone(), |
| 86 |
shareable: parent.shareable, |
86 |
shareable: parent.shareable, |
| 87 |
writing_mode: parent.writing_mode, |
87 |
writing_mode: parent.writing_mode, |
| 88 |
root_font_size: parent.root_font_size, |
88 |
root_font_size: parent.root_font_size, |
| 89 |
% for style_struct in data.style_structs: |
89 |
% for style_struct in data.style_structs: |
| 90 |
% if style_struct.inherited: |
90 |
% if style_struct.inherited: |
| 91 |
${style_struct.ident}: parent.${style_struct.ident}.clone(), |
91 |
${style_struct.ident}: parent.${style_struct.ident}.clone(), |
| 92 |
% else: |
92 |
% else: |
| 93 |
${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(), |
93 |
${style_struct.ident}: default.${style_struct.ident}.clone(), |
| 94 |
% endif |
94 |
% endif |
| 95 |
% endfor |
95 |
% endfor |
| 96 |
}) |
96 |
}) |
| 97 |
} |
97 |
} |
| 98 |
|
98 |
|
| 99 |
pub fn new(custom_properties: Option<Arc<ComputedValuesMap>>, |
99 |
pub fn new(custom_properties: Option<Arc<ComputedValuesMap>>, |
| 100 |
shareable: bool, |
100 |
shareable: bool, |
| 101 |
writing_mode: WritingMode, |
101 |
writing_mode: WritingMode, |
|
Lines 110-132
impl ComputedValues {
|
Link Here
|
|---|
|
| 110 |
writing_mode: writing_mode, |
110 |
writing_mode: writing_mode, |
| 111 |
root_font_size: root_font_size, |
111 |
root_font_size: root_font_size, |
| 112 |
% for style_struct in data.style_structs: |
112 |
% for style_struct in data.style_structs: |
| 113 |
${style_struct.ident}: ${style_struct.ident}, |
113 |
${style_struct.ident}: ${style_struct.ident}, |
| 114 |
% endfor |
114 |
% endfor |
| 115 |
} |
115 |
} |
| 116 |
} |
116 |
} |
| 117 |
|
117 |
|
| 118 |
pub fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self> { |
|
|
| 119 |
// Gecko expects text nodes to be styled as if they were elements that |
| 120 |
// matched no rules (that is, inherited style structs are inherited and |
| 121 |
// non-inherited style structs are set to their initial values). |
| 122 |
ComputedValues::inherit_from(parent) |
| 123 |
} |
| 124 |
|
| 125 |
pub fn initial_values() -> &'static Self { |
118 |
pub fn initial_values() -> &'static Self { |
| 126 |
unsafe { |
119 |
unsafe { |
| 127 |
debug_assert!(!raw_initial_values().is_null()); |
120 |
debug_assert!(!raw_initial_values().is_null()); |
| 128 |
&*raw_initial_values() |
121 |
&*raw_initial_values() |
| 129 |
} |
122 |
} |
| 130 |
} |
123 |
} |
| 131 |
|
124 |
|
| 132 |
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> { |
125 |
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> { |