From 7d622afa70e27be9370c83644dc167d1187ca4cd Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Sat, 22 Aug 2026 13:32:01 -0400 Subject: [PATCH] Resolve various assertions in debug builds --- layout/forms/nsHTMLButtonControlFrame.cpp | 15 +++++++-------- layout/style/CSSStyleSheet.cpp | 4 +++- layout/style/Declaration.cpp | 8 ++++++-- layout/style/nsCSSParser.cpp | 10 ++++------ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 794834e906..e1edac0b59 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -235,18 +235,17 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, WritingMode wm = GetWritingMode(); LogicalSize availSize = aButtonReflowInput.ComputedSize(wm); + // The anonymous button-content frame cannot have a continuation. Give it + // unconstrained available block-size so flex/grid layout does not treat a + // definite button block-size as a fragmentainer constraint. Its computed + // block-size is overridden separately below when it needs to be definite. + availSize.BSize(wm) = NS_INTRINSICSIZE; + // Identify if the inner anonymous block is actually functioning as a flex or grid container. nsIAtom* kidType = aFirstKid->GetType(); bool isFlexOrGrid = (kidType == nsGkAtoms::flexContainerFrame || kidType == nsGkAtoms::gridContainerFrame); - // Preserve the button's definite BSize ONLY for flex/grid children so they - // see a definite containing block main size. For standard buttons, clobber - // to intrinsic so standard vertical centering (extraSpace) calculations work. - if (!isFlexOrGrid || aButtonReflowInput.ComputedBSize() == NS_INTRINSICSIZE) { - availSize.BSize(wm) = NS_INTRINSICSIZE; - } - // shorthand for a value we need to use in a bunch of places const LogicalMargin& clbp = aButtonReflowInput.ComputedLogicalBorderPadding(); @@ -260,7 +259,7 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, availSize); // Apply the definite BSize directly on the inner reflow input ONLY if it's - // a flex or grid container, allowing it to be used as-is. + // a flex or grid container, without constraining its available BSize. if (isFlexOrGrid && aButtonReflowInput.ComputedBSize() != NS_INTRINSICSIZE) { contentsReflowInput.SetComputedBSize(aButtonReflowInput.ComputedBSize()); } diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index 259eb25291..0cf4584ddd 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -1871,7 +1871,9 @@ CSSStyleSheet::InsertRuleInternal(const nsAString& aRule, RefPtr rule; aRv = css.ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI, mInner->mPrincipal, getter_AddRefs(rule)); - if (NS_WARN_IF(aRv.Failed())) { + // A syntax error from web content is an expected insertRule() outcome. The + // binding reports it to script; do not flood debug stderr as well. + if (aRv.Failed()) { return 0; } diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index 0944a992f8..41fe03b1da 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -639,8 +639,12 @@ Declaration::GetPropertyValueInternal( } if (revertCount == totalCount) { // Simplify serialization below by serializing revert up-front. - nsCSSValue(eCSSUnit_Revert).AppendToString(eCSSProperty_UNKNOWN, aValue, - nsCSSValue::eNormalized); + // eCSSUnit_Revert carries the cascade origin, so it cannot use the + // nsCSSValue constructor reserved for valueless units. + nsCSSValue revert; + revert.SetRevertValue(SheetType::Unknown); + revert.AppendToString(eCSSProperty_UNKNOWN, aValue, + nsCSSValue::eNormalized); return; } if (revertLayerCount == totalCount) { diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 8b4563ae90..a99f3ea75f 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -13454,18 +13454,16 @@ bool CSSParserImpl::ParseAspectRatioRatio(nsCSSValue& aValue) { nsCSSValue width; - if (!ParseSingleTokenNonNegativeVariant(width, - VARIANT_NUMBER | VARIANT_CALC, - nullptr)) { + if (ParseNonNegativeVariant(width, VARIANT_NUMBER | VARIANT_CALC, + nullptr) != CSSParseResult::Ok) { return false; } nsCSSValue height; height.SetFloatValue(1.0f, eCSSUnit_Number); if (ExpectSymbol('/', true)) { - if (!ParseSingleTokenNonNegativeVariant(height, - VARIANT_NUMBER | VARIANT_CALC, - nullptr)) { + if (ParseNonNegativeVariant(height, VARIANT_NUMBER | VARIANT_CALC, + nullptr) != CSSParseResult::Ok) { return false; } }