2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-07 13:15:23 +04: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/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/SVGFEImageElement.h"
|
2013-08-14 10:55:46 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-03-07 13:15:23 +04:00
|
|
|
#include "mozilla/dom/SVGFEImageElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2019-09-20 23:51:25 +03:00
|
|
|
#include "mozilla/dom/UserActivation.h"
|
2014-04-15 22:02:23 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-14 10:55:46 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-03-07 13:15:23 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "nsNetUtil.h"
|
2018-08-31 18:30:03 +03:00
|
|
|
#include "SVGObserverUtils.h"
|
2013-10-02 01:00:38 +04:00
|
|
|
#include "imgIContainer.h"
|
2013-11-27 15:25:29 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEImage)
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* SVGFEImageElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGFEImageElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGFEImageElement::sStringInfo[3] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::result, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, true}};
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(SVGFEImageElement, SVGFEImageElementBase,
|
2017-11-01 13:59:10 +03:00
|
|
|
imgINotificationObserver, nsIImageLoadingContent)
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGFEImageElement::SVGFEImageElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGFEImageElementBase(std::move(aNodeInfo)), mImageAnimationMode(0) {
|
2013-03-07 13:15:23 +04:00
|
|
|
// We start out broken
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_BROKEN);
|
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
SVGFEImageElement::~SVGFEImageElement() { DestroyImageLoadingContent(); }
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
nsresult SVGFEImageElement::LoadSVGImage(bool aForce, bool aNotify) {
|
2013-03-07 13:15:23 +04:00
|
|
|
// resolve href attribute
|
2019-07-15 21:29:05 +03:00
|
|
|
nsIURI* baseURI = GetBaseURI();
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
nsAutoString href;
|
2016-07-07 09:22:57 +03:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
|
|
|
mStringAttributes[HREF].GetAnimValue(href, this);
|
|
|
|
} else {
|
|
|
|
mStringAttributes[XLINK_HREF].GetAnimValue(href, this);
|
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
href.Trim(" \t\n\r");
|
|
|
|
|
|
|
|
if (baseURI && !href.IsEmpty()) NS_MakeAbsoluteURI(href, href, baseURI);
|
|
|
|
|
|
|
|
// Make sure we don't get in a recursive death-spiral
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = OwnerDoc();
|
2013-03-07 13:15:23 +04:00
|
|
|
nsCOMPtr<nsIURI> hrefAsURI;
|
|
|
|
if (NS_SUCCEEDED(StringToURI(href, doc, getter_AddRefs(hrefAsURI)))) {
|
|
|
|
bool isEqual;
|
|
|
|
if (NS_SUCCEEDED(hrefAsURI->Equals(baseURI, &isEqual)) && isEqual) {
|
|
|
|
// Image URI matches our URI exactly! Bail out.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 04:17:38 +03:00
|
|
|
// Mark channel as urgent-start before load image if the image load is
|
|
|
|
// initaiated by a user interaction.
|
2019-09-20 23:51:25 +03:00
|
|
|
mUseUrgentStartForChannel = UserActivation::IsHandlingUserInput();
|
2014-08-20 01:49:38 +04:00
|
|
|
return LoadImage(href, aForce, aNotify, eImageLoadType_Normal);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2016-10-06 07:30:35 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// EventTarget methods:
|
|
|
|
|
|
|
|
void SVGFEImageElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) {
|
|
|
|
nsImageLoadingContent::AsyncEventRunning(aEvent);
|
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGFEImageElement::IsAttributeMapped(const nsAtom* name) const {
|
2013-03-07 13:15:23 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {sGraphicsMap};
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-03-07 13:15:23 +04:00
|
|
|
SVGFEImageElementBase::IsAttributeMapped(name);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult SVGFEImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
bool aNotify) {
|
2016-07-07 09:22:57 +03:00
|
|
|
if (aName == nsGkAtoms::href && (aNamespaceID == kNameSpaceID_XLink ||
|
|
|
|
aNamespaceID == kNameSpaceID_None)) {
|
2017-05-06 22:51:59 +03:00
|
|
|
if (aValue) {
|
|
|
|
LoadSVGImage(true, aNotify);
|
|
|
|
} else {
|
|
|
|
CancelImageRequests(aNotify);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
return SVGFEImageElementBase::AfterSetAttr(
|
|
|
|
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
void SVGFEImageElement::MaybeLoadSVGImage() {
|
2016-07-07 09:22:57 +03:00
|
|
|
if ((mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_HREF].IsExplicitlySet()) &&
|
2013-03-07 13:15:23 +04:00
|
|
|
(NS_FAILED(LoadSVGImage(false, true)) || !LoadingEnabled())) {
|
|
|
|
CancelImageRequests(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult SVGFEImageElement::BindToTree(BindContext& aContext,
|
|
|
|
nsINode& aParent) {
|
|
|
|
nsresult rv = SVGFEImageElementBase::BindToTree(aContext, aParent);
|
2013-03-07 13:15:23 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsImageLoadingContent::BindToTree(aContext, aParent);
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2016-07-07 09:22:57 +03:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_HREF].IsExplicitlySet()) {
|
2013-03-07 13:15:23 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2017-06-12 22:34:10 +03:00
|
|
|
NewRunnableMethod("dom::SVGFEImageElement::MaybeLoadSVGImage", this,
|
|
|
|
&SVGFEImageElement::MaybeLoadSVGImage));
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void SVGFEImageElement::UnbindFromTree(bool aNullParent) {
|
|
|
|
nsImageLoadingContent::UnbindFromTree(aNullParent);
|
|
|
|
SVGFEImageElementBase::UnbindFromTree(aNullParent);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
EventStates SVGFEImageElement::IntrinsicState() const {
|
|
|
|
return SVGFEImageElementBase::IntrinsicState() |
|
2013-03-07 13:15:23 +04:00
|
|
|
nsImageLoadingContent::ImageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEImageElement)
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGFEImageElement::Href() {
|
2016-07-07 09:22:57 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMSVGFEImageElement methods
|
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
FilterPrimitiveDescription SVGFEImageElement::GetPrimitiveDescription(
|
2020-06-30 21:11:50 +03:00
|
|
|
SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
|
2014-01-08 13:30:03 +04:00
|
|
|
const nsTArray<bool>& aInputsAreTainted,
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<SourceSurface>>& aInputImages) {
|
2013-03-07 13:15:23 +04:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2013-11-27 15:25:29 +04:00
|
|
|
if (!frame) {
|
2018-09-19 20:18:44 +03:00
|
|
|
return FilterPrimitiveDescription();
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
2013-11-27 15:25:29 +04:00
|
|
|
if (currentRequest) {
|
2013-03-07 13:15:23 +04:00
|
|
|
currentRequest->GetImage(getter_AddRefs(imageContainer));
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> image;
|
2013-11-27 15:25:29 +04:00
|
|
|
if (imageContainer) {
|
2016-11-23 04:32:03 +03:00
|
|
|
uint32_t flags =
|
|
|
|
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY;
|
|
|
|
image = imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, flags);
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2014-04-15 22:02:23 +04:00
|
|
|
if (!image) {
|
2018-09-19 20:18:44 +03:00
|
|
|
return FilterPrimitiveDescription();
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
IntSize nativeSize;
|
|
|
|
imageContainer->GetWidth(&nativeSize.width);
|
|
|
|
imageContainer->GetHeight(&nativeSize.height);
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2018-02-19 23:15:23 +03:00
|
|
|
Matrix viewBoxTM = SVGContentUtils::GetViewBoxTransform(
|
|
|
|
aFilterSubregion.width, aFilterSubregion.height, 0, 0, nativeSize.width,
|
2013-11-27 15:25:29 +04:00
|
|
|
nativeSize.height, mPreserveAspectRatio);
|
2014-09-10 17:26:12 +04:00
|
|
|
Matrix TM = viewBoxTM;
|
2018-02-19 23:15:23 +03:00
|
|
|
TM.PostTranslate(aFilterSubregion.x, aFilterSubregion.y);
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2016-05-25 19:01:18 +03:00
|
|
|
SamplingFilter samplingFilter =
|
|
|
|
nsLayoutUtils::GetSamplingFilterForFrame(frame);
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2018-09-19 20:18:16 +03:00
|
|
|
ImageAttributes atts;
|
|
|
|
atts.mFilter = (uint32_t)samplingFilter;
|
|
|
|
atts.mTransform = TM;
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
// Append the image to aInputImages and store its index in the description.
|
|
|
|
size_t imageIndex = aInputImages.Length();
|
2013-11-28 18:38:43 +04:00
|
|
|
aInputImages.AppendElement(image);
|
2018-09-19 20:18:16 +03:00
|
|
|
atts.mInputIndex = (uint32_t)imageIndex;
|
2018-09-19 20:18:44 +03:00
|
|
|
return FilterPrimitiveDescription(AsVariant(std::move(atts)));
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
bool SVGFEImageElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute) const {
|
2013-03-07 13:15:23 +04:00
|
|
|
// nsGkAtoms::href is deliberately omitted as the frame has special
|
|
|
|
// handling to load the image
|
2013-03-07 13:15:23 +04:00
|
|
|
return SVGFEImageElementBase::AttributeAffectsRendering(aNameSpaceID,
|
|
|
|
aAttribute) ||
|
2013-03-07 13:15:23 +04:00
|
|
|
(aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::preserveAspectRatio);
|
|
|
|
}
|
|
|
|
|
2014-01-08 13:30:03 +04:00
|
|
|
bool SVGFEImageElement::OutputIsTainted(const nsTArray<bool>& aInputsAreTainted,
|
|
|
|
nsIPrincipal* aReferencePrincipal) {
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
|
|
|
|
if (!currentRequest) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
rv = currentRequest->GetImagePrincipal(getter_AddRefs(principal));
|
|
|
|
if (NS_FAILED(rv) || !principal) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t corsmode;
|
|
|
|
if (NS_SUCCEEDED(currentRequest->GetCORSMode(&corsmode)) &&
|
|
|
|
corsmode != imgIRequest::CORS_NONE) {
|
|
|
|
// If CORS was used to load the image, the page is allowed to read from it.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-14 06:57:36 +04:00
|
|
|
if (aReferencePrincipal->Subsumes(principal)) {
|
2014-01-08 13:30:03 +04:00
|
|
|
// The page is allowed to read from the image.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2013-03-07 13:15:23 +04:00
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGFEImageElement::PreserveAspectRatio() {
|
2015-01-27 12:51:34 +03:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 07:08:14 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio*
|
|
|
|
SVGFEImageElement::GetAnimatedPreserveAspectRatio() {
|
2013-03-07 13:15:23 +04:00
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGFEImageElement::GetStringInfo() {
|
2013-03-07 13:15:23 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
|
|
|
ArrayLength(sStringInfo));
|
|
|
|
}
|
|
|
|
|
2018-10-12 21:25:49 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIImageLoadingContent methods
|
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
SVGFEImageElement::FrameCreated(nsIFrame* aFrame) {
|
|
|
|
nsImageLoadingContent::FrameCreated(aFrame);
|
|
|
|
|
|
|
|
uint64_t mode = aFrame->PresContext()->ImageAnimationMode();
|
|
|
|
if (mode == mImageAnimationMode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mImageAnimationMode = mode;
|
|
|
|
|
|
|
|
if (mPendingRequest) {
|
|
|
|
nsCOMPtr<imgIContainer> container;
|
|
|
|
mPendingRequest->GetImage(getter_AddRefs(container));
|
|
|
|
if (container) {
|
|
|
|
container->SetAnimationMode(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCurrentRequest) {
|
|
|
|
nsCOMPtr<imgIContainer> container;
|
|
|
|
mCurrentRequest->GetImage(getter_AddRefs(container));
|
|
|
|
if (container) {
|
|
|
|
container->SetAnimationMode(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 13:15:23 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// imgINotificationObserver methods
|
|
|
|
|
2020-03-12 07:25:34 +03:00
|
|
|
void SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType,
|
|
|
|
const nsIntRect* aData) {
|
|
|
|
nsImageLoadingContent::Notify(aRequest, aType, aData);
|
2013-03-07 13:15:23 +04:00
|
|
|
|
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
|
|
|
// Request a decode
|
|
|
|
nsCOMPtr<imgIContainer> container;
|
|
|
|
aRequest->GetImage(getter_AddRefs(container));
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(container, "who sent the notification then?");
|
2016-11-26 10:56:26 +03:00
|
|
|
container->StartDecoding(imgIContainer::FLAG_NONE);
|
2018-10-12 21:25:49 +03:00
|
|
|
container->SetAnimationMode(mImageAnimationMode);
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE ||
|
|
|
|
aType == imgINotificationObserver::FRAME_UPDATE ||
|
|
|
|
aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
2018-08-31 18:30:03 +03:00
|
|
|
if (GetParent() && GetParent()->IsSVGElement(nsGkAtoms::filter)) {
|
|
|
|
SVGObserverUtils::InvalidateDirectRenderingObservers(
|
|
|
|
static_cast<SVGFilterElement*>(GetParent()));
|
|
|
|
}
|
2013-03-07 13:15:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|