2015-05-03 19:32:37 +00: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 09:15:23 +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/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/SVGFEImageElement.h"
|
2013-08-14 06:55:46 +00:00
|
|
|
|
2014-04-03 04:18:36 +00:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-03-07 09:15:23 +00:00
|
|
|
#include "mozilla/dom/SVGFEImageElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2014-04-15 18:02:23 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-14 06:55:46 +00:00
|
|
|
#include "nsContentUtils.h"
|
2013-03-07 09:15:23 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "nsNetUtil.h"
|
2013-10-01 21:00:38 +00:00
|
|
|
#include "imgIContainer.h"
|
2013-11-27 11:25:29 +00:00
|
|
|
#include "gfx2DGlue.h"
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEImage)
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-11-27 11:25:29 +00:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
JSObject*
|
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 14:13:33 +00:00
|
|
|
SVGFEImageElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
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 14:13:33 +00:00
|
|
|
return SVGFEImageElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::StringInfo SVGFEImageElement::sStringInfo[2] =
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::result, kNameSpaceID_None, true },
|
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(SVGFEImageElement, SVGFEImageElementBase,
|
|
|
|
nsIDOMNode, nsIDOMElement, nsIDOMSVGElement,
|
|
|
|
imgINotificationObserver, nsIImageLoadingContent,
|
|
|
|
imgIOnloadBlocker)
|
2013-03-07 09:15:23 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
SVGFEImageElement::SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-03-07 09:15:23 +00:00
|
|
|
: SVGFEImageElementBase(aNodeInfo)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
// We start out broken
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_BROKEN);
|
|
|
|
}
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::~SVGFEImageElement()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
DestroyImageLoadingContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::LoadSVGImage(bool aForce, bool aNotify)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
// resolve href attribute
|
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
|
|
|
|
nsAutoString href;
|
|
|
|
mStringAttributes[HREF].GetAnimValue(href, this);
|
|
|
|
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
|
|
|
|
nsIDocument* doc = OwnerDoc();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 21:49:38 +00:00
|
|
|
return LoadImage(href, aForce, aNotify, eImageLoadType_Normal);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(bool)
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::IsAttributeMapped(const nsIAtom* name) const
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sGraphicsMap
|
|
|
|
};
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElementBase::IsAttributeMapped(name);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue, bool aNotify)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
|
|
|
|
|
|
|
|
// If there isn't a frame we still need to load the image in case
|
|
|
|
// the frame is created later e.g. by attaching to a document.
|
|
|
|
// If there is a frame then it should deal with loading as the image
|
|
|
|
// url may be animated.
|
|
|
|
if (!GetPrimaryFrame()) {
|
|
|
|
|
|
|
|
// Prevent setting image.src by exiting early
|
|
|
|
if (nsContentUtils::IsImageSrcSetDisabled()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aValue) {
|
|
|
|
LoadSVGImage(true, aNotify);
|
|
|
|
} else {
|
|
|
|
CancelImageRequests(aNotify);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
return SVGFEImageElementBase::AfterSetAttr(aNamespaceID, aName,
|
|
|
|
aValue, aNotify);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::MaybeLoadSVGImage()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() &&
|
|
|
|
(NS_FAILED(LoadSVGImage(false, true)) ||
|
|
|
|
!LoadingEnabled())) {
|
|
|
|
CancelImageRequests(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
2013-03-07 09:15:23 +00:00
|
|
|
nsresult rv = SVGFEImageElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2013-03-07 09:15:23 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
|
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
|
|
|
// FIXME: Bug 660963 it would be nice if we could just have
|
|
|
|
// ClearBrokenState update our state and do it fast...
|
|
|
|
ClearBrokenState();
|
|
|
|
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
|
|
|
|
nsContentUtils::AddScriptRunner(
|
2013-03-07 09:15:23 +00:00
|
|
|
NS_NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage));
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElementBase::UnbindFromTree(aDeep, aNullParent);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 04:18:36 +00:00
|
|
|
EventStates
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::IntrinsicState() const
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
2013-03-07 09:15:23 +00:00
|
|
|
return SVGFEImageElementBase::IntrinsicState() |
|
2013-03-07 09:15:23 +00:00
|
|
|
nsImageLoadingContent::ImageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEImageElement)
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::Href()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
2013-03-07 09:15:23 +00:00
|
|
|
return mStringAttributes[HREF].ToDOMAnimatedString(this);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMSVGFEImageElement methods
|
|
|
|
|
2013-11-27 11:25:29 +00:00
|
|
|
FilterPrimitiveDescription
|
|
|
|
SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
|
|
|
const IntRect& aFilterSubregion,
|
2014-01-08 09:30:03 +00:00
|
|
|
const nsTArray<bool>& aInputsAreTainted,
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<SourceSurface>>& aInputImages)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2013-11-27 11:25:29 +00:00
|
|
|
if (!frame) {
|
2014-03-20 02:12:43 +00:00
|
|
|
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
2013-11-27 11:25:29 +00:00
|
|
|
}
|
2013-03-07 09:15:23 +00:00
|
|
|
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
2013-11-27 11:25:29 +00:00
|
|
|
if (currentRequest) {
|
2013-03-07 09:15:23 +00:00
|
|
|
currentRequest->GetImage(getter_AddRefs(imageContainer));
|
2013-11-27 11:25:29 +00:00
|
|
|
}
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> image;
|
2013-11-27 11:25:29 +00:00
|
|
|
if (imageContainer) {
|
2014-04-15 18:02:23 +00:00
|
|
|
image = imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
|
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2013-11-27 11:25:29 +00:00
|
|
|
}
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2014-04-15 18:02:23 +00:00
|
|
|
if (!image) {
|
2014-03-20 02:12:43 +00:00
|
|
|
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
2013-11-27 11:25:29 +00:00
|
|
|
}
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-11-27 11:25:29 +00:00
|
|
|
IntSize nativeSize;
|
|
|
|
imageContainer->GetWidth(&nativeSize.width);
|
|
|
|
imageContainer->GetHeight(&nativeSize.height);
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
Matrix viewBoxTM =
|
2013-11-27 11:25:29 +00:00
|
|
|
SVGContentUtils::GetViewBoxTransform(aFilterSubregion.width, aFilterSubregion.height,
|
|
|
|
0, 0, nativeSize.width, nativeSize.height,
|
|
|
|
mPreserveAspectRatio);
|
2014-09-10 13:26:12 +00:00
|
|
|
Matrix TM = viewBoxTM;
|
|
|
|
TM.PostTranslate(aFilterSubregion.x, aFilterSubregion.y);
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2015-10-06 00:12:46 +00:00
|
|
|
Filter filter = nsLayoutUtils::GetGraphicsFilterForFrame(frame);
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2014-03-20 02:12:43 +00:00
|
|
|
FilterPrimitiveDescription descr(PrimitiveType::Image);
|
2013-11-27 11:25:29 +00:00
|
|
|
descr.Attributes().Set(eImageFilter, (uint32_t)filter);
|
|
|
|
descr.Attributes().Set(eImageTransform, TM);
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-11-27 11:25:29 +00:00
|
|
|
// Append the image to aInputImages and store its index in the description.
|
|
|
|
size_t imageIndex = aInputImages.Length();
|
2013-11-28 14:38:43 +00:00
|
|
|
aInputImages.AppendElement(image);
|
2013-11-27 11:25:29 +00:00
|
|
|
descr.Attributes().Set(eImageInputIndex, (uint32_t)imageIndex);
|
2013-03-07 09:15:23 +00:00
|
|
|
|
2013-11-27 11:25:29 +00:00
|
|
|
return descr;
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute) const
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
// nsGkAtoms::href is deliberately omitted as the frame has special
|
|
|
|
// handling to load the image
|
2013-03-07 09:15:23 +00:00
|
|
|
return SVGFEImageElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
|
2013-03-07 09:15:23 +00:00
|
|
|
(aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::preserveAspectRatio);
|
|
|
|
}
|
|
|
|
|
2014-01-08 09:30:03 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t status;
|
|
|
|
currentRequest->GetImageStatus(&status);
|
|
|
|
if ((status & imgIRequest::STATUS_LOAD_COMPLETE) == 0) {
|
|
|
|
// The load has not completed yet.
|
|
|
|
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 02:57:36 +00:00
|
|
|
if (aReferencePrincipal->Subsumes(principal)) {
|
2014-01-08 09:30:03 +00:00
|
|
|
// The page is allowed to read from the image.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGFEImageElement::PreserveAspectRatio()
|
|
|
|
{
|
2015-01-27 09:51:34 +00:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
2013-03-07 09:15:23 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::GetPreserveAspectRatio()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::GetStringInfo()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
|
|
|
ArrayLength(sStringInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// imgINotificationObserver methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData)
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
|
|
|
nsresult rv = nsImageLoadingContent::Notify(aRequest, aType, aData);
|
|
|
|
|
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
|
|
|
// Request a decode
|
|
|
|
nsCOMPtr<imgIContainer> container;
|
|
|
|
aRequest->GetImage(getter_AddRefs(container));
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(container, "who sent the notification then?");
|
2013-03-07 09:15:23 +00:00
|
|
|
container->StartDecoding();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE ||
|
|
|
|
aType == imgINotificationObserver::FRAME_UPDATE ||
|
|
|
|
aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// helper methods
|
|
|
|
|
|
|
|
void
|
2013-03-07 09:15:23 +00:00
|
|
|
SVGFEImageElement::Invalidate()
|
2013-03-07 09:15:23 +00:00
|
|
|
{
|
2015-03-03 11:08:59 +00:00
|
|
|
if (GetParent() && GetParent()->IsSVGElement(nsGkAtoms::filter)) {
|
2013-03-07 09:15:23 +00:00
|
|
|
static_cast<SVGFilterElement*>(GetParent())->Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|