2008-08-08 01:34:43 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-08-08 01:34:43 +00:00
|
|
|
|
|
|
|
#ifndef NSSVGEFFECTS_H_
|
|
|
|
#define NSSVGEFFECTS_H_
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "FramePropertyTable.h"
|
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsID.h"
|
2008-08-08 01:34:43 +00:00
|
|
|
#include "nsIFrame.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsIMutationObserver.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsISupportsBase.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2008-08-08 01:34:43 +00:00
|
|
|
#include "nsReferencedElement.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsTHashtable.h"
|
2010-08-13 13:30:45 +00:00
|
|
|
#include "nsURIHashKey.h"
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2012-03-20 12:15:55 +00:00
|
|
|
class nsIAtom;
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIURI;
|
2008-10-01 00:51:05 +00:00
|
|
|
class nsSVGClipPathFrame;
|
2012-08-05 19:10:21 +00:00
|
|
|
class nsSVGPaintServerFrame;
|
2008-10-01 00:51:05 +00:00
|
|
|
class nsSVGFilterFrame;
|
|
|
|
class nsSVGMaskFrame;
|
|
|
|
|
|
|
|
/*
|
2010-09-08 20:40:39 +00:00
|
|
|
* This interface allows us to be notified when a piece of SVG content is
|
|
|
|
* re-rendered.
|
|
|
|
*
|
|
|
|
* Concrete implementations of this interface need to implement
|
|
|
|
* "GetTarget()" to specify the piece of SVG content that they'd like to
|
|
|
|
* monitor, and they need to implement "DoUpdate" to specify how we'll react
|
|
|
|
* when that content gets re-rendered. They also need to implement a
|
|
|
|
* constructor and destructor, which should call StartListening and
|
|
|
|
* StopListening, respectively.
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
|
|
|
class nsSVGRenderingObserver : public nsStubMutationObserver {
|
2014-06-23 22:40:01 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsSVGRenderingObserver()
|
|
|
|
{}
|
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
public:
|
2010-08-13 13:31:31 +00:00
|
|
|
typedef mozilla::dom::Element Element;
|
2010-09-08 20:40:39 +00:00
|
|
|
nsSVGRenderingObserver()
|
2011-10-17 14:59:28 +00:00
|
|
|
: mInObserverList(false)
|
2010-09-08 20:40:39 +00:00
|
|
|
{}
|
2008-08-08 01:34:43 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
2010-08-13 13:31:31 +00:00
|
|
|
void InvalidateViaReferencedElement();
|
2010-11-16 18:35:59 +00:00
|
|
|
|
|
|
|
// When a nsSVGRenderingObserver list gets forcibly cleared, it uses this
|
|
|
|
// callback to notify every observer that's cleared from it, so they can
|
|
|
|
// react.
|
|
|
|
void NotifyEvictedFromRenderingObserverList();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsInObserverList() const { return mInObserverList; }
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2010-12-19 17:47:01 +00:00
|
|
|
nsIFrame* GetReferencedFrame();
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* @param aOK this is only for the convenience of callers. We set *aOK to false
|
2010-12-19 17:47:01 +00:00
|
|
|
* if the frame is the wrong type
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIFrame* GetReferencedFrame(nsIAtom* aFrameType, bool* aOK);
|
2008-10-01 00:51:05 +00:00
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
Element* GetReferencedElement();
|
|
|
|
|
2012-08-29 05:49:16 +00:00
|
|
|
virtual bool ObservesReflow() { return true; }
|
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
protected:
|
2010-09-08 20:40:39 +00:00
|
|
|
// Non-virtual protected methods
|
2010-08-13 13:31:31 +00:00
|
|
|
void StartListening();
|
|
|
|
void StopListening();
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
// Virtual protected methods
|
|
|
|
virtual void DoUpdate() = 0; // called when the referenced resource changes.
|
|
|
|
|
|
|
|
// This is an internally-used version of GetReferencedElement that doesn't
|
|
|
|
// forcibly add us as an observer. (whereas GetReferencedElement does)
|
|
|
|
virtual Element* GetTarget() = 0;
|
|
|
|
|
|
|
|
// Whether we're in our referenced element's observer list at this time.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInObserverList;
|
2010-09-08 20:40:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SVG elements reference supporting resources by element ID. We need to
|
|
|
|
* track when those resources change and when the DOM changes in ways
|
|
|
|
* that affect which element is referenced by a given ID (e.g., when
|
|
|
|
* element IDs change). The code here is responsible for that.
|
2014-08-01 00:37:35 +00:00
|
|
|
*
|
2010-09-08 20:40:39 +00:00
|
|
|
* When a frame references a supporting resource, we create a property
|
|
|
|
* object derived from nsSVGIDRenderingObserver to manage the relationship. The
|
|
|
|
* property object is attached to the referencing frame.
|
|
|
|
*/
|
|
|
|
class nsSVGIDRenderingObserver : public nsSVGRenderingObserver {
|
|
|
|
public:
|
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
nsSVGIDRenderingObserver(nsIURI* aURI, nsIFrame *aFrame,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aReferenceImage);
|
2010-09-08 20:40:39 +00:00
|
|
|
virtual ~nsSVGIDRenderingObserver();
|
|
|
|
|
|
|
|
protected:
|
2012-09-14 16:10:08 +00:00
|
|
|
Element* GetTarget() MOZ_OVERRIDE { return mElement.get(); }
|
2010-09-08 20:40:39 +00:00
|
|
|
|
|
|
|
// This is called when the referenced resource changes.
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DoUpdate() MOZ_OVERRIDE;
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
class SourceReference : public nsReferencedElement {
|
|
|
|
public:
|
2010-09-08 20:40:39 +00:00
|
|
|
SourceReference(nsSVGIDRenderingObserver* aContainer) : mContainer(aContainer) {}
|
2008-08-08 01:34:43 +00:00
|
|
|
protected:
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_OVERRIDE {
|
2010-08-13 13:31:31 +00:00
|
|
|
mContainer->StopListening();
|
2010-05-14 17:04:51 +00:00
|
|
|
nsReferencedElement::ElementChanged(aFrom, aTo);
|
2010-08-13 13:31:31 +00:00
|
|
|
mContainer->StartListening();
|
2008-08-08 01:34:43 +00:00
|
|
|
mContainer->DoUpdate();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Override IsPersistent because we want to keep tracking the element
|
|
|
|
* for the ID even when it changes.
|
|
|
|
*/
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual bool IsPersistent() MOZ_OVERRIDE { return true; }
|
2008-08-08 01:34:43 +00:00
|
|
|
private:
|
2010-09-08 20:40:39 +00:00
|
|
|
nsSVGIDRenderingObserver* mContainer;
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
2014-08-01 00:37:35 +00:00
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
SourceReference mElement;
|
2008-10-01 00:51:05 +00:00
|
|
|
// The frame that this property is attached to
|
2013-02-11 06:22:20 +00:00
|
|
|
nsIFrame *mFrame;
|
2008-10-01 00:51:05 +00:00
|
|
|
// When a presshell is torn down, we don't delete the properties for
|
|
|
|
// each frame until after the frames are destroyed. So here we remember
|
|
|
|
// the presshell for the frames we care about and, before we use the frame,
|
|
|
|
// we test the presshell to see if it's destroying itself. If it is,
|
|
|
|
// then the frame pointer is not valid and we know the frame has gone away.
|
|
|
|
nsIPresShell *mFramePresShell;
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 04:31:03 +00:00
|
|
|
/**
|
|
|
|
* In a filter chain, there can be multiple SVG reference filters.
|
|
|
|
* e.g. filter: url(#svg-filter-1) blur(10px) url(#svg-filter-2);
|
|
|
|
*
|
|
|
|
* This class keeps track of one SVG reference filter in a filter chain.
|
|
|
|
* e.g. url(#svg-filter-1)
|
|
|
|
*
|
|
|
|
* It fires invalidations when the SVG filter element's id changes or when
|
|
|
|
* the SVG filter element's content changes.
|
|
|
|
*
|
|
|
|
* The nsSVGFilterProperty class manages a list of nsSVGFilterReferences.
|
|
|
|
*/
|
2014-08-05 17:33:55 +00:00
|
|
|
class nsSVGFilterReference MOZ_FINAL :
|
2014-02-10 04:31:03 +00:00
|
|
|
public nsSVGIDRenderingObserver, public nsISVGFilterReference {
|
2008-08-08 01:34:43 +00:00
|
|
|
public:
|
2014-02-10 04:31:03 +00:00
|
|
|
nsSVGFilterReference(nsIURI *aURI, nsIFrame *aFilteredFrame)
|
|
|
|
: nsSVGIDRenderingObserver(aURI, aFilteredFrame, false) {}
|
|
|
|
|
|
|
|
bool ReferencesValidResource() { return GetFilterFrame(); }
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* @return the filter frame, or null if there is no filter frame
|
|
|
|
*/
|
|
|
|
nsSVGFilterFrame *GetFilterFrame();
|
2008-08-08 01:34:43 +00:00
|
|
|
|
|
|
|
// nsISupports
|
2014-07-14 19:21:34 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2014-02-10 04:31:03 +00:00
|
|
|
// nsISVGFilterReference
|
|
|
|
virtual void Invalidate() MOZ_OVERRIDE { DoUpdate(); };
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2014-07-08 21:23:18 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsSVGFilterReference() {}
|
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
private:
|
2014-02-10 04:31:03 +00:00
|
|
|
// nsSVGIDRenderingObserver
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DoUpdate() MOZ_OVERRIDE;
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 04:31:03 +00:00
|
|
|
/**
|
|
|
|
* This class manages a list of nsSVGFilterReferences, which represent SVG
|
|
|
|
* reference filters in a filter chain.
|
|
|
|
* e.g. filter: url(#svg-filter-1) blur(10px) url(#svg-filter-2);
|
|
|
|
*
|
|
|
|
* In the above example, the nsSVGFilterProperty will manage two
|
|
|
|
* nsSVGFilterReferences, one for each SVG reference filter. CSS filters like
|
|
|
|
* "blur(10px)" don't reference filter elements, so they don't need an
|
|
|
|
* nsSVGFilterReference. The style system invalidates changes to CSS filters.
|
|
|
|
*/
|
|
|
|
class nsSVGFilterProperty : public nsISupports {
|
|
|
|
public:
|
|
|
|
nsSVGFilterProperty(const nsTArray<nsStyleFilter> &aFilters,
|
|
|
|
nsIFrame *aFilteredFrame);
|
|
|
|
|
|
|
|
const nsTArray<nsStyleFilter>& GetFilters() { return mFilters; }
|
|
|
|
bool ReferencesValidResources();
|
|
|
|
bool IsInObserverLists() const;
|
|
|
|
void Invalidate();
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2014-06-23 22:40:01 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsSVGFilterProperty();
|
|
|
|
|
2014-02-10 04:31:03 +00:00
|
|
|
private:
|
|
|
|
nsTArray<nsSVGFilterReference*> mReferences;
|
|
|
|
nsTArray<nsStyleFilter> mFilters;
|
|
|
|
};
|
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
class nsSVGMarkerProperty : public nsSVGIDRenderingObserver {
|
2008-10-10 13:14:05 +00:00
|
|
|
public:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSVGMarkerProperty(nsIURI *aURI, nsIFrame *aFrame, bool aReferenceImage)
|
2010-09-08 20:40:39 +00:00
|
|
|
: nsSVGIDRenderingObserver(aURI, aFrame, aReferenceImage) {}
|
2008-10-10 13:14:05 +00:00
|
|
|
|
|
|
|
protected:
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DoUpdate() MOZ_OVERRIDE;
|
2008-10-10 13:14:05 +00:00
|
|
|
};
|
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
class nsSVGTextPathProperty : public nsSVGIDRenderingObserver {
|
2008-10-11 11:29:35 +00:00
|
|
|
public:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSVGTextPathProperty(nsIURI *aURI, nsIFrame *aFrame, bool aReferenceImage)
|
2013-02-11 06:22:20 +00:00
|
|
|
: nsSVGIDRenderingObserver(aURI, aFrame, aReferenceImage)
|
|
|
|
, mValid(true) {}
|
2008-10-11 11:29:35 +00:00
|
|
|
|
2012-08-29 05:49:16 +00:00
|
|
|
virtual bool ObservesReflow() MOZ_OVERRIDE { return false; }
|
|
|
|
|
2008-10-11 11:29:35 +00:00
|
|
|
protected:
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DoUpdate() MOZ_OVERRIDE;
|
2013-02-11 06:22:20 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Returns true if the target of the textPath is the frame of a 'path' element.
|
|
|
|
*/
|
|
|
|
bool TargetIsValid();
|
|
|
|
|
|
|
|
bool mValid;
|
2008-10-11 11:29:35 +00:00
|
|
|
};
|
2014-08-01 00:37:35 +00:00
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
class nsSVGPaintingProperty : public nsSVGIDRenderingObserver {
|
2008-08-08 01:34:43 +00:00
|
|
|
public:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSVGPaintingProperty(nsIURI *aURI, nsIFrame *aFrame, bool aReferenceImage)
|
2010-09-08 20:40:39 +00:00
|
|
|
: nsSVGIDRenderingObserver(aURI, aFrame, aReferenceImage) {}
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
protected:
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DoUpdate() MOZ_OVERRIDE;
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* A manager for one-shot nsSVGRenderingObserver tracking.
|
|
|
|
* nsSVGRenderingObservers can be added or removed. They are not strongly
|
2010-01-23 18:47:53 +00:00
|
|
|
* referenced so an observer must be removed before it dies.
|
2008-10-01 00:51:05 +00:00
|
|
|
* When InvalidateAll is called, all outstanding references get
|
2010-08-13 13:31:31 +00:00
|
|
|
* InvalidateViaReferencedElement()
|
2008-10-01 00:51:05 +00:00
|
|
|
* called on them and the list is cleared. The intent is that
|
|
|
|
* the observer will force repainting of whatever part of the document
|
2010-01-23 18:47:53 +00:00
|
|
|
* is needed, and then at paint time the observer will do a clean lookup
|
2010-08-13 13:31:31 +00:00
|
|
|
* of the referenced element and [re-]add itself to the element's observer list.
|
2014-08-01 00:37:35 +00:00
|
|
|
*
|
2008-10-01 00:51:05 +00:00
|
|
|
* InvalidateAll must be called before this object is destroyed, i.e.
|
|
|
|
* before the referenced frame is destroyed. This should normally happen
|
|
|
|
* via nsSVGContainerFrame::RemoveFrame, since only frames in the frame
|
|
|
|
* tree should be referenced.
|
|
|
|
*/
|
|
|
|
class nsSVGRenderingObserverList {
|
2008-08-08 01:34:43 +00:00
|
|
|
public:
|
2013-09-02 08:41:57 +00:00
|
|
|
nsSVGRenderingObserverList()
|
2014-08-06 13:31:21 +00:00
|
|
|
: mObservers(4)
|
2013-09-02 08:41:57 +00:00
|
|
|
{
|
2009-06-24 21:19:02 +00:00
|
|
|
MOZ_COUNT_CTOR(nsSVGRenderingObserverList);
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsSVGRenderingObserverList() {
|
|
|
|
InvalidateAll();
|
|
|
|
MOZ_COUNT_DTOR(nsSVGRenderingObserverList);
|
|
|
|
}
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
void Add(nsSVGRenderingObserver* aObserver)
|
|
|
|
{ mObservers.PutEntry(aObserver); }
|
|
|
|
void Remove(nsSVGRenderingObserver* aObserver)
|
|
|
|
{ mObservers.RemoveEntry(aObserver); }
|
2010-08-13 13:31:31 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool Contains(nsSVGRenderingObserver* aObserver)
|
2012-07-30 14:20:58 +00:00
|
|
|
{ return (mObservers.GetEntry(aObserver) != nullptr); }
|
2010-08-13 13:31:31 +00:00
|
|
|
#endif
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsEmpty()
|
2010-08-13 13:31:31 +00:00
|
|
|
{ return mObservers.Count() == 0; }
|
2010-01-23 18:47:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop all our observers, and notify them that we have changed and dropped
|
|
|
|
* our reference to them.
|
|
|
|
*/
|
2008-10-01 00:51:05 +00:00
|
|
|
void InvalidateAll();
|
2008-08-08 01:34:43 +00:00
|
|
|
|
2012-08-29 05:49:16 +00:00
|
|
|
/**
|
|
|
|
* Drop all observers that observe reflow, and notify them that we have changed and dropped
|
|
|
|
* our reference to them.
|
|
|
|
*/
|
|
|
|
void InvalidateAllForReflow();
|
|
|
|
|
2010-11-16 18:35:59 +00:00
|
|
|
/**
|
|
|
|
* Drop all our observers, and notify them that we have dropped our reference
|
|
|
|
* to them.
|
|
|
|
*/
|
|
|
|
void RemoveAll();
|
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
private:
|
2012-03-21 18:07:31 +00:00
|
|
|
nsTHashtable<nsPtrHashKey<nsSVGRenderingObserver> > mObservers;
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsSVGEffects {
|
|
|
|
public:
|
2010-08-13 13:31:31 +00:00
|
|
|
typedef mozilla::dom::Element Element;
|
2010-03-29 01:46:55 +00:00
|
|
|
typedef mozilla::FramePropertyDescriptor FramePropertyDescriptor;
|
2010-08-13 13:30:45 +00:00
|
|
|
typedef nsInterfaceHashtable<nsURIHashKey, nsIMutationObserver>
|
|
|
|
URIObserverHashtable;
|
2010-03-29 01:46:55 +00:00
|
|
|
|
|
|
|
static void DestroySupports(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
(static_cast<nsISupports*>(aPropertyValue))->Release();
|
|
|
|
}
|
|
|
|
|
2010-08-13 13:30:45 +00:00
|
|
|
static void DestroyHashtable(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<URIObserverHashtable*> (aPropertyValue);
|
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(FilterProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(MaskProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ClipPathProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(MarkerBeginProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(MarkerMiddleProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(MarkerEndProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(FillProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(StrokeProperty, DestroySupports)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(HrefProperty, DestroySupports)
|
2010-08-13 13:30:45 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(BackgroundImageProperty, DestroyHashtable)
|
2010-03-29 01:46:55 +00:00
|
|
|
|
2012-08-05 19:10:21 +00:00
|
|
|
/**
|
|
|
|
* Get the paint server for a aTargetFrame.
|
|
|
|
*/
|
|
|
|
static nsSVGPaintServerFrame *GetPaintServer(nsIFrame *aTargetFrame,
|
|
|
|
const nsStyleSVGPaint *aPaint,
|
|
|
|
const FramePropertyDescriptor *aProperty);
|
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
struct EffectProperties {
|
|
|
|
nsSVGFilterProperty* mFilter;
|
2008-10-01 00:51:05 +00:00
|
|
|
nsSVGPaintingProperty* mMask;
|
|
|
|
nsSVGPaintingProperty* mClipPath;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the clip-path frame, or null if there is no clip-path frame
|
2010-12-19 17:47:01 +00:00
|
|
|
* @param aOK if a clip-path was specified and the designated element
|
|
|
|
* exists but is an element of the wrong type, *aOK is set to false.
|
|
|
|
* Otherwise *aOK is untouched.
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSVGClipPathFrame *GetClipPathFrame(bool *aOK);
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* @return the mask frame, or null if there is no mask frame
|
2010-12-19 17:47:01 +00:00
|
|
|
* @param aOK if a mask was specified and the designated element
|
|
|
|
* exists but is an element of the wrong type, *aOK is set to false.
|
|
|
|
* Otherwise *aOK is untouched.
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSVGMaskFrame *GetMaskFrame(bool *aOK);
|
2014-02-24 15:22:58 +00:00
|
|
|
|
|
|
|
bool HasValidFilter() {
|
|
|
|
return mFilter && mFilter->ReferencesValidResources();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasNoFilterOrHasValidFilter() {
|
|
|
|
return !mFilter || mFilter->ReferencesValidResources();
|
2008-10-01 00:51:05 +00:00
|
|
|
}
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aFrame should be the first continuation
|
|
|
|
*/
|
|
|
|
static EffectProperties GetEffectProperties(nsIFrame *aFrame);
|
2012-11-07 13:54:55 +00:00
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
/**
|
2012-11-07 13:54:55 +00:00
|
|
|
* Called when changes to an element (e.g. CSS property changes) cause its
|
|
|
|
* frame to start/stop referencing (or reference different) SVG resource
|
|
|
|
* elements. (_Not_ called for changes to referenced resource elements.)
|
|
|
|
*
|
|
|
|
* This function handles such changes by discarding _all_ the frame's SVG
|
|
|
|
* effects frame properties (causing those properties to stop watching their
|
|
|
|
* target element). It also synchronously (re)creates the filter and marker
|
|
|
|
* frame properties (XXX why not the other properties?), which makes it
|
|
|
|
* useful for initializing those properties during first reflow.
|
|
|
|
*
|
|
|
|
* XXX rename to something more meaningful like RefreshResourceReferences?
|
2008-08-08 01:34:43 +00:00
|
|
|
*/
|
|
|
|
static void UpdateEffects(nsIFrame *aFrame);
|
2012-11-07 13:54:55 +00:00
|
|
|
|
2008-08-08 01:34:43 +00:00
|
|
|
/**
|
|
|
|
* @param aFrame should be the first continuation
|
|
|
|
*/
|
|
|
|
static nsSVGFilterProperty *GetFilterProperty(nsIFrame *aFrame);
|
2008-10-01 00:51:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aFrame must be a first-continuation.
|
|
|
|
*/
|
2010-08-13 13:31:31 +00:00
|
|
|
static void AddRenderingObserver(Element *aElement, nsSVGRenderingObserver *aObserver);
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* @param aFrame must be a first-continuation.
|
|
|
|
*/
|
2010-08-13 13:31:31 +00:00
|
|
|
static void RemoveRenderingObserver(Element *aElement, nsSVGRenderingObserver *aObserver);
|
2010-11-16 18:35:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all rendering observers from aElement.
|
|
|
|
*/
|
|
|
|
static void RemoveAllRenderingObservers(Element *aElement);
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
2010-08-13 13:31:31 +00:00
|
|
|
* This can be called on any frame. We invalidate the observers of aFrame's
|
|
|
|
* element, if any, or else walk up to the nearest observable SVG parent
|
2010-01-23 18:47:53 +00:00
|
|
|
* frame with observers and invalidate them instead.
|
|
|
|
*
|
|
|
|
* Note that this method is very different to e.g.
|
2010-08-13 13:31:31 +00:00
|
|
|
* nsNodeUtils::AttributeChanged which walks up the content node tree all the
|
|
|
|
* way to the root node (not stopping if it encounters a non-container SVG
|
|
|
|
* node) invalidating all mutation observers (not just
|
|
|
|
* nsSVGRenderingObservers) on all nodes along the way (not just the first
|
|
|
|
* node it finds with observers). In other words, by doing all the
|
2010-05-13 12:19:50 +00:00
|
|
|
* things in parentheses in the preceding sentence, this method uses
|
2010-01-23 18:47:53 +00:00
|
|
|
* knowledge about our implementation and what can be affected by SVG effects
|
|
|
|
* to make invalidation relatively lightweight when an SVG effect changes.
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
|
|
|
static void InvalidateRenderingObservers(nsIFrame *aFrame);
|
2012-08-29 05:49:16 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
INVALIDATE_REFLOW = 1
|
|
|
|
};
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
2010-08-13 13:31:31 +00:00
|
|
|
* This can be called on any element or frame. Only direct observers of this
|
|
|
|
* (frame's) element, if any, are invalidated.
|
2008-10-01 00:51:05 +00:00
|
|
|
*/
|
2012-08-29 05:49:16 +00:00
|
|
|
static void InvalidateDirectRenderingObservers(Element *aElement, uint32_t aFlags = 0);
|
|
|
|
static void InvalidateDirectRenderingObservers(nsIFrame *aFrame, uint32_t aFlags = 0);
|
2008-10-01 00:51:05 +00:00
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
/**
|
|
|
|
* Get an nsSVGMarkerProperty for the frame, creating a fresh one if necessary
|
|
|
|
*/
|
|
|
|
static nsSVGMarkerProperty *
|
2010-03-29 01:46:55 +00:00
|
|
|
GetMarkerProperty(nsIURI *aURI, nsIFrame *aFrame,
|
|
|
|
const FramePropertyDescriptor *aProperty);
|
2008-10-11 11:29:35 +00:00
|
|
|
/**
|
|
|
|
* Get an nsSVGTextPathProperty for the frame, creating a fresh one if necessary
|
|
|
|
*/
|
|
|
|
static nsSVGTextPathProperty *
|
2010-03-29 01:46:55 +00:00
|
|
|
GetTextPathProperty(nsIURI *aURI, nsIFrame *aFrame,
|
|
|
|
const FramePropertyDescriptor *aProperty);
|
2008-10-01 00:51:05 +00:00
|
|
|
/**
|
|
|
|
* Get an nsSVGPaintingProperty for the frame, creating a fresh one if necessary
|
|
|
|
*/
|
|
|
|
static nsSVGPaintingProperty *
|
2010-03-29 01:46:55 +00:00
|
|
|
GetPaintingProperty(nsIURI *aURI, nsIFrame *aFrame,
|
|
|
|
const FramePropertyDescriptor *aProperty);
|
2010-08-13 13:30:45 +00:00
|
|
|
/**
|
|
|
|
* Get an nsSVGPaintingProperty for the frame for that URI, creating a fresh
|
|
|
|
* one if necessary
|
|
|
|
*/
|
|
|
|
static nsSVGPaintingProperty *
|
|
|
|
GetPaintingPropertyForURI(nsIURI *aURI, nsIFrame *aFrame,
|
|
|
|
const FramePropertyDescriptor *aProp);
|
2008-08-08 01:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*NSSVGEFFECTS_H_*/
|