@@ -1176,12 +1176,17 @@ static LogicalSize CalculateContainingBlockSizeForAbsolutes(
1176
1176
1177
1177
1178
1178
static const nsBlockFrame* GetAsLineClampDescendant (const nsIFrame* aFrame) {
1179
- if (const nsBlockFrame* block = do_QueryFrame (aFrame)) {
1180
- if (!block->HasAnyStateBits (NS_BLOCK_BFC)) {
1181
- return block;
1182
- }
1179
+ const nsBlockFrame* block = do_QueryFrame (aFrame);
1180
+ if (!block) {
1181
+ return nullptr ;
1183
1182
}
1184
- return nullptr ;
1183
+ if (block->HasAllStateBits (NS_FRAME_OUT_OF_FLOW)) {
1184
+ return nullptr ;
1185
+ }
1186
+ if (block->HasAllStateBits (NS_BLOCK_BFC)) {
1187
+ return nullptr ;
1188
+ }
1189
+ return block;
1185
1190
}
1186
1191
1187
1192
static nsBlockFrame* GetAsLineClampDescendant (nsIFrame* aFrame) {
@@ -1343,28 +1348,30 @@ class MOZ_RAII LineClampLineIterator {
1343
1348
};
1344
1349
1345
1350
static bool ClearLineClampEllipsis (nsBlockFrame* aFrame) {
1346
- if (!aFrame->HasAnyStateBits (NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS)) {
1351
+ if (aFrame->HasLineClampEllipsis ()) {
1352
+ MOZ_ASSERT (!aFrame->HasLineClampEllipsisDescendant ());
1353
+ for (auto & line : aFrame->Lines ()) {
1354
+ if (line.HasLineClampEllipsis ()) {
1355
+ line.ClearHasLineClampEllipsis ();
1356
+ aFrame->SetHasLineClampEllipsis (false );
1357
+ return true ;
1358
+ }
1359
+ }
1360
+ }
1361
+
1362
+ if (aFrame->HasLineClampEllipsisDescendant ()) {
1363
+ aFrame->SetHasLineClampEllipsisDescendant (false );
1347
1364
for (nsIFrame* f : aFrame->PrincipalChildList ()) {
1348
1365
if (nsBlockFrame* child = GetAsLineClampDescendant (f)) {
1349
1366
if (ClearLineClampEllipsis (child)) {
1350
1367
return true ;
1351
1368
}
1352
1369
}
1353
1370
}
1354
- return false ;
1355
- }
1356
-
1357
- aFrame->RemoveStateBits (NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS);
1358
-
1359
- for (auto & line : aFrame->Lines ()) {
1360
- if (line.HasLineClampEllipsis ()) {
1361
- line.ClearHasLineClampEllipsis ();
1362
- return true ;
1363
- }
1364
1371
}
1365
1372
1366
1373
1367
- return true ;
1374
+ return false ;
1368
1375
}
1369
1376
1370
1377
void nsBlockFrame::ClearLineClampEllipsis () { ::ClearLineClampEllipsis (this ); }
@@ -2019,9 +2026,7 @@ nsReflowStatus nsBlockFrame::TrialReflow(nsPresContext* aPresContext,
2019
2026
}
2020
2027
2021
2028
2022
- if (aReflowInput.mStyleDisplay ->mWebkitLineClamp ) {
2023
- ClearLineClampEllipsis ();
2024
- }
2029
+ ClearLineClampEllipsis ();
2025
2030
2026
2031
CheckFloats (state);
2027
2032
@@ -2052,7 +2057,7 @@ static nsLineBox* FindLineClampTarget(nsBlockFrame*& aFrame,
2052
2057
nsBlockFrame* aStopAtFrame,
2053
2058
StyleLineClamp aLineNumber) {
2054
2059
MOZ_ASSERT (aLineNumber > 0 );
2055
- MOZ_ASSERT (!aFrame->HasAnyStateBits (NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS ),
2060
+ MOZ_ASSERT (!aFrame->HasLineClampEllipsis ( ),
2056
2061
" Should have been removed earlier in nsBlockReflow::Reflow" );
2057
2062
2058
2063
nsLineBox* target = nullptr ;
@@ -2114,11 +2119,16 @@ nscoord nsBlockFrame::ApplyLineClamp(nscoord aContentBlockEndEdge) {
2114
2119
2115
2120
2116
2121
line->SetHasLineClampEllipsis ();
2117
- target->AddStateBits (NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS );
2122
+ target->SetHasLineClampEllipsis ( true );
2118
2123
2119
2124
2120
2125
nscoord edge = line->BEnd ();
2121
2126
for (nsIFrame* f = target; f; f = f->GetParent ()) {
2127
+ MOZ_ASSERT (f->IsBlockFrameOrSubclass (),
2128
+ " GetAsLineClampDescendant guarantees this" );
2129
+ if (f != target) {
2130
+ static_cast <nsBlockFrame*>(f)->SetHasLineClampEllipsisDescendant (true );
2131
+ }
2122
2132
if (f == this ) {
2123
2133
break ;
2124
2134
}
@@ -7637,7 +7647,7 @@ static void DisplayLine(nsDisplayListBuilder* aBuilder,
7637
7647
const bool aLineInLine, const nsDisplayListSet& aLists,
7638
7648
nsBlockFrame* aFrame, TextOverflow* aTextOverflow,
7639
7649
uint32_t aLineNumberForTextOverflow, int32_t aDepth,
7640
- int32_t & aDrawnLines) {
7650
+ int32_t & aDrawnLines, bool & aFoundLineClamp ) {
7641
7651
#ifdef DEBUG
7642
7652
if (nsBlockFrame::gLamePaintMetrics ) {
7643
7653
aDrawnLines++;
@@ -7670,6 +7680,14 @@ static void DisplayLine(nsDisplayListBuilder* aBuilder,
7670
7680
kid = kid->GetNextSibling ();
7671
7681
}
7672
7682
7683
+ if (aFrame->HasLineClampEllipsisDescendant () && !aLineInLine) {
7684
+ if (nsBlockFrame* f = GetAsLineClampDescendant (aLine->mFirstChild )) {
7685
+ if (f->HasLineClampEllipsis () || f->HasLineClampEllipsisDescendant ()) {
7686
+ aFoundLineClamp = true ;
7687
+ }
7688
+ }
7689
+ }
7690
+
7673
7691
if (aTextOverflow && aLineInLine) {
7674
7692
aTextOverflow->ProcessLine (collection, aLine.get (),
7675
7693
aLineNumberForTextOverflow);
@@ -7774,12 +7792,14 @@ void nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
7774
7792
7775
7793
7776
7794
nsLineBox* cursor =
7777
- (hasDescendantPlaceHolders || textOverflow.isSome () || backplateColor)
7795
+ (hasDescendantPlaceHolders || textOverflow.isSome () || backplateColor ||
7796
+ HasLineClampEllipsis () || HasLineClampEllipsisDescendant ())
7778
7797
? nullptr
7779
7798
: GetFirstLineContaining (aBuilder->GetDirtyRect ().y );
7780
7799
LineIterator line_end = LinesEnd ();
7781
7800
7782
7801
TextOverflow* textOverflowPtr = textOverflow.ptrOr (nullptr );
7802
+ bool foundClamp = false ;
7783
7803
7784
7804
if (cursor) {
7785
7805
for (LineIterator line = mLines .begin (cursor); line != line_end; ++line) {
@@ -7794,7 +7814,8 @@ void nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
7794
7814
7795
7815
if (ShouldDescendIntoLine (lineArea)) {
7796
7816
DisplayLine (aBuilder, line, line->IsInline (), aLists, this , nullptr ,
7797
- 0 , depth, drawnLines);
7817
+ 0 , depth, drawnLines, foundClamp);
7818
+ MOZ_ASSERT (!foundClamp);
7798
7819
}
7799
7820
}
7800
7821
}
@@ -7825,7 +7846,7 @@ void nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
7825
7846
7826
7847
if ((lineInLine && textOverflowPtr) || ShouldDescendIntoLine (lineArea)) {
7827
7848
DisplayLine (aBuilder, line, lineInLine, aLists, this , textOverflowPtr,
7828
- lineCount, depth, drawnLines);
7849
+ lineCount, depth, drawnLines, foundClamp );
7829
7850
}
7830
7851
7831
7852
if (!lineInLine && !curBackplateArea.IsEmpty ()) {
@@ -7856,6 +7877,10 @@ void nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
7856
7877
}
7857
7878
}
7858
7879
}
7880
+ foundClamp = foundClamp || line->HasLineClampEllipsis ();
7881
+ if (foundClamp) {
7882
+ break ;
7883
+ }
7859
7884
lineCount++;
7860
7885
}
7861
7886
0 commit comments