@@ -6,7 +6,8 @@ use euclid::num::Zero;
66pub use float_pigment_css:: length_num:: LengthNum ;
77use float_pigment_css:: {
88 parser:: parse_inline_style,
9- property:: NodeProperties ,
9+ property:: { NodeProperties , Property , PropertyValueWithGlobal } ,
10+ sheet:: PropertyMeta ,
1011 typing:: { AspectRatio , Display , Gap } ,
1112} ;
1213pub use float_pigment_forest:: Len ;
@@ -169,10 +170,6 @@ impl TextInfoBuilder {
169170 text_len : 0 ,
170171 } )
171172 }
172- // fn with_text(mut self, text: String) -> Self {
173- // self.0.raw_text = text;
174- // self
175- // }
176173 fn with_text_len ( mut self , text_len : usize ) -> Self {
177174 self . 0 . text_len = text_len;
178175 self
@@ -181,11 +178,22 @@ impl TextInfoBuilder {
181178 self . 0 . font_size = font_size;
182179 self
183180 }
181+ fn set_font_size ( & mut self , font_size : f32 ) {
182+ self . 0 . font_size = font_size;
183+ }
184184 fn build ( self ) -> TextInfo {
185185 self . 0
186186 }
187187}
188188
189+ #[ inline( always) ]
190+ fn convert_font_size_to_px ( font_size : float_pigment_css:: typing:: Length ) -> f32 {
191+ match font_size {
192+ float_pigment_css:: typing:: Length :: Px ( x) => x,
193+ _ => 16. ,
194+ }
195+ }
196+
189197#[ inline( always) ]
190198fn prepare_measure_node ( node : * mut Node , text_info : TextInfo ) {
191199 let node = unsafe { & mut * node } ;
@@ -361,8 +369,14 @@ impl TestCtx {
361369 match cur {
362370 NodeType :: Text ( t) => {
363371 let node = Node :: new_ptr ( ) ;
364- let text_info = TextInfoBuilder :: new ( ) . with_text_len ( t. text ( ) . len ( ) ) . build ( ) ;
365- prepare_measure_node ( node, text_info) ;
372+ let mut text_info_builder = TextInfoBuilder :: new ( ) . with_text_len ( t. text ( ) . len ( ) ) ;
373+ if let Some ( parent_node_props) = parent_node_props {
374+ let font_size = parent_node_props. font_size ( ) ;
375+ if let float_pigment_css:: typing:: Length :: Px ( x) = font_size {
376+ text_info_builder. set_font_size ( x) ;
377+ }
378+ }
379+ prepare_measure_node ( node, text_info_builder. build ( ) ) ;
366380 node
367381 }
368382 NodeType :: Element ( e) => {
@@ -443,8 +457,48 @@ impl TestCtx {
443457 style,
444458 float_pigment_css:: parser:: StyleParsingDebugMode :: None ,
445459 ) ;
460+ let mut font_size_p = float_pigment_css:: typing:: Length :: Px ( 16. ) ;
461+ for pm in props. iter ( ) {
462+ match pm {
463+ PropertyMeta :: Normal { property : p } | PropertyMeta :: Important { property : p } => {
464+ if let Property :: FontSize ( x) = p {
465+ font_size_p = x
466+ . to_inner (
467+ parent_node_props. map ( |p| p. font_size ( ) ) . as_ref ( ) ,
468+ float_pigment_css:: typing:: Length :: Px ( 16. ) ,
469+ true ,
470+ )
471+ . unwrap ( ) ;
472+ }
473+ }
474+ PropertyMeta :: DebugGroup {
475+ properties,
476+ disabled,
477+ ..
478+ } => {
479+ if !disabled {
480+ for p in & * * properties {
481+ if let Property :: FontSize ( x) = p {
482+ font_size_p = x
483+ . clone ( )
484+ . to_inner (
485+ parent_node_props. map ( |p| p. font_size ( ) ) . as_ref ( ) ,
486+ float_pigment_css:: typing:: Length :: Px ( 16. ) ,
487+ true ,
488+ )
489+ . unwrap ( ) ;
490+ }
491+ }
492+ }
493+ }
494+ } ;
495+ }
446496 props. iter ( ) . for_each ( |p| {
447- p. merge_to_node_properties ( node_props, parent_node_props, 16. ) ;
497+ p. merge_to_node_properties (
498+ node_props,
499+ parent_node_props,
500+ convert_font_size_to_px ( font_size_p. clone ( ) ) ,
501+ ) ;
448502 match p. get_property_name ( ) . to_string ( ) . as_str ( ) {
449503 "display" => node. set_display ( node_props. display ( ) ) ,
450504 "box-sizing" => node. set_box_sizing ( node_props. box_sizing ( ) ) ,
0 commit comments