From a2769c4330d1067c3d4ca4c2e1a2936fb710af36 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Sat, 19 May 2012 14:50:07 +0100 Subject: [PATCH] Bug 756462 - Stop unnecessary propagating COORD_CONTEXT_CHANGED notifications to descendants of nsSVGInnerSVGFrame. r=longsonr. --- layout/svg/base/src/nsSVGInnerSVGFrame.cpp | 26 ++++++++++------------ layout/svg/base/src/nsSVGUseFrame.cpp | 4 ++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index 4d6dd0a8dac0..2c2667c59aa7 100644 --- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -155,20 +155,18 @@ nsSVGInnerSVGFrame::NotifySVGChanged(PRUint32 aFlags) aFlags |= TRANSFORM_CHANGED; } - // XXX We could clear the COORD_CONTEXT_CHANGED flag in some circumstances - // if we have a non-percentage 'width' AND 'height, or if we have a 'viewBox' - // rect. This is because, when we have a viewBox rect, the viewBox rect - // is the coordinate context for our children, and it isn't changing. - // Percentage lengths on our children will continue to resolve to the - // same number of user units because they're relative to our viewBox rect. The - // same is true if we have a non-percentage width and height and don't have a - // viewBox. We (the ) establish the coordinate context for our children. Our - // children don't care about changes to our parent coordinate context unless that - // change results in a change to the coordinate context that _we_ establish. Hence - // we can (should, really) stop propagating COORD_CONTEXT_CHANGED in these cases. - // We'd actually need to check that we have a viewBox rect and not just - // that viewBox is set, since it could be set to none. - // Take care not to break the testcase for bug 394463 when implementing this + if (svg->HasViewBox() || + (!svg->mLengthAttributes[nsSVGSVGElement::WIDTH].IsPercentage() && + !svg->mLengthAttributes[nsSVGSVGElement::HEIGHT].IsPercentage())) { + // Remove COORD_CONTEXT_CHANGED, since we establish the coordinate + // context for our descendants and this notification won't change its + // dimensions: + aFlags &= ~COORD_CONTEXT_CHANGED; + + if (!(aFlags & ~DO_NOT_NOTIFY_RENDERING_OBSERVERS)) { + return; // No notification flags left + } + } } if (aFlags & TRANSFORM_CHANGED) { diff --git a/layout/svg/base/src/nsSVGUseFrame.cpp b/layout/svg/base/src/nsSVGUseFrame.cpp index 477ff021c773..a936b2ebb8e8 100644 --- a/layout/svg/base/src/nsSVGUseFrame.cpp +++ b/layout/svg/base/src/nsSVGUseFrame.cpp @@ -225,6 +225,10 @@ nsSVGUseFrame::NotifySVGChanged(PRUint32 aFlags) } } + // We don't remove the TRANSFORM_CHANGED flag here if we have a viewBox or + // non-percentage width/height, since if they're set then they are cloned to + // an anonymous child , and its nsSVGInnerSVGFrame will do that. + nsSVGUseFrameBase::NotifySVGChanged(aFlags); }