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: */
|
2012-05-21 15:12:37 +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/. */
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2005-09-07 02:30:40 +04:00
|
|
|
#include "nsSVGElement.h"
|
2006-07-28 22:10:48 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsSVGNumber2.h"
|
2011-07-01 11:19:52 +04:00
|
|
|
#include "nsSVGNumberPair.h"
|
2007-09-18 16:09:26 +04:00
|
|
|
#include "nsSVGInteger.h"
|
2011-07-01 11:19:52 +04:00
|
|
|
#include "nsSVGIntegerPair.h"
|
2007-09-26 13:22:08 +04:00
|
|
|
#include "nsSVGBoolean.h"
|
2005-09-07 02:30:40 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsSVGFilterInstance.h"
|
|
|
|
#include "nsSVGEnum.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
#include "SVGNumberList.h"
|
|
|
|
#include "SVGAnimatedNumberList.h"
|
|
|
|
#include "DOMSVGAnimatedNumberList.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
#include "nsSVGFilters.h"
|
2009-04-11 21:57:58 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-06-29 01:54:12 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2007-01-08 19:48:56 +03:00
|
|
|
#include "nsIFrame.h"
|
2008-01-02 23:49:13 +03:00
|
|
|
#include "imgIContainer.h"
|
2013-02-18 03:28:47 +04:00
|
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
2008-07-14 05:21:25 +04:00
|
|
|
#include "nsSVGString.h"
|
2012-09-22 23:26:05 +04:00
|
|
|
#include "SVGContentUtils.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2013-03-07 11:17:00 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedLength.h"
|
2013-02-12 14:01:17 +04:00
|
|
|
#include "mozilla/dom/SVGComponentTransferFunctionElement.h"
|
2013-03-15 12:20:30 +04:00
|
|
|
#include "mozilla/dom/SVGFEDistantLightElement.h"
|
2013-02-12 14:10:24 +04:00
|
|
|
#include "mozilla/dom/SVGFEFuncAElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncBElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncGElementBinding.h"
|
|
|
|
#include "mozilla/dom/SVGFEFuncRElementBinding.h"
|
2013-03-14 01:41:20 +04:00
|
|
|
#include "mozilla/dom/SVGFEPointLightElement.h"
|
2013-03-25 10:26:04 +04:00
|
|
|
#include "mozilla/dom/SVGFESpotLightElement.h"
|
2018-02-02 16:21:33 +03:00
|
|
|
#include "mozilla/dom/SVGLengthBinding.h"
|
2008-07-14 05:21:25 +04:00
|
|
|
|
2013-03-25 10:26:04 +04:00
|
|
|
#if defined(XP_WIN)
|
2008-01-08 01:23:01 +03:00
|
|
|
// Prevent Windows redefining LoadImage
|
|
|
|
#undef LoadImage
|
|
|
|
#endif
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
using namespace mozilla;
|
2010-12-05 14:37:45 +03:00
|
|
|
using namespace mozilla::dom;
|
2013-11-27 15:25:29 +04:00
|
|
|
using namespace mozilla::gfx;
|
2012-04-13 11:01:55 +04:00
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
//--------------------Filter Element Base Class-----------------------
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::x, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::width, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::height, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
|
|
|
|
SVGContentUtils::Y}};
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2005-09-07 02:30:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsSVGFE, nsSVGFEBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsSVGFE, nsSVGFEBase)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGFE)
|
2018-05-22 02:33:18 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONCRETE(nsSVGFE)
|
2007-07-26 10:57:42 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2009-01-22 03:56:51 +03:00
|
|
|
void nsSVGFE::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) {}
|
2008-02-18 10:29:00 +03:00
|
|
|
|
2014-01-08 13:30:03 +04: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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
bool nsSVGFE::AttributeAffectsRendering(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute) const {
|
2011-11-19 21:53:52 +04:00
|
|
|
return aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y ||
|
|
|
|
aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height ||
|
|
|
|
aAttribute == nsGkAtoms::result);
|
|
|
|
}
|
|
|
|
|
2013-03-07 11:17:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> nsSVGFE::X() {
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2007-07-26 10:57:42 +04:00
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-03-07 11:17:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> nsSVGFE::Y() {
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-03-07 11:17:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> nsSVGFE::Width() {
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2007-07-26 10:57:42 +04:00
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-03-07 11:17:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> nsSVGFE::Height() {
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> nsSVGFE::Result() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return GetResultImageName().ToDOMAnimatedString(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 17:02:41 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGFE::IsAttributeMapped(const nsAtom* name) const {
|
2011-08-20 17:02:41 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {sFiltersMap};
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2011-08-20 17:02:41 +04:00
|
|
|
nsSVGFEBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
bool nsSVGFE::StyleIsSetToSRGB() {
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
if (!frame) return false;
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* style = frame->Style();
|
2013-11-27 15:25:29 +04:00
|
|
|
return style->StyleSVG()->mColorInterpolationFilters ==
|
|
|
|
NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
|
|
}
|
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
/* virtual */ bool nsSVGFE::HasValidDimensions() const {
|
2013-03-07 11:17:00 +04:00
|
|
|
return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
|
|
(!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
2012-03-03 13:21:09 +04:00
|
|
|
}
|
|
|
|
|
2013-11-27 15:25:29 +04: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-26 10:57:42 +04:00
|
|
|
nsSVGElement::LengthAttributesInfo nsSVGFE::GetLengthInfo() {
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
nsSVGElement::NumberListInfo
|
|
|
|
SVGComponentTransferFunctionElement::sNumberListInfo[1] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::tableValues}};
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
nsSVGElement::NumberInfo SVGComponentTransferFunctionElement::sNumberInfo[5] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::slope, 1, false},
|
|
|
|
{nsGkAtoms::intercept, 0, false},
|
|
|
|
{nsGkAtoms::amplitude, 1, false},
|
|
|
|
{nsGkAtoms::exponent, 1, false},
|
|
|
|
{nsGkAtoms::offset, 0, false}};
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
nsSVGEnumMapping SVGComponentTransferFunctionElement::sTypeMap[] = {
|
2013-03-18 21:54:04 +04:00
|
|
|
{nsGkAtoms::identity, SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY},
|
|
|
|
{nsGkAtoms::table, SVG_FECOMPONENTTRANSFER_TYPE_TABLE},
|
|
|
|
{nsGkAtoms::discrete, SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE},
|
|
|
|
{nsGkAtoms::linear, SVG_FECOMPONENTTRANSFER_TYPE_LINEAR},
|
|
|
|
{nsGkAtoms::gamma, SVG_FECOMPONENTTRANSFER_TYPE_GAMMA},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr, 0}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
nsSVGElement::EnumInfo SVGComponentTransferFunctionElement::sEnumInfo[1] = {
|
2013-03-18 21:54:04 +04:00
|
|
|
{nsGkAtoms::type, sTypeMap, SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY}};
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2005-09-07 02:30:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SVGComponentTransferFunctionElement,
|
|
|
|
SVGComponentTransferFunctionElementBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SVGComponentTransferFunctionElement,
|
|
|
|
SVGComponentTransferFunctionElementBase)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(SVGComponentTransferFunctionElement)
|
2018-05-22 02:33:18 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONCRETE(SVGComponentTransferFunctionElement)
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(SVGComponentTransferFunctionElementBase)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2011-11-19 21:53:52 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsFEUnstyledElement methods
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
bool SVGComponentTransferFunctionElement::AttributeAffectsRendering(
|
2017-10-03 01:05:19 +03:00
|
|
|
int32_t aNameSpaceID, nsAtom* aAttribute) const {
|
2011-11-19 21:53:52 +04: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);
|
|
|
|
}
|
|
|
|
|
2005-09-07 02:30:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Type() {
|
|
|
|
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 14:10:24 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumberList>
|
|
|
|
SVGComponentTransferFunctionElement::TableValues() {
|
|
|
|
return DOMSVGAnimatedNumberList::GetDOMWrapper(
|
|
|
|
&mNumberListAttributes[TABLEVALUES], this, TABLEVALUES);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Slope() {
|
|
|
|
return mNumberAttributes[SLOPE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Intercept() {
|
|
|
|
return mNumberAttributes[INTERCEPT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Amplitude() {
|
|
|
|
return mNumberAttributes[AMPLITUDE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Exponent() {
|
|
|
|
return mNumberAttributes[EXPONENT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Offset() {
|
|
|
|
return mNumberAttributes[OFFSET].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2018-09-19 20:18:16 +03:00
|
|
|
void SVGComponentTransferFunctionElement::ComputeAttributes(
|
|
|
|
int32_t aChannel, ComponentTransferAttributes& aAttributes) {
|
2013-11-27 15:25:29 +04:00
|
|
|
uint32_t type = mEnumAttributes[TYPE].GetAnimValue();
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
float slope, intercept, amplitude, exponent, offset;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetAnimatedNumberValues(&slope, &intercept, &litude, &exponent, &offset,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr);
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
const SVGNumberList& tableValues =
|
2011-07-01 11:19:52 +04:00
|
|
|
mNumberListAttributes[TABLEVALUES].GetAnimValue();
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2018-09-19 20:18:16 +03:00
|
|
|
aAttributes.mTypes[aChannel] = (uint8_t)type;
|
|
|
|
switch (type) {
|
|
|
|
case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: {
|
|
|
|
aAttributes.mValues[aChannel].SetLength(2);
|
|
|
|
aAttributes.mValues[aChannel][kComponentTransferSlopeIndex] = slope;
|
|
|
|
aAttributes.mValues[aChannel][kComponentTransferInterceptIndex] =
|
|
|
|
intercept;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: {
|
|
|
|
aAttributes.mValues[aChannel].SetLength(3);
|
|
|
|
aAttributes.mValues[aChannel][kComponentTransferAmplitudeIndex] =
|
|
|
|
amplitude;
|
|
|
|
aAttributes.mValues[aChannel][kComponentTransferExponentIndex] = exponent;
|
|
|
|
aAttributes.mValues[aChannel][kComponentTransferOffsetIndex] = offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
|
|
|
|
case SVG_FECOMPONENTTRANSFER_TYPE_TABLE: {
|
2018-09-26 20:07:41 +03:00
|
|
|
if (!tableValues.IsEmpty()) {
|
|
|
|
aAttributes.mValues[aChannel].AppendElements(&tableValues[0],
|
|
|
|
tableValues.Length());
|
|
|
|
}
|
2018-09-19 20:18:16 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
nsSVGElement::NumberListAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberListInfo() {
|
2010-12-03 19:40:23 +03:00
|
|
|
return NumberListAttributesInfo(mNumberListAttributes, sNumberListInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sNumberListInfo));
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
2007-09-18 16:09:26 +04:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetEnumInfo() {
|
2007-09-18 16:09:26 +04:00
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
nsSVGElement::NumberAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberInfo() {
|
2006-07-28 22:10:48 +04:00
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sNumberInfo));
|
2006-07-28 22:10:48 +04: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 17:13:33 +03:00
|
|
|
/* virtual */ JSObject* SVGFEFuncRElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGFEFuncRElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-12 14:10:24 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncR)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncRElement)
|
|
|
|
|
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
|
|
|
/* virtual */ JSObject* SVGFEFuncGElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGFEFuncGElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-12 14:10:24 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncG)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncGElement)
|
|
|
|
|
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
|
|
|
/* virtual */ JSObject* SVGFEFuncBElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGFEFuncBElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-12 14:10:24 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncB)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncBElement)
|
2005-09-07 02:30:40 +04: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 17:13:33 +03:00
|
|
|
/* virtual */ JSObject* SVGFEFuncAElement::WrapNode(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGFEFuncAElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-12 14:10:24 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncA)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncAElement)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-03-25 10:26:05 +04:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//
|
2018-12-20 11:01:54 +03:00
|
|
|
nsSVGElement::NumberInfo SVGFELightingElement::sNumberInfo[4] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::surfaceScale, 1, false},
|
|
|
|
{nsGkAtoms::diffuseConstant, 1, false},
|
|
|
|
{nsGkAtoms::specularConstant, 1, false},
|
|
|
|
{nsGkAtoms::specularExponent, 1, false}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
nsSVGElement::NumberPairInfo SVGFELightingElement::sNumberPairInfo[1] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::kernelUnitLength, 0, 0}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
nsSVGElement::StringInfo SVGFELightingElement::sStringInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::result, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::in, kNameSpaceID_None, true}};
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2007-08-31 18:44:28 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
2007-06-27 23:02:58 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2018-12-20 11:01:54 +03:00
|
|
|
SVGFELightingElement::IsAttributeMapped(const nsAtom* name) const {
|
2007-07-26 10:57:42 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {sColorMap,
|
|
|
|
sLightingEffectsMap};
|
2007-06-27 23:02:58 +04:00
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2018-12-20 11:01:54 +03:00
|
|
|
SVGFELightingElementBase::IsAttributeMapped(name);
|
2007-06-27 23:02:58 +04:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
void SVGFELightingElement::GetSourceImageNames(
|
2009-01-22 03:56:51 +03:00
|
|
|
nsTArray<nsSVGStringInfo>& aSources) {
|
|
|
|
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
|
2008-02-18 10:29:00 +03:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
LightType SVGFELightingElement::ComputeLightAttributes(
|
2018-09-19 20:18:16 +03:00
|
|
|
nsSVGFilterInstance* aInstance, nsTArray<float>& aFloatAttributes) {
|
2013-03-14 01:41:20 +04:00
|
|
|
// find specified light
|
2011-09-27 11:54:58 +04:00
|
|
|
for (nsCOMPtr<nsIContent> child = nsINode::GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (child->IsAnyOfSVGElements(nsGkAtoms::feDistantLight,
|
|
|
|
nsGkAtoms::fePointLight,
|
|
|
|
nsGkAtoms::feSpotLight)) {
|
2018-09-19 20:18:16 +03:00
|
|
|
return static_cast<SVGFELightElement*>(child.get())
|
|
|
|
->ComputeLightAttributes(aInstance, aFloatAttributes);
|
2007-06-27 23:02:58 +04:00
|
|
|
}
|
2007-07-26 10:57:42 +04:00
|
|
|
}
|
2007-06-27 23:02:58 +04:00
|
|
|
|
2018-09-19 20:18:16 +03:00
|
|
|
return LightType::None;
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
2007-06-27 23:02:58 +04:00
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
bool SVGFELightingElement::AddLightingAttributes(
|
2018-09-19 20:18:16 +03:00
|
|
|
mozilla::gfx::DiffuseLightingAttributes* aAttributes,
|
2013-11-27 15:25:29 +04:00
|
|
|
nsSVGFilterInstance* aInstance) {
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
if (!frame) {
|
2018-09-19 20:18:16 +03:00
|
|
|
return false;
|
2007-06-27 23:02:58 +04:00
|
|
|
}
|
|
|
|
|
2018-04-27 05:07:20 +03:00
|
|
|
const nsStyleSVGReset* styleSVGReset = frame->Style()->StyleSVGReset();
|
|
|
|
Color color(Color::FromABGR(styleSVGReset->mLightingColor.CalcColor(frame)));
|
2014-10-17 15:53:16 +04:00
|
|
|
color.a = 1.f;
|
2013-11-27 15:25:29 +04:00
|
|
|
float surfaceScale = mNumberAttributes[SURFACE_SCALE].GetAnimValue();
|
|
|
|
Size kernelUnitLength = GetKernelUnitLength(
|
|
|
|
aInstance, &mNumberPairAttributes[KERNEL_UNIT_LENGTH]);
|
|
|
|
|
2017-01-19 16:07:25 +03:00
|
|
|
if (kernelUnitLength.width <= 0 || kernelUnitLength.height <= 0) {
|
|
|
|
// According to spec, A negative or zero value is an error. See link below
|
|
|
|
// for details.
|
|
|
|
// https://www.w3.org/TR/SVG/filters.html#feSpecularLightingKernelUnitLengthAttribute
|
2018-09-19 20:18:16 +03:00
|
|
|
return false;
|
2017-01-19 16:07:25 +03:00
|
|
|
}
|
|
|
|
|
2018-09-19 20:18:16 +03:00
|
|
|
aAttributes->mLightType =
|
|
|
|
ComputeLightAttributes(aInstance, aAttributes->mLightValues);
|
|
|
|
aAttributes->mSurfaceScale = surfaceScale;
|
|
|
|
aAttributes->mKernelUnitLength = kernelUnitLength;
|
|
|
|
aAttributes->mColor = color;
|
|
|
|
|
|
|
|
return true;
|
2007-06-27 23:02:58 +04:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
bool SVGFELightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
|
|
nsAtom* aAttribute) const {
|
|
|
|
return SVGFELightingElementBase::AttributeAffectsRendering(aNameSpaceID,
|
|
|
|
aAttribute) ||
|
2011-11-19 21:53:52 +04:00
|
|
|
(aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::in ||
|
|
|
|
aAttribute == nsGkAtoms::surfaceScale ||
|
|
|
|
aAttribute == nsGkAtoms::kernelUnitLength));
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
nsSVGElement::NumberAttributesInfo SVGFELightingElement::GetNumberInfo() {
|
2008-06-14 13:01:02 +04:00
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sNumberInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
nsSVGElement::NumberPairAttributesInfo
|
2018-12-20 11:01:54 +03:00
|
|
|
SVGFELightingElement::GetNumberPairInfo() {
|
2011-07-01 11:19:52 +04:00
|
|
|
return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sNumberPairInfo));
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
nsSVGElement::StringAttributesInfo SVGFELightingElement::GetStringInfo() {
|
2008-06-14 13:01:02 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2018-12-20 11:01:54 +03:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|