diff options
author | Moonchild <moonchild@palemoon.org> | 2021-07-15 23:13:31 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-07-15 23:13:31 +0000 |
commit | feafc2f129df921f9e2954f0a21b1060588e4a0f (patch) | |
tree | 248d2f8df51e96c0d518ae5c782ad801ec53702f /layout/style | |
parent | 84825468041d590ff8c660c42cf93b0d2243ad52 (diff) | |
parent | c198ef11b9d2697501b3ea4cbcab98e4dad48a9d (diff) | |
download | uxp-RELBASE_20210719.tar.gz |
Merge branch 'master' into releaseRELBASE_20210719RC_20210715
Diffstat (limited to 'layout/style')
-rw-r--r-- | layout/style/StyleAnimationValue.cpp | 14 | ||||
-rw-r--r-- | layout/style/nsCSSParser.cpp | 2 | ||||
-rw-r--r-- | layout/style/nsCSSPropList.h | 5 | ||||
-rw-r--r-- | layout/style/nsCSSRuleProcessor.cpp | 15 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.cpp | 9 | ||||
-rw-r--r-- | layout/style/nsMediaFeatures.cpp | 67 | ||||
-rw-r--r-- | layout/style/nsRuleNode.cpp | 111 | ||||
-rw-r--r-- | layout/style/res/forms.css | 6 |
8 files changed, 183 insertions, 46 deletions
diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index ff67835536..2332de6a6a 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -63,11 +63,15 @@ GetCommonUnit(nsCSSPropertyID aProperty, StyleAnimationValue::Unit aSecondUnit) { if (aFirstUnit != aSecondUnit) { + bool numberAsPixel = + nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_NUMBERS_ARE_PIXELS); if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_STORES_CALC) && - (aFirstUnit == StyleAnimationValue::eUnit_Coord || + ((aFirstUnit == StyleAnimationValue::eUnit_Float && numberAsPixel) || + aFirstUnit == StyleAnimationValue::eUnit_Coord || aFirstUnit == StyleAnimationValue::eUnit_Percent || aFirstUnit == StyleAnimationValue::eUnit_Calc) && - (aSecondUnit == StyleAnimationValue::eUnit_Coord || + ((aSecondUnit == StyleAnimationValue::eUnit_Float && numberAsPixel) || + aSecondUnit == StyleAnimationValue::eUnit_Coord || aSecondUnit == StyleAnimationValue::eUnit_Percent || aSecondUnit == StyleAnimationValue::eUnit_Calc)) { // We can use calc() as the common unit. @@ -354,6 +358,12 @@ ExtractCalcValue(const StyleAnimationValue& aValue) result.mHasPercent = true; return result; } + if (aValue.GetUnit() == StyleAnimationValue::eUnit_Float) { + result.mLength = aValue.GetFloatValue(); + result.mPercent = 0.0f; + result.mHasPercent = false; + return result; + } MOZ_ASSERT(aValue.GetUnit() == StyleAnimationValue::eUnit_Calc, "unexpected unit"); nsCSSValue *val = aValue.GetCSSValueValue(); diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 0f1b04a178..9866dd09e8 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -4667,7 +4667,7 @@ CSSParserImpl::ParseSupportsConditionInParens(bool& aConditionMet) return true; } - if (AgentRulesEnabled() && + if ((AgentRulesEnabled() || ChromeRulesEnabled()) && mToken.mType == eCSSToken_Function && mToken.mIdent.LowerCaseEqualsLiteral("-moz-bool-pref")) { return ParseSupportsMozBoolPrefName(aConditionMet); diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index e78dafcc5c..45e919d4f8 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -3814,9 +3814,10 @@ CSS_PROP_SVG( stroke_dashoffset, StrokeDashoffset, CSS_PROPERTY_PARSE_VALUE | - CSS_PROPERTY_NUMBERS_ARE_PIXELS, + CSS_PROPERTY_NUMBERS_ARE_PIXELS | + CSS_PROPERTY_STORES_CALC, "", - VARIANT_HLPN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_HLPN | VARIANT_OPENTYPE_SVG_KEYWORD | VARIANT_CALC, kStrokeContextValueKTable, offsetof(nsStyleSVG, mStrokeDashoffset), eStyleAnimType_Coord) diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 810a8f8f00..6de279ac5c 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1191,21 +1191,6 @@ InitSystemMetrics() case LookAndFeel::eWindowsTheme_AeroLite: sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_aero_lite); break; - case LookAndFeel::eWindowsTheme_LunaBlue: - sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_blue); - break; - case LookAndFeel::eWindowsTheme_LunaOlive: - sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_olive); - break; - case LookAndFeel::eWindowsTheme_LunaSilver: - sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_silver); - break; - case LookAndFeel::eWindowsTheme_Royale: - sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_royale); - break; - case LookAndFeel::eWindowsTheme_Zune: - sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_zune); - break; case LookAndFeel::eWindowsTheme_Generic: sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_generic); break; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 7ac5fa604e..efa485f613 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -6648,14 +6648,7 @@ nsComputedDOMStyle::DoGetAnimationIterationCount() RefPtr<nsROCSSPrimitiveValue> iterationCount = new nsROCSSPrimitiveValue; float f = animation->GetIterationCount(); - /* Need a nasty hack here to work around an optimizer bug in gcc - 4.2 on Mac, which somehow gets confused when directly comparing - a float to the return value of NS_IEEEPositiveInfinity when - building 32-bit builds. */ -#ifdef XP_MACOSX - volatile -#endif - float inf = NS_IEEEPositiveInfinity(); + float inf = NS_IEEEPositiveInfinity(); if (f == inf) { iterationCount->SetIdent(eCSSKeyword_infinite); } else { diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index 9b5331a4a1..ab423ad9ef 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -62,11 +62,6 @@ struct WindowsThemeName { const WindowsThemeName themeStrings[] = { { LookAndFeel::eWindowsTheme_Aero, L"aero" }, { LookAndFeel::eWindowsTheme_AeroLite, L"aero-lite" }, - { LookAndFeel::eWindowsTheme_LunaBlue, L"luna-blue" }, - { LookAndFeel::eWindowsTheme_LunaOlive, L"luna-olive" }, - { LookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" }, - { LookAndFeel::eWindowsTheme_Royale, L"royale" }, - { LookAndFeel::eWindowsTheme_Zune, L"zune" }, { LookAndFeel::eWindowsTheme_Generic, L"generic" } }; @@ -464,20 +459,60 @@ GetOperatingSystemVersion(nsPresContext* aPresContext, const nsMediaFeature* aFe static nsresult GetPrefersColorScheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature, - nsCSSValue& aResult) + nsCSSValue& aResult) { switch(Preferences::GetInt("browser.display.prefers_color_scheme", 1)) { case 1: - aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_LIGHT, - eCSSUnit_Enumerated); - break; + aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_LIGHT, + eCSSUnit_Enumerated); + break; case 2: - aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_DARK, - eCSSUnit_Enumerated); - break; + aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_DARK, + eCSSUnit_Enumerated); + break; + case 3: + // If the pref is 3, we follow ui.color_scheme instead. When following + // ui.color_scheme, light theme is the fallback behavior. + switch(Preferences::GetInt("ui.color_scheme", 1)) { + case 2: + aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_DARK, + eCSSUnit_Enumerated); + break; + default: + aResult.SetIntValue(NS_STYLE_PREFERS_COLOR_SCHEME_LIGHT, + eCSSUnit_Enumerated); + } + break; default: + aResult.Reset(); + } + + return NS_OK; +} + +static nsresult +GetDarkTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature, + nsCSSValue& aResult) +{ +#ifdef XP_WIN + // Under Windows, do nothing if High Contrast Theme is on. + if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0)) { aResult.Reset(); + return NS_OK; } +#endif + + switch(Preferences::GetInt("ui.color_scheme", 1)) { + case 1: + aResult.SetIntValue(0, eCSSUnit_Integer); + break; + case 2: + aResult.SetIntValue(1, eCSSUnit_Integer); + break; + default: + aResult.Reset(); + } + return NS_OK; } @@ -644,6 +679,14 @@ nsMediaFeatures::features[] = { // Mozilla extensions { + &nsGkAtoms::_moz_dark_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { nullptr }, + GetDarkTheme + }, + { &nsGkAtoms::_moz_device_pixel_ratio, nsMediaFeature::eMinMaxAllowed, nsMediaFeature::eFloat, diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 04715aa99a..74ba732885 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4492,6 +4492,15 @@ struct LengthNumberCalcObj bool mIsNumber; }; +struct RealNumberComputedCalc +{ + // We use float for mLength, so it can support real numbers. + float mLength = 0.0f; + float mPercent = 0.0f; + bool mIsNumber = false; +}; + + struct LengthNumberCalcOps : public css::NumbersAlreadyNormalizedOps { typedef LengthNumberCalcObj result_type; @@ -4574,6 +4583,96 @@ struct LengthNumberCalcOps : public css::NumbersAlreadyNormalizedOps } }; +// This is like LengthNumberCalcOps, but then for real/float. +struct LengthPercentNumberCalcOps : public css::NumbersAlreadyNormalizedOps +{ + typedef RealNumberComputedCalc result_type; + + nsStyleContext* const mContext; + nsPresContext* const mPresContext; + RuleNodeCacheConditions& mConditions; + bool mHasPercent = false; + + LengthPercentNumberCalcOps(nsStyleContext* aContext, + nsPresContext* aPresContext, + RuleNodeCacheConditions& aConditions) + : mContext(aContext), + mPresContext(aPresContext), + mConditions(aConditions) { } + + result_type + MergeAdditive(nsCSSUnit aCalcFunction, + result_type aValue1, result_type aValue2) + { + MOZ_ASSERT(aValue1.mIsNumber == aValue2.mIsNumber); + MOZ_ASSERT(aCalcFunction == eCSSUnit_Calc_Plus || + aCalcFunction == eCSSUnit_Calc_Minus, + "unexpected unit"); + + result_type result; + result.mIsNumber = aValue1.mIsNumber; + if (aCalcFunction == eCSSUnit_Calc_Plus) { + result.mLength = aValue1.mLength + aValue2.mLength; + result.mPercent = aValue1.mPercent + aValue2.mPercent; + } else { + result.mLength = aValue2.mLength == NS_IEEEPositiveInfinity() ? + 0.0f : + aValue1.mLength - aValue2.mLength; + result.mPercent = aValue1.mPercent - aValue2.mPercent; + } + return result; + } + + result_type + MergeMultiplicativeL(nsCSSUnit aCalcFunction, + float aValue1, result_type aValue2) + { + MOZ_ASSERT(aCalcFunction == eCSSUnit_Calc_Times_L, + "unexpected unit"); + result_type result; + result.mLength = aValue1 * aValue2.mLength; + result.mPercent = aValue1 * aValue2.mPercent; + result.mIsNumber = aValue2.mIsNumber; + return result; + } + + result_type + MergeMultiplicativeR(nsCSSUnit aCalcFunction, + result_type aValue1, float aValue2) + { + MOZ_ASSERT(aCalcFunction == eCSSUnit_Calc_TimesR || + aCalcFunction == eCSSUnit_Divided, + "unexpected unit"); + result_type result; + if (aCalcFunction == eCSSUnit_Calc_Divided) { + aValue2 = 1.0f / aValue2; + } + result.mLength = aValue1.mLength * aValue2; + result.mPercent = aValue1.mPercent * aValue2; + result.mIsNumber = aValue1.mIsNumber; + return result; + } + + result_type + ComputeLeafValue(const nsCSSValue& aValue) + { + result_type result; + if (aValue.IsLengthUnit()) { + result.mLength = CalcLength(aValue, mContext, mPresContext, mConditions); + } else if (aValue.GetUnit() == eCSSUnit_Percent) { + result.mPercent = aValue.GetPercentValue(); + mHasPercent = true; + } else if (aValue.GetUnit() == eCSSUnit_Number) { + result.mLength = aValue.GetFloatValue(); + result.mIsNumber = true; + } else { + MOZ_ASSERT_UNREACHABLE("unexpected unit"); + result.mLength = CalcLength(aValue, mContext, mPresContext, mConditions); + } + return result; + } +}; + struct SetLineHeightCalcOps : public LengthNumberCalcOps { SetLineHeightCalcOps(nsStyleContext* aStyleContext, @@ -9626,6 +9725,18 @@ nsRuleNode::ComputeSVGData(void* aStartStruct, strokeDashoffsetValue->GetIntValue() == NS_STYLE_STROKE_PROP_CONTEXT_VALUE); if (svg->StrokeDashoffsetFromObject()) { svg->mStrokeDashoffset.SetCoordValue(0); + } else if (strokeDashoffsetValue->IsCalcUnit()) { + LengthPercentNumberCalcOps ops(aContext, mPresContext, conditions); + RealNumberComputedCalc obj = css::ComputeCalc(*strokeDashoffsetValue, ops); + if (obj.mIsNumber) { + svg->mStrokeDashoffset.SetFactorValue(obj.mLength); + } else { + nsStyleCoord::Calc* calcObj = new nsStyleCoord::Calc; + calcObj->mLength = NSToCoordRoundWithClamp(obj.mLength); + calcObj->mPercent = obj.mPercent; + calcObj->mHasPercent = ops.mHasPercent; + svg->mStrokeDashoffset.SetCalcValue(calcObj); + } } else { SetCoord(*aRuleData->ValueForStrokeDashoffset(), svg->mStrokeDashoffset, parentSVG->mStrokeDashoffset, diff --git a/layout/style/res/forms.css b/layout/style/res/forms.css index db75151d48..281b75d769 100644 --- a/layout/style/res/forms.css +++ b/layout/style/res/forms.css @@ -593,15 +593,11 @@ input[type="checkbox"]:disabled:hover:active { cursor: inherit; } -% On Mac, the native theme takes care of this. -% See nsNativeThemeCocoa::ThemeDrawsFocusForWidget. -%ifndef XP_MACOSX input[type="checkbox"]:-moz-focusring, input[type="radio"]:-moz-focusring { /* Don't specify the outline-color, we should always use initial value. */ outline: 1px dotted; } -%endif input[type="checkbox"]:hover:active, input[type="radio"]:hover:active { @@ -723,12 +719,10 @@ input[type="color"]:-moz-system-metric(color-picker-available):active:hover, input[type="reset"]:active:hover, input[type="button"]:active:hover, input[type="submit"]:active:hover { -%ifndef XP_MACOSX padding-block-start: 0px; padding-inline-end: 5px; padding-block-end: 0px; padding-inline-start: 7px; -%endif border-style: inset; background-color: ButtonFace; } |