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
|
|
|
|
2018-12-28 05:47:10 +03:00
|
|
|
#include "SVGFilters.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2019-01-02 21:24:11 +03:00
|
|
|
#include <algorithm>
|
|
|
|
#include "DOMSVGAnimatedNumberList.h"
|
2019-03-19 03:01:03 +03:00
|
|
|
#include "DOMSVGAnimatedLength.h"
|
2006-07-28 22:10:48 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2019-01-02 21:44:12 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2019-01-02 21:24:11 +03:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2019-04-04 20:40:56 +03:00
|
|
|
#include "SVGAnimatedEnumeration.h"
|
|
|
|
#include "SVGAnimatedNumberPair.h"
|
|
|
|
#include "SVGAnimatedString.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
#include "SVGNumberList.h"
|
2018-12-28 05:47:10 +03:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2019-01-02 21:24:11 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
|
|
|
#include "mozilla/SVGContentUtils.h"
|
2020-06-30 21:11:50 +03:00
|
|
|
#include "mozilla/SVGFilterInstance.h"
|
2013-02-12 14:01:17 +04:00
|
|
|
#include "mozilla/dom/SVGComponentTransferFunctionElement.h"
|
2019-01-02 21:24:11 +03:00
|
|
|
#include "mozilla/dom/SVGElement.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"
|
2019-01-02 21:24:11 +03:00
|
|
|
#include "mozilla/dom/SVGFilterElement.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
|
|
|
|
2013-11-27 15:25:29 +04:00
|
|
|
using namespace mozilla::gfx;
|
2012-04-13 11:01:55 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::dom {
|
2018-12-21 15:32:35 +03:00
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
//--------------------Filter Element Base Class-----------------------
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
SVGElement::LengthInfo SVGFilterPrimitiveElement::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
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
void SVGFilterPrimitiveElement::GetSourceImageNames(
|
|
|
|
nsTArray<SVGStringInfo>& aSources) {}
|
2008-02-18 10:29:00 +03:00
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
bool SVGFilterPrimitiveElement::OutputIsTainted(
|
|
|
|
const nsTArray<bool>& aInputsAreTainted,
|
|
|
|
nsIPrincipal* aReferencePrincipal) {
|
2014-01-08 13:30:03 +04:00
|
|
|
// This is the default implementation for OutputIsTainted.
|
|
|
|
// Our output is tainted if we have at least one tainted input.
|
2023-11-05 21:04:53 +03:00
|
|
|
return aInputsAreTainted.Contains(true);
|
2014-01-08 13:30:03 +04:00
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
bool SVGFilterPrimitiveElement::AttributeAffectsRendering(
|
|
|
|
int32_t aNameSpaceID, 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);
|
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGFilterPrimitiveElement::X() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2007-07-26 10:57:42 +04:00
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGFilterPrimitiveElement::Y() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGFilterPrimitiveElement::Width() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2007-07-26 10:57:42 +04:00
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGFilterPrimitiveElement::Height() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGFilterPrimitiveElement::Result() {
|
2013-03-07 11:17:00 +04:00
|
|
|
return GetResultImageName().ToDOMAnimatedString(this);
|
2005-09-07 02:30:40 +04:00
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
bool SVGFilterPrimitiveElement::StyleIsSetToSRGB() {
|
2013-11-27 15:25:29 +04:00
|
|
|
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 ==
|
2020-02-29 18:41:13 +03:00
|
|
|
StyleColorInterpolation::Srgb;
|
2013-11-27 15:25:29 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* virtual */
|
2023-10-03 13:40:45 +03:00
|
|
|
bool SVGFilterPrimitiveElement::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
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
Size SVGFilterPrimitiveElement::GetKernelUnitLength(
|
|
|
|
SVGFilterInstance* aInstance, SVGAnimatedNumberPair* aKernelUnitLength) {
|
2013-11-27 15:25:29 +04:00
|
|
|
if (!aKernelUnitLength->IsExplicitlySet()) {
|
|
|
|
return Size(1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float kernelX = aInstance->GetPrimitiveNumber(
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGContentUtils::X, aKernelUnitLength, SVGAnimatedNumberPair::eFirst);
|
2013-11-27 15:25:29 +04:00
|
|
|
float kernelY = aInstance->GetPrimitiveNumber(
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGContentUtils::Y, aKernelUnitLength, SVGAnimatedNumberPair::eSecond);
|
2013-11-27 15:25:29 +04:00
|
|
|
return Size(kernelX, kernelY);
|
|
|
|
}
|
|
|
|
|
2023-10-03 13:40:45 +03:00
|
|
|
SVGElement::LengthAttributesInfo SVGFilterPrimitiveElement::GetLengthInfo() {
|
2007-07-26 10:57:42 +04:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sLengthInfo));
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberListInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::sNumberListInfo[1] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::tableValues}};
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberInfo SVGComponentTransferFunctionElement::sNumberInfo[5] = {
|
2023-10-12 12:40:24 +03:00
|
|
|
{nsGkAtoms::slope, 1},
|
|
|
|
{nsGkAtoms::intercept, 0},
|
|
|
|
{nsGkAtoms::amplitude, 1},
|
|
|
|
{nsGkAtoms::exponent, 1},
|
|
|
|
{nsGkAtoms::offset, 0}};
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2019-01-02 21:24:11 +03:00
|
|
|
SVGEnumMapping 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
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::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
|
|
|
//----------------------------------------------------------------------
|
2023-10-04 13:41:41 +03:00
|
|
|
// nsSVGFilterPrimitiveChildElement methods
|
2011-11-19 21:53:52 +04:00
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration>
|
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
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Slope() {
|
|
|
|
return mNumberAttributes[SLOPE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Intercept() {
|
|
|
|
return mNumberAttributes[INTERCEPT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Amplitude() {
|
|
|
|
return mNumberAttributes[AMPLITUDE].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumber>
|
2013-02-12 14:10:24 +04:00
|
|
|
SVGComponentTransferFunctionElement::Exponent() {
|
|
|
|
return mNumberAttributes[EXPONENT].ToDOMAnimatedNumber(this);
|
|
|
|
}
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedNumber>
|
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;
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberListAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberListInfo() {
|
2010-12-03 19:40:23 +03:00
|
|
|
return NumberListAttributesInfo(mNumberListAttributes, sNumberListInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sNumberListInfo));
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::EnumAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetEnumInfo() {
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, std::size(sEnumInfo));
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberAttributesInfo
|
2013-02-12 13:56:55 +04:00
|
|
|
SVGComponentTransferFunctionElement::GetNumberInfo() {
|
2006-07-28 22:10:48 +04:00
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sNumberInfo));
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +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
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncR)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::dom {
|
2013-02-12 13:56:55 +04:00
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncRElement)
|
|
|
|
|
2019-02-26 01:05:29 +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
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncG)
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::dom {
|
2005-09-07 02:30:40 +04:00
|
|
|
|
2013-02-12 13:56:55 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncGElement)
|
|
|
|
|
2019-02-26 01:05:29 +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
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|
2013-02-12 13:56:55 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncB)
|
2013-02-12 13:56:55 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::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
|
|
|
|
2019-02-26 01:05:29 +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
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|
2013-02-12 13:56:55 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncA)
|
2013-02-12 13:56:55 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::dom {
|
2013-02-12 13:56:55 +04:00
|
|
|
|
|
|
|
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-21 11:58:14 +03:00
|
|
|
SVGElement::NumberInfo SVGFELightingElement::sNumberInfo[4] = {
|
2023-10-12 12:40:24 +03:00
|
|
|
{nsGkAtoms::surfaceScale, 1},
|
|
|
|
{nsGkAtoms::diffuseConstant, 1},
|
|
|
|
{nsGkAtoms::specularConstant, 1},
|
|
|
|
{nsGkAtoms::specularExponent, 1}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::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-21 11:58:14 +03:00
|
|
|
SVGElement::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
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
void SVGFELightingElement::GetSourceImageNames(
|
2018-12-21 19:24:17 +03:00
|
|
|
nsTArray<SVGStringInfo>& aSources) {
|
|
|
|
aSources.AppendElement(SVGStringInfo(&mStringAttributes[IN1], this));
|
2008-02-18 10:29:00 +03:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:01:54 +03:00
|
|
|
LightType SVGFELightingElement::ComputeLightAttributes(
|
2020-06-30 21:11:50 +03:00
|
|
|
SVGFilterInstance* 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,
|
2020-06-30 21:11:50 +03:00
|
|
|
SVGFilterInstance* aInstance) {
|
2023-12-11 12:09:38 +03:00
|
|
|
const auto* frame = GetPrimaryFrame();
|
2013-11-27 15:25:29 +04:00
|
|
|
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();
|
2020-03-09 17:16:17 +03:00
|
|
|
sRGBColor color(
|
|
|
|
sRGBColor::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
|
|
|
}
|
|
|
|
|
2023-12-11 12:09:38 +03:00
|
|
|
bool SVGFELightingElement::OutputIsTainted(
|
|
|
|
const nsTArray<bool>& aInputsAreTainted,
|
|
|
|
nsIPrincipal* aReferencePrincipal) {
|
|
|
|
if (const auto* frame = GetPrimaryFrame()) {
|
|
|
|
if (frame->Style()->StyleSVGReset()->mLightingColor.IsCurrentColor()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SVGFELightingElementBase::OutputIsTainted(aInputsAreTainted,
|
|
|
|
aReferencePrincipal);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberAttributesInfo SVGFELightingElement::GetNumberInfo() {
|
2008-06-14 13:01:02 +04:00
|
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sNumberInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::NumberPairAttributesInfo SVGFELightingElement::GetNumberPairInfo() {
|
2011-07-01 11:19:52 +04:00
|
|
|
return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sNumberPairInfo));
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGFELightingElement::GetStringInfo() {
|
2008-06-14 13:01:02 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.
Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 11:21:19 +03:00
|
|
|
std::size(sStringInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2018-12-20 11:01:54 +03:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|