mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-02 22:08:40 +09:00
Issue #2104 - Part 1: Implement "clip" attribute value for XUL string cropping
This implements the "clip" attribute value for the "crop" attribute found in XUL label elements. It functions similarly to having the text-overflow property set to an empty string or "". This shouldn't break previously established behavior as it only adds a new value to be checked. The behavior of the "none" attribute value in the documentation (https://udn.realityripple.com/docs/Archive/Mozilla/XUL/Attribute/crop) is incorrect. The "none" attribute value literally means "don't crop anything" if you'd check the code and is also equivalent to not setting the "crop" attribute at all. This has always been the case since Firefox 2 (earliest version I checked) and apparently, this section of the documentation was copied verbatim from XULPlanet without even checking if it's correct.
This commit is contained in:
parent
8d3f23ed00
commit
60c344a56b
2 changed files with 10 additions and 3 deletions
|
|
@ -230,7 +230,8 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute,
|
|||
if (aAttribute == nullptr || aAttribute == nsGkAtoms::crop) {
|
||||
static nsIContent::AttrValuesArray strings[] =
|
||||
{&nsGkAtoms::left, &nsGkAtoms::start, &nsGkAtoms::center,
|
||||
&nsGkAtoms::right, &nsGkAtoms::end, &nsGkAtoms::none, nullptr};
|
||||
&nsGkAtoms::right, &nsGkAtoms::end, &nsGkAtoms::none,
|
||||
&nsGkAtoms::clip, nullptr};
|
||||
CroppingStyle cropType;
|
||||
switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::crop,
|
||||
strings, eCaseMatters)) {
|
||||
|
|
@ -248,6 +249,9 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute,
|
|||
case 5:
|
||||
cropType = CropNone;
|
||||
break;
|
||||
case 6:
|
||||
cropType = CropClip;
|
||||
break;
|
||||
default:
|
||||
cropType = CropAuto;
|
||||
break;
|
||||
|
|
@ -647,7 +651,9 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
|
|||
}
|
||||
|
||||
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
|
||||
if (mCropType != CropNone) {
|
||||
if (mCropType == CropClip) {
|
||||
mCroppedTitle.Truncate();
|
||||
} else if (mCropType != CropNone) {
|
||||
// start with an ellipsis
|
||||
mCroppedTitle.Assign(kEllipsis);
|
||||
|
||||
|
|
@ -681,6 +687,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
|
|||
case CropAuto:
|
||||
case CropNone:
|
||||
case CropRight:
|
||||
case CropClip:
|
||||
{
|
||||
ClusterIterator iter(mTitle.Data(), mTitle.Length());
|
||||
const char16_t* dataBegin = iter;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue