NS_IMETHODIMP nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { NS_ABORT_IF_FALSE(!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD), "Should not have been called"); // Only InvalidateAndScheduleBoundsUpdate marks us with NS_FRAME_IS_DIRTY, // so if that bit is still set we still have a resize pending. If we hit // this assertion, then we should get the presShell to skip reflow roots // that have a dirty parent since a reflow is going to come via the // reflow root's parent anyway. NS_ASSERTION(!(GetStateBits() & NS_FRAME_IS_DIRTY), "Reflowing while a resize is pending is wasteful"); // UpdateBounds makes sure mRect is up to date before we're called. NS_ASSERTION(!aReflowState.parentReflowState, "should only get reflow from being reflow root"); NS_ASSERTION(aReflowState.ComputedWidth() == GetSize().width && aReflowState.ComputedHeight() == GetSize().height, "reflow roots should be reflowed at existing size and " "svg.css should ensure we have no padding/border/margin"); DoReflow(); aDesiredSize.width = aReflowState.ComputedWidth(); aDesiredSize.height = aReflowState.ComputedHeight(); aDesiredSize.SetOverflowAreasToDesiredBounds(); aStatus = NS_FRAME_COMPLETE; return NS_OK; }
void nsSVGForeignObjectFrame::MaybeReflowFromOuterSVGFrame() { // If IsDisabled() is true, then we know that our DoReflow() call will return // early, leaving us with a marked-dirty but not-reflowed kid. That'd be bad; // it'd mean that all future calls to this method would be doomed to take the // NS_FRAME_IS_DIRTY early-return below. To avoid that problem, we need to // bail out *before* we mark our kid as dirty. if (IsDisabled()) { return; } nsIFrame* kid = GetFirstChild(nsnull); // If we're already scheduled to reflow (if we or our kid is dirty) we don't // want to reflow now or else our presShell will do extra work trying to // reflow us a second time. (It will also complain if it finds that a reflow // root scheduled for reflow isn't dirty). if (kid->GetStateBits() & NS_FRAME_IS_DIRTY) { return; } kid->AddStateBits(NS_FRAME_IS_DIRTY); // we must be fully marked dirty if (kid->GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN) { return; } // Make sure to not allow interrupts if we're not being reflown as a root nsPresContext::InterruptPreventer noInterrupts(PresContext()); DoReflow(); }
NS_IMETHODIMP nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { // InitialUpdate and AttributeChanged make sure mRect is up to date before // we're called (UpdateCoveredRegion sets mRect). NS_ASSERTION(!aReflowState.parentReflowState, "should only get reflow from being reflow root"); NS_ASSERTION(aReflowState.ComputedWidth() == GetSize().width && aReflowState.ComputedHeight() == GetSize().height, "reflow roots should be reflowed at existing size and " "svg.css should ensure we have no padding/border/margin"); DoReflow(); aDesiredSize.width = aReflowState.ComputedWidth(); aDesiredSize.height = aReflowState.ComputedHeight(); aDesiredSize.SetOverflowAreasToDesiredBounds(); aStatus = NS_FRAME_COMPLETE; return NS_OK; }
void nsSVGForeignObjectFrame::UpdateBounds() { NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingUpdateBounds(this), "This call is probaby a wasteful mistake"); NS_ABORT_IF_FALSE(!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD), "UpdateBounds mechanism not designed for this"); if (!nsSVGUtils::NeedsUpdatedBounds(this)) { return; } // We update mRect before the DoReflow call so that DoReflow uses the // correct dimensions: float x, y, w, h; static_cast<nsSVGForeignObjectElement*>(mContent)-> GetAnimatedLengthValues(&x, &y, &w, &h, nsnull); // If mRect's width or height are negative, reflow blows up! We must clamp! if (w < 0.0f) w = 0.0f; if (h < 0.0f) h = 0.0f; // GetCanvasTM includes the x,y translation mRect = nsLayoutUtils::RoundGfxRectToAppRect( gfxRect(0.0, 0.0, w, h), PresContext()->AppUnitsPerCSSPixel()); mCoveredRegion = ToCanvasBounds(gfxRect(0.0, 0.0, w, h), GetCanvasTM(), PresContext()); // Since we'll invalidate our entire area at the end of this method, we // empty our cached dirty regions to prevent FlushDirtyRegion under DoReflow // from wasting time invalidating: mSameDocDirtyRegion.SetEmpty(); mSubDocDirtyRegion.SetEmpty(); // Fully mark our kid dirty so that it gets resized if necessary // (NS_FRAME_HAS_DIRTY_CHILDREN isn't enough in that case): nsIFrame* kid = GetFirstPrincipalChild(); kid->AddStateBits(NS_FRAME_IS_DIRTY); // Make sure to not allow interrupts if we're not being reflown as a root: nsPresContext::InterruptPreventer noInterrupts(PresContext()); DoReflow(); // Now unset the various reflow bits: mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { // We only invalidate if our outer-<svg> has already had its // initial reflow (since if it hasn't, its entire area will be // invalidated when it gets that initial reflow): nsSVGUtils::InvalidateBounds(this, true); } }
NS_IMETHODIMP nsLeafFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("enter nsLeafFrame::Reflow: aMaxSize=%d,%d", aReflowState.availableWidth, aReflowState.availableHeight)); NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow"); DoReflow(aPresContext, aMetrics, aReflowState, aStatus); FinishAndStoreOverflow(&aMetrics); return NS_OK; }
NS_IMETHODIMP nsImageLoader::OnStopRequest(imgIRequest *aRequest, bool aLastPart) { if (!mFrame) return NS_ERROR_FAILURE; if (!mRequest) { // We're in the middle of a paint anyway return NS_OK; } // Take requested actions if (mActions & ACTION_REFLOW_ON_LOAD) { DoReflow(); } if (mActions & ACTION_REDRAW_ON_LOAD) { DoRedraw(nsnull); } return NS_OK; }
NS_IMETHODIMP nsSVGForeignObjectFrame::InitialUpdate() { NS_ASSERTION(GetStateBits() & NS_FRAME_FIRST_REFLOW, "Yikes! We've been called already! Hopefully we weren't called " "before our nsSVGOuterSVGFrame's initial Reflow()!!!"); UpdateCoveredRegion(); // Make sure to not allow interrupts if we're not being reflown as a root nsPresContext::InterruptPreventer noInterrupts(PresContext()); DoReflow(); NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW), "We don't actually participate in reflow"); // Do unset the various reflow bits, though. mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); return NS_OK; }