author | cku <cku@mozilla.com> |
Thu, 20 Apr 2017 15:58:19 +0800 | |
changeset 354043 | 932320750dfe9d7df94beea21e488bf2970fe280 |
parent 354042 | 2fddfb975738d2196b40df878a1f60262f431fe8 |
child 354044 | 92f7611393f631a0de8d192d261dd1cf3f9b2d25 |
push id | 31685 |
push user | kwierso@gmail.com |
push date | Thu, 20 Apr 2017 21:45:29 +0000 |
treeherder | mozilla-central@5e3dc7e1288a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | heycam |
bugs | 1357432 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
layout/svg/nsSVGEffects.cpp | file | annotate | diff | comparison | revisions | |
layout/svg/nsSVGEffects.h | file | annotate | diff | comparison | revisions |
--- a/layout/svg/nsSVGEffects.cpp +++ b/layout/svg/nsSVGEffects.cpp @@ -905,34 +905,23 @@ void nsSVGEffects::InvalidateDirectRenderingObservers(nsIFrame* aFrame, uint32_t aFlags /* = 0 */) { nsIContent* content = aFrame->GetContent(); if (content && content->IsElement()) { InvalidateDirectRenderingObservers(content->AsElement(), aFlags); } } -static already_AddRefed<nsIURI> -ResolveURLUsingLocalRef(nsIFrame* aFrame, const css::URLValueData* aURL) +already_AddRefed<nsIURI> +nsSVGEffects::GetBaseURLForLocalRef(nsIContent* content, nsIURI* aDocURI) { - MOZ_ASSERT(aFrame); - - if (!aURL) { - return nullptr; - } - - // Non-local-reference URL. - if (!aURL->IsLocalRef()) { - nsCOMPtr<nsIURI> result = aURL->GetURI(); - return result.forget(); - } + MOZ_ASSERT(content); // For a local-reference URL, resolve that fragment against the current // document that relative URLs are resolved against. - nsIContent* content = aFrame->GetContent(); nsCOMPtr<nsIURI> baseURI = content->OwnerDoc()->GetDocumentURI(); if (content->IsInAnonymousSubtree()) { nsIContent* bindingParent = content->GetBindingParent(); nsCOMPtr<nsIURI> originalURI; // content is in a shadow tree. If this URL was specified in the subtree // referenced by the <use>(or -moz-binding) element, and that subtree came @@ -950,22 +939,47 @@ ResolveURLUsingLocalRef(nsIFrame* aFrame originalURI = binding->GetSourceDocURI(); } else { MOZ_ASSERT(content->IsInNativeAnonymousSubtree(), "an non-native anonymous tree which is not from " "an XBL binding?"); } } - if (originalURI && aURL->EqualsExceptRef(originalURI)) { - baseURI = originalURI; + if (originalURI) { + bool isEqualsExceptRef = false; + aDocURI->EqualsExceptRef(originalURI, &isEqualsExceptRef); + if (isEqualsExceptRef) { + baseURI = originalURI; + } } } } + return baseURI.forget(); +} + +static already_AddRefed<nsIURI> +ResolveURLUsingLocalRef(nsIFrame* aFrame, const css::URLValueData* aURL) +{ + MOZ_ASSERT(aFrame); + + if (!aURL) { + return nullptr; + } + + // Non-local-reference URL. + if (!aURL->IsLocalRef()) { + nsCOMPtr<nsIURI> result = aURL->GetURI(); + return result.forget(); + } + + nsCOMPtr<nsIURI> baseURI = + nsSVGEffects::GetBaseURLForLocalRef(aFrame->GetContent(), aURL->GetURI()); + return aURL->ResolveLocalRef(baseURI); } already_AddRefed<nsIURI> nsSVGEffects::GetMarkerURI(nsIFrame* aFrame, RefPtr<css::URLValue> nsStyleSVG::* aMarker) { return ResolveURLUsingLocalRef(aFrame, aFrame->StyleSVG()->*aMarker);
--- a/layout/svg/nsSVGEffects.h +++ b/layout/svg/nsSVGEffects.h @@ -661,16 +661,28 @@ public: GetFilterURI(nsIFrame* aFrame, const nsStyleFilter& aFilter); /** * A helper function to resolve paint-server URL. */ static already_AddRefed<nsIURI> GetPaintURI(nsIFrame* aFrame, nsStyleSVGPaint nsStyleSVG::* aPaint); - /** + /** * A helper function to resolve SVG mask URL. */ static already_AddRefed<nsIURI> GetMaskURI(nsIFrame* aFrame, uint32_t aIndex); + + /** + * Return a baseURL for resolving a local-ref URL. + * + * @param aContent an element which uses a local-ref property. Here are some + * examples: + * <rect fill=url(#foo)> + * <circle clip-path=url(#foo)> + * <use xlink:href="#foo"> + */ + static already_AddRefed<nsIURI> + GetBaseURLForLocalRef(nsIContent* aContent, nsIURI* aDocURI); }; #endif /*NSSVGEFFECTS_H_*/