зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077355 - Stop over inflating for stroke-miterlimit in nsSVGUtils::PathExtentsToMaxStrokeExtents. r=longsonr
This commit is contained in:
Родитель
f6f8d40041
Коммит
31043b8380
|
@ -159,10 +159,13 @@ function runTest()
|
|||
is(rect3aBounds.width, 108, "rect3a.getBoundingClientRect().width");
|
||||
is(rect3aBounds.height, 108, "rect3a.getBoundingClientRect().height");
|
||||
|
||||
is(rect3bBounds.left, 198, "rect3b.getBoundingClientRect().left");
|
||||
is(rect3bBounds.top, 198, "rect3b.getBoundingClientRect().top");
|
||||
is(rect3bBounds.width, 54, "rect3b.getBoundingClientRect().width");
|
||||
is(rect3bBounds.height, 54, "rect3b.getBoundingClientRect().height");
|
||||
// Our PathExtentsToMaxStrokeExtents implementation considers the stroke
|
||||
// width to be sqrt(2)*stroke-width in case the rect is rotated 45 degrees,
|
||||
// so unfortunately we get slightly large results currently. Bug 1092125.
|
||||
isWithAbsTolerance(rect3bBounds.left, 198, 1, "rect3b.getBoundingClientRect().left");
|
||||
isWithAbsTolerance(rect3bBounds.top, 198, 1, "rect3b.getBoundingClientRect().top");
|
||||
isWithAbsTolerance(rect3bBounds.width, 54, 2, "rect3b.getBoundingClientRect().width");
|
||||
isWithAbsTolerance(rect3bBounds.height, 54, 2, "rect3b.getBoundingClientRect().height");
|
||||
|
||||
rect = new Rect(350 - 108 * sin45, 150 - 108 * sin45, 108 * sin45 * 2, 108 * sin45 * 2);
|
||||
isWithAbsTolerance(rect4aBounds.left, rect.left, 0.1, "rect4a.getBoundingClientRect().left");
|
||||
|
|
|
@ -1163,19 +1163,27 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
|
|||
nsSVGPathGeometryFrame* aFrame,
|
||||
const gfxMatrix& aMatrix)
|
||||
{
|
||||
double styleExpansionFactor = 0.5;
|
||||
const nsIAtom* tag = aFrame->GetContent()->Tag();
|
||||
|
||||
if (static_cast<nsSVGPathGeometryElement*>(aFrame->GetContent())->IsMarkable()) {
|
||||
bool strokeMayHaveCorners = (tag != nsGkAtoms::circle &&
|
||||
tag != nsGkAtoms::ellipse);
|
||||
|
||||
// For a shape without corners the stroke can only extend half the stroke
|
||||
// width from the path in the x/y-axis directions. For shapes with corners
|
||||
// the stroke can extend by sqrt(1/2) (think 45 degree rotated rect, or line
|
||||
// with stroke-linecaps="square").
|
||||
double styleExpansionFactor = strokeMayHaveCorners ? M_SQRT1_2 : 0.5;
|
||||
|
||||
// The stroke can extend even further for paths that can be affected by
|
||||
// stroke-miterlimit.
|
||||
bool affectedByMiterlimit = (tag == nsGkAtoms::path ||
|
||||
tag == nsGkAtoms::polyline ||
|
||||
tag == nsGkAtoms::polygon);
|
||||
if (affectedByMiterlimit) {
|
||||
const nsStyleSVG* style = aFrame->StyleSVG();
|
||||
|
||||
if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) {
|
||||
styleExpansionFactor = M_SQRT1_2;
|
||||
}
|
||||
|
||||
if (style->mStrokeLinejoin == NS_STYLE_STROKE_LINEJOIN_MITER &&
|
||||
styleExpansionFactor < style->mStrokeMiterlimit &&
|
||||
aFrame->GetContent()->Tag() != nsGkAtoms::line) {
|
||||
styleExpansionFactor = style->mStrokeMiterlimit;
|
||||
styleExpansionFactor < style->mStrokeMiterlimit / 2.0) {
|
||||
styleExpansionFactor = style->mStrokeMiterlimit / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче