diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 0b07131d6ff7..e8b0d8902c78 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -4719,9 +4719,8 @@ f f - > -HasAnyStateBits +HasLineClampEllipsis ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ) ; } @@ -4754,9 +4753,8 @@ return aBlockFrame - > -HasAnyStateBits +HasLineClampEllipsis ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ) ; } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index e3e3a852acc7..6ec16e3781cf 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -6454,8 +6454,6 @@ nsIFrame aFrame ) { -if -( const nsBlockFrame * @@ -6465,29 +6463,51 @@ do_QueryFrame ( aFrame ) +; +if +( +! +block ) { +return +nullptr +; +} if ( -! block - > -HasAnyStateBits +HasAllStateBits ( -NS_BLOCK_BFC +NS_FRAME_OUT_OF_FLOW ) ) { return -block +nullptr ; } -} +if +( +block +- +> +HasAllStateBits +( +NS_BLOCK_BFC +) +) +{ return nullptr ; } +return +block +; +} static nsBlockFrame * @@ -7239,104 +7259,129 @@ aFrame { if ( -! aFrame - > -HasAnyStateBits +HasLineClampEllipsis ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ) ) { +MOZ_ASSERT +( +! +aFrame +- +> +HasLineClampEllipsisDescendant +( +) +) +; for ( -nsIFrame -* -f +auto +& +line : aFrame - > -PrincipalChildList +Lines ( ) ) { if ( -nsBlockFrame -* -child -= -GetAsLineClampDescendant +line +. +HasLineClampEllipsis ( -f ) ) { -if -( -ClearLineClampEllipsis +line +. +ClearHasLineClampEllipsis ( -child ) +; +aFrame +- +> +SetHasLineClampEllipsis +( +false ) -{ +; return true ; } } } -return -false -; -} +if +( aFrame - > -RemoveStateBits +HasLineClampEllipsisDescendant ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS +) +) +{ +aFrame +- +> +SetHasLineClampEllipsisDescendant +( +false ) ; for ( -auto -& -line +nsIFrame +* +f : aFrame - > -Lines +PrincipalChildList ( ) ) { if ( -line -. -HasLineClampEllipsis +nsBlockFrame +* +child += +GetAsLineClampDescendant ( +f ) ) { -line -. -ClearHasLineClampEllipsis +if +( +ClearLineClampEllipsis ( +child ) -; +) +{ return true ; } } +} +} return -true +false ; } void @@ -10203,21 +10248,10 @@ PhysicalSize ; } } -if -( -aReflowInput -. -mStyleDisplay -- -> -mWebkitLineClamp -) -{ ClearLineClampEllipsis ( ) ; -} CheckFloats ( state @@ -10354,9 +10388,8 @@ MOZ_ASSERT aFrame - > -HasAnyStateBits +HasLineClampEllipsis ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ) " Should @@ -10583,9 +10616,9 @@ SetHasLineClampEllipsis target - > -AddStateBits +SetHasLineClampEllipsis ( -NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS +true ) ; nscoord @@ -10618,6 +10651,45 @@ GetParent ) ) { +MOZ_ASSERT +( +f +- +> +IsBlockFrameOrSubclass +( +) +" +GetAsLineClampDescendant +guarantees +this +" +) +; +if +( +f +! += +target +) +{ +static_cast +< +nsBlockFrame +* +> +( +f +) +- +> +SetHasLineClampEllipsisDescendant +( +true +) +; +} if ( f @@ -37070,6 +37142,9 @@ aDepth int32_t & aDrawnLines +bool +& +aFoundLineClamp ) { # @@ -37225,6 +37300,60 @@ GetNextSibling } if ( +aFrame +- +> +HasLineClampEllipsisDescendant +( +) +& +& +! +aLineInLine +) +{ +if +( +nsBlockFrame +* +f += +GetAsLineClampDescendant +( +aLine +- +> +mFirstChild +) +) +{ +if +( +f +- +> +HasLineClampEllipsis +( +) +| +| +f +- +> +HasLineClampEllipsisDescendant +( +) +) +{ +aFoundLineClamp += +true +; +} +} +} +if +( aTextOverflow & & @@ -37697,6 +37826,16 @@ isSome | | backplateColor +| +| +HasLineClampEllipsis +( +) +| +| +HasLineClampEllipsisDescendant +( +) ) ? nullptr @@ -37731,6 +37870,11 @@ ptrOr nullptr ) ; +bool +foundClamp += +false +; if ( cursor @@ -37834,6 +37978,13 @@ nullptr 0 depth drawnLines +foundClamp +) +; +MOZ_ASSERT +( +! +foundClamp ) ; } @@ -37972,6 +38123,7 @@ textOverflowPtr lineCount depth drawnLines +foundClamp ) ; } @@ -38134,6 +38286,26 @@ lineBackplate } } } +foundClamp += +foundClamp +| +| +line +- +> +HasLineClampEllipsis +( +) +; +if +( +foundClamp +) +{ +break +; +} lineCount + + diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index e6b1477d3a3e..61bca0eebb60 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -1906,6 +1906,60 @@ MaybeHasFloats ) const ; +bool +HasLineClampEllipsis +( +) +const +{ +return +HasAnyStateBits +( +NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS +) +; +} +bool +HasLineClampEllipsisDescendant +( +) +const +{ +return +HasAnyStateBits +( +NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS_DESCENDANT +) +; +} +void +SetHasLineClampEllipsis +( +bool +aValue +) +{ +AddOrRemoveStateBits +( +NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS +aValue +) +; +} +void +SetHasLineClampEllipsisDescendant +( +bool +aValue +) +{ +AddOrRemoveStateBits +( +NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS_DESCENDANT +aValue +) +; +} protected : nsBlockFrame diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index bdfd0c242410..f9265a6ee77a 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -679,25 +679,31 @@ NS_BLOCK_NEEDS_BIDI_RESOLUTION FRAME_STATE_BIT ( Block -60 +30 NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ) FRAME_STATE_BIT ( Block -61 +31 +NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS_DESCENDANT +) +FRAME_STATE_BIT +( +Block +60 NS_BLOCK_LOOK_FOR_DIRTY_FRAMES ) FRAME_STATE_BIT ( Block -62 +61 NS_BLOCK_INTRINSICS_INFLATED ) FRAME_STATE_BIT ( Block -63 +62 NS_BLOCK_HAS_FIRST_LETTER_CHILD ) FRAME_STATE_GROUP diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/webkit-line-clamp-040-ref.html b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/webkit-line-clamp-040-ref.html index 211bece6d8d7..595c27d2c8be 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/reference/webkit-line-clamp-040-ref.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/reference/webkit-line-clamp-040-ref.html @@ -69,12 +69,6 @@ 1 Line 2 -Line -3 -Line -4 -Line -5 < / div diff --git a/testing/web-platform/tests/css/css-overflow/line-clamp/webkit-line-clamp-050.html b/testing/web-platform/tests/css/css-overflow/line-clamp/webkit-line-clamp-050.html index 4dd01285adfd..414e7b1a1889 100644 --- a/testing/web-platform/tests/css/css-overflow/line-clamp/webkit-line-clamp-050.html +++ b/testing/web-platform/tests/css/css-overflow/line-clamp/webkit-line-clamp-050.html @@ -158,28 +158,6 @@ 15px ; } -span -{ -/ -* -TODO -: -Remove -once -we -don -' -t -paint -clamped -lines -* -/ -color -: -transparent -; -} < / style @@ -200,27 +178,13 @@ < br > -< -span -> Line3 < / -span -> -< -/ div > -< -span -> Line4 < -/ -span -> -< div > Line5