Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef NSSVGEFFECTS_H_
7 : #define NSSVGEFFECTS_H_
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "FrameProperties.h"
11 : #include "mozilla/dom/Element.h"
12 : #include "nsHashKeys.h"
13 : #include "nsID.h"
14 : #include "nsIFrame.h"
15 : #include "nsIMutationObserver.h"
16 : #include "nsInterfaceHashtable.h"
17 : #include "nsISupportsBase.h"
18 : #include "nsISupportsImpl.h"
19 : #include "nsReferencedElement.h"
20 : #include "nsStubMutationObserver.h"
21 : #include "nsSVGUtils.h"
22 : #include "nsTHashtable.h"
23 : #include "nsURIHashKey.h"
24 : #include "nsCycleCollectionParticipant.h"
25 :
26 : class nsIAtom;
27 : class nsIPresShell;
28 : class nsIURI;
29 : class nsSVGClipPathFrame;
30 : class nsSVGPaintServerFrame;
31 : class nsSVGFilterFrame;
32 : class nsSVGMaskFrame;
33 : class nsSVGFilterChainObserver;
34 :
35 : /*
36 : * This interface allows us to be notified when a piece of SVG content is
37 : * re-rendered.
38 : *
39 : * Concrete implementations of this interface need to implement
40 : * "GetTarget()" to specify the piece of SVG content that they'd like to
41 : * monitor, and they need to implement "DoUpdate" to specify how we'll react
42 : * when that content gets re-rendered. They also need to implement a
43 : * constructor and destructor, which should call StartListening and
44 : * StopListening, respectively.
45 : */
46 : class nsSVGRenderingObserver : public nsStubMutationObserver
47 : {
48 :
49 : protected:
50 0 : virtual ~nsSVGRenderingObserver()
51 0 : {}
52 :
53 : public:
54 : typedef mozilla::dom::Element Element;
55 24 : nsSVGRenderingObserver()
56 24 : : mInObserverList(false)
57 24 : {}
58 :
59 : // nsIMutationObserver
60 : NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
61 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
62 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
63 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
64 :
65 : void InvalidateViaReferencedElement();
66 :
67 : // When a nsSVGRenderingObserver list gets forcibly cleared, it uses this
68 : // callback to notify every observer that's cleared from it, so they can
69 : // react.
70 : void NotifyEvictedFromRenderingObserverList();
71 :
72 0 : bool IsInObserverList() const { return mInObserverList; }
73 :
74 : nsIFrame* GetReferencedFrame();
75 : /**
76 : * @param aOK this is only for the convenience of callers. We set *aOK to false
77 : * if the frame is the wrong type
78 : */
79 : nsIFrame* GetReferencedFrame(mozilla::LayoutFrameType aFrameType, bool* aOK);
80 :
81 : Element* GetReferencedElement();
82 :
83 54 : virtual bool ObservesReflow() { return true; }
84 :
85 : protected:
86 : // Non-virtual protected methods
87 : void StartListening();
88 : void StopListening();
89 :
90 : // Virtual protected methods
91 : virtual void DoUpdate() = 0; // called when the referenced resource changes.
92 :
93 : // This is an internally-used version of GetReferencedElement that doesn't
94 : // forcibly add us as an observer. (whereas GetReferencedElement does)
95 : virtual Element* GetTarget() = 0;
96 :
97 : // Whether we're in our referenced element's observer list at this time.
98 : bool mInObserverList;
99 : };
100 :
101 :
102 : /*
103 : * SVG elements reference supporting resources by element ID. We need to
104 : * track when those resources change and when the DOM changes in ways
105 : * that affect which element is referenced by a given ID (e.g., when
106 : * element IDs change). The code here is responsible for that.
107 : *
108 : * When a frame references a supporting resource, we create a property
109 : * object derived from nsSVGIDRenderingObserver to manage the relationship. The
110 : * property object is attached to the referencing frame.
111 : */
112 : class nsSVGIDRenderingObserver : public nsSVGRenderingObserver
113 : {
114 : public:
115 : typedef mozilla::dom::Element Element;
116 : nsSVGIDRenderingObserver(nsIURI* aURI, nsIContent* aObservingContent,
117 : bool aReferenceImage);
118 : virtual ~nsSVGIDRenderingObserver();
119 :
120 : protected:
121 23 : Element* GetTarget() override { return mElement.get(); }
122 :
123 : // This is called when the referenced resource changes.
124 : virtual void DoUpdate() override;
125 :
126 0 : class SourceReference : public nsReferencedElement
127 : {
128 : public:
129 3 : explicit SourceReference(nsSVGIDRenderingObserver* aContainer) : mContainer(aContainer) {}
130 : protected:
131 0 : virtual void ElementChanged(Element* aFrom, Element* aTo) override {
132 0 : mContainer->StopListening();
133 0 : nsReferencedElement::ElementChanged(aFrom, aTo);
134 0 : mContainer->StartListening();
135 0 : mContainer->DoUpdate();
136 0 : }
137 : /**
138 : * Override IsPersistent because we want to keep tracking the element
139 : * for the ID even when it changes.
140 : */
141 0 : virtual bool IsPersistent() override { return true; }
142 : private:
143 : nsSVGIDRenderingObserver* mContainer;
144 : };
145 :
146 : SourceReference mElement;
147 : };
148 :
149 : struct nsSVGFrameReferenceFromProperty
150 : {
151 3 : explicit nsSVGFrameReferenceFromProperty(nsIFrame* aFrame)
152 3 : : mFrame(aFrame)
153 3 : , mFramePresShell(aFrame->PresContext()->PresShell())
154 3 : {}
155 :
156 : // Clear our reference to the frame.
157 : void Detach();
158 :
159 : // null if the frame has become invalid
160 : nsIFrame* Get();
161 :
162 : private:
163 : // The frame that this property is attached to, may be null
164 : nsIFrame *mFrame;
165 : // When a presshell is torn down, we don't delete the properties for
166 : // each frame until after the frames are destroyed. So here we remember
167 : // the presshell for the frames we care about and, before we use the frame,
168 : // we test the presshell to see if it's destroying itself. If it is,
169 : // then the frame pointer is not valid and we know the frame has gone away.
170 : // mFramePresShell may be null, but when mFrame is non-null, mFramePresShell
171 : // is guaranteed to be non-null, too.
172 : nsIPresShell *mFramePresShell;
173 : };
174 :
175 : class nsSVGRenderingObserverProperty : public nsSVGIDRenderingObserver
176 : {
177 : public:
178 : NS_DECL_ISUPPORTS
179 :
180 3 : nsSVGRenderingObserverProperty(nsIURI* aURI, nsIFrame *aFrame,
181 : bool aReferenceImage)
182 3 : : nsSVGIDRenderingObserver(aURI, aFrame->GetContent(), aReferenceImage)
183 3 : , mFrameReference(aFrame)
184 3 : {}
185 :
186 : protected:
187 0 : virtual ~nsSVGRenderingObserverProperty() {}
188 :
189 : virtual void DoUpdate() override;
190 :
191 : nsSVGFrameReferenceFromProperty mFrameReference;
192 : };
193 :
194 : /**
195 : * In a filter chain, there can be multiple SVG reference filters.
196 : * e.g. filter: url(#svg-filter-1) blur(10px) url(#svg-filter-2);
197 : *
198 : * This class keeps track of one SVG reference filter in a filter chain.
199 : * e.g. url(#svg-filter-1)
200 : *
201 : * It fires invalidations when the SVG filter element's id changes or when
202 : * the SVG filter element's content changes.
203 : *
204 : * The nsSVGFilterChainObserver class manages a list of nsSVGFilterReferences.
205 : */
206 : class nsSVGFilterReference final : public nsSVGIDRenderingObserver
207 : , public nsISVGFilterReference
208 : {
209 : public:
210 0 : nsSVGFilterReference(nsIURI* aURI,
211 : nsIContent* aObservingContent,
212 : nsSVGFilterChainObserver* aFilterChainObserver)
213 0 : : nsSVGIDRenderingObserver(aURI, aObservingContent, false)
214 0 : , mFilterChainObserver(aFilterChainObserver)
215 : {
216 0 : }
217 :
218 0 : bool ReferencesValidResource() { return GetFilterFrame(); }
219 :
220 0 : void DetachFromChainObserver() { mFilterChainObserver = nullptr; }
221 :
222 : /**
223 : * @return the filter frame, or null if there is no filter frame
224 : */
225 : nsSVGFilterFrame *GetFilterFrame();
226 :
227 : // nsISupports
228 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
229 0 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSVGFilterReference, nsSVGIDRenderingObserver)
230 :
231 : // nsISVGFilterReference
232 0 : virtual void Invalidate() override { DoUpdate(); };
233 :
234 : protected:
235 0 : virtual ~nsSVGFilterReference() {}
236 :
237 : // nsSVGIDRenderingObserver
238 : virtual void DoUpdate() override;
239 :
240 : private:
241 : nsSVGFilterChainObserver* mFilterChainObserver;
242 : };
243 :
244 : /**
245 : * This class manages a list of nsSVGFilterReferences, which represent SVG
246 : * reference filters in a filter chain.
247 : * e.g. filter: url(#svg-filter-1) blur(10px) url(#svg-filter-2);
248 : *
249 : * In the above example, the nsSVGFilterChainObserver will manage two
250 : * nsSVGFilterReferences, one for each SVG reference filter. CSS filters like
251 : * "blur(10px)" don't reference filter elements, so they don't need an
252 : * nsSVGFilterReference. The style system invalidates changes to CSS filters.
253 : */
254 : class nsSVGFilterChainObserver : public nsISupports
255 : {
256 : public:
257 : nsSVGFilterChainObserver(const nsTArray<nsStyleFilter>& aFilters,
258 : nsIContent* aFilteredElement,
259 : nsIFrame* aFiltedFrame = nullptr);
260 :
261 : bool ReferencesValidResources();
262 : bool IsInObserverLists() const;
263 0 : void Invalidate() { DoUpdate(); }
264 :
265 : // nsISupports
266 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
267 0 : NS_DECL_CYCLE_COLLECTION_CLASS(nsSVGFilterChainObserver)
268 :
269 : protected:
270 : virtual ~nsSVGFilterChainObserver();
271 :
272 : virtual void DoUpdate() = 0;
273 :
274 : private:
275 :
276 0 : void DetachReferences()
277 : {
278 0 : for (uint32_t i = 0; i < mReferences.Length(); i++) {
279 0 : mReferences[i]->DetachFromChainObserver();
280 : }
281 0 : }
282 :
283 : nsTArray<RefPtr<nsSVGFilterReference>> mReferences;
284 : };
285 :
286 0 : class nsSVGFilterProperty : public nsSVGFilterChainObserver
287 : {
288 : public:
289 0 : nsSVGFilterProperty(const nsTArray<nsStyleFilter>& aFilters,
290 : nsIFrame* aFilteredFrame)
291 0 : : nsSVGFilterChainObserver(aFilters, aFilteredFrame->GetContent(),
292 : aFilteredFrame)
293 0 : , mFrameReference(aFilteredFrame)
294 0 : {}
295 :
296 0 : void DetachFromFrame() { mFrameReference.Detach(); }
297 :
298 : protected:
299 : virtual void DoUpdate() override;
300 :
301 : nsSVGFrameReferenceFromProperty mFrameReference;
302 : };
303 :
304 0 : class nsSVGMarkerProperty final: public nsSVGRenderingObserverProperty
305 : {
306 : public:
307 0 : nsSVGMarkerProperty(nsIURI* aURI, nsIFrame* aFrame, bool aReferenceImage)
308 0 : : nsSVGRenderingObserverProperty(aURI, aFrame, aReferenceImage) {}
309 :
310 : protected:
311 : virtual void DoUpdate() override;
312 : };
313 :
314 0 : class nsSVGTextPathProperty final : public nsSVGRenderingObserverProperty
315 : {
316 : public:
317 0 : nsSVGTextPathProperty(nsIURI* aURI, nsIFrame* aFrame, bool aReferenceImage)
318 0 : : nsSVGRenderingObserverProperty(aURI, aFrame, aReferenceImage)
319 0 : , mValid(true) {}
320 :
321 0 : virtual bool ObservesReflow() override { return false; }
322 :
323 : protected:
324 : virtual void DoUpdate() override;
325 :
326 : private:
327 : /**
328 : * Returns true if the target of the textPath is the frame of a 'path' element.
329 : */
330 : bool TargetIsValid();
331 :
332 : bool mValid;
333 : };
334 :
335 0 : class nsSVGPaintingProperty final : public nsSVGRenderingObserverProperty
336 : {
337 : public:
338 3 : nsSVGPaintingProperty(nsIURI* aURI, nsIFrame* aFrame, bool aReferenceImage)
339 3 : : nsSVGRenderingObserverProperty(aURI, aFrame, aReferenceImage) {}
340 :
341 : protected:
342 : virtual void DoUpdate() override;
343 : };
344 :
345 : class nsSVGMaskProperty final : public nsISupports
346 : {
347 : public:
348 : explicit nsSVGMaskProperty(nsIFrame* aFrame);
349 :
350 : // nsISupports
351 : NS_DECL_ISUPPORTS
352 :
353 14 : const nsTArray<RefPtr<nsSVGPaintingProperty>>& GetProps() const
354 : {
355 14 : return mProperties;
356 : }
357 :
358 : private:
359 0 : virtual ~nsSVGMaskProperty() {}
360 : nsTArray<RefPtr<nsSVGPaintingProperty>> mProperties;
361 : };
362 :
363 : /**
364 : * A manager for one-shot nsSVGRenderingObserver tracking.
365 : * nsSVGRenderingObservers can be added or removed. They are not strongly
366 : * referenced so an observer must be removed before it dies.
367 : * When InvalidateAll is called, all outstanding references get
368 : * InvalidateViaReferencedElement()
369 : * called on them and the list is cleared. The intent is that
370 : * the observer will force repainting of whatever part of the document
371 : * is needed, and then at paint time the observer will do a clean lookup
372 : * of the referenced element and [re-]add itself to the element's observer list.
373 : *
374 : * InvalidateAll must be called before this object is destroyed, i.e.
375 : * before the referenced frame is destroyed. This should normally happen
376 : * via nsSVGContainerFrame::RemoveFrame, since only frames in the frame
377 : * tree should be referenced.
378 : */
379 : class nsSVGRenderingObserverList
380 : {
381 : public:
382 23 : nsSVGRenderingObserverList()
383 23 : : mObservers(4)
384 : {
385 23 : MOZ_COUNT_CTOR(nsSVGRenderingObserverList);
386 23 : }
387 :
388 0 : ~nsSVGRenderingObserverList() {
389 0 : InvalidateAll();
390 0 : MOZ_COUNT_DTOR(nsSVGRenderingObserverList);
391 0 : }
392 :
393 95 : void Add(nsSVGRenderingObserver* aObserver)
394 95 : { mObservers.PutEntry(aObserver); }
395 0 : void Remove(nsSVGRenderingObserver* aObserver)
396 0 : { mObservers.RemoveEntry(aObserver); }
397 : #ifdef DEBUG
398 4 : bool Contains(nsSVGRenderingObserver* aObserver)
399 4 : { return (mObservers.GetEntry(aObserver) != nullptr); }
400 : #endif
401 0 : bool IsEmpty()
402 0 : { return mObservers.Count() == 0; }
403 :
404 : /**
405 : * Drop all our observers, and notify them that we have changed and dropped
406 : * our reference to them.
407 : */
408 : void InvalidateAll();
409 :
410 : /**
411 : * Drop all observers that observe reflow, and notify them that we have changed and dropped
412 : * our reference to them.
413 : */
414 : void InvalidateAllForReflow();
415 :
416 : /**
417 : * Drop all our observers, and notify them that we have dropped our reference
418 : * to them.
419 : */
420 : void RemoveAll();
421 :
422 : private:
423 : nsTHashtable<nsPtrHashKey<nsSVGRenderingObserver> > mObservers;
424 : };
425 :
426 : class nsSVGEffects
427 : {
428 : public:
429 : typedef mozilla::dom::Element Element;
430 : typedef nsInterfaceHashtable<nsURIHashKey, nsIMutationObserver>
431 : URIObserverHashtable;
432 :
433 : using PaintingPropertyDescriptor =
434 : const mozilla::FramePropertyDescriptor<nsSVGPaintingProperty>*;
435 : using URIObserverHashtablePropertyDescriptor =
436 : const mozilla::FramePropertyDescriptor<URIObserverHashtable>*;
437 :
438 0 : static void DestroyFilterProperty(nsSVGFilterProperty* aProp)
439 : {
440 : // nsSVGFilterProperty is cycle-collected, so dropping the last reference
441 : // doesn't necessarily destroy it. We need to tell it that the frame
442 : // has now become invalid.
443 0 : aProp->DetachFromFrame();
444 :
445 0 : aProp->Release();
446 0 : }
447 :
448 100 : NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(FilterProperty, nsSVGFilterProperty,
449 : DestroyFilterProperty)
450 116 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MaskProperty, nsSVGMaskProperty)
451 108 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(ClipPathProperty, nsSVGPaintingProperty)
452 228 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MarkerBeginProperty, nsSVGMarkerProperty)
453 228 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MarkerMiddleProperty, nsSVGMarkerProperty)
454 228 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MarkerEndProperty, nsSVGMarkerProperty)
455 132 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(FillProperty, nsSVGPaintingProperty)
456 102 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(StrokeProperty, nsSVGPaintingProperty)
457 0 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(HrefAsTextPathProperty,
458 : nsSVGTextPathProperty)
459 0 : NS_DECLARE_FRAME_PROPERTY_RELEASABLE(HrefAsPaintingProperty,
460 : nsSVGPaintingProperty)
461 100 : NS_DECLARE_FRAME_PROPERTY_DELETABLE(BackgroundImageProperty,
462 : URIObserverHashtable)
463 :
464 : /**
465 : * Get the paint server for a aTargetFrame.
466 : */
467 : static nsSVGPaintServerFrame *GetPaintServer(nsIFrame* aTargetFrame,
468 : nsStyleSVGPaint nsStyleSVG::* aPaint,
469 : PaintingPropertyDescriptor aProperty);
470 :
471 : struct EffectProperties {
472 : nsSVGFilterProperty* mFilter;
473 : nsSVGMaskProperty* mMask;
474 : nsSVGPaintingProperty* mClipPath;
475 :
476 : /**
477 : * @return the clip-path frame, or null if there is no clip-path frame
478 : */
479 : nsSVGClipPathFrame* GetClipPathFrame();
480 :
481 : /**
482 : * @return an array which contains all SVG mask frames.
483 : */
484 : nsTArray<nsSVGMaskFrame*> GetMaskFrames();
485 :
486 : /*
487 : * @return true if all effects we have are valid or we have no effect
488 : * at all.
489 : */
490 : bool HasNoOrValidEffects();
491 :
492 : /*
493 : * @return true if we have any invalid effect.
494 : */
495 0 : bool HasInvalidEffects() {
496 0 : return !HasNoOrValidEffects();
497 : }
498 :
499 : /*
500 : * @return true if we either do not have clip-path or have a valid
501 : * clip-path.
502 : */
503 : bool HasNoOrValidClipPath();
504 :
505 : /*
506 : * @return true if we have an invalid clip-path.
507 : */
508 9 : bool HasInvalidClipPath() {
509 9 : return !HasNoOrValidClipPath();
510 : }
511 :
512 : /*
513 : * @return true if we either do not have mask or all masks we have
514 : * are valid.
515 : */
516 : bool HasNoOrValidMask();
517 :
518 : /*
519 : * @return true if we have an invalid mask.
520 : */
521 7 : bool HasInvalidMask() {
522 7 : return !HasNoOrValidMask();
523 : }
524 :
525 1 : bool HasValidFilter() {
526 1 : return mFilter && mFilter->ReferencesValidResources();
527 : }
528 :
529 : /*
530 : * @return true if we either do not have filter or all filters we have
531 : * are valid.
532 : */
533 0 : bool HasNoOrValidFilter() {
534 0 : return !mFilter || mFilter->ReferencesValidResources();
535 : }
536 :
537 : /*
538 : * @return true if we have an invalid filter.
539 : */
540 0 : bool HasInvalidFilter() {
541 0 : return !HasNoOrValidFilter();
542 : }
543 : };
544 :
545 : /**
546 : * @param aFrame should be the first continuation
547 : */
548 : static EffectProperties GetEffectProperties(nsIFrame* aFrame);
549 :
550 : /**
551 : * Called when changes to an element (e.g. CSS property changes) cause its
552 : * frame to start/stop referencing (or reference different) SVG resource
553 : * elements. (_Not_ called for changes to referenced resource elements.)
554 : *
555 : * This function handles such changes by discarding _all_ the frame's SVG
556 : * effects frame properties (causing those properties to stop watching their
557 : * target element). It also synchronously (re)creates the filter and marker
558 : * frame properties (XXX why not the other properties?), which makes it
559 : * useful for initializing those properties during first reflow.
560 : *
561 : * XXX rename to something more meaningful like RefreshResourceReferences?
562 : */
563 : static void UpdateEffects(nsIFrame* aFrame);
564 :
565 : /**
566 : * @param aFrame should be the first continuation
567 : */
568 : static nsSVGFilterProperty *GetFilterProperty(nsIFrame* aFrame);
569 :
570 : /**
571 : * @param aFrame must be a first-continuation.
572 : */
573 : static void AddRenderingObserver(Element* aElement, nsSVGRenderingObserver *aObserver);
574 : /**
575 : * @param aFrame must be a first-continuation.
576 : */
577 : static void RemoveRenderingObserver(Element* aElement, nsSVGRenderingObserver *aObserver);
578 :
579 : /**
580 : * Removes all rendering observers from aElement.
581 : */
582 : static void RemoveAllRenderingObservers(Element* aElement);
583 :
584 : /**
585 : * This can be called on any frame. We invalidate the observers of aFrame's
586 : * element, if any, or else walk up to the nearest observable SVG parent
587 : * frame with observers and invalidate them instead.
588 : *
589 : * Note that this method is very different to e.g.
590 : * nsNodeUtils::AttributeChanged which walks up the content node tree all the
591 : * way to the root node (not stopping if it encounters a non-container SVG
592 : * node) invalidating all mutation observers (not just
593 : * nsSVGRenderingObservers) on all nodes along the way (not just the first
594 : * node it finds with observers). In other words, by doing all the
595 : * things in parentheses in the preceding sentence, this method uses
596 : * knowledge about our implementation and what can be affected by SVG effects
597 : * to make invalidation relatively lightweight when an SVG effect changes.
598 : */
599 : static void InvalidateRenderingObservers(nsIFrame* aFrame);
600 :
601 : enum {
602 : INVALIDATE_REFLOW = 1
603 : };
604 :
605 : /**
606 : * This can be called on any element or frame. Only direct observers of this
607 : * (frame's) element, if any, are invalidated.
608 : */
609 : static void InvalidateDirectRenderingObservers(Element* aElement, uint32_t aFlags = 0);
610 : static void InvalidateDirectRenderingObservers(nsIFrame* aFrame, uint32_t aFlags = 0);
611 :
612 : /**
613 : * Get an nsSVGMarkerProperty for the frame, creating a fresh one if necessary
614 : */
615 : static nsSVGMarkerProperty *
616 : GetMarkerProperty(nsIURI* aURI, nsIFrame* aFrame,
617 : const mozilla::FramePropertyDescriptor<nsSVGMarkerProperty>* aProperty);
618 : /**
619 : * Get an nsSVGTextPathProperty for the frame, creating a fresh one if necessary
620 : */
621 : static nsSVGTextPathProperty *
622 : GetTextPathProperty(nsIURI* aURI, nsIFrame* aFrame,
623 : const mozilla::FramePropertyDescriptor<nsSVGTextPathProperty>* aProperty);
624 : /**
625 : * Get an nsSVGPaintingProperty for the frame, creating a fresh one if necessary
626 : */
627 : static nsSVGPaintingProperty*
628 : GetPaintingProperty(nsIURI* aURI, nsIFrame* aFrame,
629 : const mozilla::FramePropertyDescriptor<nsSVGPaintingProperty>* aProperty);
630 : /**
631 : * Get an nsSVGPaintingProperty for the frame for that URI, creating a fresh
632 : * one if necessary
633 : */
634 : static nsSVGPaintingProperty*
635 : GetPaintingPropertyForURI(nsIURI* aURI, nsIFrame* aFrame,
636 : URIObserverHashtablePropertyDescriptor aProp);
637 :
638 : /**
639 : * A helper function to resolve marker's URL.
640 : */
641 : static already_AddRefed<nsIURI>
642 : GetMarkerURI(nsIFrame* aFrame,
643 : RefPtr<mozilla::css::URLValue> nsStyleSVG::* aMarker);
644 :
645 : /**
646 : * A helper function to resolve clip-path URL.
647 : */
648 : static already_AddRefed<nsIURI>
649 : GetClipPathURI(nsIFrame* aFrame);
650 :
651 : /**
652 : * A helper function to resolve filter URL.
653 : */
654 : static already_AddRefed<nsIURI>
655 : GetFilterURI(nsIFrame* aFrame, uint32_t aIndex);
656 :
657 : /**
658 : * A helper function to resolve filter URL.
659 : */
660 : static already_AddRefed<nsIURI>
661 : GetFilterURI(nsIFrame* aFrame, const nsStyleFilter& aFilter);
662 :
663 : /**
664 : * A helper function to resolve paint-server URL.
665 : */
666 : static already_AddRefed<nsIURI>
667 : GetPaintURI(nsIFrame* aFrame, nsStyleSVGPaint nsStyleSVG::* aPaint);
668 :
669 : /**
670 : * A helper function to resolve SVG mask URL.
671 : */
672 : static already_AddRefed<nsIURI>
673 : GetMaskURI(nsIFrame* aFrame, uint32_t aIndex);
674 :
675 : /**
676 : * Return a baseURL for resolving a local-ref URL.
677 : *
678 : * @param aContent an element which uses a local-ref property. Here are some
679 : * examples:
680 : * <rect fill=url(#foo)>
681 : * <circle clip-path=url(#foo)>
682 : * <use xlink:href="#foo">
683 : */
684 : static already_AddRefed<nsIURI>
685 : GetBaseURLForLocalRef(nsIContent* aContent, nsIURI* aDocURI);
686 : };
687 :
688 : #endif /*NSSVGEFFECTS_H_*/
|