Remove text style stack from LayoutContext

This commit is contained in:
Nathan Sobo 2023-08-29 21:33:08 -06:00
parent 81957c49d5
commit 42cd257287

View file

@ -3463,7 +3463,6 @@ pub struct LayoutContext<'a, 'b, 'c, V> {
pub view_context: &'c mut ViewContext<'a, 'b, V>, pub view_context: &'c mut ViewContext<'a, 'b, V>,
new_parents: &'c mut HashMap<usize, usize>, new_parents: &'c mut HashMap<usize, usize>,
views_to_notify_if_ancestors_change: &'c mut HashMap<usize, SmallVec<[usize; 2]>>, views_to_notify_if_ancestors_change: &'c mut HashMap<usize, SmallVec<[usize; 2]>>,
text_style_stack: Vec<TextStyle>,
pub refreshing: bool, pub refreshing: bool,
} }
@ -3478,7 +3477,6 @@ impl<'a, 'b, 'c, V> LayoutContext<'a, 'b, 'c, V> {
view_context, view_context,
new_parents, new_parents,
views_to_notify_if_ancestors_change, views_to_notify_if_ancestors_change,
text_style_stack: Vec::new(),
refreshing, refreshing,
} }
} }
@ -3544,18 +3542,19 @@ impl<'a, 'b, 'c, V> LayoutContext<'a, 'b, 'c, V> {
impl<'a, 'b, 'c, V> RenderContext<'a, 'b, V> for LayoutContext<'a, 'b, 'c, V> { impl<'a, 'b, 'c, V> RenderContext<'a, 'b, V> for LayoutContext<'a, 'b, 'c, V> {
fn text_style(&self) -> TextStyle { fn text_style(&self) -> TextStyle {
self.text_style_stack self.window
.text_style_stack
.last() .last()
.cloned() .cloned()
.unwrap_or(TextStyle::default(&self.font_cache)) .unwrap_or(TextStyle::default(&self.font_cache))
} }
fn push_text_style(&mut self, style: TextStyle) { fn push_text_style(&mut self, style: TextStyle) {
self.text_style_stack.push(style); self.window.text_style_stack.push(style);
} }
fn pop_text_style(&mut self) { fn pop_text_style(&mut self) {
self.text_style_stack.pop(); self.window.text_style_stack.pop();
} }
fn as_view_context(&mut self) -> &mut ViewContext<'a, 'b, V> { fn as_view_context(&mut self) -> &mut ViewContext<'a, 'b, V> {