mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
1e24b22ef4
- Bug 1150366 - Remove duplicate d3.js. r=jsantell (71f991da6) - Bug 1175352 - Refactor LoadInfo arguments to be more self contained (r=bent) (3f7d08164) - Bug 1181533 - Add nsCRTGlue.h and prtime.h includes to nsDownloadManager.cpp to fix --disable-safe-browsing build bustage. r=froydnj (af338edf1) - Bug 905127 - Part 1 - Make some functions from nsNetUtil not inline. r=jduell Bug 905127 - Part 2 - remove unnecessary nsNetUtil.h includes r=jduell Bug 905127 - Make some functions from nsNetUtil not inline. r=jduell (bc47d5b3a) - Bug 1117650 - Part 1: Move all CORS tests into dom/security/test. r=sicking (6f727387c) - Bug 1117650 - Part 2: Move all MixedContent tests into dom/security/test. r=tanvi (73f273829) - Bug 1004703 - ignore 'unsafe-inline' if nonce- or hash-source specifed - tests (r=sstamm) (ebf411159) - Bug 921493 - CSP: test whitelisting of scheme-relative sources (r=dveditz) (f0618b189) - Bug 1139569 - Optimize update function for element editors in markup view;r=mratcliffe (c60d38dca) - Partil of Bug 1139644 - Make markupview use sdk timers instead of individual timers for each window;r=pbrosset (8bc1a4d66) - Bug 1146568 - Avoid unsafe CPOW usage warnings in browser_markupview_tag_edit_08.js; r=bgrins Making use of the devtools test frame-script to set the test node's attributes instead of using a CPOW. (61d7eed64) - Bug 1146568 - Avoid unsafe CPOW usage in markupview tests, in assertAttributes helper; r=bgrins (efc492d5d) - Bug 858038 - Allow moving elements in the markupview by drag/drop; r=pbrosset (51d79c15c) - Bug 1139644 - Flash only relevant attributes in markup view when changed;r=pbrosset (29807fa46) - Bug 1147128 - Make sure attribute shows up in markup view after removing and setting to the previous value;r=mratcliffe (1947f7417) - Bug 1147325 - Clear box model timer on markup view destroy. r=pbrosset Prevents 'this._inspector.toolbox is null' spam in mochitest-dt (1d6808b4a) - Bug 921102 - 1 - Linkify URIs in the inspector; r=tromey, miker This first part adds a parser for node attributes which, given some node information and an attribute name, generates a small AST-like array of objects that tells which parts of the attribute (if any) are links, and what they link to. Using this, the markup-view generates the right HTML structure to display these parts as links. This part 1 doesn't yet allow users to follow these links. (c500e270e) - Bug 1139667 - CSP tests for fetch(). r=ckirschb (df030457f) - Bug 1086999 - CSP: Asterisk (*) wildcard should not allow blob:, data:, or filesystem: when matching source expressions - tests (r=sstamm) (dee0f2239) - Bug 1117650 - Part 3: Move all CSP tests into dom/security/test. r=sstamm (29c95475c) - Bug 1146566 - 1 - Use devtools common frame-script in markupview tests and add helper; r=bgrins (b10e42468) - Bug 1146566 - 2 - Avoid using CPOWs in test browser_markupview_tag_edit_03.js; r=bgrins This change updates the browser_markupview_tag_edit_03.js test by making use of the getDomElementInfo message listener to retrieve information about the tested nodes without having to go through CPOWs. (07f0ee3ff) - Bug 1036324 - Adds option to walker.parents() to not traverse DocShellTreeItems of different types (24123a5d2) - Bug 921102 - 2 - Markup-view tests for attribute links; r=miker (f6da81799) - Bug 901250 - Add scroll into view menu item for the inspector. r=bgrins (bfc7518b1) - Bug 994055 - Part 1: Add a toggle sidebar panel button to the inspector. r=miker This adds a new icon, next to the searchbox (like in the debugger) to expand or collapse the sidebar panel in the inspector. The state is *not* persisted yet when the toolbox is closed. The button is hidden when the toolbox host switches to 'side'. (87730e20a) - Bug 994055 - Part 2: Add tests for the inspector sidebar toggle button. r=miker (2872c3fbd) - Bug 921102 - 3 - Open/copy markup-view attribute links; r=bgrins This part adds contextual menu items that become enabled when the user right clicks on an attribute that has a link. Depending on the nature of the link, a new tab will be opened or a node selected. The user can also choose to copy the link in the clipboard. (9b93485f6) - Bug 921102 - 4 - Tests for the open/copy links on markup-view attributes; r=bgrins (861ba51f6)
568 lines
17 KiB
C++
568 lines
17 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/ArrayUtils.h"
|
|
|
|
#include "nsSVGElement.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsSVGNumber2.h"
|
|
#include "nsSVGNumberPair.h"
|
|
#include "nsSVGInteger.h"
|
|
#include "nsSVGIntegerPair.h"
|
|
#include "nsSVGBoolean.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsSVGFilterInstance.h"
|
|
#include "nsSVGEnum.h"
|
|
#include "SVGNumberList.h"
|
|
#include "SVGAnimatedNumberList.h"
|
|
#include "DOMSVGAnimatedNumberList.h"
|
|
#include "nsSVGFilters.h"
|
|
#include "nsLayoutUtils.h"
|
|
#include "nsSVGUtils.h"
|
|
#include "nsStyleContext.h"
|
|
#include "nsIFrame.h"
|
|
#include "imgIContainer.h"
|
|
#include "mozilla/dom/SVGFilterElement.h"
|
|
#include "nsSVGString.h"
|
|
#include "SVGContentUtils.h"
|
|
#include <algorithm>
|
|
#include "mozilla/dom/SVGAnimatedLength.h"
|
|
#include "mozilla/dom/SVGComponentTransferFunctionElement.h"
|
|
#include "mozilla/dom/SVGFEDistantLightElement.h"
|
|
#include "mozilla/dom/SVGFEFuncAElementBinding.h"
|
|
#include "mozilla/dom/SVGFEFuncBElementBinding.h"
|
|
#include "mozilla/dom/SVGFEFuncGElementBinding.h"
|
|
#include "mozilla/dom/SVGFEFuncRElementBinding.h"
|
|
#include "mozilla/dom/SVGFEPointLightElement.h"
|
|
#include "mozilla/dom/SVGFESpotLightElement.h"
|
|
|
|
#if defined(XP_WIN)
|
|
// Prevent Windows redefining LoadImage
|
|
#undef LoadImage
|
|
#endif
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::dom;
|
|
using namespace mozilla::gfx;
|
|
|
|
//--------------------Filter Element Base Class-----------------------
|
|
|
|
nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] =
|
|
{
|
|
{ &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 }
|
|
};
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsISupports methods
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsSVGFE,nsSVGFEBase)
|
|
NS_IMPL_RELEASE_INHERITED(nsSVGFE,nsSVGFEBase)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGFE)
|
|
// nsISupports is an ambiguous base of nsSVGFE so we have to work
|
|
// around that
|
|
if ( aIID.Equals(NS_GET_IID(nsSVGFE)) )
|
|
foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
|
|
else
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase)
|
|
|
|
//----------------------------------------------------------------------
|
|
// Implementation
|
|
|
|
void
|
|
nsSVGFE::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
|
|
{
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
bool
|
|
nsSVGFE::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute) const
|
|
{
|
|
return aNameSpaceID == kNameSpaceID_None &&
|
|
(aAttribute == nsGkAtoms::x ||
|
|
aAttribute == nsGkAtoms::y ||
|
|
aAttribute == nsGkAtoms::width ||
|
|
aAttribute == nsGkAtoms::height ||
|
|
aAttribute == nsGkAtoms::result);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
nsSVGFE::X()
|
|
{
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
nsSVGFE::Y()
|
|
{
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
nsSVGFE::Width()
|
|
{
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedLength>
|
|
nsSVGFE::Height()
|
|
{
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedString>
|
|
nsSVGFE::Result()
|
|
{
|
|
return GetResultImageName().ToDOMAnimatedString(this);
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsIContent methods
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
nsSVGFE::IsAttributeMapped(const nsIAtom* name) const
|
|
{
|
|
static const MappedAttributeEntry* const map[] = {
|
|
sFiltersMap
|
|
};
|
|
|
|
return FindAttributeDependence(name, map) ||
|
|
nsSVGFEBase::IsAttributeMapped(name);
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsSVGElement methods
|
|
|
|
|
|
bool
|
|
nsSVGFE::StyleIsSetToSRGB()
|
|
{
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
if (!frame) return false;
|
|
|
|
nsStyleContext* style = frame->StyleContext();
|
|
return style->StyleSVG()->mColorInterpolationFilters ==
|
|
NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
}
|
|
|
|
/* virtual */ bool
|
|
nsSVGFE::HasValidDimensions() const
|
|
{
|
|
return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
(!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
nsSVGFE::GetLengthInfo()
|
|
{
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
ArrayLength(sLengthInfo));
|
|
}
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
nsSVGElement::NumberListInfo SVGComponentTransferFunctionElement::sNumberListInfo[1] =
|
|
{
|
|
{ &nsGkAtoms::tableValues }
|
|
};
|
|
|
|
nsSVGElement::NumberInfo SVGComponentTransferFunctionElement::sNumberInfo[5] =
|
|
{
|
|
{ &nsGkAtoms::slope, 1, false },
|
|
{ &nsGkAtoms::intercept, 0, false },
|
|
{ &nsGkAtoms::amplitude, 1, false },
|
|
{ &nsGkAtoms::exponent, 1, false },
|
|
{ &nsGkAtoms::offset, 0, false }
|
|
};
|
|
|
|
nsSVGEnumMapping SVGComponentTransferFunctionElement::sTypeMap[] = {
|
|
{&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},
|
|
{nullptr, 0}
|
|
};
|
|
|
|
nsSVGElement::EnumInfo SVGComponentTransferFunctionElement::sEnumInfo[1] =
|
|
{
|
|
{ &nsGkAtoms::type,
|
|
sTypeMap,
|
|
SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY
|
|
}
|
|
};
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsISupports methods
|
|
|
|
NS_IMPL_ADDREF_INHERITED(SVGComponentTransferFunctionElement,SVGComponentTransferFunctionElementBase)
|
|
NS_IMPL_RELEASE_INHERITED(SVGComponentTransferFunctionElement,SVGComponentTransferFunctionElementBase)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(SVGComponentTransferFunctionElement)
|
|
// nsISupports is an ambiguous base of nsSVGFE so we have to work
|
|
// around that
|
|
if ( aIID.Equals(NS_GET_IID(SVGComponentTransferFunctionElement)) )
|
|
foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
|
|
else
|
|
NS_INTERFACE_MAP_END_INHERITING(SVGComponentTransferFunctionElementBase)
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsFEUnstyledElement methods
|
|
|
|
bool
|
|
SVGComponentTransferFunctionElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute) const
|
|
{
|
|
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);
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
|
SVGComponentTransferFunctionElement::Type()
|
|
{
|
|
return mEnumAttributes[TYPE].ToDOMAnimatedEnum(this);
|
|
}
|
|
|
|
already_AddRefed<DOMSVGAnimatedNumberList>
|
|
SVGComponentTransferFunctionElement::TableValues()
|
|
{
|
|
return DOMSVGAnimatedNumberList::GetDOMWrapper(
|
|
&mNumberListAttributes[TABLEVALUES], this, TABLEVALUES);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
|
SVGComponentTransferFunctionElement::Slope()
|
|
{
|
|
return mNumberAttributes[SLOPE].ToDOMAnimatedNumber(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
|
SVGComponentTransferFunctionElement::Intercept()
|
|
{
|
|
return mNumberAttributes[INTERCEPT].ToDOMAnimatedNumber(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
|
SVGComponentTransferFunctionElement::Amplitude()
|
|
{
|
|
return mNumberAttributes[AMPLITUDE].ToDOMAnimatedNumber(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
|
SVGComponentTransferFunctionElement::Exponent()
|
|
{
|
|
return mNumberAttributes[EXPONENT].ToDOMAnimatedNumber(this);
|
|
}
|
|
|
|
already_AddRefed<SVGAnimatedNumber>
|
|
SVGComponentTransferFunctionElement::Offset()
|
|
{
|
|
return mNumberAttributes[OFFSET].ToDOMAnimatedNumber(this);
|
|
}
|
|
|
|
AttributeMap
|
|
SVGComponentTransferFunctionElement::ComputeAttributes()
|
|
{
|
|
uint32_t type = mEnumAttributes[TYPE].GetAnimValue();
|
|
|
|
float slope, intercept, amplitude, exponent, offset;
|
|
GetAnimatedNumberValues(&slope, &intercept, &litude,
|
|
&exponent, &offset, nullptr);
|
|
|
|
const SVGNumberList &tableValues =
|
|
mNumberListAttributes[TABLEVALUES].GetAnimValue();
|
|
|
|
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);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsSVGElement methods
|
|
|
|
nsSVGElement::NumberListAttributesInfo
|
|
SVGComponentTransferFunctionElement::GetNumberListInfo()
|
|
{
|
|
return NumberListAttributesInfo(mNumberListAttributes, sNumberListInfo,
|
|
ArrayLength(sNumberListInfo));
|
|
}
|
|
|
|
nsSVGElement::EnumAttributesInfo
|
|
SVGComponentTransferFunctionElement::GetEnumInfo()
|
|
{
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
|
ArrayLength(sEnumInfo));
|
|
}
|
|
|
|
nsSVGElement::NumberAttributesInfo
|
|
SVGComponentTransferFunctionElement::GetNumberInfo()
|
|
{
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
|
ArrayLength(sNumberInfo));
|
|
}
|
|
|
|
/* virtual */ JSObject*
|
|
SVGFEFuncRElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return SVGFEFuncRElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncR)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncRElement)
|
|
|
|
/* virtual */ JSObject*
|
|
SVGFEFuncGElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return SVGFEFuncGElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncG)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncGElement)
|
|
|
|
/* virtual */ JSObject*
|
|
SVGFEFuncBElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return SVGFEFuncBElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncB)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncBElement)
|
|
|
|
/* virtual */ JSObject*
|
|
SVGFEFuncAElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return SVGFEFuncAElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFuncA)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFuncAElement)
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
//--------------------------------------------------------------------
|
|
//
|
|
nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[4] =
|
|
{
|
|
{ &nsGkAtoms::surfaceScale, 1, false },
|
|
{ &nsGkAtoms::diffuseConstant, 1, false },
|
|
{ &nsGkAtoms::specularConstant, 1, false },
|
|
{ &nsGkAtoms::specularExponent, 1, false }
|
|
};
|
|
|
|
nsSVGElement::NumberPairInfo nsSVGFELightingElement::sNumberPairInfo[1] =
|
|
{
|
|
{ &nsGkAtoms::kernelUnitLength, 0, 0 }
|
|
};
|
|
|
|
nsSVGElement::StringInfo nsSVGFELightingElement::sStringInfo[2] =
|
|
{
|
|
{ &nsGkAtoms::result, kNameSpaceID_None, true },
|
|
{ &nsGkAtoms::in, kNameSpaceID_None, true }
|
|
};
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsISupports methods
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
|
|
NS_IMPL_RELEASE_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGFELightingElement)
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFELightingElementBase)
|
|
|
|
//----------------------------------------------------------------------
|
|
// Implementation
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
nsSVGFELightingElement::IsAttributeMapped(const nsIAtom* name) const
|
|
{
|
|
static const MappedAttributeEntry* const map[] = {
|
|
sLightingEffectsMap
|
|
};
|
|
|
|
return FindAttributeDependence(name, map) ||
|
|
nsSVGFELightingElementBase::IsAttributeMapped(name);
|
|
}
|
|
|
|
void
|
|
nsSVGFELightingElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
|
|
{
|
|
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
|
|
}
|
|
|
|
AttributeMap
|
|
nsSVGFELightingElement::ComputeLightAttributes(nsSVGFilterInstance* aInstance)
|
|
{
|
|
// find specified light
|
|
for (nsCOMPtr<nsIContent> child = nsINode::GetFirstChild();
|
|
child;
|
|
child = child->GetNextSibling()) {
|
|
if (child->IsAnyOfSVGElements(nsGkAtoms::feDistantLight,
|
|
nsGkAtoms::fePointLight,
|
|
nsGkAtoms::feSpotLight)) {
|
|
return static_cast<SVGFELightElement*>(child.get())->ComputeLightAttributes(aInstance);
|
|
}
|
|
}
|
|
|
|
AttributeMap map;
|
|
map.Set(eLightType, (uint32_t)eLightTypeNone);
|
|
return map;
|
|
}
|
|
|
|
FilterPrimitiveDescription
|
|
nsSVGFELightingElement::AddLightingAttributes(FilterPrimitiveDescription aDescription,
|
|
nsSVGFilterInstance* aInstance)
|
|
{
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
if (!frame) {
|
|
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
|
}
|
|
|
|
nsStyleContext* style = frame->StyleContext();
|
|
Color color(Color::FromABGR(style->StyleSVGReset()->mLightingColor));
|
|
color.a = 1.f;
|
|
float surfaceScale = mNumberAttributes[SURFACE_SCALE].GetAnimValue();
|
|
Size kernelUnitLength =
|
|
GetKernelUnitLength(aInstance, &mNumberPairAttributes[KERNEL_UNIT_LENGTH]);
|
|
|
|
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
|
|
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
bool
|
|
nsSVGFELightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute) const
|
|
{
|
|
return nsSVGFELightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
|
|
(aNameSpaceID == kNameSpaceID_None &&
|
|
(aAttribute == nsGkAtoms::in ||
|
|
aAttribute == nsGkAtoms::surfaceScale ||
|
|
aAttribute == nsGkAtoms::kernelUnitLength));
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// nsSVGElement methods
|
|
|
|
nsSVGElement::NumberAttributesInfo
|
|
nsSVGFELightingElement::GetNumberInfo()
|
|
{
|
|
return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
|
|
ArrayLength(sNumberInfo));
|
|
}
|
|
|
|
nsSVGElement::NumberPairAttributesInfo
|
|
nsSVGFELightingElement::GetNumberPairInfo()
|
|
{
|
|
return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo,
|
|
ArrayLength(sNumberPairInfo));
|
|
}
|
|
|
|
nsSVGElement::StringAttributesInfo
|
|
nsSVGFELightingElement::GetStringInfo()
|
|
{
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
|
ArrayLength(sStringInfo));
|
|
}
|