Bug 1213895: Part 1 - Correctly support crop="none" in XUL labels. r=neil
This commit is contained in:
@@ -228,7 +228,7 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute,
|
|||||||
if (aAttribute == nullptr || aAttribute == nsGkAtoms::crop) {
|
if (aAttribute == nullptr || aAttribute == nsGkAtoms::crop) {
|
||||||
static nsIContent::AttrValuesArray strings[] =
|
static nsIContent::AttrValuesArray strings[] =
|
||||||
{&nsGkAtoms::left, &nsGkAtoms::start, &nsGkAtoms::center,
|
{&nsGkAtoms::left, &nsGkAtoms::start, &nsGkAtoms::center,
|
||||||
&nsGkAtoms::right, &nsGkAtoms::end, nullptr};
|
&nsGkAtoms::none, &nsGkAtoms::right, &nsGkAtoms::end, nullptr};
|
||||||
CroppingStyle cropType;
|
CroppingStyle cropType;
|
||||||
switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::crop,
|
switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::crop,
|
||||||
strings, eCaseMatters)) {
|
strings, eCaseMatters)) {
|
||||||
@@ -240,12 +240,13 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute,
|
|||||||
cropType = CropCenter;
|
cropType = CropCenter;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
|
||||||
cropType = CropRight;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cropType = CropNone;
|
cropType = CropNone;
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
default:
|
||||||
|
cropType = CropRight;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cropType != mCropType) {
|
if (cropType != mCropType) {
|
||||||
@@ -647,26 +648,31 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
|
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
|
||||||
// start with an ellipsis
|
if (mCropType != CropNone) {
|
||||||
mCroppedTitle.Assign(kEllipsis);
|
// start with an ellipsis
|
||||||
|
mCroppedTitle.Assign(kEllipsis);
|
||||||
|
|
||||||
// see if the width is even smaller than the ellipsis
|
// see if the width is even smaller than the ellipsis
|
||||||
// if so, clear the text (XXX set as many '.' as we can?).
|
// if so, clear the text (XXX set as many '.' as we can?).
|
||||||
fm->SetTextRunRTL(false);
|
fm->SetTextRunRTL(false);
|
||||||
titleWidth = nsLayoutUtils::AppUnitWidthOfString(kEllipsis, *fm,
|
titleWidth = nsLayoutUtils::AppUnitWidthOfString(kEllipsis, *fm,
|
||||||
drawTarget);
|
drawTarget);
|
||||||
|
|
||||||
if (titleWidth > aWidth) {
|
if (titleWidth > aWidth) {
|
||||||
mCroppedTitle.SetLength(0);
|
mCroppedTitle.SetLength(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the ellipsis fits perfectly, no use in trying to insert
|
||||||
|
if (titleWidth == aWidth)
|
||||||
|
return titleWidth;
|
||||||
|
|
||||||
|
aWidth -= titleWidth;
|
||||||
|
} else {
|
||||||
|
mCroppedTitle.Truncate(0);
|
||||||
|
titleWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the ellipsis fits perfectly, no use in trying to insert
|
|
||||||
if (titleWidth == aWidth)
|
|
||||||
return titleWidth;
|
|
||||||
|
|
||||||
aWidth -= titleWidth;
|
|
||||||
|
|
||||||
// XXX: This whole block should probably take surrogates into account
|
// XXX: This whole block should probably take surrogates into account
|
||||||
// XXX and clusters!
|
// XXX and clusters!
|
||||||
// ok crop things
|
// ok crop things
|
||||||
|
|||||||
Reference in New Issue
Block a user