зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250143. Account for border/padding on outer <svg> elements in GeometryUtils. r=mats
MozReview-Commit-ID: KwEwnukNgeF --HG-- extra : rebase_source : d0ba2e4cd3e45280d8d030517c515caa04cb0b66
This commit is contained in:
Родитель
77a77d1df9
Коммит
e0d9d3c032
|
@ -140,8 +140,8 @@ GetBoxRectForFrame(nsIFrame** aFrame, CSSBoxType aType)
|
||||||
{
|
{
|
||||||
nsRect r;
|
nsRect r;
|
||||||
nsIFrame* f = nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(*aFrame, &r);
|
nsIFrame* f = nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(*aFrame, &r);
|
||||||
if (f) {
|
if (f && f != *aFrame) {
|
||||||
// For SVG, the BoxType is ignored.
|
// For non-outer SVG frames, the BoxType is ignored.
|
||||||
*aFrame = f;
|
*aFrame = f;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,7 @@ TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="svgContainer">
|
<div id="svgContainer">
|
||||||
<svg id="svg" style="width:200px; height:200px; background:lightgray;">
|
<svg id="svg" style="width:200px; height:200px; background:lightgray; border:7px solid blue; padding:4px">
|
||||||
<circle id="circle" cx="50" cy="50" r="20" fill="red" style="margin:20px; padding:10px; border:15px solid black"></circle>
|
<circle id="circle" cx="50" cy="50" r="20" fill="red" style="margin:20px; padding:10px; border:15px solid black"></circle>
|
||||||
<g transform="scale(2)">
|
<g transform="scale(2)">
|
||||||
<foreignObject x="50" y="20">
|
<foreignObject x="50" y="20">
|
||||||
|
@ -660,19 +660,26 @@ function runTest() {
|
||||||
var svgContainerX = svgContainer.getBoundingClientRect().left;
|
var svgContainerX = svgContainer.getBoundingClientRect().left;
|
||||||
var svgContainerY = svgContainer.getBoundingClientRect().top;
|
var svgContainerY = svgContainer.getBoundingClientRect().top;
|
||||||
checkQuadIsRect("circle", {},
|
checkQuadIsRect("circle", {},
|
||||||
svgContainerX + 30, svgContainerY + 30, 40, 40);
|
svgContainerX + 41, svgContainerY + 41, 40, 40);
|
||||||
// Box types are ignored for SVG elements.
|
// Box types are ignored for SVG elements.
|
||||||
checkQuadIsRect("circle", {box:"content"},
|
checkQuadIsRect("circle", {box:"content"},
|
||||||
svgContainerX + 30, svgContainerY + 30, 40, 40);
|
svgContainerX + 41, svgContainerY + 41, 40, 40);
|
||||||
checkQuadIsRect("circle", {box:"padding"},
|
checkQuadIsRect("circle", {box:"padding"},
|
||||||
svgContainerX + 30, svgContainerY + 30, 40, 40);
|
svgContainerX + 41, svgContainerY + 41, 40, 40);
|
||||||
checkQuadIsRect("circle", {box:"margin"},
|
checkQuadIsRect("circle", {box:"margin"},
|
||||||
svgContainerX + 30, svgContainerY + 30, 40, 40);
|
svgContainerX + 41, svgContainerY + 41, 40, 40);
|
||||||
checkQuadIsRect("d", {toStr:"circle"},
|
checkQuadIsRect("d", {toStr:"circle"},
|
||||||
dX - (svgContainerX + 30), dY - (svgContainerY + 30), dW, dH);
|
dX - (svgContainerX + 41), dY - (svgContainerY + 41), dW, dH);
|
||||||
// Test foreignObject inside an SVG transform.
|
// Test foreignObject inside an SVG transform.
|
||||||
checkQuadIsRect("foreign", {},
|
checkQuadIsRect("foreign", {},
|
||||||
svgContainerX + 100, svgContainerY + 40, 200, 120);
|
svgContainerX + 111, svgContainerY + 51, 200, 120);
|
||||||
|
// Outer <svg> elements support padding and content boxes
|
||||||
|
checkQuadIsRect("svg", {box:"border"},
|
||||||
|
svgContainerX, svgContainerY, 222, 222);
|
||||||
|
checkQuadIsRect("svg", {box:"padding"},
|
||||||
|
svgContainerX + 7, svgContainerY + 7, 208, 208);
|
||||||
|
checkQuadIsRect("svg", {box:"content"},
|
||||||
|
svgContainerX + 11, svgContainerY + 11, 200, 200);
|
||||||
|
|
||||||
// XXX Test SVG text (probably broken; unclear what the best way is to handle it)
|
// XXX Test SVG text (probably broken; unclear what the best way is to handle it)
|
||||||
|
|
||||||
|
|
|
@ -384,8 +384,10 @@ nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, nsRect* aRect)
|
||||||
if (outer == svg) {
|
if (outer == svg) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
*aRect = (aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) ?
|
nsMargin bp = outer->GetUsedBorderAndPadding();
|
||||||
nsRect(0, 0, 0, 0) : svg->GetCoveredRegion();
|
*aRect = ((aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) ?
|
||||||
|
nsRect(0, 0, 0, 0) : svg->GetCoveredRegion()) +
|
||||||
|
nsPoint(bp.left, bp.top);
|
||||||
return outer;
|
return outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче