mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 530985 - Make getBoundingClientRect give more sensible results for <svg> elements. r=roc
This commit is contained in:
parent
45a97c4aa5
commit
e4e54c4a9d
@ -6,6 +6,13 @@ text { font: 20px monospace; }
|
||||
</style>
|
||||
|
||||
<g id="g">
|
||||
<svg id="svg1" x="10" y="10" width="25" height="30"/>
|
||||
<svg id="svg2" width="1" height="1" overflow="visible">
|
||||
<rect width="2" height="2" fill="yellow"/>
|
||||
</svg>
|
||||
<svg id="svg3" width="1" height="1" overflow="hidden">
|
||||
<rect width="2" height="2" fill="yellow"/>
|
||||
</svg>
|
||||
<text id="text1" x="25" y="25">abc</text>
|
||||
<text id="text1a" x="85" y="25" stroke="black" stroke-width="4">abc</text>
|
||||
<rect id="rect1" x="50" y="50" width="50" height="50" fill="green"/>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.8 KiB |
@ -44,6 +44,24 @@ function runTest()
|
||||
{
|
||||
var doc = $("svg").contentWindow.document;
|
||||
|
||||
var svg1Bounds = doc.getElementById("svg1").getBoundingClientRect();
|
||||
is(svg1Bounds.left, 10, "svg1.getBoundingClientRect().left");
|
||||
is(svg1Bounds.top, 10, "svg1.getBoundingClientRect().top");
|
||||
is(svg1Bounds.width, 25, "svg1.getBoundingClientRect().width");
|
||||
is(svg1Bounds.height, 30, "svg1.getBoundingClientRect().height");
|
||||
|
||||
var svg2Bounds = doc.getElementById("svg2").getBoundingClientRect();
|
||||
is(svg2Bounds.left, 0, "svg2.getBoundingClientRect().left");
|
||||
is(svg2Bounds.top, 0, "svg2.getBoundingClientRect().top");
|
||||
is(svg2Bounds.width, 2, "svg2.getBoundingClientRect().width");
|
||||
is(svg2Bounds.height, 2, "svg2.getBoundingClientRect().height");
|
||||
|
||||
var svg3Bounds = doc.getElementById("svg3").getBoundingClientRect();
|
||||
is(svg3Bounds.left, 0, "svg3.getBoundingClientRect().left");
|
||||
is(svg3Bounds.top, 0, "svg3.getBoundingClientRect().top");
|
||||
is(svg3Bounds.width, 1, "svg3.getBoundingClientRect().width");
|
||||
is(svg3Bounds.height, 1, "svg3.getBoundingClientRect().height");
|
||||
|
||||
var text1 = doc.getElementById("text1");
|
||||
|
||||
var text1Bounds = text1.getBoundingClientRect();
|
||||
|
@ -90,6 +90,25 @@ nsSVGInnerSVGFrame::PaintSVG(nsRenderingContext *aContext,
|
||||
return nsSVGInnerSVGFrameBase::PaintSVG(aContext, aDirtyRect);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsRect)
|
||||
nsSVGInnerSVGFrame::GetCoveredRegion()
|
||||
{
|
||||
float x, y, w, h;
|
||||
static_cast<SVGSVGElement*>(mContent)->
|
||||
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
||||
if (w < 0.0f) w = 0.0f;
|
||||
if (h < 0.0f) h = 0.0f;
|
||||
// GetCanvasTM includes the x,y translation
|
||||
nsRect bounds = nsSVGUtils::ToCanvasBounds(gfxRect(0.0, 0.0, w, h),
|
||||
GetCanvasTM(FOR_OUTERSVG_TM),
|
||||
PresContext());
|
||||
|
||||
if (!StyleDisplay()->IsScrollableOverflow()) {
|
||||
bounds.UnionRect(bounds, nsSVGUtils::GetCoveredRegion(mFrames));
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGInnerSVGFrame::ReflowSVG()
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
|
||||
// nsISVGChildFrame interface:
|
||||
NS_IMETHOD PaintSVG(nsRenderingContext *aContext, const nsIntRect *aDirtyRect) MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
|
||||
virtual void ReflowSVG() MOZ_OVERRIDE;
|
||||
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
|
||||
|
@ -889,6 +889,25 @@ nsSVGOuterSVGFrame::PaintSVG(nsRenderingContext* aContext,
|
||||
return anonKid->PaintSVG(aContext, aDirtyRect);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsRect)
|
||||
nsSVGOuterSVGFrame::GetCoveredRegion()
|
||||
{
|
||||
float x, y, w, h;
|
||||
static_cast<SVGSVGElement*>(mContent)->
|
||||
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
||||
if (w < 0.0f) w = 0.0f;
|
||||
if (h < 0.0f) h = 0.0f;
|
||||
// GetCanvasTM includes the x,y translation
|
||||
nsRect bounds = nsSVGUtils::ToCanvasBounds(gfxRect(0.0, 0.0, w, h),
|
||||
GetCanvasTM(FOR_OUTERSVG_TM),
|
||||
PresContext());
|
||||
|
||||
if (!(mIsRootContent || StyleDisplay()->IsScrollableOverflow())) {
|
||||
bounds.UnionRect(bounds, nsSVGUtils::GetCoveredRegion(mFrames));
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
SVGBBox
|
||||
nsSVGOuterSVGFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
|
||||
uint32_t aFlags)
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
// nsISVGChildFrame methods:
|
||||
NS_IMETHOD PaintSVG(nsRenderingContext* aContext,
|
||||
const nsIntRect *aDirtyRect) MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
|
||||
|
||||
virtual SVGBBox GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
|
||||
uint32_t aFlags) MOZ_OVERRIDE;
|
||||
|
Loading…
Reference in New Issue
Block a user