@@ -6,7 +6,8 @@ use euclid::num::Zero;
6
6
pub use float_pigment_css:: length_num:: LengthNum ;
7
7
use float_pigment_css:: {
8
8
parser:: parse_inline_style,
9
- property:: NodeProperties ,
9
+ property:: { NodeProperties , Property , PropertyValueWithGlobal } ,
10
+ sheet:: PropertyMeta ,
10
11
typing:: { AspectRatio , Display , Gap } ,
11
12
} ;
12
13
pub use float_pigment_forest:: Len ;
@@ -169,10 +170,6 @@ impl TextInfoBuilder {
169
170
text_len : 0 ,
170
171
} )
171
172
}
172
- // fn with_text(mut self, text: String) -> Self {
173
- // self.0.raw_text = text;
174
- // self
175
- // }
176
173
fn with_text_len ( mut self , text_len : usize ) -> Self {
177
174
self . 0 . text_len = text_len;
178
175
self
@@ -181,11 +178,22 @@ impl TextInfoBuilder {
181
178
self . 0 . font_size = font_size;
182
179
self
183
180
}
181
+ fn set_font_size ( & mut self , font_size : f32 ) {
182
+ self . 0 . font_size = font_size;
183
+ }
184
184
fn build ( self ) -> TextInfo {
185
185
self . 0
186
186
}
187
187
}
188
188
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
+
189
197
#[ inline( always) ]
190
198
fn prepare_measure_node ( node : * mut Node , text_info : TextInfo ) {
191
199
let node = unsafe { & mut * node } ;
@@ -361,8 +369,14 @@ impl TestCtx {
361
369
match cur {
362
370
NodeType :: Text ( t) => {
363
371
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 ( ) ) ;
366
380
node
367
381
}
368
382
NodeType :: Element ( e) => {
@@ -443,8 +457,48 @@ impl TestCtx {
443
457
style,
444
458
float_pigment_css:: parser:: StyleParsingDebugMode :: None ,
445
459
) ;
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
+ }
446
496
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
+ ) ;
448
502
match p. get_property_name ( ) . to_string ( ) . as_str ( ) {
449
503
"display" => node. set_display ( node_props. display ( ) ) ,
450
504
"box-sizing" => node. set_box_sizing ( node_props. box_sizing ( ) ) ,
0 commit comments