In the current spec text for css-overflow-4, which only describes continue: discard (not yet continue: collapse as described in #7708), both line-clamp and the legacy -webkit-line-clamp property are shorthands for other properties, including max-lines. This means that if both are specified on some element, whichever wins in the cascade will be applied.
However, this leads to unexpected results. Consider the following:
display: block;
line-clamp: 3;
-webkit-line-clamp: 4;
Since line-clamp and -webkit-line-clamp are shorthands for the same set of properties, -webkit-line-clamp will win. This means that max-lines will have a specified value of 4, but also that continue will have a specified value of -webkit-discard – which will cause the continue property (and by extension, max-lines) to not take effect, because display is not set to -webkit-box.
My current implementation of continue: collapse in Blink (see #7708) implements both line-clamp and -webkit-line-clamp as longhands which don't alias. If both are present (and not specified to none) on some box, line-clamp wins. AFAIU this behavior wouldn't be possible to specify while making (-webkit-)line-clamp shorthands, unless we make a separate -webkit-max-lines property.
If we want to keep the shorthands, while making the code above actually work, my understanding is that -webkit-line-clamp would have to be specified such that it sets the longhands if display: -webkit-box and -webkit-box-orient: vertical are set, and to not be a shorthand for anything otherwise.
cc @frivoal
In the current spec text for css-overflow-4, which only describes
continue: discard(not yetcontinue: collapseas described in #7708), bothline-clampand the legacy-webkit-line-clampproperty are shorthands for other properties, includingmax-lines. This means that if both are specified on some element, whichever wins in the cascade will be applied.However, this leads to unexpected results. Consider the following:
Since
line-clampand-webkit-line-clampare shorthands for the same set of properties,-webkit-line-clampwill win. This means thatmax-lineswill have a specified value of4, but also thatcontinuewill have a specified value of-webkit-discard– which will cause thecontinueproperty (and by extension,max-lines) to not take effect, becausedisplayis not set to-webkit-box.My current implementation of
continue: collapsein Blink (see #7708) implements bothline-clampand-webkit-line-clampas longhands which don't alias. If both are present (and not specified tonone) on some box,line-clampwins. AFAIU this behavior wouldn't be possible to specify while making(-webkit-)line-clampshorthands, unless we make a separate-webkit-max-linesproperty.If we want to keep the shorthands, while making the code above actually work, my understanding is that
-webkit-line-clampwould have to be specified such that it sets the longhands ifdisplay: -webkit-boxand-webkit-box-orient: verticalare set, and to not be a shorthand for anything otherwise.cc @frivoal