NS_IMETHODIMP nsSVGForeignObjectFrame::NotifyRedrawUnsuspended() { if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) { if (GetStateBits() & NS_STATE_SVG_DIRTY) { UpdateGraphic(); // invalidate our entire area } else { FlushDirtyRegion(0); // only invalidate areas dirtied by our descendants } } return NS_OK; }
void nsSVGForeignObjectFrame::DoReflow() { // Skip reflow if we're zero-sized, unless this is our first reflow. if (IsDisabled() && !(GetStateBits() & NS_FRAME_FIRST_REFLOW)) return; nsPresContext *presContext = PresContext(); nsIFrame* kid = GetFirstPrincipalChild(); if (!kid) return; // initiate a synchronous reflow here and now: nsIPresShell* presShell = presContext->PresShell(); NS_ASSERTION(presShell, "null presShell"); nsRefPtr<nsRenderingContext> renderingContext = presShell->GetReferenceRenderingContext(); if (!renderingContext) return; mInReflow = true; nsHTMLReflowState reflowState(presContext, kid, renderingContext, nsSize(mRect.width, NS_UNCONSTRAINEDSIZE)); nsHTMLReflowMetrics desiredSize; nsReflowStatus status; // We don't use mRect.height above because that tells the child to do // page/column breaking at that height. NS_ASSERTION(reflowState.mComputedBorderPadding == nsMargin(0, 0, 0, 0) && reflowState.mComputedMargin == nsMargin(0, 0, 0, 0), "style system should ensure that :-moz-svg-foreign-content " "does not get styled"); NS_ASSERTION(reflowState.ComputedWidth() == mRect.width, "reflow state made child wrong size"); reflowState.SetComputedHeight(mRect.height); ReflowChild(kid, presContext, desiredSize, reflowState, 0, 0, NS_FRAME_NO_MOVE_FRAME, status); NS_ASSERTION(mRect.width == desiredSize.width && mRect.height == desiredSize.height, "unexpected size"); FinishReflowChild(kid, presContext, &reflowState, desiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); mInReflow = false; if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) { FlushDirtyRegion(0); } }
void nsSVGForeignObjectFrame::InvalidateInternal(const nsRect& aDamageRect, nscoord aX, nscoord aY, nsIFrame* aForChild, PRUint32 aFlags) { // This is called by our descendants when they change. if (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD) return; nsRegion* region = (aFlags & INVALIDATE_CROSS_DOC) ? &mSubDocDirtyRegion : &mSameDocDirtyRegion; region->Or(*region, aDamageRect + nsPoint(aX, aY)); FlushDirtyRegion(aFlags); }
void nsSVGForeignObjectFrame::DoReflow() { NS_ASSERTION(!(nsSVGUtils::GetOuterSVGFrame(this)-> GetStateBits() & NS_FRAME_FIRST_REFLOW), "Calling InitialUpdate too early - must not call DoReflow!!!"); // Skip reflow if we're zero-sized, unless this is our first reflow. if (IsDisabled() && !(GetStateBits() & NS_FRAME_FIRST_REFLOW)) return; if (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD) return; nsPresContext *presContext = PresContext(); nsIFrame* kid = GetFirstChild(nsnull); if (!kid) return; // initiate a synchronous reflow here and now: nsSize availableSpace(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); nsIPresShell* presShell = presContext->PresShell(); NS_ASSERTION(presShell, "null presShell"); nsRefPtr<nsRenderingContext> renderingContext = presShell->GetReferenceRenderingContext(); if (!renderingContext) return; nsSVGForeignObjectElement *fO = static_cast<nsSVGForeignObjectElement*> (mContent); float width = fO->mLengthAttributes[nsSVGForeignObjectElement::WIDTH].GetAnimValue(fO); float height = fO->mLengthAttributes[nsSVGForeignObjectElement::HEIGHT].GetAnimValue(fO); // Clamp height & width to be non-negative (to match UpdateCoveredRegion). width = NS_MAX(width, 0.0f); height = NS_MAX(height, 0.0f); nsSize size(nsPresContext::CSSPixelsToAppUnits(width), nsPresContext::CSSPixelsToAppUnits(height)); mInReflow = PR_TRUE; nsHTMLReflowState reflowState(presContext, kid, renderingContext, nsSize(size.width, NS_UNCONSTRAINEDSIZE)); nsHTMLReflowMetrics desiredSize; nsReflowStatus status; // We don't use size.height above because that tells the child to do // page/column breaking at that height. NS_ASSERTION(reflowState.mComputedBorderPadding == nsMargin(0, 0, 0, 0) && reflowState.mComputedMargin == nsMargin(0, 0, 0, 0), "style system should ensure that :-moz-svg-foreign content " "does not get styled"); NS_ASSERTION(reflowState.ComputedWidth() == size.width, "reflow state made child wrong size"); reflowState.SetComputedHeight(size.height); ReflowChild(kid, presContext, desiredSize, reflowState, 0, 0, NS_FRAME_NO_MOVE_FRAME, status); NS_ASSERTION(size.width == desiredSize.width && size.height == desiredSize.height, "unexpected size"); FinishReflowChild(kid, presContext, &reflowState, desiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); mInReflow = PR_FALSE; FlushDirtyRegion(0); }