Issue #2104 - Part 2: Indicate if a label was cropped via the "_is_cropped" attribute

This commit is contained in:
FranklinDM 2023-02-03 11:16:04 +08:00 committed by roytam1
commit 4c9665a4ae
2 changed files with 8 additions and 0 deletions

View file

@ -629,6 +629,10 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
{
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_is_cropped)) {
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_is_cropped, true);
}
if (mTitle.IsEmpty()) {
mCroppedTitle.Truncate();
return 0;
@ -831,6 +835,9 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
break;
}
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_is_cropped,
NS_LITERAL_STRING("true"), true);
return nsLayoutUtils::AppUnitWidthOfStringBidi(mCroppedTitle, this, *fm,
aRenderingContext);
}