@@ -2221,7 +2221,7 @@ fn block_size_is_zero_or_intrinsic(size: &StyleSize, containing_block: &Containi
2221
2221
2222
2222
pub ( crate ) struct IndependentFloatOrAtomicLayoutResult {
2223
2223
pub fragment : BoxFragment ,
2224
- pub baselines : Option < Baselines > ,
2224
+ pub baselines : Baselines ,
2225
2225
pub pbm_sums : LogicalSides < Au > ,
2226
2226
}
2227
2227
@@ -2233,120 +2233,103 @@ impl IndependentFormattingContext {
2233
2233
containing_block : & ContainingBlock ,
2234
2234
) -> IndependentFloatOrAtomicLayoutResult {
2235
2235
let style = self . style ( ) ;
2236
+ let writing_mode = style. writing_mode ;
2236
2237
let container_writing_mode = containing_block. style . writing_mode ;
2237
2238
let layout_style = self . layout_style ( ) ;
2238
2239
let content_box_sizes_and_pbm =
2239
2240
layout_style. content_box_sizes_and_padding_border_margin ( & containing_block. into ( ) ) ;
2240
2241
let pbm = & content_box_sizes_and_pbm. pbm ;
2241
2242
let margin = pbm. margin . auto_is ( Au :: zero) ;
2242
2243
let pbm_sums = pbm. padding + pbm. border + margin;
2244
+ let preferred_aspect_ratio = self . preferred_aspect_ratio ( & pbm. padding_border_sums ) ;
2245
+ let is_table = self . is_table ( ) ;
2243
2246
2244
- let ( fragments, content_rect, baselines) = match & self . contents {
2245
- IndependentFormattingContextContents :: Replaced ( replaced) => {
2246
- // Floats and atomic inlines can't collapse margins with their parent,
2247
- // so don't ignore block margins when resolving a stretch block size.
2248
- // https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing
2249
- let ignore_block_margins_for_stretch = LogicalSides1D :: new ( false , false ) ;
2250
-
2251
- // https://drafts.csswg.org/css2/visudet.html#float-replaced-width
2252
- // https://drafts.csswg.org/css2/visudet.html#inline-replaced-height
2253
- let content_size = replaced
2254
- . used_size_as_if_inline_element (
2255
- containing_block,
2256
- style,
2257
- & content_box_sizes_and_pbm,
2258
- ignore_block_margins_for_stretch,
2259
- )
2260
- . to_physical_size ( container_writing_mode) ;
2261
- let fragments = replaced. make_fragments ( layout_context, style, content_size) ;
2247
+ let available_inline_size =
2248
+ Au :: zero ( ) . max ( containing_block. size . inline - pbm_sums. inline_sum ( ) ) ;
2249
+ let available_block_size = containing_block
2250
+ . size
2251
+ . block
2252
+ . to_definite ( )
2253
+ . map ( |block_size| Au :: zero ( ) . max ( block_size - pbm_sums. block_sum ( ) ) ) ;
2262
2254
2263
- let content_rect = PhysicalRect :: new ( PhysicalPoint :: zero ( ) , content_size) ;
2264
- ( fragments, content_rect, None )
2265
- } ,
2266
- IndependentFormattingContextContents :: NonReplaced ( non_replaced) => {
2267
- let writing_mode = self . style ( ) . writing_mode ;
2268
- let available_inline_size =
2269
- Au :: zero ( ) . max ( containing_block. size . inline - pbm_sums. inline_sum ( ) ) ;
2270
- let available_block_size = containing_block
2271
- . size
2272
- . block
2273
- . to_definite ( )
2274
- . map ( |block_size| Au :: zero ( ) . max ( block_size - pbm_sums. block_sum ( ) ) ) ;
2275
- let tentative_block_size = content_box_sizes_and_pbm
2276
- . content_box_sizes
2277
- . block
2278
- . resolve_extrinsic ( Size :: FitContent , Au :: zero ( ) , available_block_size) ;
2279
-
2280
- let get_content_size = || {
2281
- let constraint_space = ConstraintSpace :: new (
2282
- tentative_block_size,
2283
- writing_mode,
2284
- non_replaced. preferred_aspect_ratio ( ) ,
2285
- ) ;
2286
- self . inline_content_sizes ( layout_context, & constraint_space)
2287
- . sizes
2288
- } ;
2255
+ let tentative_block_content_size =
2256
+ self . tentative_block_content_size ( preferred_aspect_ratio) ;
2257
+ let tentative_block_size = if let Some ( block_content_size) = tentative_block_content_size {
2258
+ SizeConstraint :: Definite ( content_box_sizes_and_pbm. content_box_sizes . block . resolve (
2259
+ Direction :: Block ,
2260
+ Size :: FitContent ,
2261
+ Au :: zero,
2262
+ available_block_size,
2263
+ || block_content_size,
2264
+ is_table,
2265
+ ) )
2266
+ } else {
2267
+ content_box_sizes_and_pbm
2268
+ . content_box_sizes
2269
+ . block
2270
+ . resolve_extrinsic ( Size :: FitContent , Au :: zero ( ) , available_block_size)
2271
+ } ;
2289
2272
2290
- let is_table = layout_style. is_table ( ) ;
2291
- let inline_size = content_box_sizes_and_pbm. content_box_sizes . inline . resolve (
2292
- Direction :: Inline ,
2293
- Size :: FitContent ,
2294
- Au :: zero,
2295
- Some ( available_inline_size) ,
2296
- get_content_size,
2297
- is_table,
2298
- ) ;
2273
+ let get_content_size = || {
2274
+ let constraint_space =
2275
+ ConstraintSpace :: new ( tentative_block_size, writing_mode, preferred_aspect_ratio) ;
2276
+ self . inline_content_sizes ( layout_context, & constraint_space)
2277
+ . sizes
2278
+ } ;
2299
2279
2300
- let containing_block_for_children = ContainingBlock {
2301
- size : ContainingBlockSize {
2302
- inline : inline_size,
2303
- block : tentative_block_size,
2304
6D3F
- } ,
2305
- style : self . style ( ) ,
2306
- } ;
2307
- assert_eq ! (
2308
- container_writing_mode. is_horizontal( ) ,
2309
- writing_mode. is_horizontal( ) ,
2310
- "Mixed horizontal and vertical writing modes are not supported yet"
2311
- ) ;
2280
+ let inline_size = content_box_sizes_and_pbm. content_box_sizes . inline . resolve (
2281
+ Direction :: Inline ,
2282
+ Size :: FitContent ,
2283
+ Au :: zero,
2284
+ Some ( available_inline_size) ,
2285
+ get_content_size,
2286
+ is_table,
2287
+ ) ;
2312
2288
2313
- let lazy_block_size = LazySize :: new (
2314
- & content_box_sizes_and_pbm. content_box_sizes . block ,
2315
- Direction :: Block ,
2316
- Size :: FitContent ,
2317
- Au :: zero,
2318
- available_block_size,
2319
- is_table,
2320
- ) ;
2289
+ let containing_block_for_children = ContainingBlock {
2290
+ size : ContainingBlockSize {
2291
+ inline : inline_size,
2292
+ block : tentative_block_size,
2293
+ } ,
2294
+ style,
2295
+ } ;
2296
+ assert_eq ! (
2297
+ container_writing_mode. is_horizontal( ) ,
2298
+ writing_mode. is_horizontal( ) ,
2299
+ "Mixed horizontal and vertical writing modes are not supported yet"
2300
+ ) ;
2321
2301
2322
- let independent_layout = non_replaced. layout (
2323
- layout_context,
2324
- child_positioning_context,
2325
- & containing_block_for_children,
2326
- containing_block,
2327
- & self . base ,
2328
- false , /* depends_on_block_constraints */
2329
- & lazy_block_size,
2330
- ) ;
2331
- let inline_size = independent_layout
2332
- . content_inline_size_for_table
2333
- . unwrap_or ( inline_size) ;
2334
- let block_size = lazy_block_size. resolve ( || independent_layout. content_block_size ) ;
2302
+ let lazy_block_size = LazySize :: new (
2303
+ & content_box_sizes_and_pbm. content_box_sizes . block ,
2304
+ Direction :: Block ,
2305
+ Size :: FitContent ,
2306
+ Au :: zero,
2307
+ available_block_size,
2308
+ is_table,
2309
+ ) ;
2335
2310
2336
- let content_size = LogicalVec2 {
2337
- block : block_size,
2338
- inline : inline_size,
2339
- }
2340
- . to_physical_size ( container_writing_mode) ;
2341
- let content_rect = PhysicalRect :: new ( PhysicalPoint :: zero ( ) , content_size) ;
2311
+ let CacheableLayoutResult {
2312
+ content_inline_size_for_table,
2313
+ content_block_size,
2314
+ fragments,
2315
+ baselines,
2316
+ ..
2317
+ } = self . layout (
2318
+ layout_context,
2319
+ child_positioning_context,
2320
+ & containing_block_for_children,
2321
+ containing_block,
2322
+ preferred_aspect_ratio,
2323
+ false , /* depends_on_block_constraints */
2324
+ & lazy_block_size,
2325
+ ) ;
2342
2326
2343
- (
2344
- independent_layout. fragments ,
2345
- content_rect,
2346
- Some ( independent_layout. baselines ) ,
2347
- )
2348
- } ,
2349
- } ;
2327
+ let content_size = LogicalVec2 {
2328
+ inline : content_inline_size_for_table. unwrap_or ( inline_size) ,
2329
+ block : lazy_block_size. resolve ( || content_block_size) ,
2330
+ }
2331
+ . to_physical_size ( container_writing_mode) ;
2332
+ let content_rect = PhysicalRect :: new ( PhysicalPoint :: zero ( ) , content_size) ;
2350
2333
2351
2334
let mut base_fragment_info = self . base_fragment_info ( ) ;
2352
2335
if content_box_sizes_and_pbm. depends_on_block_constraints {
@@ -2357,7 +2340,7 @@ impl IndependentFormattingContext {
2357
2340
2358
2341
let fragment = BoxFragment :: new (
2359
2342
base_fragment_info,
2360
- self . style ( ) . clone ( ) ,
2343
+ style. clone ( ) ,
2361
2344
fragments,
2362
2345
content_rect,
2363
2346
pbm. padding . to_physical ( container_writing_mode) ,
0 commit comments