mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1062832 - Move frame invalidation from nsSVGFilterReference to nsSVGFilterProperty. r=roc
This commit is contained in:
parent
5ca816d536
commit
b12757247a
@ -245,39 +245,37 @@ nsSVGFilterReference::GetFilterFrame()
|
||||
void
|
||||
nsSVGFilterReference::DoUpdate()
|
||||
{
|
||||
nsSVGRenderingObserverProperty::DoUpdate();
|
||||
nsSVGIDRenderingObserver::DoUpdate();
|
||||
|
||||
nsIFrame* frame = mFrameReference.Get();
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
// Repaint asynchronously in case the filter frame is being torn down
|
||||
nsChangeHint changeHint =
|
||||
nsChangeHint(nsChangeHint_RepaintFrame);
|
||||
|
||||
// Don't need to request UpdateOverflow if we're being reflowed.
|
||||
if (!(frame->GetStateBits() & NS_FRAME_IN_REFLOW)) {
|
||||
NS_UpdateHint(changeHint, nsChangeHint_UpdateOverflow);
|
||||
if (mFilterChainObserver) {
|
||||
mFilterChainObserver->Invalidate();
|
||||
}
|
||||
frame->PresContext()->RestyleManager()->PostRestyleEvent(
|
||||
frame->GetContent()->AsElement(), nsRestyleHint(0), changeHint);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSVGFilterProperty, nsISupports)
|
||||
|
||||
nsSVGFilterProperty::nsSVGFilterProperty(const nsTArray<nsStyleFilter> &aFilters,
|
||||
nsIFrame *aFilteredFrame)
|
||||
: mFrameReference(aFilteredFrame)
|
||||
{
|
||||
nsIContent* filteredElement = aFilteredFrame->GetContent();
|
||||
for (uint32_t i = 0; i < aFilters.Length(); i++) {
|
||||
if (aFilters[i].GetType() != NS_STYLE_FILTER_URL)
|
||||
continue;
|
||||
|
||||
nsRefPtr<nsSVGFilterReference> reference =
|
||||
new nsSVGFilterReference(aFilters[i].GetURL(), aFilteredFrame);
|
||||
new nsSVGFilterReference(aFilters[i].GetURL(), filteredElement, this);
|
||||
mReferences.AppendElement(reference);
|
||||
}
|
||||
}
|
||||
|
||||
nsSVGFilterProperty::~nsSVGFilterProperty()
|
||||
{
|
||||
for (uint32_t i = 0; i < mReferences.Length(); i++) {
|
||||
mReferences[i]->DetachFromChainObserver();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsSVGFilterProperty::ReferencesValidResources()
|
||||
{
|
||||
@ -299,11 +297,28 @@ nsSVGFilterProperty::IsInObserverLists() const
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGFilterProperty::Invalidate()
|
||||
nsSVGFilterProperty::DoUpdate()
|
||||
{
|
||||
for (uint32_t i = 0; i < mReferences.Length(); i++) {
|
||||
mReferences[i]->Invalidate();
|
||||
nsIFrame* frame = mFrameReference.Get();
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
if (frame && frame->IsFrameOfType(nsIFrame::eSVG)) {
|
||||
// Changes should propagate out to things that might be observing
|
||||
// the referencing frame or its ancestors.
|
||||
nsSVGEffects::InvalidateRenderingObservers(frame);
|
||||
}
|
||||
|
||||
// Repaint asynchronously in case the filter frame is being torn down
|
||||
nsChangeHint changeHint =
|
||||
nsChangeHint(nsChangeHint_RepaintFrame);
|
||||
|
||||
// Don't need to request UpdateOverflow if we're being reflowed.
|
||||
if (!(frame->GetStateBits() & NS_FRAME_IN_REFLOW)) {
|
||||
NS_UpdateHint(changeHint, nsChangeHint_UpdateOverflow);
|
||||
}
|
||||
frame->PresContext()->RestyleManager()->PostRestyleEvent(
|
||||
frame->GetContent()->AsElement(), nsRestyleHint(0), changeHint);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -29,6 +29,7 @@ class nsSVGClipPathFrame;
|
||||
class nsSVGPaintServerFrame;
|
||||
class nsSVGFilterFrame;
|
||||
class nsSVGMaskFrame;
|
||||
class nsSVGFilterProperty;
|
||||
|
||||
/*
|
||||
* This interface allows us to be notified when a piece of SVG content is
|
||||
@ -197,13 +198,20 @@ protected:
|
||||
* The nsSVGFilterProperty class manages a list of nsSVGFilterReferences.
|
||||
*/
|
||||
class nsSVGFilterReference MOZ_FINAL :
|
||||
public nsSVGRenderingObserverProperty, public nsISVGFilterReference {
|
||||
public nsSVGIDRenderingObserver, public nsISVGFilterReference {
|
||||
public:
|
||||
nsSVGFilterReference(nsIURI *aURI, nsIFrame *aFilteredFrame)
|
||||
: nsSVGRenderingObserverProperty(aURI, aFilteredFrame, false) {}
|
||||
nsSVGFilterReference(nsIURI* aURI,
|
||||
nsIContent* aObservingContent,
|
||||
nsSVGFilterProperty* aFilterChainObserver)
|
||||
: nsSVGIDRenderingObserver(aURI, aObservingContent, false)
|
||||
, mFilterChainObserver(aFilterChainObserver)
|
||||
{
|
||||
}
|
||||
|
||||
bool ReferencesValidResource() { return GetFilterFrame(); }
|
||||
|
||||
void DetachFromChainObserver() { mFilterChainObserver = nullptr; }
|
||||
|
||||
/**
|
||||
* @return the filter frame, or null if there is no filter frame
|
||||
*/
|
||||
@ -218,9 +226,11 @@ public:
|
||||
protected:
|
||||
virtual ~nsSVGFilterReference() {}
|
||||
|
||||
private:
|
||||
// nsSVGRenderingObserverProperty
|
||||
// nsSVGIDRenderingObserver
|
||||
virtual void DoUpdate() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
nsSVGFilterProperty* mFilterChainObserver;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -240,16 +250,19 @@ public:
|
||||
|
||||
bool ReferencesValidResources();
|
||||
bool IsInObserverLists() const;
|
||||
void Invalidate();
|
||||
void Invalidate() { DoUpdate(); }
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
protected:
|
||||
virtual ~nsSVGFilterProperty() {}
|
||||
virtual ~nsSVGFilterProperty();
|
||||
|
||||
virtual void DoUpdate();
|
||||
|
||||
private:
|
||||
nsTArray<nsRefPtr<nsSVGFilterReference>> mReferences;
|
||||
nsSVGFrameReferenceFromProperty mFrameReference;
|
||||
};
|
||||
|
||||
class nsSVGMarkerProperty : public nsSVGRenderingObserverProperty {
|
||||
|
Loading…
Reference in New Issue
Block a user