summaryrefslogtreecommitdiffstats
path: root/layout/style/ServoStyleConstsInlines.h
diff options
context:
space:
mode:
Diffstat (limited to 'layout/style/ServoStyleConstsInlines.h')
-rw-r--r--layout/style/ServoStyleConstsInlines.h44
1 files changed, 31 insertions, 13 deletions
diff --git a/layout/style/ServoStyleConstsInlines.h b/layout/style/ServoStyleConstsInlines.h
index 1985e8fbeb..50893f5112 100644
--- a/layout/style/ServoStyleConstsInlines.h
+++ b/layout/style/ServoStyleConstsInlines.h
@@ -45,6 +45,7 @@ template struct StyleStrong<StyleLockedKeyframesRule>;
template struct StyleStrong<StyleMediaRule>;
template struct StyleStrong<StyleDocumentRule>;
template struct StyleStrong<StyleNamespaceRule>;
+template struct StyleStrong<StyleMarginRule>;
template struct StyleStrong<StyleLockedPageRule>;
template struct StyleStrong<StylePropertyRule>;
template struct StyleStrong<StyleSupportsRule>;
@@ -53,6 +54,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 +700,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 +730,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 +742,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 +757,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 +1205,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