diff options
Diffstat (limited to 'layout/style/ServoStyleConstsInlines.h')
-rw-r--r-- | layout/style/ServoStyleConstsInlines.h | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/layout/style/ServoStyleConstsInlines.h b/layout/style/ServoStyleConstsInlines.h index 1985e8fbeb..5a86e4ccd0 100644 --- a/layout/style/ServoStyleConstsInlines.h +++ b/layout/style/ServoStyleConstsInlines.h @@ -53,6 +53,8 @@ template struct StyleStrong<StyleFontPaletteValuesRule>; template struct StyleStrong<StyleLockedFontFaceRule>; template struct StyleStrong<StyleLockedCounterStyleRule>; template struct StyleStrong<StyleContainerRule>; +template struct StyleStrong<StyleScopeRule>; +template struct StyleStrong<StyleStartingStyleRule>; template <typename T> inline void StyleOwnedSlice<T>::Clear() { @@ -697,9 +699,12 @@ CSSCoord StyleCalcLengthPercentage::ResolveToCSSPixels(CSSCoord aBasis) const { return Servo_ResolveCalcLengthPercentage(this, aBasis); } -nscoord StyleCalcLengthPercentage::Resolve(nscoord aBasis) const { - return detail::DefaultLengthToAppUnits( - ResolveToCSSPixels(CSSPixel::FromAppUnits(aBasis))); +template <typename Rounder> +nscoord StyleCalcLengthPercentage::Resolve(nscoord aBasis, + Rounder aRounder) const { + static_assert(std::is_same_v<decltype(aRounder(1.0f)), nscoord>); + CSSCoord result = ResolveToCSSPixels(CSSPixel::FromAppUnits(aBasis)); + return aRounder(result * AppUnitsPerCSSPixel()); } template <> @@ -724,11 +729,10 @@ CSSCoord LengthPercentage::ResolveToCSSPixelsWith(T aPercentageGetter) const { return ResolveToCSSPixels(aPercentageGetter()); } -template <typename T, typename PercentRounder> -nscoord LengthPercentage::Resolve(T aPercentageGetter, - PercentRounder aPercentRounder) const { +template <typename T, typename Rounder> +nscoord LengthPercentage::Resolve(T aPercentageGetter, Rounder aRounder) const { static_assert(std::is_same_v<decltype(aPercentageGetter()), nscoord>); - static_assert(std::is_same_v<decltype(aPercentRounder(1.0f)), nscoord>); + static_assert(std::is_same_v<decltype(aRounder(1.0f)), nscoord>); if (ConvertsToLength()) { return ToLength(); } @@ -737,9 +741,9 @@ nscoord LengthPercentage::Resolve(T aPercentageGetter, } nscoord basis = aPercentageGetter(); if (IsPercentage()) { - return aPercentRounder(basis * AsPercentage()._0); + return aRounder(basis * AsPercentage()._0); } - return AsCalc().Resolve(basis); + return AsCalc().Resolve(basis, aRounder); } nscoord LengthPercentage::Resolve(nscoord aPercentageBasis) const { @@ -752,11 +756,10 @@ nscoord LengthPercentage::Resolve(T aPercentageGetter) const { return Resolve(aPercentageGetter, detail::DefaultPercentLengthToAppUnits); } -template <typename PercentRounder> +template <typename Rounder> nscoord LengthPercentage::Resolve(nscoord aPercentageBasis, - PercentRounder aPercentRounder) const { - return Resolve([aPercentageBasis] { return aPercentageBasis; }, - aPercentRounder); + Rounder aRounder) const { + return Resolve([aPercentageBasis] { return aPercentageBasis; }, aRounder); } void LengthPercentage::ScaleLengthsBy(float aScale) { @@ -1201,6 +1204,20 @@ inline nsRect StyleZoom::Unzoom(const nsRect& aValue) const { UnzoomCoord(aValue.Width()), UnzoomCoord(aValue.Height())); } +template <> +inline gfx::Point StyleCoordinatePair<StyleCSSFloat>::ToGfxPoint( + const CSSSize* aBasis) const { + return gfx::Point(x, y); +} + +template <> +inline gfx::Point StyleCoordinatePair<LengthPercentage>::ToGfxPoint( + const CSSSize* aBasis) const { + MOZ_ASSERT(aBasis); + return gfx::Point(x.ResolveToCSSPixels(aBasis->Width()), + y.ResolveToCSSPixels(aBasis->Height())); +} + } // namespace mozilla #endif |