From 60c344a56bc6123dae5219169ccf56b654612c9e Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Thu, 2 Feb 2023 15:45:53 +0800 Subject: [PATCH 1/3] 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. --- layout/xul/nsTextBoxFrame.cpp | 11 +++++++++-- layout/xul/nsTextBoxFrame.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index e1650e0d00..4c420f9323 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -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; diff --git a/layout/xul/nsTextBoxFrame.h b/layout/xul/nsTextBoxFrame.h index e12b97b32d..4ca4013c4b 100644 --- a/layout/xul/nsTextBoxFrame.h +++ b/layout/xul/nsTextBoxFrame.h @@ -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); From 4c9665a4ae7d194b55d46f01e06a09ed0a940431 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 3 Feb 2023 11:16:04 +0800 Subject: [PATCH 2/3] Issue #2104 - Part 2: Indicate if a label was cropped via the "_is_cropped" attribute --- dom/base/nsGkAtomList.h | 1 + layout/xul/nsTextBoxFrame.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 75c031afac..af25f97e1c 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -39,6 +39,7 @@ GK_ATOM(_moz_resizing, "_moz_resizing") GK_ATOM(mozallowfullscreen, "mozallowfullscreen") GK_ATOM(moztype, "_moz-type") GK_ATOM(mozdirty, "_moz_dirty") +GK_ATOM(_is_cropped, "_is_cropped") GK_ATOM(mozdisallowselectionprint, "mozdisallowselectionprint") GK_ATOM(mozdonotsend, "moz-do-not-send") GK_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node") diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 4c420f9323..755668d806 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -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); } From 1644bf94f0bf84ae09333ca6033508f3ccfb6e28 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 7 Feb 2023 19:58:04 +0100 Subject: [PATCH 3/3] No issue - Accept also `video/vp8` as MIME type --- dom/media/platforms/agnostic/VPXDecoder.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp index f2f84487fc..f06f6e08b1 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -26,6 +26,8 @@ static VPXDecoder::Codec MimeTypeToCodec(const nsACString& aMimeType) { if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) { return VPXDecoder::Codec::VP8; + } else if (aMimeType.EqualsLiteral("video/vp8")) { + return VPXDecoder::Codec::VP8; } else if (aMimeType.EqualsLiteral("video/webm; codecs=vp9")) { return VPXDecoder::Codec::VP9; } else if (aMimeType.EqualsLiteral("video/vp9")) { @@ -222,6 +224,8 @@ VPXDecoder::IsVPX(const nsACString& aMimeType, uint8_t aCodecMask) { return ((aCodecMask & VPXDecoder::VP8) && aMimeType.EqualsLiteral("video/webm; codecs=vp8")) || + ((aCodecMask & VPXDecoder::VP8) && + aMimeType.EqualsLiteral("video/vp8")) || ((aCodecMask & VPXDecoder::VP9) && aMimeType.EqualsLiteral("video/webm; codecs=vp9")) || ((aCodecMask & VPXDecoder::VP9) &&