mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
import from UXP: Issue #2104 - Part 1: Implement "clip" attribute value for XUL string cropping (60c344a5)
This commit is contained in:
@@ -233,7 +233,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)) {
|
||||
@@ -251,6 +252,9 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom* aAttribute,
|
||||
case 5:
|
||||
cropType = CropNone;
|
||||
break;
|
||||
case 6:
|
||||
cropType = CropClip;
|
||||
break;
|
||||
default:
|
||||
cropType = CropAuto;
|
||||
break;
|
||||
@@ -650,7 +654,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);
|
||||
|
||||
@@ -684,6 +690,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext,
|
||||
case CropAuto:
|
||||
case CropNone:
|
||||
case CropRight:
|
||||
case CropClip:
|
||||
{
|
||||
ClusterIterator iter(mTitle.Data(), mTitle.Length());
|
||||
const char16_t* dataBegin = iter;
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual void MarkIntrinsicISizesDirty() override;
|
||||
|
||||
enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter, CropAuto };
|
||||
enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter, CropClip, CropAuto };
|
||||
|
||||
friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user