Bug 802628 - Part 1, Kill nsSVGUtils::InvalidateAndScheduleReflowSVG. r=mattwoodrow.

This commit is contained in:
Jonathan Watt 2012-11-28 09:42:13 +00:00
parent 717317ae39
commit 1e1e657295
15 changed files with 51 additions and 46 deletions

View File

@ -68,7 +68,8 @@ nsSVGSwitchElement::MaybeInvalidate()
nsIFrame *frame = GetPrimaryFrame();
if (frame) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(frame);
nsSVGUtils::InvalidateBounds(frame, false);
nsSVGUtils::ScheduleReflowSVG(frame);
}
mActiveChild = newActiveChild;

View File

@ -7744,7 +7744,8 @@ DoApplyRenderingChangeToTree(nsIFrame* aFrame,
if (aChange & nsChangeHint_UpdateEffects) {
needInvalidatingPaint = true;
// Invalidate and update our area:
nsSVGUtils::InvalidateAndScheduleReflowSVG(aFrame);
nsSVGUtils::InvalidateBounds(aFrame, false);
nsSVGUtils::ScheduleReflowSVG(aFrame);
} else {
needInvalidatingPaint = true;
// Just invalidate our area:

View File

@ -107,7 +107,8 @@ nsSVGAFrame::AttributeChanged(int32_t aNameSpaceID,
{
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::transform) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifySVGChanged(TRANSFORM_CHANGED);
}

View File

@ -280,7 +280,9 @@ nsSVGMarkerProperty::DoUpdate()
if (!(mFrame->GetStateBits() & NS_FRAME_IN_REFLOW)) {
// XXXjwatt: We need to unify SVG into standard reflow so we can just use
// nsChangeHint_NeedReflow | nsChangeHint_NeedDirtyReflow here.
nsSVGUtils::InvalidateAndScheduleReflowSVG(mFrame);
nsSVGUtils::InvalidateBounds(mFrame, false);
// XXXSDL KILL THIS!!!
nsSVGUtils::ScheduleReflowSVG(mFrame);
}
mFramePresShell->FrameConstructor()->PostRestyleEvent(
mFrame->GetContent()->AsElement(), nsRestyleHint(0), changeHint);

View File

@ -97,7 +97,8 @@ nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
// XXXjwatt: why mark intrinsic widths dirty? can't we just use eResize?
RequestReflow(nsIPresShell::eStyleChange);
} else if (aAttribute == nsGkAtoms::x ||
@ -105,7 +106,8 @@ nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::transform) {
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nullptr;
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
} else if (aAttribute == nsGkAtoms::viewBox ||
aAttribute == nsGkAtoms::preserveAspectRatio) {
nsSVGUtils::InvalidateBounds(this);
@ -127,7 +129,8 @@ nsSVGForeignObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
// XXXperf: probably only need a bounds update if 'font-size' changed and
// we have em unit width/height. Or, once we map 'transform' into style,
// if some transform property changed.
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
}
}

View File

@ -91,7 +91,8 @@ nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID,
{
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::transform) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifySVGChanged(TRANSFORM_CHANGED);
}

View File

@ -185,7 +185,8 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
return NS_OK;
}
else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
@ -564,7 +565,8 @@ nsSVGImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect
return NS_ERROR_FAILURE;
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(mFrame);
nsSVGUtils::InvalidateBounds(mFrame, false);
nsSVGUtils::ScheduleReflowSVG(mFrame);
}
if (aType == imgINotificationObserver::FRAME_UPDATE) {
@ -577,7 +579,8 @@ nsSVGImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
// Called once the resource's dimensions have been obtained.
aRequest->GetImage(getter_AddRefs(mFrame->mImageContainer));
nsSVGUtils::InvalidateAndScheduleReflowSVG(mFrame);
nsSVGUtils::InvalidateBounds(mFrame, false);
nsSVGUtils::ScheduleReflowSVG(mFrame);
}
return NS_OK;

View File

