2013-03-13 14:41:20 -07:00
|
|
|
/* a*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-08 18:52:54 -08:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsSVGNumber2.h"
|
2011-07-01 00:19:52 -07:00
|
|
|
#include "nsSVGNumberPair.h"
|
2007-09-18 05:09:26 -07:00
|
|
|
#include "nsSVGInteger.h"
|
2011-07-01 00:19:52 -07:00
|
|
|
#include "nsSVGIntegerPair.h"
|
2007-09-26 02:22:08 -07:00
|
|
|
#include "nsSVGBoolean.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsSVGFilterInstance.h"
|
|
|
|
#include "nsSVGEnum.h"
|
2010-12-03 08:40:23 -08:00
|
|
|
#include "SVGNumberList.h"
|
|
|
|
#include "SVGAnimatedNumberList.h"
|
|
|
|
#include "DOMSVGAnimatedNumberList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGFilters.h"
|
2009-04-11 10:57:58 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsIFrame.h"
|
2008-01-02 12:49:13 -08:00
|
|
|
#include "imgIContainer.h"
|
2008-08-07 07:03:58 -07:00
|
|
|
#include "nsNetUtil.h"
|
2013-02-17 15:28:47 -08:00
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2008-07-13 18:21:25 -07:00
|
|
|
#include "nsSVGString.h"
|
2012-09-22 12:26:05 -07:00
|
|
|
#include "SVGContentUtils.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2013-03-06 23:17:00 -08:00
|
|
|
#include "mozilla/dom/SVGAnimatedLength.h"
|
2013-02-12 02:01:17 -08:00
|
|
|
#include "mozilla/dom/SVGComponentTransferFunctionElement.h"
|
2013-03-15 01:20:30 -07:00
|
|
|
#include "mozilla/dom/SVGFEDistantLightElement.h"
|
2013-02-12 02:10:24 -08:00
|
|
|
#include "mozilla/dom/SVGFEFuncAElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncBElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncGElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncRElementBinding.h"
|
2013-03-13 14:41:20 -07:00
|
|
|
#include "mozilla/dom/SVGFEPointLightElement.h"
|
2013-03-24 23:26:04 -07:00
|
|
|
#include "mozilla/dom/SVGFESpotLightElement.h"
|
2008-07-13 18:21:25 -07:00
|
|
|
|
2013-03-24 23:26:04 -07:00
|
|
|
#if defined(XP_WIN)
|
2008-01-07 14:23:01 -08:00
|
|
|
// Prevent Windows redefining LoadImage
|
|
|
|
#undef LoadImage
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
using namespace mozilla;
|
2010-12-05 03:37:45 -08:00
|
|
|
using namespace mozilla::dom;
|
2013-11-27 03:25:29 -08:00
|
|
|
using namespace mozilla::gfx;
|
2012-04-13 00:01:55 -07:00
|
|
|
|
2007-07-25 23:57:42 -07:00
|
|
|
//--------------------Filter Element Base Class-----------------------
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 23:57:42 -07:00
|
|
|
nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] =
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-22 12:26:05 -07:00
|
|
|
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2007-07-25 23:57:42 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsSVGFE,nsSVGFEBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsSVGFE,nsSVGFEBase)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 23:57:42 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGFE)
|
2008-02-17 23:29:00 -08:00
|
|
|
// nsISupports is an ambiguous base of nsSVGFE so we have to work
|
|
|
|
// around that
|
|
|
|
if ( aIID.Equals(NS_GET_IID(nsSVGFE)) )
|
2008-02-19 18:11:53 -08:00
|
|
|
foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
|
2008-02-17 23:29:00 -08:00
|
|
|
else
|
2007-07-25 23:57:42 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2008-02-17 23:29:00 -08:00
|
|
|
void
|
2009-01-21 16:56:51 -08:00
|
|
|
nsSVGFE::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
|
2008-02-17 23:29:00 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-08 01:30:03 -08:00
|
|
|
bool
|
|
|
|
nsSVGFE::OutputIsTainted(const nsTArray<bool>& aInputsAreTainted,
|
|
|
|
nsIPrincipal* aReferencePrincipal)
|
|
|
|
{
|
|
|
|
// This is the default implementation for OutputIsTainted.
|
|
|
|
// Our output is tainted if we have at least one tainted input.
|
|
|
|
for (uint32_t i = 0; i < aInputsAreTainted.Length(); i++) {
|
|
|
|
if (aInputsAreTainted[i]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-19 09:53:52 -08:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGFE::AttributeAffectsRendering(int32_t aNameSpaceID,
|
2011-11-19 09:53:52 -08:00
|
|
|
nsIAtom* aAttribute) const
|
|
|
|
{
|
|
|
|
return aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::x ||
|
|
|
|
aAttribute == nsGkAtoms::y ||
|
|
|
|
aAttribute == nsGkAtoms::width ||
|
|
|
|
aAttribute == nsGkAtoms::height ||
|
|
|
|
aAttribute == nsGkAtoms::result);
|
|
|
|
}
|
|
|
|
|
2013-03-06 23:17:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
nsSVGFE::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2007-07-25 23:57:42 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-06 23:17:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
nsSVGFE::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-06 23:17:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
nsSVGFE::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2007-07-25 23:57:42 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-06 23:17:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
|
|
nsSVGFE::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-14 15:37:27 -07:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-03-06 23:17:00 -08:00
|
|
|
nsSVGFE::Result()
|
|
|
|
{
|
|
|
|
return GetResultImageName().ToDOMAnimatedString(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-08-20 06:02:41 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2011-08-20 06:02:41 -07:00
|
|
|
nsSVGFE::IsAttributeMapped(const nsIAtom* name) const
|
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sFiltersMap
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2011-08-20 06:02:41 -07:00
|
|
|
nsSVGFEBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
|
|
|
|
bool
|
|
|
|
nsSVGFE::StyleIsSetToSRGB()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
if (!frame) return false;
|
|
|
|
|
|
|
|
nsStyleContext* style = frame->StyleContext();
|
|
|
|
return style->StyleSVG()->mColorInterpolationFilters ==
|
|
|
|
NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
|
|
}
|
|
|
|
|
2012-03-03 01:21:09 -08:00
|
|
|
/* virtual */ bool
|
|
|
|
nsSVGFE::HasValidDimensions() const
|
|
|
|
{
|
2013-03-06 23:17:00 -08:00
|
|
|
return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
|
|
(!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
2012-03-03 01:21:09 -08:00
|
|
|
}
|
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
Size
|
|
|
|
nsSVGFE::GetKernelUnitLength(nsSVGFilterInstance* aInstance,
|
|
|
|
nsSVGNumberPair *aKernelUnitLength)
|
|
|
|
{
|
|
|
|
if (!aKernelUnitLength->IsExplicitlySet()) {
|
|
|
|
return Size(1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float kernelX = aInstance->GetPrimitiveNumber(SVGContentUtils::X,
|
|
|
|
aKernelUnitLength,
|
|
|
|
nsSVGNumberPair::eFirst);
|
|
|
|
float kernelY = aInstance->GetPrimitiveNumber(SVGContentUtils::Y,
|
|
|
|
aKernelUnitLength,
|
|
|
|
nsSVGNumberPair::eSecond);
|
|
|
|
return Size(kernelX, kernelY);
|
|
|
|
}
|
|
|
|
|
2007-07-25 23:57:42 -07:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
nsSVGFE::GetLengthInfo()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-07-25 23:57:42 -07:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sLengthInfo));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
nsSVGElement::NumberListInfo SVGComponentTransferFunctionElement::sNumberListInfo[1] =
|
2010-12-03 08:40:23 -08:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::tableValues }
|
|
|
|
};
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
nsSVGElement::NumberInfo SVGComponentTransferFunctionElement::sNumberInfo[5] =
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
{ &nsGkAtoms::slope, 1, false },
|
|
|
|
{ &nsGkAtoms::intercept, 0, false },
|
|
|
|
{ &nsGkAtoms::amplitude, 1, false },
|
|
|
|
{ &nsGkAtoms::exponent, 1, false },
|
|
|
|
{ &nsGkAtoms::offset, 0, false }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
nsSVGEnumMapping SVGComponentTransferFunctionElement::sTypeMap[] = {
|
2007-08-27 16:11:14 -07:00
|
|
|
{&nsGkAtoms::identity,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY},
|
2007-08-27 16:11:14 -07:00
|
|
|
{&nsGkAtoms::table,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_TABLE},
|
2007-08-27 16:11:14 -07:00
|
|
|
{&nsGkAtoms::discrete,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE},
|
2007-08-27 16:11:14 -07:00
|
|
|
{&nsGkAtoms::linear,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_LINEAR},
|
2007-08-27 16:11:14 -07:00
|
|
|
{&nsGkAtoms::gamma,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_GAMMA},
|
2012-07-30 07:20:58 -07:00
|
|
|
{nullptr, 0}
|
2007-08-27 16:11:14 -07:00
|
|
|
};
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
nsSVGElement::EnumInfo SVGComponentTransferFunctionElement::sEnumInfo[1] =
|
2007-08-27 16:11:14 -07:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::type,
|
|
|
|
sTypeMap,
|
2013-03-18 10:54:04 -07:00
|
|
|
SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY
|
2007-08-27 16:11:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SVGComponentTransferFunctionElement,SVGComponentTransferFunctionElementBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SVGComponentTransferFunctionElement,SVGComponentTransferFunctionElementBase)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_INTERFACE_MAP_BEGIN(SVGComponentTransferFunctionElement)
|
2008-02-19 18:11:53 -08:00
|
|
|
// nsISupports is an ambiguous base of nsSVGFE so we have to work
|
|
|
|
// around that
|
2013-02-12 01:56:55 -08:00
|
|
|
if ( aIID.Equals(NS_GET_IID(SVGComponentTransferFunctionElement)) )
|
2008-02-19 18:11:53 -08:00
|
|
|
foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
|
|
|
|
else
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(SVGComponentTransferFunctionElementBase)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
2011-11-19 09:53:52 -08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsFEUnstyledElement methods
|
|
|
|
|
|
|
|
bool
|
2013-02-12 01:56:55 -08:00
|
|
|
SVGComponentTransferFunctionElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
2013-03-18 10:54:04 -07:00
|
|
|
nsIAtom* aAttribute) const
|
2011-11-19 09:53:52 -08:00
|
|
|
{
|
|
|
|
return aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::tableValues ||
|
|
|
|
aAttribute == nsGkAtoms::slope ||
|
|
|
|
aAttribute == nsGkAtoms::intercept ||
|
|
|
|
aAttribute == nsGkAtoms::amplitude ||
|
|
|
|
aAttribute == nsGkAtoms::exponent ||
|
|
|
|
aAttribute == nsGkAtoms::offset ||
|
|
|
|
aAttribute == nsGkAtoms::type);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-07-01 00:02:46 -07:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Type()
|
|
|
|
{
|
|
|
|
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 02:10:24 -08:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumberList>
|
|
|
|
SVGComponentTransferFunctionElement::TableValues()
|
|
|
|
{
|
|
|
|
return DOMSVGAnimatedNumberList::GetDOMWrapper(
|
|
|
|
&mNumberListAttributes[TABLEVALUES], this, TABLEVALUES);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:03:04 -07:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Slope()
|
|
|
|
{
|
|
|
|
return mNumberAttributes[SLOPE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:03:04 -07:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Intercept()
|
|
|
|
{
|
|
|
|
return mNumberAttributes[INTERCEPT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:03:04 -07:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Amplitude()
|
|
|
|
{
|
|
|
|
return mNumberAttributes[AMPLITUDE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:03:04 -07:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Exponent()
|
|
|
|
{
|
|
|
|
return mNumberAttributes[EXPONENT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:03:04 -07:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 02:10:24 -08:00
|
|
|
SVGComponentTransferFunctionElement::Offset()
|
|
|
|
{
|
|
|
|
return mNumberAttributes[OFFSET].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
AttributeMap
|
|
|
|
SVGComponentTransferFunctionElement::ComputeAttributes()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-11-27 03:25:29 -08:00
|
|
|
uint32_t type = mEnumAttributes[TYPE].GetAnimValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
float slope, intercept, amplitude, exponent, offset;
|
|
|
|
GetAnimatedNumberValues(&slope, &intercept, &litude,
|
2012-07-30 07:20:58 -07:00
|
|
|
&exponent, &offset, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
const SVGNumberList &tableValues =
|
2011-07-01 00:19:52 -07:00
|
|
|
mNumberListAttributes[TABLEVALUES].GetAnimValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
AttributeMap map;
|
|
|
|
map.Set(eComponentTransferFunctionType, type);
|
|
|
|
map.Set(eComponentTransferFunctionSlope, slope);
|
|
|
|
map.Set(eComponentTransferFunctionIntercept, intercept);
|
|
|
|
map.Set(eComponentTransferFunctionAmplitude, amplitude);
|
|
|
|
map.Set(eComponentTransferFunctionExponent, exponent);
|
|
|
|
map.Set(eComponentTransferFunctionOffset, offset);
|
|
|
|
if (tableValues.Length()) {
|
|
|
|
map.Set(eComponentTransferFunctionTableValues, &tableValues[0], tableValues.Length());
|
|
|
|
} else {
|
|
|
|
map.Set(eComponentTransferFunctionTableValues, nullptr, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-11-27 03:25:29 -08:00
|
|
|
return map;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
nsSVGElement::NumberListAttributesInfo
|
2013-02-12 01:56:55 -08:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberListInfo()
|
2010-12-03 08:40:23 -08:00
|
|
|
{
|
|
|
|
return NumberListAttributesInfo(mNumberListAttributes, sNumberListInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sNumberListInfo));
|
2010-12-03 08:40:23 -08:00
|
|
|
}
|
|
|
|
|
2007-09-18 05:09:26 -07:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-02-12 01:56:55 -08:00
|
|
|
SVGComponentTransferFunctionElement::GetEnumInfo()
|
2007-09-18 05:09:26 -07:00
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sEnumInfo));
|
2007-09-18 05:09:26 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGElement::NumberAttributesInfo
|
2013-02-12 01:56:55 -08:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberInfo()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sNumberInfo));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-12 02:10:24 -08:00
|
|
|
/* virtual */ JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGFEFuncRElement::WrapNode(JSContext* aCx)
|
2013-02-12 02:10:24 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGFEFuncRElementBinding::Wrap(aCx, this);
|
2013-02-12 02:10:24 -08:00
|
|
|
}
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncR)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncRElement)
|
|
|
|
|
2013-02-12 02:10:24 -08:00
|
|
|
/* virtual */ JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGFEFuncGElement::WrapNode(JSContext* aCx)
|
2013-02-12 02:10:24 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGFEFuncGElementBinding::Wrap(aCx, this);
|
2013-02-12 02:10:24 -08:00
|
|
|
}
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncG)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncGElement)
|
|
|
|
|
2013-02-12 02:10:24 -08:00
|
|
|
/* virtual */ JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGFEFuncBElement::WrapNode(JSContext* aCx)
|
2013-02-12 02:10:24 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGFEFuncBElementBinding::Wrap(aCx, this);
|
2013-02-12 02:10:24 -08:00
|
|
|
}
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncB)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncBElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 02:10:24 -08:00
|
|
|
/* virtual */ JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGFEFuncAElement::WrapNode(JSContext* aCx)
|
2013-02-12 02:10:24 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGFEFuncAElementBinding::Wrap(aCx, this);
|
2013-02-12 02:10:24 -08:00
|
|
|
}
|
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncA)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncAElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-12 01:56:55 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-24 23:26:05 -07:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//
|
2011-07-01 00:19:52 -07:00
|
|
|
nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[4] =
|
2007-06-27 12:02:58 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
{ &nsGkAtoms::surfaceScale, 1, false },
|
|
|
|
{ &nsGkAtoms::diffuseConstant, 1, false },
|
|
|
|
{ &nsGkAtoms::specularConstant, 1, false },
|
|
|
|
{ &nsGkAtoms::specularExponent, 1, false }
|
2011-07-01 00:19:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
nsSVGElement::NumberPairInfo nsSVGFELightingElement::sNumberPairInfo[1] =
|
|
|
|
{
|
|
|
|
{ &nsGkAtoms::kernelUnitLength, 0, 0 }
|
2007-07-25 23:57:42 -07:00
|
|
|
};
|
2007-06-27 12:02:58 -07:00
|
|
|
|
2008-06-14 02:01:02 -07:00
|
|
|
nsSVGElement::StringInfo nsSVGFELightingElement::sStringInfo[2] =
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
{ &nsGkAtoms::result, kNameSpaceID_None, true },
|
|
|
|
{ &nsGkAtoms::in, kNameSpaceID_None, true }
|
2008-06-14 02:01:02 -07:00
|
|
|
};
|
|
|
|
|
2007-08-31 07:44:28 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
|
|
|
|
|
2008-07-22 19:15:27 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGFELightingElement)
|
2007-08-31 07:44:28 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFELightingElementBase)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
2007-06-27 12:02:58 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2007-07-25 23:57:42 -07:00
|
|
|
nsSVGFELightingElement::IsAttributeMapped(const nsIAtom* name) const
|
2007-06-27 12:02:58 -07:00
|
|
|
{
|
2007-07-25 23:57:42 -07:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sLightingEffectsMap
|
|
|
|
};
|
2007-06-27 12:02:58 -07:00
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2007-07-25 23:57:42 -07:00
|
|
|
nsSVGFELightingElementBase::IsAttributeMapped(name);
|
2007-06-27 12:02:58 -07:00
|
|
|
}
|
|
|
|
|
2008-02-17 23:29:00 -08:00
|
|
|
void
|
2009-01-21 16:56:51 -08:00
|
|
|
nsSVGFELightingElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
|
2008-02-17 17:10:14 -08:00
|
|
|
{
|
2009-01-21 16:56:51 -08:00
|
|
|
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
|
2008-02-17 23:29:00 -08:00
|
|
|
}
|
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
AttributeMap
|
|
|
|
nsSVGFELightingElement::ComputeLightAttributes(nsSVGFilterInstance* aInstance)
|
|
|
|
{
|
2013-03-13 14:41:20 -07:00
|
|
|
// find specified light
|
2011-09-27 00:54:58 -07:00
|
|
|
for (nsCOMPtr<nsIContent> child = nsINode::GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
2013-11-27 03:25:29 -08:00
|
|
|
if (child->IsSVG(nsGkAtoms::feDistantLight) ||
|
|
|
|
child->IsSVG(nsGkAtoms::fePointLight) ||
|
|
|
|
child->IsSVG(nsGkAtoms::feSpotLight)) {
|
|
|
|
return static_cast<SVGFELightElement*>(child.get())->ComputeLightAttributes(aInstance);
|
2007-06-27 12:02:58 -07:00
|
|
|
}
|
2007-07-25 23:57:42 -07:00
|
|
|
}
|
2007-06-27 12:02:58 -07:00
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
AttributeMap map;
|
|
|
|
map.Set(eLightType, (uint32_t)eLightTypeNone);
|
|
|
|
return map;
|
|
|
|
}
|
2007-06-27 12:02:58 -07:00
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
FilterPrimitiveDescription
|
|
|
|
nsSVGFELightingElement::AddLightingAttributes(FilterPrimitiveDescription aDescription,
|
|
|
|
nsSVGFilterInstance* aInstance)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
if (!frame) {
|
2014-03-19 19:12:43 -07:00
|
|
|
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
2007-06-27 12:02:58 -07:00
|
|
|
}
|
|
|
|
|
2013-11-27 03:25:29 -08:00
|
|
|
nsStyleContext* style = frame->StyleContext();
|
2014-10-17 04:53:16 -07:00
|
|
|
Color color(Color::FromABGR(style->StyleSVGReset()->mLightingColor));
|
|
|
|
color.a = 1.f;
|
2013-11-27 03:25:29 -08:00
|
|
|
float surfaceScale = mNumberAttributes[SURFACE_SCALE].GetAnimValue();
|
|
|
|
Size kernelUnitLength =
|
|
|
|
GetKernelUnitLength(aInstance, &mNumberPairAttributes[KERNEL_UNIT_LENGTH]);
|
|
|
|
|
|
|
|
FilterPrimitiveDescription& descr = aDescription;
|
|
|
|
descr.Attributes().Set(eLightingLight, ComputeLightAttributes(aInstance));
|
|
|
|
descr.Attributes().Set(eLightingSurfaceScale, surfaceScale);
|
|
|
|
descr.Attributes().Set(eLightingKernelUnitLength, kernelUnitLength);
|
|
|
|
descr.Attributes().Set(eLightingColor, color);
|
|
|
|
return descr;
|
2007-06-27 12:02:58 -07:00
|
|
|
}
|
|
|
|
|
2011-11-19 09:53:52 -08:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGFELightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
2011-11-19 09:53:52 -08:00
|
|
|
nsIAtom* aAttribute) const
|
|
|
|
{
|
|
|
|
return nsSVGFELightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
|
|
|
|
(aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::in ||
|
|
|
|
aAttribute == nsGkAtoms::surfaceScale ||
|
|
|
|
aAttribute == nsGkAtoms::kernelUnitLength));
|
|
|
|
}
|
|
|
|
|
2008-06-14 02:01:02 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
nsSVGElement::NumberAttributesInfo
|
|
|
|
nsSVGFELightingElement::GetNumberInfo()
|
|
|
|
{
|
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sNumberInfo));
|
2008-06-14 02:01:02 -07:00
|
|
|
}
|
|
|
|
|
2011-07-01 00:19:52 -07:00
|
|
|
nsSVGElement::NumberPairAttributesInfo
|
|
|
|
nsSVGFELightingElement::GetNumberPairInfo()
|
|
|
|
{
|
|
|
|
return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sNumberPairInfo));
|
2011-07-01 00:19:52 -07:00
|
|
|
}
|
|
|
|
|
2008-06-14 02:01:02 -07:00
|
|
|
nsSVGElement::StringAttributesInfo
|
|
|
|
nsSVGFELightingElement::GetStringInfo()
|
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-10 22:50:08 -07:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 02:01:02 -07:00
|
|
|
}
|