mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 958160 - Compute bounds in transformed space instead of user space in GetCoveredRegion. r=longsonr
--HG-- extra : rebase_source : 021b5fe58b234b83eb792d832296c79fe0160c48
This commit is contained in:
parent
a9650528da
commit
d8f2add1c4
@ -59,5 +59,17 @@ text { font: 20px monospace; }
|
||||
transform="rotate(45 280 15) scale(2 3)"
|
||||
stroke-width="10" stroke-linecap="butt" stroke="indigo"
|
||||
vector-effect="non-scaling-stroke" />
|
||||
|
||||
<marker id="marker1" markerWidth="100" markerHeight="100"
|
||||
refX="0" refY="50" markerUnits="userSpaceOnUse">
|
||||
<line x1="0" y1="50" x2="50" y2="100" stroke="aqua" stroke-width="20"
|
||||
transform="rotate(-45 0 50)" />
|
||||
</marker>
|
||||
<line id="shapeWithMarker1" x1="160" y1="130" x2="170" y2="130"
|
||||
stroke="black" stroke-width="3" marker-end="url(#marker1)"/>
|
||||
|
||||
<line id="rotatedLine1" x1="160" y1="150" x2="180" y2="170"
|
||||
stroke="darkmagenta" stroke-width="10"
|
||||
transform="rotate(-45 160 150)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.6 KiB |
@ -261,6 +261,28 @@ function runTest()
|
||||
isWithAbsTolerance(nonScalingStrokedLine3Bounds.height, rect.height, 0.1,
|
||||
"nonScalingStrokedLine3.getBoundingClientRect().height");
|
||||
|
||||
var shapeWithMarker1Bounds =
|
||||
doc.getElementById("shapeWithMarker1").getBoundingClientRect();
|
||||
isWithAbsTolerance(shapeWithMarker1Bounds.left, 160, 0.1,
|
||||
"shapeWithMarker1Bounds.left");
|
||||
isWithAbsTolerance(shapeWithMarker1Bounds.top, 120, 0.1,
|
||||
"shapeWithMarker1Bounds.top");
|
||||
isWithAbsTolerance(shapeWithMarker1Bounds.width, 10 + Math.SQRT2 * 50, 0.1,
|
||||
"shapeWithMarker1Bounds.width");
|
||||
isWithAbsTolerance(shapeWithMarker1Bounds.height, 20, 0.1,
|
||||
"shapeWithMarker1Bounds.height");
|
||||
|
||||
var rotatedLine1Bounds =
|
||||
doc.getElementById("rotatedLine1").getBoundingClientRect();
|
||||
isWithAbsTolerance(rotatedLine1Bounds.left, 160, 0.1,
|
||||
"rotatedLine1Bounds.left");
|
||||
isWithAbsTolerance(rotatedLine1Bounds.top, 145, 0.1,
|
||||
"rotatedLine1Bounds.top");
|
||||
isWithAbsTolerance(rotatedLine1Bounds.width, Math.SQRT2 * 20, 0.1,
|
||||
"rotatedLine1Bounds.width");
|
||||
isWithAbsTolerance(rotatedLine1Bounds.height, 10, 0.1,
|
||||
"rotatedLine1Bounds.height");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -351,8 +351,23 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint)
|
||||
nsRect
|
||||
nsSVGPathGeometryFrame::GetCoveredRegion()
|
||||
{
|
||||
gfxMatrix canvasTM = GetCanvasTM();
|
||||
if (canvasTM.PreservesAxisAlignedRectangles()) {
|
||||
return nsSVGUtils::TransformFrameRectToOuterSVG(
|
||||
mRect, canvasTM, PresContext());
|
||||
}
|
||||
|
||||
// To get tight bounds we need to compute directly in outer SVG coordinates
|
||||
uint32_t flags = nsSVGUtils::eBBoxIncludeFill |
|
||||
nsSVGUtils::eBBoxIncludeStroke |
|
||||
nsSVGUtils::eBBoxIncludeMarkers;
|
||||
gfxRect extent =
|
||||
GetBBoxContribution(ToMatrix(canvasTM), flags).ToThebesRect();
|
||||
nsRect region = nsLayoutUtils::RoundGfxRectToAppRect(
|
||||
extent, PresContext()->AppUnitsPerCSSPixel());
|
||||
|
||||
return nsSVGUtils::TransformFrameRectToOuterSVG(
|
||||
mRect, GetCanvasTM(), PresContext());
|
||||
region, gfxMatrix(), PresContext());
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user