Bug 873806 - Part 2: Make descendants of non-display nsSVGForeignObjectFrame also non-display. r=longsonr

This commit is contained in:
Cameron McCormack 2013-06-04 00:15:29 +10:00
parent 202592f20d
commit ba14fda171
6 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg">
<foreignObject requiredFeatures="fail">
<svg>
<text>a</text>
</svg>
</foreignObject>
<script>
document.querySelector("text").getBBox();
</script>
</svg>

After

Width:  |  Height:  |  Size: 220 B

View File

@ -163,4 +163,5 @@ load 849688-1.svg
load 849688-2.svg
load 860378-1.svg
load 868904-1.svg
load 873806-1.svg
load 877029-1.svg

View File

@ -167,6 +167,19 @@ nsSVGOuterSVGFrame::Init(nsIContent* aContent,
SVGSVGElement *svg = static_cast<SVGSVGElement*>(aContent);
if (!svg->PassesConditionalProcessingTests()) {
AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD);
} else {
// If this outer <svg> element is the child of a <foreignObject> that
// is non-display, or is the child of a frame for HTML content that
// itself is a descendant of a non-display SVG frame, then we want to
// it non-display also. The second case is not as simple to handle
// as copying a state bit from the parent, since non-SVG frames do
// not use NS_STATE_SVG_NONDISPLAY_CHILD.
for (nsIFrame* f = aParent; f; f = f->GetParent()) {
if (f->IsFrameOfType(eSVG)) {
AddStateBits(f->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
break;
}
}
}
nsSVGOuterSVGFrameBase::Init(aContent, aParent, aPrevInFlow);

View File

@ -3074,6 +3074,9 @@ nsSVGTextFrame2::DidSetStyleContext(nsStyleContext* aOldStyleContext)
void
nsSVGTextFrame2::ReflowSVGNonDisplayText()
{
MOZ_ASSERT(nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(this),
"only call ReflowSVGNonDisplayText when an outer SVG frame is "
"under ReflowSVG");
MOZ_ASSERT(mState & NS_STATE_SVG_NONDISPLAY_CHILD,
"only call ReflowSVGNonDisplayText if the frame is "
"NS_STATE_SVG_NONDISPLAY_CHILD");
@ -4832,6 +4835,8 @@ nsSVGTextFrame2::UpdateGlyphPositioning()
// by nsSVGDisplayContainerFrame::ReflowSVG.)
kid->AddStateBits(NS_FRAME_IS_DIRTY);
}
MOZ_ASSERT(nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(this),
"should be under ReflowSVG");
nsPresContext::InterruptPreventer noInterrupts(PresContext());
DoReflow();
}

View File

@ -451,6 +451,19 @@ nsSVGUtils::OuterSVGIsCallingReflowSVG(nsIFrame *aFrame)
return GetOuterSVGFrame(aFrame)->IsCallingReflowSVG();
}
bool
nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(nsIFrame* aFrame)
{
nsSVGOuterSVGFrame* outer = GetOuterSVGFrame(aFrame);
do {
if (outer->IsCallingReflowSVG()) {
return true;
}
outer = GetOuterSVGFrame(outer->GetParent());
} while (outer);
return false;
}
void
nsSVGUtils::ScheduleReflowSVG(nsIFrame *aFrame)
{

View File

@ -521,6 +521,7 @@ public:
static nsIFrame* GetFirstNonAAncestorFrame(nsIFrame* aStartFrame);
static bool OuterSVGIsCallingReflowSVG(nsIFrame *aFrame);
static bool AnyOuterSVGIsCallingReflowSVG(nsIFrame *aFrame);
/*
* Get any additional transforms that apply only to stroking