Issue #438: Rename coord/coords to originValue/transformOrigin.

For clarity and to prevent typoes.
This commit is contained in:
wolfbeast 2019-08-14 13:46:25 +02:00 • committed by Roy Tam
commit 0c8d8938e2

View file

@ -5708,7 +5708,7 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
} }
/* Allows us to access dimension getters by index. */ /* Allows us to access dimension getters by index. */
float coords[2]; float transformOrigin[2];
TransformReferenceBox::DimensionGetter dimensionGetter[] = TransformReferenceBox::DimensionGetter dimensionGetter[] =
{ &TransformReferenceBox::Width, &TransformReferenceBox::Height }; { &TransformReferenceBox::Width, &TransformReferenceBox::Height };
TransformReferenceBox::DimensionGetter offsetGetter[] = TransformReferenceBox::DimensionGetter offsetGetter[] =
@ -5718,33 +5718,33 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
/* If the transform-origin specifies a percentage, take the percentage /* If the transform-origin specifies a percentage, take the percentage
* of the size of the box. * of the size of the box.
*/ */
const nsStyleCoord &coord = display->mTransformOrigin[index]; const nsStyleCoord &originValue = display->mTransformOrigin[index];
if (coord.GetUnit() == eStyleUnit_Calc) { if (originValue.GetUnit() == eStyleUnit_Calc) {
const nsStyleCoord::Calc *calc = coord.GetCalcValue(); const nsStyleCoord::Calc *calc = originValue.GetCalcValue();
coords[index] = transformOrigin[index] =
NSAppUnitsToFloatPixels((refBox.*dimensionGetter[index])(), aAppUnitsPerPixel) * NSAppUnitsToFloatPixels((refBox.*dimensionGetter[index])(), aAppUnitsPerPixel) *
calc->mPercent + calc->mPercent +
NSAppUnitsToFloatPixels(calc->mLength, aAppUnitsPerPixel); NSAppUnitsToFloatPixels(calc->mLength, aAppUnitsPerPixel);
} else if (coord.GetUnit() == eStyleUnit_Percent) { } else if (originValue.GetUnit() == eStyleUnit_Percent) {
coords[index] = transformOrigin[index] =
NSAppUnitsToFloatPixels((refBox.*dimensionGetter[index])(), aAppUnitsPerPixel) * NSAppUnitsToFloatPixels((refBox.*dimensionGetter[index])(), aAppUnitsPerPixel) *
coord.GetPercentValue(); originValue.GetPercentValue();
} else { } else {
MOZ_ASSERT(coord.GetUnit() == eStyleUnit_Coord, "unexpected unit"); MOZ_ASSERT(originValue.GetUnit() == eStyleUnit_Coord, "unexpected unit");
coords[index] = transformOrigin[index] =
NSAppUnitsToFloatPixels(coord.GetCoordValue(), aAppUnitsPerPixel); NSAppUnitsToFloatPixels(originValue.GetCoordValue(), aAppUnitsPerPixel);
} }
if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) { if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
// SVG frames (unlike other frames) have a reference box that can be (and // SVG frames (unlike other frames) have a reference box that can be (and
// typically is) offset from the TopLeft() of the frame. We need to // typically is) offset from the TopLeft() of the frame. We need to
// account for that here. // account for that here.
coords[index] += transformOrigin[index] +=
NSAppUnitsToFloatPixels((refBox.*offsetGetter[index])(), aAppUnitsPerPixel); NSAppUnitsToFloatPixels((refBox.*offsetGetter[index])(), aAppUnitsPerPixel);
} }
} }
return Point3D(coords[0], coords[1], return Point3D(transformOrigin[0], transformOrigin[1],
NSAppUnitsToFloatPixels(display->mTransformOrigin[2].GetCoordValue(), NSAppUnitsToFloatPixels(display->mTransformOrigin[2].GetCoordValue(),
aAppUnitsPerPixel)); aAppUnitsPerPixel));
} }