Bug 1213895: Part 1 - Correctly support crop="none" in XUL labels. r?neil
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -223,33 +223,34 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom
{
bool doUpdateTitle = false;
aResize = false;
aRedraw = false;
if (aAttribute == nullptr || aAttribute == nsGkAtoms::crop) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::left, &nsGkAtoms::start, &nsGkAtoms::center,
- &nsGkAtoms::right, &nsGkAtoms::end, nullptr};
+ &nsGkAtoms::none, &nsGkAtoms::right, &nsGkAtoms::end, nullptr};
CroppingStyle cropType;
switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::crop,
strings, eCaseMatters)) {
case 0:
case 1:
cropType = CropLeft;
break;
case 2:
cropType = CropCenter;
break;
case 3:
- case 4:
- cropType = CropRight;
+ cropType = CropNone;
break;
+ case 4:
+ case 5:
default:
- cropType = CropNone;
+ cropType = CropRight;
break;
}
if (cropType != mCropType) {
aResize = true;
mCropType = cropType;
}
}
@@ -642,35 +643,40 @@ nsTextBoxFrame::CalculateTitleForWidth(n
if (HasRTLChars(mTitle) ||
StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
mState |= NS_FRAME_IS_BIDI;
}
return titleWidth; // fits, done.
}
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
- // start with an ellipsis
- mCroppedTitle.Assign(kEllipsis);
+ if (mCropType != CropNone) {
+ // start with an ellipsis
+ mCroppedTitle.Assign(kEllipsis);
- // see if the width is even smaller than the ellipsis
- // if so, clear the text (XXX set as many '.' as we can?).
- fm->SetTextRunRTL(false);
- titleWidth = nsLayoutUtils::AppUnitWidthOfString(kEllipsis, *fm,
- drawTarget);
+ // see if the width is even smaller than the ellipsis
+ // if so, clear the text (XXX set as many '.' as we can?).
+ fm->SetTextRunRTL(false);
+ titleWidth = nsLayoutUtils::AppUnitWidthOfString(kEllipsis, *fm,
+ drawTarget);
- if (titleWidth > aWidth) {
- mCroppedTitle.SetLength(0);
- return 0;
- }
+ if (titleWidth > aWidth) {
+ mCroppedTitle.SetLength(0);
+ return 0;
+ }
- // if the ellipsis fits perfectly, no use in trying to insert
- if (titleWidth == aWidth)
- return titleWidth;
+ // if the ellipsis fits perfectly, no use in trying to insert
+ if (titleWidth == aWidth)
+ return titleWidth;
- aWidth -= titleWidth;
+ aWidth -= titleWidth;
+ } else {
+ mCroppedTitle.Truncate(0);
+ titleWidth = 0;
+ }
// XXX: This whole block should probably take surrogates into account
// XXX and clusters!
// ok crop things
switch (mCropType)
{
case CropNone:
case CropRight: