Bug 1355380 - Part 2: Make Servo's rounding of image-orientation values agree with Gecko's, and pass orientations directly as an enum instead of as angles. r?Manishearth
Both Servo and Gecko store the specified value of the image-orientation
property as a single-precision float, but Gecko does the conversion to radians
and the computation to identify which quarter-turn the angle is closest to
using doubles.
We add Angle::radians64 to perform the conversion to radians using doubles,
just as Gecko does, and then update image_orientation to perform the
computation the same exact way Gecko does in
nsStyleImageOrientation::CreateAsAngleAndFlip. This lets the previously failing
reftests pass.
We also update Gecko_SetImageOrientation to take an orientation directly
instead of an angle (otherwise we'd be doing the which-quarter-turn-is-closest
computation twice).
Finally this lets us re-enable the reftests for image-orientation previously
marked as fails-if(styloVsGecko||stylo).
MozReview-Commit-ID: 2zMMzQlsYEC
--- a/layout/reftests/image/reftest.list
+++ b/layout/reftests/image/reftest.list
@@ -40,29 +40,29 @@ fuzzy(1,1) == image-orientation-explicit
fuzzy(1,1) == image-orientation-explicit.html?270 image-orientation-ref.html?270
fuzzy(1,1) == image-orientation-explicit.html?0&flip image-orientation-ref.html?0&flip
fuzzy(1,1) == image-orientation-explicit.html?90&flip image-orientation-ref.html?90&flip
fuzzy(1,1) == image-orientation-explicit.html?180&flip image-orientation-ref.html?180&flip
fuzzy(1,1) == image-orientation-explicit.html?270&flip image-orientation-ref.html?270&flip
# Tests for image-orientation used with non-axis-aligned angles:
fuzzy(1,1) == image-orientation-explicit.html?-46 image-orientation-ref.html?270
-fuzzy(1,1) fails-if(styloVsGecko||stylo) == image-orientation-explicit.html?-45 image-orientation-ref.html?0
+fuzzy(1,1) == image-orientation-explicit.html?-45 image-orientation-ref.html?0
fuzzy(1,1) == image-orientation-explicit.html?-15 image-orientation-ref.html?0
fuzzy(1,1) == image-orientation-explicit.html?15 image-orientation-ref.html?0
fuzzy(1,1) == image-orientation-explicit.html?45 image-orientation-ref.html?90
fuzzy(1,1) == image-orientation-explicit.html?75 image-orientation-ref.html?90
fuzzy(1,1) == image-orientation-explicit.html?105 image-orientation-ref.html?90
fuzzy(1,1) == image-orientation-explicit.html?135 image-orientation-ref.html?180
fuzzy(1,1) == image-orientation-explicit.html?165 image-orientation-ref.html?180
fuzzy(1,1) == image-orientation-explicit.html?195 image-orientation-ref.html?180
fuzzy(1,1) == image-orientation-explicit.html?225 image-orientation-ref.html?270
fuzzy(1,1) == image-orientation-explicit.html?255 image-orientation-ref.html?270
fuzzy(1,1) == image-orientation-explicit.html?285 image-orientation-ref.html?270
-fuzzy(1,1) fails-if(styloVsGecko||stylo) == image-orientation-explicit.html?315 image-orientation-ref.html?0
+fuzzy(1,1) == image-orientation-explicit.html?315 image-orientation-ref.html?0
fuzzy(1,1) == image-orientation-explicit.html?345 image-orientation-ref.html?0
# Tests for image-orientation used on generated content:
fuzzy(1,1) == image-orientation-generated-content.html?from-image image-orientation-generated-content-ref.html?270&flip
fuzzy(1,1) == image-orientation-generated-content.html?0 image-orientation-generated-content-ref.html?0
fuzzy(1,1) == image-orientation-generated-content.html?90 image-orientation-generated-content-ref.html?90
fuzzy(1,1) == image-orientation-generated-content.html?180 image-orientation-generated-content-ref.html?180
fuzzy(1,1) == image-orientation-generated-content.html?270 image-orientation-generated-content-ref.html?270
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1307,20 +1307,20 @@ void
Gecko_CopyAlternateValuesFrom(nsFont* aDest, const nsFont* aSrc)
{
aDest->alternateValues.Clear();
aDest->alternateValues.AppendElements(aSrc->alternateValues);
}
void
Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
- double aRadians, bool aFlip)
+ uint8_t aOrientation, bool aFlip)
{
aVisibility->mImageOrientation =
- nsStyleImageOrientation::CreateAsAngleAndFlip(aRadians, aFlip);
+ nsStyleImageOrientation::CreateAsOrientationAndFlip(aOrientation, aFlip);
}
void
Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility)
{
aVisibility->mImageOrientation = nsStyleImageOrientation::CreateAsFromImage();
}
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -280,17 +280,17 @@ void Gecko_nsFont_Destroy(nsFont* dst);
// Font variant alternates
void Gecko_ClearAlternateValues(nsFont* font, size_t length);
void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name, nsIAtom* atom);
void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
// Visibility style
void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
- double aRadians,
+ uint8_t aOrientation,
bool aFlip);
void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
const nsStyleVisibility* aSrc);
// Counter style.
// This function takes an already addrefed nsIAtom
void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsIAtom* name,
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2042,16 +2042,25 @@ struct nsStyleImageOrientation
// Add a bit for 'flip' if needed.
if (aFlip) {
orientation |= FLIP_MASK;
}
return nsStyleImageOrientation(orientation);
}
+ static nsStyleImageOrientation CreateAsOrientationAndFlip(uint8_t aOrientation,
+ bool aFlip) {
+ MOZ_ASSERT(aOrientation <= ANGLE_270);
+ if (aFlip) {
+ aOrientation |= FLIP_MASK;
+ }
+ return nsStyleImageOrientation(aOrientation);
+ }
+
static nsStyleImageOrientation CreateAsFlip() {
return nsStyleImageOrientation(FLIP_MASK);
}
static nsStyleImageOrientation CreateAsFromImage() {
return nsStyleImageOrientation(FROM_IMAGE_MASK);
}