@ -169,7 +169,8 @@ nsSVGInnerSVGFrame::AttributeChanged(int32_t aNameSpaceID,
if (aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
if (content->HasViewBoxOrSyntheticViewBox()) {
// make sure our cached transform matrix gets (lazily) updated
@ -193,7 +194,8 @@ nsSVGInnerSVGFrame::AttributeChanged(int32_t aNameSpaceID,
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nullptr;
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
nsSVGUtils::NotifyChildrenOfSVGChange(
this, aAttribute == nsGkAtoms::viewBox ?

View File

@ -108,9 +108,10 @@ nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
if (aNameSpaceID == kNameSpaceID_None &&
(static_cast<nsSVGPathGeometryElement*>
(mContent)->AttributeDefinesGeometry(aAttribute) ||
aAttribute == nsGkAtoms::transform))
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
aAttribute == nsGkAtoms::transform)) {
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
}
return NS_OK;
}
@ -125,7 +126,8 @@ nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
// style_hints don't map very well onto svg. Here seems to be the
// best place to deal with style changes:
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
}
nsIAtom *

View File

@ -80,7 +80,8 @@ nsSVGTSpanFrame::AttributeChanged(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::dx ||
aAttribute == nsGkAtoms::dy ||
aAttribute == nsGkAtoms::rotate)) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifyGlyphMetricsChange();
}

View File

@ -56,14 +56,16 @@ nsSVGTextFrame::AttributeChanged(int32_t aNameSpaceID,
return NS_OK;
if (aAttribute == nsGkAtoms::transform) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifySVGChanged(TRANSFORM_CHANGED);
} else if (aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::dx ||
aAttribute == nsGkAtoms::dy ||
aAttribute == nsGkAtoms::rotate) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifyGlyphMetricsChange();
}
@ -320,7 +322,8 @@ nsSVGTextFrame::NotifyGlyphMetricsChange()
// as fully dirty to get ReflowSVG() called on them:
MarkDirtyBitsOnDescendants(this);
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
mPositioningDirty = true;
}

View File

@ -158,11 +158,13 @@ nsSVGTextPathFrame::AttributeChanged(int32_t aNameSpaceID,
{
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::startOffset) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
NotifyGlyphMetricsChange();
} else if (aNameSpaceID == kNameSpaceID_XLink &&
aAttribute == nsGkAtoms::href) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
// Blow away our reference, if any
Properties().Delete(nsSVGEffects::HrefProperty());
NotifyGlyphMetricsChange();

View File

@ -124,7 +124,8 @@ nsSVGUseFrame::AttributeChanged(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::y) {
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nullptr;
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
nsSVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED);
} else if (aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height) {
@ -138,13 +139,15 @@ nsSVGUseFrame::AttributeChanged(int32_t aNameSpaceID,
useElement->SyncWidthOrHeight(aAttribute);
}
if (invalidate) {
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
}
}
} else if (aNameSpaceID == kNameSpaceID_XLink &&
aAttribute == nsGkAtoms::href) {
// we're changing our nature, clear out the clone information
nsSVGUtils::InvalidateAndScheduleReflowSVG(this);
nsSVGUtils::InvalidateBounds(this, false);
nsSVGUtils::ScheduleReflowSVG(this);
useElement->mOriginal = nullptr;
useElement->UnlinkSource();
useElement->TriggerReclone();

View File

@ -560,19 +560,6 @@ nsSVGUtils::ScheduleReflowSVG(nsIFrame *aFrame)
outerSVGFrame, nsIPresShell::eResize, dirtyBit);
}
void
nsSVGUtils::InvalidateAndScheduleReflowSVG(nsIFrame *aFrame)
{
// If this is triggered, the callers should be fixed to call us much
// earlier. If we try to mark dirty bits on frames while we're in the
// process of removing them, things will get messed up.
NS_ASSERTION(!OuterSVGIsCallingReflowSVG(aFrame),
"Must not call under nsISVGChildFrame::ReflowSVG!");
InvalidateBounds(aFrame, false);
ScheduleReflowSVG(aFrame);
}
bool
nsSVGUtils::NeedsReflowSVG(nsIFrame *aFrame)
{

View File

@ -302,13 +302,6 @@ public:
*/
static void ScheduleReflowSVG(nsIFrame *aFrame);
/**
* Invalidates the area that the frame last painted to, then schedules an
* update of the frame's bounds (which will in turn invalidate the new area
* that the frame should paint to).
*/
static void InvalidateAndScheduleReflowSVG(nsIFrame *aFrame);
/**
* Returns true if the frame or any of its children need ReflowSVG
* to be called on them.