@@ -1295,7 +1295,7 @@ export class StylePolicy {
1295
1295
* @returns { boolean | object } Wether or not size is controlled via layout and if so, the concrete policy.
1296
1296
*/
1297
1297
isResizedByLayout ( aSubmorph ) {
1298
- const layout = aSubmorph . owner && aSubmorph . owner . layout ;
1298
+ let layout = aSubmorph . owner && aSubmorph . owner . layout ;
1299
1299
let heightPolicy = 'fixed' ; let widthPolicy = 'fixed' ;
1300
1300
if ( aSubmorph . isText ) {
1301
1301
if ( ! aSubmorph . fixedHeight ) heightPolicy = 'hug' ;
@@ -1306,6 +1306,19 @@ export class StylePolicy {
1306
1306
if ( widthPolicy !== 'hug' ) widthPolicy = layout . getResizeWidthPolicyFor ( aSubmorph ) ;
1307
1307
if ( heightPolicy === 'fill' || widthPolicy === 'fill' ) return { widthPolicy, heightPolicy } ;
1308
1308
}
1309
+
1310
+ layout = aSubmorph . layout ;
1311
+
1312
+ if ( layout ?. hugContentsVertically ||
1313
+ layout ?. hugContentsHorizontally ||
1314
+ widthPolicy === 'hug' ||
1315
+ heightPolicy === 'hug' ) {
1316
+ return {
1317
+ widthPolicy : layout ?. hugContentsHorizontally ? 'hug' : widthPolicy ,
1318
+ heightPolicy : layout ?. hugContentsVertically ? 'hug' : heightPolicy
1319
+ } ;
1320
+ }
1321
+
1309
1322
return false ;
1310
1323
}
1311
1324
@@ -1498,8 +1511,17 @@ export class PolicyApplicator extends StylePolicy {
1498
1511
if ( propName === 'position' && this . isPositionedByLayout ( morphToBeStyled ) ) continue ;
1499
1512
let resizePolicy ;
1500
1513
if ( propName === 'extent' && ( resizePolicy = this . isResizedByLayout ( morphToBeStyled ) ) ) {
1501
- if ( resizePolicy . widthPolicy === 'fixed' && morphToBeStyled . width !== propValue . x ) morphToBeStyled . width = propValue . x ;
1502
- if ( resizePolicy . heightPolicy === 'fixed' && morphToBeStyled . height !== propValue . y ) morphToBeStyled . height = propValue . y ;
1514
+ morphToBeStyled . withMetaDo ( { deferLayoutApplication : true } , ( ) => {
1515
+ if ( resizePolicy . widthPolicy === 'fixed' && morphToBeStyled . width !== propValue . x ) {
1516
+ morphToBeStyled . width = propValue . x ;
1517
+ }
1518
+ if ( resizePolicy . heightPolicy === 'fixed' && morphToBeStyled . height !== propValue . y ) {
1519
+ morphToBeStyled . height = propValue . y ;
1520
+ }
1521
+ if ( morphToBeStyled . isText && ( resizePolicy . widthPolicy === 'hug' || resizePolicy . heightPolicy === 'hug' ) ) {
1522
+ morphToBeStyled . withMetaDo ( { doNotFit : false } , ( ) => morphToBeStyled . fit ( ) ) ;
1523
+ }
1524
+ } ) ;
1503
1525
continue ;
1504
1526
}
1505
1527
@@ -1514,32 +1536,11 @@ export class PolicyApplicator extends StylePolicy {
1514
1536
if ( propName === 'position' ) continue ;
1515
1537
}
1516
1538
1517
- // FIXME: other special cases??
1518
- if ( morphToBeStyled . isText && propName === 'extent' ) {
1519
- if ( ! morphToBeStyled . fixedWidth && ! morphToBeStyled . fixedHeight ) continue ;
1520
- if ( ! morphToBeStyled . fixedWidth ) propValue = propValue . withX ( morphToBeStyled . width ) ;
1521
- if ( ! morphToBeStyled . fixedHeight ) propValue = propValue . withY ( morphToBeStyled . height ) ;
1522
- }
1523
-
1524
- if ( morphToBeStyled . isText && propName === 'width' && morphToBeStyled . lineWrapping !== 'no-wrap' ) {
1525
- if ( ! morphToBeStyled . fixedWidth ) continue ;
1526
- morphToBeStyled . width = propValue ;
1527
- morphToBeStyled . withMetaDo ( { doNotFit : false } , ( ) => morphToBeStyled . fit ( ) ) ;
1528
- }
1529
-
1530
1539
if ( [ 'border' , 'borderTop' , 'borderBottom' , 'borderRight' , 'borderLeft' ] . includes ( propName ) ) continue ; // handled by sub props;
1531
1540
1532
1541
if ( ! obj . equals ( morphToBeStyled [ propName ] , propValue ) ) {
1533
1542
morphToBeStyled [ propName ] = propValue ;
1534
1543
}
1535
-
1536
- // we may be late for the game when setting these props
1537
- // se we need to make sure, we restore the morphs "intended extent"
1538
- // for this purpose we enforce the masterSubmorph extent
1539
- if ( [ 'fixedHeight' , 'fixedWidth' ] . includes ( propName ) &&
1540
- morphToBeStyled . _parametrizedProps ?. extent ) {
1541
- morphToBeStyled . extent = morphToBeStyled . _parametrizedProps . extent ;
1542
- }
1543
1544
}
1544
1545
}
1545
1546
0 commit comments