Backed out changeset 4a68226609c8 (bug 1092125) for M3 bustage on CLOSED TREE

This commit is contained in:
Nigel Babu 2015-09-02 11:34:34 +05:30
parent df39e7bdd4
commit d0e1a05afc
4 changed files with 17 additions and 106 deletions

View File

@ -153,6 +153,10 @@ SVGLineElement::GetGeometryBounds(Rect* aBounds,
const Matrix& aToBoundsSpace,
const Matrix* aToNonScalingStrokeSpace)
{
if (aToNonScalingStrokeSpace) {
return false;
}
float x1, y1, x2, y2;
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
@ -162,53 +166,21 @@ SVGLineElement::GetGeometryBounds(Rect* aBounds,
return true;
}
// transform from non-scaling-stroke space to the space in which we compute
// bounds
Matrix nonScalingToBounds;
if (aToNonScalingStrokeSpace) {
Matrix nonScalingToUser = aToNonScalingStrokeSpace->Inverse();
nonScalingToBounds = nonScalingToUser * aToBoundsSpace;
}
if (aStrokeOptions.mLineCap == CapStyle::ROUND) {
if (!aToBoundsSpace.IsRectilinear() ||
(aToNonScalingStrokeSpace &&
!aToNonScalingStrokeSpace->IsRectilinear())) {
if (!aToBoundsSpace.IsRectilinear()) {
// TODO: handle this case.
return false;
}
Rect bounds(Point(x1, y1), Size());
bounds.ExpandToEnclose(Point(x2, y2));
if (aToNonScalingStrokeSpace) {
bounds = aToNonScalingStrokeSpace->TransformBounds(bounds);
bounds.Inflate(aStrokeOptions.mLineWidth / 2.f);
*aBounds = nonScalingToBounds.TransformBounds(bounds);
} else {
bounds.Inflate(aStrokeOptions.mLineWidth / 2.f);
*aBounds = aToBoundsSpace.TransformBounds(bounds);
}
bounds.Inflate(aStrokeOptions.mLineWidth / 2.f);
*aBounds = aToBoundsSpace.TransformBounds(bounds);
return true;
}
// Handle butt and square linecap, normal and non-scaling stroke cases
// together: start with endpoints (x1, y1), (x2, y2) in the stroke space,
// compute the four corners of the stroked line, transform the corners to
// bounds space, and compute bounds there.
if (aToNonScalingStrokeSpace) {
Point nonScalingSpaceP1, nonScalingSpaceP2;
nonScalingSpaceP1 = *aToNonScalingStrokeSpace * Point(x1, y1);
nonScalingSpaceP2 = *aToNonScalingStrokeSpace * Point(x2, y2);
x1 = nonScalingSpaceP1.x;
y1 = nonScalingSpaceP1.y;
x2 = nonScalingSpaceP2.x;
y2 = nonScalingSpaceP2.y;
}
Float length = Float(NS_hypot(x2 - x1, y2 - y1));
Float xDelta;
Float yDelta;
Point points[4];
if (aStrokeOptions.mLineCap == CapStyle::BUTT) {
if (length == 0.f) {
@ -218,37 +190,27 @@ SVGLineElement::GetGeometryBounds(Rect* aBounds,
xDelta = ratio * (y2 - y1);
yDelta = ratio * (x2 - x1);
}
points[0] = Point(x1 - xDelta, y1 + yDelta);
points[1] = Point(x1 + xDelta, y1 - yDelta);
points[2] = Point(x2 + xDelta, y2 - yDelta);
points[3] = Point(x2 - xDelta, y2 + yDelta);
} else {
MOZ_ASSERT(aStrokeOptions.mLineCap == CapStyle::SQUARE);
if (length == 0.f) {
xDelta = yDelta = aStrokeOptions.mLineWidth / 2.f;
points[0] = Point(x1 - xDelta, y1 + yDelta);
points[1] = Point(x1 - xDelta, y1 - yDelta);
points[2] = Point(x1 + xDelta, y1 - yDelta);
points[3] = Point(x1 + xDelta, y1 + yDelta);
} else {
Float ratio = aStrokeOptions.mLineWidth / 2.f / length;
yDelta = ratio * (x2 - x1);
xDelta = ratio * (y2 - y1);
points[0] = Point(x1 - yDelta - xDelta, y1 - xDelta + yDelta);
points[1] = Point(x1 - yDelta + xDelta, y1 - xDelta - yDelta);
points[2] = Point(x2 + yDelta + xDelta, y2 + xDelta - yDelta);
points[3] = Point(x2 + yDelta - xDelta, y2 + xDelta + yDelta);
xDelta = yDelta = ratio * (fabs(y2 - y1) + fabs(x2 - x1));
}
}
const Matrix& toBoundsSpace = aToNonScalingStrokeSpace ?
nonScalingToBounds : aToBoundsSpace;
Point points[4];
*aBounds = Rect(toBoundsSpace * points[0], Size());
points[0] = Point(x1 - xDelta, y1 - yDelta);
points[1] = Point(x1 + xDelta, y1 + yDelta);
points[2] = Point(x2 + xDelta, y2 + yDelta);
points[3] = Point(x2 - xDelta, y2 - yDelta);
*aBounds = Rect(aToBoundsSpace * points[0], Size());
for (uint32_t i = 1; i < 4; ++i) {
aBounds->ExpandToEnclose(toBoundsSpace * points[i]);
aBounds->ExpandToEnclose(aToBoundsSpace * points[i]);
}
return true;
}

View File

@ -47,17 +47,5 @@ text { font: 20px monospace; }
transform="matrix(0 3 -2 0 0 0)"
fill="none" stroke="steelblue" stroke-width="10"
vector-effect="non-scaling-stroke" />
<line id="nonScalingStrokedLine1" x1="120" y1="5" x2="120" y2="10"
transform="scale(2 3)"
stroke-width="10" stroke-linecap="round" stroke="orange"
vector-effect="non-scaling-stroke" />
<line id="nonScalingStrokedLine2" x1="130" y1="5" x2="140" y2="5"
transform="rotate(45 260 15) scale(2 3)"
stroke-width="10" stroke-linecap="square" stroke="crimson"
vector-effect="non-scaling-stroke" />
<line id="nonScalingStrokedLine3" x1="140" y1="5" x2="150" y2="5"
transform="rotate(45 280 15) scale(2 3)"
stroke-width="10" stroke-linecap="butt" stroke="indigo"
vector-effect="non-scaling-stroke" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -222,45 +222,6 @@ function runTest()
isWithAbsTolerance(nonScalingStrokedEllipse1Bounds.height, 40, 0.15,
"nonScalingStrokedEllipse1.getBoundingClientRect().height");
var nonScalingStrokedLine1Bounds =
doc.getElementById("nonScalingStrokedLine1").getBoundingClientRect();
isWithAbsTolerance(nonScalingStrokedLine1Bounds.left, 235, 0.1,
"nonScalingStrokedLine1.getBoundingClientRect().left");
isWithAbsTolerance(nonScalingStrokedLine1Bounds.top, 10, 0.1,
"nonScalingStrokedLine1.getBoundingClientRect().top");
isWithAbsTolerance(nonScalingStrokedLine1Bounds.width, 10, 0.1,
"nonScalingStrokedLine1.getBoundingClientRect().width");
isWithAbsTolerance(nonScalingStrokedLine1Bounds.height, 25, 0.1,
"nonScalingStrokedLine1.getBoundingClientRect().height");
var nonScalingStrokedLine2Bounds =
doc.getElementById("nonScalingStrokedLine2").getBoundingClientRect();
var capDelta = 5/Math.SQRT2 + 5/Math.SQRT2;
rect = new Rect(260 - capDelta, 15 - capDelta, 20/Math.SQRT2 + 2 * capDelta,
20/Math.SQRT2 + 2 * capDelta);
isWithAbsTolerance(nonScalingStrokedLine2Bounds.left, rect.left, 0.1,
"nonScalingStrokedLine2.getBoundingClientRect().left");
isWithAbsTolerance(nonScalingStrokedLine2Bounds.top, rect.top, 0.1,
"nonScalingStrokedLine2.getBoundingClientRect().top");
isWithAbsTolerance(nonScalingStrokedLine2Bounds.width, rect.width, 0.1,
"nonScalingStrokedLine2.getBoundingClientRect().width");
isWithAbsTolerance(nonScalingStrokedLine2Bounds.height, rect.height, 0.1,
"nonScalingStrokedLine2.getBoundingClientRect().height");
var nonScalingStrokedLine3Bounds =
doc.getElementById("nonScalingStrokedLine3").getBoundingClientRect();
var capDelta = 5/Math.SQRT2;
rect = new Rect(280 - capDelta, 15 - capDelta, 20/Math.SQRT2 + 2 * capDelta,
20/Math.SQRT2 + 2 * capDelta);
isWithAbsTolerance(nonScalingStrokedLine3Bounds.left, rect.left, 0.1,
"nonScalingStrokedLine3.getBoundingClientRect().left");
isWithAbsTolerance(nonScalingStrokedLine3Bounds.top, rect.top, 0.1,
"nonScalingStrokedLine3.getBoundingClientRect().top");
isWithAbsTolerance(nonScalingStrokedLine3Bounds.width, rect.width, 0.1,
"nonScalingStrokedLine3.getBoundingClientRect().width");
isWithAbsTolerance(nonScalingStrokedLine3Bounds.height, rect.height, 0.1,
"nonScalingStrokedLine3.getBoundingClientRect().height");
SimpleTest.finish();
}

View File

@ -1171,7 +1171,7 @@ PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
gfxMatrix outerSVGToUser;
if (nsSVGUtils::GetNonScalingStrokeTransform(aFrame, &outerSVGToUser)) {
outerSVGToUser.Invert();
matrix.PreMultiply(outerSVGToUser);
matrix *= outerSVGToUser;
}
double dx = style_expansion * (fabs(matrix._11) + fabs(matrix._21));