diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 028e41f63596..3ca17ec0848c 100755 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -928,6 +928,7 @@ GK_ATOM(animateMotion, "animateMotion") GK_ATOM(animateTransform, "animateTransform") GK_ATOM(arithmetic, "arithmetic") GK_ATOM(atop, "atop") +GK_ATOM(azimuth, "azimuth") GK_ATOM(baseFrequency, "baseFrequency") GK_ATOM(baseline_shift, "baseline-shift") GK_ATOM(bias, "bias") @@ -948,6 +949,7 @@ GK_ATOM(defs, "defs") GK_ATOM(definition_src, "definition-src") GK_ATOM(deg, "deg") GK_ATOM(desc, "desc") +GK_ATOM(diffuseConstant, "diffuseConstant") GK_ATOM(dilate, "dilate") GK_ATOM(direction, "direction") GK_ATOM(disable, "disable") @@ -959,6 +961,7 @@ GK_ATOM(dx, "dx") GK_ATOM(dy, "dy") GK_ATOM(edgeMode, "edgeMode") GK_ATOM(ellipse, "ellipse") +GK_ATOM(elevation, "elevation") GK_ATOM(erode, "erode") GK_ATOM(ex, "ex") GK_ATOM(exact, "exact") @@ -1038,6 +1041,8 @@ GK_ATOM(kernelMatrix, "kernelMatrix") GK_ATOM(kernelUnitLength, "kernelUnitLength") GK_ATOM(letter_spacing, "letter-spacing") GK_ATOM(lighten, "lighten") +GK_ATOM(lighting_color, "lighting-color") +GK_ATOM(limitingConeAngle, "limitingConeAngle") GK_ATOM(linear, "linear") GK_ATOM(linearGradient, "linearGradient") GK_ATOM(linearRGB, "linearRGB") @@ -1085,6 +1090,9 @@ GK_ATOM(patternUnits, "patternUnits") GK_ATOM(pc, "pc") GK_ATOM(pointer_events, "pointer-events") GK_ATOM(points, "points") +GK_ATOM(pointsAtX, "pointsAtX") +GK_ATOM(pointsAtY, "pointsAtY") +GK_ATOM(pointsAtZ, "pointsAtZ") GK_ATOM(polyline, "polyline") GK_ATOM(preserveAlpha, "preserveAlpha") GK_ATOM(preserveAspectRatio, "preserveAspectRatio") @@ -1112,6 +1120,8 @@ GK_ATOM(skewX, "skewX") GK_ATOM(skewY, "skewY") GK_ATOM(slope, "slope") GK_ATOM(spacing, "spacing") +GK_ATOM(specularConstant, "specularConstant") +GK_ATOM(specularExponent, "specularExponent") GK_ATOM(spreadMethod, "spreadMethod") GK_ATOM(sRGB, "sRGB") GK_ATOM(startOffset, "startOffset") @@ -1129,6 +1139,7 @@ GK_ATOM(stroke_miterlimit, "stroke-miterlimit") GK_ATOM(stroke_opacity, "stroke-opacity") GK_ATOM(stroke_width, "stroke-width") GK_ATOM(strokeWidth, "strokeWidth") +GK_ATOM(surfaceScale, "surfaceScale") GK_ATOM(svg, "svg") GK_ATOM(svgSwitch, "switch") GK_ATOM(symbol, "symbol") @@ -1155,6 +1166,7 @@ GK_ATOM(x2, "x2") GK_ATOM(y, "y") GK_ATOM(y1, "y1") GK_ATOM(y2, "y2") +GK_ATOM(z, "z") GK_ATOM(zoomAndPan, "zoomAndPan") #endif diff --git a/content/svg/content/src/nsSVGDefsElement.cpp b/content/svg/content/src/nsSVGDefsElement.cpp index 72a00223108f..fe7c58eb1dfe 100644 --- a/content/svg/content/src/nsSVGDefsElement.cpp +++ b/content/svg/content/src/nsSVGDefsElement.cpp @@ -113,6 +113,7 @@ nsSVGDefsElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 8b4b03cc9087..247f376d4bc2 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -487,6 +487,13 @@ nsSVGElement::sFEFloodMap[] = { { nsnull } }; +// PresentationAttributes-LightingEffects +/* static */ const nsGenericElement::MappedAttributeEntry +nsSVGElement::sLightingEffectsMap[] = { + { &nsGkAtoms::lighting_color }, + { nsnull } +}; + //---------------------------------------------------------------------- // nsIDOMNode methods diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index 08888031fe68..c7c31416867c 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -92,7 +92,8 @@ public: static const MappedAttributeEntry sColorMap[]; static const MappedAttributeEntry sFiltersMap[]; static const MappedAttributeEntry sFEFloodMap[]; - + static const MappedAttributeEntry sLightingEffectsMap[]; + // nsIDOMNode NS_IMETHOD IsSupported(const nsAString& aFeature, const nsAString& aVersion, PRBool* aReturn); @@ -218,5 +219,4 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ return rv; \ } - #endif // __NS_SVGELEMENT_H__ diff --git a/content/svg/content/src/nsSVGElementFactory.cpp b/content/svg/content/src/nsSVGElementFactory.cpp index 7222f5d0e715..2d0fbaf57d4d 100644 --- a/content/svg/content/src/nsSVGElementFactory.cpp +++ b/content/svg/content/src/nsSVGElementFactory.cpp @@ -146,6 +146,16 @@ nsresult NS_NewSVGSwitchElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); nsresult NS_NewSVGFEConvolveMatrixElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); +nsresult +NS_NewSVGFEDistantLightElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); +nsresult +NS_NewSVGFEPointLightElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); +nsresult +NS_NewSVGFESpotLightElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); +nsresult +NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); +nsresult +NS_NewSVGFESpecularLightingElement(nsIContent **aResult, nsINodeInfo *aNodeInfo); nsresult NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) @@ -254,10 +264,18 @@ NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) return NS_NewSVGFETurbulenceElement(aResult, aNodeInfo); if (name == nsGkAtoms::feConvolveMatrix) return NS_NewSVGFEConvolveMatrixElement(aResult, aNodeInfo); - if (name == nsGkAtoms::feDiffuseLighting || - name == nsGkAtoms::feDisplacementMap || + if (name == nsGkAtoms::feDistantLight) + return NS_NewSVGFEDistantLightElement(aResult, aNodeInfo); + if (name == nsGkAtoms::fePointLight) + return NS_NewSVGFEPointLightElement(aResult, aNodeInfo); + if (name == nsGkAtoms::feSpotLight) + return NS_NewSVGFESpotLightElement(aResult, aNodeInfo); + if (name == nsGkAtoms::feDiffuseLighting) + return NS_NewSVGFEDiffuseLightingElement(aResult, aNodeInfo); + if (name == nsGkAtoms::feSpecularLighting) + return NS_NewSVGFESpecularLightingElement(aResult, aNodeInfo); + if (name == nsGkAtoms::feDisplacementMap || name == nsGkAtoms::feImage || - name == nsGkAtoms::feSpecularLighting || name == nsGkAtoms::feTile) return NS_NewSVGFEUnimplementedMOZElement(aResult, aNodeInfo); if (name == nsGkAtoms::pattern) diff --git a/content/svg/content/src/nsSVGFilterElement.cpp b/content/svg/content/src/nsSVGFilterElement.cpp index 4d9f89a25cce..0b7c345c69a9 100644 --- a/content/svg/content/src/nsSVGFilterElement.cpp +++ b/content/svg/content/src/nsSVGFilterElement.cpp @@ -271,6 +271,7 @@ nsSVGFilterElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index 751611b76d19..b372978c6ecd 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -63,153 +63,6 @@ #include "nsSVGAnimatedBoolean.h" #include "nsSVGLengthList.h" -nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] = -{ - { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X }, - { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y }, - { &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X }, - { &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y }, -}; - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGFE,nsSVGFEBase) -NS_IMPL_RELEASE_INHERITED(nsSVGFE,nsSVGFEBase) - -NS_INTERFACE_MAP_BEGIN(nsSVGFE) -NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGFE::nsSVGFE(nsINodeInfo* aNodeInfo) : nsSVGFEBase(aNodeInfo) -{ -} - -nsresult -nsSVGFE::Init() -{ - nsresult rv = nsSVGFEBase::Init(); - NS_ENSURE_SUCCESS(rv,rv); - - // DOM property: result , #REQUIRED attrib: result - { - rv = NS_NewSVGAnimatedString(getter_AddRefs(mResult)); - NS_ENSURE_SUCCESS(rv,rv); - rv = AddMappedSVGValue(nsGkAtoms::result, mResult); - NS_ENSURE_SUCCESS(rv,rv); - } - - return NS_OK; -} - -PRBool -nsSVGFE::ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute, - nsSVGNumber2* aNum1, nsSVGNumber2* aNum2, - NumberInfo* aInfo1, NumberInfo* aInfo2, - nsAttrValue& aResult) -{ - float x = 0.0f, y = 0.0f; - char *rest; - PRBool parseError = PR_FALSE; - - NS_ConvertUTF16toUTF8 value(aValue); - value.CompressWhitespace(PR_FALSE, PR_TRUE); - const char *str = value.get(); - x = static_cast(PR_strtod(str, &rest)); - if (str == rest) { - //first value was illformed - parseError = PR_TRUE; - } else { - if (*rest == '\0') { - //second value was not supplied - y = x; - } else { - y = static_cast(PR_strtod(rest, &rest)); - if (*rest != '\0') { - //second value was illformed or there was trailing content - parseError = PR_TRUE; - } - } - } - - if (parseError) { - ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue); - x = aInfo1->mDefaultValue; - y = aInfo2->mDefaultValue; - return PR_FALSE; - } - aNum1->SetBaseValue(x, this, PR_FALSE); - aNum2->SetBaseValue(y, this, PR_FALSE); - aResult.SetTo(aValue); - return PR_TRUE; -} - -nsSVGFilterInstance::ColorModel -nsSVGFE::GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel) -{ - nsSVGFilterInstance::ColorModel - colorModel(nsSVGFilterInstance::ColorModel::LINEAR_RGB, - aAlphaChannel); - - nsIFrame* frame = GetPrimaryFrame(); - if (!frame) - return colorModel; - - nsStyleContext* style = frame->GetStyleContext(); - if (style->GetStyleSVG()->mColorInterpolationFilters == - NS_STYLE_COLOR_INTERPOLATION_SRGB) - colorModel.mColorSpace = nsSVGFilterInstance::ColorModel::SRGB; - - return colorModel; -} - -//---------------------------------------------------------------------- -// nsIDOMSVGFilterPrimitiveStandardAttributes methods - -/* readonly attribute nsIDOMSVGAnimatedLength x; */ -NS_IMETHODIMP nsSVGFE::GetX(nsIDOMSVGAnimatedLength * *aX) -{ - return mLengthAttributes[X].ToDOMAnimatedLength(aX, this); -} - -/* readonly attribute nsIDOMSVGAnimatedLength y; */ -NS_IMETHODIMP nsSVGFE::GetY(nsIDOMSVGAnimatedLength * *aY) -{ - return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this); -} - -/* readonly attribute nsIDOMSVGAnimatedLength width; */ -NS_IMETHODIMP nsSVGFE::GetWidth(nsIDOMSVGAnimatedLength * *aWidth) -{ - return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this); -} - -/* readonly attribute nsIDOMSVGAnimatedLength height; */ -NS_IMETHODIMP nsSVGFE::GetHeight(nsIDOMSVGAnimatedLength * *aHeight) -{ - return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this); -} - -/* readonly attribute nsIDOMSVGAnimatedString result; */ -NS_IMETHODIMP nsSVGFE::GetResult(nsIDOMSVGAnimatedString * *aResult) -{ - *aResult = mResult; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -//---------------------------------------------------------------------- -// nsSVGElement methods - -nsSVGElement::LengthAttributesInfo -nsSVGFE::GetLengthInfo() -{ - return LengthAttributesInfo(mLengthAttributes, sLengthInfo, - NS_ARRAY_LENGTH(sLengthInfo)); -} - //--------------------Filter Resource----------------------- /** * nsSVGFilterResource provides functionality for managing images used by @@ -395,6 +248,255 @@ nsSVGFilterResource::CopyImageSubregion(PRUint8 *aDest, const PRUint8 *aSrc) } } +//--------------------Filter Element Base Class----------------------- + +nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] = +{ + { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X }, + { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y }, + { &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X }, + { &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y }, +}; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFE,nsSVGFEBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFE,nsSVGFEBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFE) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFE::nsSVGFE(nsINodeInfo* aNodeInfo) : nsSVGFEBase(aNodeInfo) +{ +} + +nsresult +nsSVGFE::Init() +{ + nsresult rv = nsSVGFEBase::Init(); + NS_ENSURE_SUCCESS(rv,rv); + + // DOM property: result , #REQUIRED attrib: result + { + rv = NS_NewSVGAnimatedString(getter_AddRefs(mResult)); + NS_ENSURE_SUCCESS(rv,rv); + rv = AddMappedSVGValue(nsGkAtoms::result, mResult); + NS_ENSURE_SUCCESS(rv,rv); + } + + return NS_OK; +} + +PRBool +nsSVGFE::ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute, + nsSVGNumber2* aNum1, nsSVGNumber2* aNum2, + NumberInfo* aInfo1, NumberInfo* aInfo2, + nsAttrValue& aResult) +{ + float x = 0.0f, y = 0.0f; + char *rest; + PRBool parseError = PR_FALSE; + + NS_ConvertUTF16toUTF8 value(aValue); + value.CompressWhitespace(PR_FALSE, PR_TRUE); + const char *str = value.get(); + x = static_cast(PR_strtod(str, &rest)); + if (str == rest) { + //first value was illformed + parseError = PR_TRUE; + } else { + if (*rest == '\0') { + //second value was not supplied + y = x; + } else { + y = static_cast(PR_strtod(rest, &rest)); + if (*rest != '\0') { + //second value was illformed or there was trailing content + parseError = PR_TRUE; + } + } + } + + if (parseError) { + ReportAttributeParseFailure(GetOwnerDoc(), aAttribute, aValue); + x = aInfo1->mDefaultValue; + y = aInfo2->mDefaultValue; + return PR_FALSE; + } + aNum1->SetBaseValue(x, this, PR_FALSE); + aNum2->SetBaseValue(y, this, PR_FALSE); + aResult.SetTo(aValue); + return PR_TRUE; +} + +nsSVGFilterInstance::ColorModel +nsSVGFE::GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel) +{ + nsSVGFilterInstance::ColorModel + colorModel(nsSVGFilterInstance::ColorModel::LINEAR_RGB, + aAlphaChannel); + + nsIFrame* frame = GetPrimaryFrame(); + if (!frame) + return colorModel; + + nsStyleContext* style = frame->GetStyleContext(); + if (style->GetStyleSVG()->mColorInterpolationFilters == + NS_STYLE_COLOR_INTERPOLATION_SRGB) + colorModel.mColorSpace = nsSVGFilterInstance::ColorModel::SRGB; + + return colorModel; +} + +nsresult +nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance, + nsSVGFilterResource *aResource, + nsIDOMSVGAnimatedString *aIn, + nsSVGNumber2 *aUnitX, nsSVGNumber2 *aUnitY, + ScaleInfo *aScaleInfo) +{ + // We need to do this even in the case where we don't need the + // target yet because AquireTargetImage sets up some needed data in + // the filter resource. + nsresult rv; + PRUint8 *sourceData, *targetData; + rv = aResource->AcquireSourceImage(aIn, this, &sourceData, + getter_AddRefs(aScaleInfo->mRealSource)); + NS_ENSURE_SUCCESS(rv, rv); + rv = aResource->AcquireTargetImage(mResult, &targetData, + getter_AddRefs(aScaleInfo->mRealTarget)); + NS_ENSURE_SUCCESS(rv, rv); + + if (HasAttr(kNameSpaceID_None, nsGkAtoms::kernelUnitLength)) { + aScaleInfo->mRescaling = PR_TRUE; + float kernelX, kernelY; + nsSVGLength2 val; + val.Init(nsSVGUtils::X, 0xff, + aUnitX->GetAnimValue(), + nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + kernelX = aInstance->GetPrimitiveLength(&val); + val.Init(nsSVGUtils::Y, 0xff, + aUnitY->GetAnimValue(), + nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); + kernelY = aInstance->GetPrimitiveLength(&val); +#ifdef DEBUG_tor + fprintf(stderr, "scaling kernelX/Y %f %f\n", kernelX, kernelY); +#endif + if (kernelX <= 0 || kernelY <= 0) + return NS_ERROR_FAILURE; + + PRBool overflow = PR_FALSE; + gfxIntSize scaledSize = + nsSVGUtils::ConvertToSurfaceSize(gfxSize(aResource->GetWidth() / kernelX, + aResource->GetHeight() / kernelY), + &overflow); + // If the requested size based on the kernel unit is too big, we + // need to bail because the effect is pixel size dependent. Also + // need to check if we ended up with a negative size (arithmetic + // overflow) or zero size (large kernel unit) + if (overflow || scaledSize.width <= 0 || scaledSize.height <= 0) + return NS_ERROR_FAILURE; + +#ifdef DEBUG_tor + fprintf(stderr, "scaled size %d %d\n", scaledSize.width, scaledSize.height); +#endif + aScaleInfo->mSource = new gfxImageSurface(scaledSize, + gfxASurface::ImageFormatARGB32); + aScaleInfo->mTarget = new gfxImageSurface(scaledSize, + gfxASurface::ImageFormatARGB32); + if (!aScaleInfo->mSource || aScaleInfo->mSource->CairoStatus() || + !aScaleInfo->mTarget || aScaleInfo->mTarget->CairoStatus()) + return NS_ERROR_FAILURE; + + gfxContext ctx(aScaleInfo->mSource); + ctx.SetOperator(gfxContext::OPERATOR_SOURCE); + ctx.Scale(double(scaledSize.width) / aResource->GetWidth(), + double(scaledSize.height) / aResource->GetHeight()); + ctx.SetSource(aScaleInfo->mRealSource); + ctx.Paint(); + + nsRect rect = aResource->GetRect(); + + aScaleInfo->mRect.x = rect.x * scaledSize.width / aResource->GetWidth(); + aScaleInfo->mRect.y = rect.y * scaledSize.height / aResource->GetHeight(); + aScaleInfo->mRect.width = rect.width * scaledSize.width / aResource->GetWidth(); + aScaleInfo->mRect.height = rect.height * scaledSize.height / aResource->GetHeight(); + } else { + aScaleInfo->mRescaling = PR_FALSE; + aScaleInfo->mRect = aResource->GetRect(); + aScaleInfo->mSource = aScaleInfo->mRealSource; + aScaleInfo->mTarget = aScaleInfo->mRealTarget; + } + + return NS_OK; +} + +void +nsSVGFE::FinishScalingFilter(nsSVGFilterResource *aResource, + ScaleInfo *aScaleInfo) +{ + if (!aScaleInfo->mRescaling) + return; + + gfxIntSize scaledSize = aScaleInfo->mTarget->GetSize(); + + gfxContext ctx(aScaleInfo->mRealTarget); + ctx.SetOperator(gfxContext::OPERATOR_SOURCE); + ctx.Scale(double(aResource->GetWidth()) / scaledSize.width, + double(aResource->GetHeight()) /scaledSize.height); + ctx.SetSource(aScaleInfo->mTarget); + ctx.Paint(); +} + +//---------------------------------------------------------------------- +// nsIDOMSVGFilterPrimitiveStandardAttributes methods + +/* readonly attribute nsIDOMSVGAnimatedLength x; */ +NS_IMETHODIMP nsSVGFE::GetX(nsIDOMSVGAnimatedLength * *aX) +{ + return mLengthAttributes[X].ToDOMAnimatedLength(aX, this); +} + +/* readonly attribute nsIDOMSVGAnimatedLength y; */ +NS_IMETHODIMP nsSVGFE::GetY(nsIDOMSVGAnimatedLength * *aY) +{ + return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this); +} + +/* readonly attribute nsIDOMSVGAnimatedLength width; */ +NS_IMETHODIMP nsSVGFE::GetWidth(nsIDOMSVGAnimatedLength * *aWidth) +{ + return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this); +} + +/* readonly attribute nsIDOMSVGAnimatedLength height; */ +NS_IMETHODIMP nsSVGFE::GetHeight(nsIDOMSVGAnimatedLength * *aHeight) +{ + return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this); +} + +/* readonly attribute nsIDOMSVGAnimatedString result; */ +NS_IMETHODIMP nsSVGFE::GetResult(nsIDOMSVGAnimatedString * *aResult) +{ + *aResult = mResult; + NS_IF_ADDREF(*aResult); + return NS_OK; +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGElement::LengthAttributesInfo +nsSVGFE::GetLengthInfo() +{ + return LengthAttributesInfo(mLengthAttributes, sLengthInfo, + NS_ARRAY_LENGTH(sLengthInfo)); +} + //---------------------Gaussian Blur------------------------ typedef nsSVGFE nsSVGFEGaussianBlurElementBase; @@ -4064,73 +4166,21 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance) ? nsSVGFilterInstance::ColorModel::UNPREMULTIPLIED : nsSVGFilterInstance::ColorModel::PREMULTIPLIED)); - nsresult rv; - PRUint8 *sourceData, *targetData; - nsRefPtr sourceSurface, targetSurface; - rv = fr.AcquireSourceImage(mIn1, this, &sourceData, - getter_AddRefs(sourceSurface)); - NS_ENSURE_SUCCESS(rv, rv); - rv = fr.AcquireTargetImage(mResult, &targetData, - getter_AddRefs(targetSurface)); + + ScaleInfo info; + nsresult rv = SetupScalingFilter(instance, &fr, mIn1, + &mNumberAttributes[KERNEL_UNIT_LENGTH_X], + &mNumberAttributes[KERNEL_UNIT_LENGTH_Y], + &info); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr scaledSource, scaledTarget; - PRBool rescaling = PR_FALSE; - float kernelX, kernelY; - gfxIntSize scaledSize; - if (HasAttr(kNameSpaceID_None, nsGkAtoms::kernelUnitLength)) { - rescaling = PR_TRUE; - nsSVGLength2 val; - val.Init(nsSVGUtils::X, 0xff, - mNumberAttributes[KERNEL_UNIT_LENGTH_X].GetAnimValue(), - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); - kernelX = instance->GetPrimitiveLength(&val); - val.Init(nsSVGUtils::Y, 0xff, - mNumberAttributes[KERNEL_UNIT_LENGTH_Y].GetAnimValue(), - nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER); - kernelY = instance->GetPrimitiveLength(&val); #ifdef DEBUG_tor - fprintf(stderr, "convolve kernelX/Y %f %f\n", kernelX, kernelY); -#endif - if (kernelX <= 0 || kernelY <= 0) - return NS_ERROR_FAILURE; + { + nsRect rect = fr.GetRect(); - PRBool overflow = PR_FALSE; - scaledSize = - nsSVGUtils::ConvertToSurfaceSize(gfxSize(fr.GetWidth() / kernelX, - fr.GetHeight() / kernelY), - &overflow); - // If the requested size based on the kernel unit is too big, we - // need to bail because the effect is pixel size dependent. Also - // need to check if we ended up with a negative size (arithmetic - // overflow) or zero size (large kernel unit) - if (overflow || scaledSize.width <= 0 || scaledSize.height <= 0) - return NS_ERROR_FAILURE; - -#ifdef DEBUG_tor - fprintf(stderr, "scaled size %d %d\n", scaledSize.width, scaledSize.height); -#endif - scaledSource = new gfxImageSurface(scaledSize, - gfxASurface::ImageFormatARGB32); - scaledTarget = new gfxImageSurface(scaledSize, - gfxASurface::ImageFormatARGB32); - if (!scaledSource || scaledSource->CairoStatus() || - !scaledTarget || scaledTarget->CairoStatus()) - return NS_ERROR_FAILURE; - - gfxContext ctx(scaledSource); - ctx.SetOperator(gfxContext::OPERATOR_SOURCE); - ctx.Scale(double(scaledSize.width) / fr.GetWidth(), - double(scaledSize.height) / fr.GetHeight()); - ctx.SetSource(sourceSurface); - ctx.Paint(); + fprintf(stderr, "FILTER CONVOLVE MATRIX rect: %d,%d %dx%d\n", + rect.x, rect.y, rect.width, rect.height); } - - nsRect rect = fr.GetRect(); - -#ifdef DEBUG_tor - fprintf(stderr, "FILTER CONVOLVE MATRIX rect: %d,%d %dx%d\n", - rect.x, rect.y, rect.width, rect.height); #endif PRUint16 edgeMode; @@ -4141,22 +4191,14 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance) bias = mNumberAttributes[BIAS].GetAnimValue(); } - PRInt32 stride, width, height; - if (rescaling) { - rect.x = rect.x * scaledSize.width / fr.GetWidth(); - rect.y = rect.y * scaledSize.height / fr.GetHeight(); - rect.width = rect.width * scaledSize.width / fr.GetWidth(); - rect.height = rect.height * scaledSize.height / fr.GetHeight(); - sourceData = scaledSource->Data(); - targetData = scaledTarget->Data(); - stride = scaledSource->Stride(); - width = scaledSize.width; - height = scaledSize.height; - } else { - stride = fr.GetDataStride(); - width = fr.GetWidth(); - height = fr.GetHeight(); - } + nsRect rect = info.mRect; + + PRInt32 stride = info.mSource->Stride(); + PRInt32 width = info.mSource->GetSize().width; + PRInt32 height = info.mSource->GetSize().height; + + PRUint8 *sourceData = info.mSource->Data(); + PRUint8 *targetData = info.mTarget->Data(); for (PRInt32 y = rect.y; y < rect.YMost(); y++) { for (PRInt32 x = rect.x; x < rect.XMost(); x++) { @@ -4168,14 +4210,7 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance) } } - if (rescaling) { - gfxContext ctx(targetSurface); - ctx.SetOperator(gfxContext::OPERATOR_SOURCE); - ctx.Scale(double(fr.GetWidth()) / scaledSize.width, - double(fr.GetHeight()) /scaledSize.height); - ctx.SetSource(scaledTarget); - ctx.Paint(); - } + FinishScalingFilter(&fr, &info); return NS_OK; } @@ -4190,6 +4225,981 @@ nsSVGFEConvolveMatrixElement::GetNumberInfo() NS_ARRAY_LENGTH(sNumberInfo)); } +//---------------------DistantLight------------------------ + +typedef nsSVGElement nsSVGFEDistantLightElementBase; + +class nsSVGFEDistantLightElement : public nsSVGFEDistantLightElementBase, + public nsIDOMSVGFEDistantLightElement +{ +protected: + friend nsresult NS_NewSVGFEDistantLightElement(nsIContent **aResult, + nsINodeInfo *aNodeInfo); + nsSVGFEDistantLightElement(nsINodeInfo* aNodeInfo); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGFEDISTANTLIGHTELEMENT + + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEDistantLightElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEDistantLightElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFEDistantLightElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + +protected: + virtual NumberAttributesInfo GetNumberInfo(); + + enum { AZIMUTH, ELEVATION }; + nsSVGNumber2 mNumberAttributes[2]; + static NumberInfo sNumberInfo[2]; +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(FEDistantLight) + +nsSVGElement::NumberInfo nsSVGFEDistantLightElement::sNumberInfo[2] = +{ + { &nsGkAtoms::azimuth, 0 }, + { &nsGkAtoms::elevation, 0 } +}; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFEDistantLightElement,nsSVGFEDistantLightElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFEDistantLightElement,nsSVGFEDistantLightElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFEDistantLightElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsIDOMElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEDistantLightElement) + NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDistantLightElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDistantLightElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFEDistantLightElement::nsSVGFEDistantLightElement(nsINodeInfo* aNodeInfo) + : nsSVGFEDistantLightElementBase(aNodeInfo) +{ +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDistantLightElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGFEDistantLightElement methods + +NS_IMETHODIMP +nsSVGFEDistantLightElement::GetAzimuth(nsIDOMSVGAnimatedNumber **aAzimuth) +{ + return mNumberAttributes[AZIMUTH].ToDOMAnimatedNumber(aAzimuth, + this); +} + +NS_IMETHODIMP +nsSVGFEDistantLightElement::GetElevation(nsIDOMSVGAnimatedNumber **aElevation) +{ + return mNumberAttributes[ELEVATION].ToDOMAnimatedNumber(aElevation, + this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGElement::NumberAttributesInfo +nsSVGFEDistantLightElement::GetNumberInfo() +{ + return NumberAttributesInfo(mNumberAttributes, sNumberInfo, + NS_ARRAY_LENGTH(sNumberInfo)); +} + +//---------------------PointLight------------------------ + +typedef nsSVGElement nsSVGFEPointLightElementBase; + +class nsSVGFEPointLightElement : public nsSVGFEPointLightElementBase, + public nsIDOMSVGFEPointLightElement +{ +protected: + friend nsresult NS_NewSVGFEPointLightElement(nsIContent **aResult, + nsINodeInfo *aNodeInfo); + nsSVGFEPointLightElement(nsINodeInfo* aNodeInfo); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGFEPOINTLIGHTELEMENT + + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEPointLightElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEPointLightElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFEPointLightElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + +protected: + virtual NumberAttributesInfo GetNumberInfo(); + + enum { X, Y, Z }; + nsSVGNumber2 mNumberAttributes[3]; + static NumberInfo sNumberInfo[3]; +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(FEPointLight) + +nsSVGElement::NumberInfo nsSVGFEPointLightElement::sNumberInfo[3] = +{ + { &nsGkAtoms::x, 0 }, + { &nsGkAtoms::y, 0 }, + { &nsGkAtoms::z, 0 } +}; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFEPointLightElement,nsSVGFEPointLightElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFEPointLightElement,nsSVGFEPointLightElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFEPointLightElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsIDOMElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEPointLightElement) + NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEPointLightElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFEPointLightElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFEPointLightElement::nsSVGFEPointLightElement(nsINodeInfo* aNodeInfo) + : nsSVGFEPointLightElementBase(aNodeInfo) +{ +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEPointLightElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGFEPointLightElement methods + +NS_IMETHODIMP +nsSVGFEPointLightElement::GetX(nsIDOMSVGAnimatedNumber **aX) +{ + return mNumberAttributes[X].ToDOMAnimatedNumber(aX, this); +} + +NS_IMETHODIMP +nsSVGFEPointLightElement::GetY(nsIDOMSVGAnimatedNumber **aY) +{ + return mNumberAttributes[Y].ToDOMAnimatedNumber(aY, this); +} + +NS_IMETHODIMP +nsSVGFEPointLightElement::GetZ(nsIDOMSVGAnimatedNumber **aZ) +{ + return mNumberAttributes[Z].ToDOMAnimatedNumber(aZ, this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGElement::NumberAttributesInfo +nsSVGFEPointLightElement::GetNumberInfo() +{ + return NumberAttributesInfo(mNumberAttributes, sNumberInfo, + NS_ARRAY_LENGTH(sNumberInfo)); +} + +//---------------------SpotLight------------------------ + +typedef nsSVGElement nsSVGFESpotLightElementBase; + +class nsSVGFESpotLightElement : public nsSVGFESpotLightElementBase, + public nsIDOMSVGFESpotLightElement +{ +protected: + friend nsresult NS_NewSVGFESpotLightElement(nsIContent **aResult, + nsINodeInfo *aNodeInfo); + nsSVGFESpotLightElement(nsINodeInfo* aNodeInfo); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGFESPOTLIGHTELEMENT + + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFESpotLightElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFESpotLightElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFESpotLightElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + +protected: + virtual NumberAttributesInfo GetNumberInfo(); + + enum { X, Y, Z, POINTS_AT_X, POINTS_AT_Y, POINTS_AT_Z, + SPECULAR_EXPONENT, LIMITING_CONE_ANGLE }; + nsSVGNumber2 mNumberAttributes[8]; + static NumberInfo sNumberInfo[8]; +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(FESpotLight) + +nsSVGElement::NumberInfo nsSVGFESpotLightElement::sNumberInfo[8] = +{ + { &nsGkAtoms::x, 0 }, + { &nsGkAtoms::y, 0 }, + { &nsGkAtoms::z, 0 }, + { &nsGkAtoms::pointsAtX, 0 }, + { &nsGkAtoms::pointsAtY, 0 }, + { &nsGkAtoms::pointsAtZ, 0 }, + { &nsGkAtoms::specularExponent, 0 }, + { &nsGkAtoms::limitingConeAngle, 0 } +}; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFESpotLightElement,nsSVGFESpotLightElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFESpotLightElement,nsSVGFESpotLightElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFESpotLightElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsIDOMElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFESpotLightElement) + NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpotLightElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpotLightElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFESpotLightElement::nsSVGFESpotLightElement(nsINodeInfo* aNodeInfo) + : nsSVGFESpotLightElementBase(aNodeInfo) +{ +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFESpotLightElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGFESpotLightElement methods + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetX(nsIDOMSVGAnimatedNumber **aX) +{ + return mNumberAttributes[X].ToDOMAnimatedNumber(aX, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetY(nsIDOMSVGAnimatedNumber **aY) +{ + return mNumberAttributes[Y].ToDOMAnimatedNumber(aY, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetZ(nsIDOMSVGAnimatedNumber **aZ) +{ + return mNumberAttributes[Z].ToDOMAnimatedNumber(aZ, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetPointsAtX(nsIDOMSVGAnimatedNumber **aX) +{ + return mNumberAttributes[POINTS_AT_X].ToDOMAnimatedNumber(aX, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetPointsAtY(nsIDOMSVGAnimatedNumber **aY) +{ + return mNumberAttributes[POINTS_AT_Y].ToDOMAnimatedNumber(aY, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetPointsAtZ(nsIDOMSVGAnimatedNumber **aZ) +{ + return mNumberAttributes[POINTS_AT_Z].ToDOMAnimatedNumber(aZ, this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetSpecularExponent(nsIDOMSVGAnimatedNumber **aExponent) +{ + return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(aExponent, + this); +} + +NS_IMETHODIMP +nsSVGFESpotLightElement::GetLimitingConeAngle(nsIDOMSVGAnimatedNumber **aAngle) +{ + return mNumberAttributes[LIMITING_CONE_ANGLE].ToDOMAnimatedNumber(aAngle, + this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGElement::NumberAttributesInfo +nsSVGFESpotLightElement::GetNumberInfo() +{ + return NumberAttributesInfo(mNumberAttributes, sNumberInfo, + NS_ARRAY_LENGTH(sNumberInfo)); +} + +//------------------------------------------------------------ + +typedef nsSVGFE nsSVGFELightingElementBase; + +class nsSVGFELightingElement : public nsSVGFELightingElementBase, + public nsISVGFilter +{ +protected: + nsSVGFELightingElement(nsINodeInfo* aNodeInfo); + nsresult Init(); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + + // FE Base + NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFELightingElementBase::) + + // nsISVGFilter + NS_IMETHOD Filter(nsSVGFilterInstance *instance); + NS_IMETHOD GetRequirements(PRUint32 *aRequirements); + + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFELightingElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFELightingElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFELightingElementBase::) + + NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual PRBool ParseAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, + nsAttrValue& aResult); +protected: + virtual void + LightPixel(const float *N, const float *L, + nscolor color, PRUint8 *targetData) = 0; + + virtual NumberAttributesInfo GetNumberInfo(); + + enum { SURFACE_SCALE, DIFFUSE_CONSTANT, SPECULAR_CONSTANT, SPECULAR_EXPONENT, + KERNEL_UNIT_LENGTH_X, KERNEL_UNIT_LENGTH_Y }; + nsSVGNumber2 mNumberAttributes[6]; + static NumberInfo sNumberInfo[6]; + + nsCOMPtr mIn1; +}; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFELightingElement) + NS_INTERFACE_MAP_ENTRY(nsISVGFilter) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFELightingElementBase) + +nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[6] = +{ + { &nsGkAtoms::surfaceScale, 1 }, + { &nsGkAtoms::diffuseConstant, 1 }, + { &nsGkAtoms::specularConstant, 1 }, + { &nsGkAtoms::specularExponent, 1 }, + { &nsGkAtoms::kernelUnitLength, 0 }, + { &nsGkAtoms::kernelUnitLength, 0 } +}; + +nsSVGFELightingElement::nsSVGFELightingElement(nsINodeInfo *aNodeInfo) + : nsSVGFELightingElementBase(aNodeInfo) +{ +} + +nsresult +nsSVGFELightingElement::Init() +{ + nsresult rv = nsSVGFELightingElementBase::Init(); + NS_ENSURE_SUCCESS(rv,rv); + + // DOM property: in1 , #IMPLIED attrib: in + { + rv = NS_NewSVGAnimatedString(getter_AddRefs(mIn1)); + NS_ENSURE_SUCCESS(rv,rv); + rv = AddMappedSVGValue(nsGkAtoms::in, mIn1); + NS_ENSURE_SUCCESS(rv,rv); + } + + return rv; +} + +NS_IMETHODIMP_(PRBool) +nsSVGFELightingElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sLightingEffectsMap + }; + + return FindAttributeDependence(name, map, NS_ARRAY_LENGTH(map)) || + nsSVGFELightingElementBase::IsAttributeMapped(name); +} + +PRBool +nsSVGFELightingElement::ParseAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aName == nsGkAtoms::kernelUnitLength && aNameSpaceID == kNameSpaceID_None) { + return ScanDualValueAttribute(aValue, nsGkAtoms::radius, + &mNumberAttributes[KERNEL_UNIT_LENGTH_X], + &mNumberAttributes[KERNEL_UNIT_LENGTH_Y], + &sNumberInfo[KERNEL_UNIT_LENGTH_X], + &sNumberInfo[KERNEL_UNIT_LENGTH_Y], + aResult); + } + return nsSVGFELightingElementBase::ParseAttribute(aNameSpaceID, aName, + aValue, aResult); +} + +NS_IMETHODIMP +nsSVGFELightingElement::GetRequirements(PRUint32 *aRequirements) +{ + *aRequirements = CheckStandardNames(mIn1); + return NS_OK; +} + +nsSVGElement::NumberAttributesInfo +nsSVGFELightingElement::GetNumberInfo() +{ + return NumberAttributesInfo(mNumberAttributes, sNumberInfo, + NS_ARRAY_LENGTH(sNumberInfo)); +} + +#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) +#define NORMALIZE(vec) \ + PR_BEGIN_MACRO \ + float norm = sqrt(DOT(vec, vec)); \ + vec[0] /= norm; \ + vec[1] /= norm; \ + vec[2] /= norm; \ + PR_END_MACRO + +static PRInt32 +Convolve3x3(const PRUint8 *index, PRInt32 stride, + const PRInt8 kernel[3][3]) +{ + PRInt32 sum = 0; + for (PRInt32 y = 0; y < 3; y++) { + for (PRInt32 x = 0; x < 3; x++) { + PRInt8 k = kernel[y][x]; + if (k) + sum += k * index[4 * (x - 1) + stride * (y - 1)]; + } + } + return sum; +} + +static void +GenerateNormal(float *N, const PRUint8 *data, PRInt32 stride, nsRect rect, + PRInt32 x, PRInt32 y, float surfaceScale) +{ + // See this for source of constants: + // http://www.w3.org/TR/SVG11/filters.html#feDiffuseLighting + static const PRInt8 Kx[3][3][3][3] = + { { { { 0, 0, 0}, { 0, -2, 2}, { 0, -1, 1} }, + { { 0, 0, 0}, {-2, 0, 2}, {-1, 0, 1} }, + { { 0, 0, 0}, {-2, 2, 0}, {-1, 1, 0} } }, + { { { 0, -1, 1}, { 0, -2, 2}, { 0, -1, 1} }, + { { -1, 0, 1}, {-2, 0, 2}, {-1, 0, 1} }, + { { -1, 1, 0}, {-2, 2, 0}, {-1, 1, 0} } }, + { { { 0, -1, 1}, { 0, -2, 2}, { 0, 0, 0} }, + { { -1, 0, 1}, {-2, 0, 2}, { 0, 0, 0} }, + { { -1, 1, 0}, {-2, 2, 0}, { 0, 0, 0} } } }; + static const PRInt8 Ky[3][3][3][3] = + { { { { 0, 0, 0}, { 0, -2, -1}, { 0, 2, 1} }, + { { 0, 0, 0}, {-1, -2, -1}, { 1, 2, 1} }, + { { 0, 0, 0}, {-1, -2, 1}, { 1, 2, 0} } }, + { { { 0, -2, -1}, { 0, 0, 0}, { 0, 2, 1} }, + { { -1, -2, -1}, { 0, 0, 0}, { 1, 2, 1} }, + { { -1, -2, 0}, { 0, 0, 0}, { 1, 2, 0} } }, + { { { 0, -2, -1}, { 0, 2, 1}, { 0, 0, 0} }, + { { -1, -2, -1}, { 1, 2, 1}, { 0, 0, 0} }, + { { -1, -2, 0}, { 1, 2, 0}, { 0, 0, 0} } } }; + static const float FACTORx[3][3] = + { { 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 }, + { 1.0 / 2.0, 1.0 / 4.0, 1.0 / 2.0 }, + { 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 } }; + static const float FACTORy[3][3] = + { { 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 }, + { 1.0 / 3.0, 1.0 / 4.0, 1.0 / 3.0 }, + { 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 } }; + + PRInt8 xflag, yflag; + if (x == 0) { + xflag = 0; + } else if (x == rect.width - 1) { + xflag = 2; + } else { + xflag = 1; + } + if (y == 0) { + yflag = 0; + } else if (y == rect.height - 1) { + yflag = 2; + } else { + yflag = 1; + } + + const PRUint8 *index = data + y * stride + 4 * x + GFX_ARGB32_OFFSET_A; + + N[0] = -surfaceScale * FACTORx[yflag][xflag] * + Convolve3x3(index, stride, Kx[yflag][xflag]); + N[1] = -surfaceScale * FACTORy[yflag][xflag] * + Convolve3x3(index, stride, Ky[yflag][xflag]); + N[2] = 255; + NORMALIZE(N); +} + +NS_IMETHODIMP +nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance) +{ + nsSVGFilterResource fr(instance, + GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED)); + + ScaleInfo info; + nsresult rv = SetupScalingFilter(instance, &fr, mIn1, + &mNumberAttributes[KERNEL_UNIT_LENGTH_X], + &mNumberAttributes[KERNEL_UNIT_LENGTH_Y], + &info); + NS_ENSURE_SUCCESS(rv, rv); + +#ifdef DEBUG_tor + { + nsRect rect = fr.GetRect(); + fprintf(stderr, "FILTER LIGHTING rect: %d,%d %dx%d\n", + rect.x, rect.y, rect.width, rect.height); + } +#endif + + nsCOMPtr distantLight; + nsCOMPtr pointLight; + nsCOMPtr spotLight; + + nsIFrame* frame = GetPrimaryFrame(); + if (!frame) return NS_ERROR_FAILURE; + nsStyleContext* style = frame->GetStyleContext(); + + nscolor lightColor = style->GetStyleSVGReset()->mLightingColor; + + // find specified light + PRUint32 count = GetChildCount(); + for (PRUint32 k = 0; k < count; k++) { + nsCOMPtr child = GetChildAt(k); + distantLight = do_QueryInterface(child); + pointLight = do_QueryInterface(child); + spotLight = do_QueryInterface(child); + if (distantLight || pointLight || spotLight) + break; + } + + if (!distantLight && !pointLight && !spotLight) + return NS_ERROR_FAILURE; + + const float radPerDeg = M_PI/180.0; + + float L[3]; + if (distantLight) { + float azimuth, elevation; + static_cast + (distantLight.get())->GetAnimatedNumberValues(&azimuth, + &elevation, + nsnull); + L[0] = cos(azimuth * radPerDeg) * cos(elevation * radPerDeg); + L[1] = sin(azimuth * radPerDeg) * cos(elevation * radPerDeg); + L[2] = sin(elevation * radPerDeg); + } + float lightPos[3], pointsAt[3], specularExponent, cosConeAngle; + if (pointLight) { + static_cast + (pointLight.get())->GetAnimatedNumberValues(lightPos, + lightPos + 1, + lightPos + 2, + nsnull); + } + if (spotLight) { + float limitingConeAngle; + static_cast + (spotLight.get())->GetAnimatedNumberValues(lightPos, + lightPos + 1, + lightPos + 2, + pointsAt, + pointsAt + 1, + pointsAt + 2, + &specularExponent, + &limitingConeAngle, + nsnull); + nsCOMPtr spot = do_QueryInterface(spotLight); + if (spot->HasAttr(kNameSpaceID_None, nsGkAtoms::limitingConeAngle)) { + cosConeAngle = PR_MAX(cos(limitingConeAngle * radPerDeg), 0); + } else { + cosConeAngle = 0; + } + } + + float surfaceScale = mNumberAttributes[SURFACE_SCALE].GetAnimValue(); + + nsRect rect = info.mRect; + PRInt32 stride = info.mSource->Stride(); + PRUint8 *sourceData = info.mSource->Data(); + PRUint8 *targetData = info.mTarget->Data(); + + for (PRInt32 y = rect.y; y < rect.YMost(); y++) { + for (PRInt32 x = rect.x; x < rect.XMost(); x++) { + PRInt32 index = y * stride + x * 4; + + float N[3]; + GenerateNormal(N, sourceData, stride, rect, x, y, surfaceScale); + + if (pointLight || spotLight) { + float Z = + surfaceScale * sourceData[index + GFX_ARGB32_OFFSET_A] / 255; + + L[0] = lightPos[0] - x; + L[1] = lightPos[1] - y; + L[2] = lightPos[2] - Z; + NORMALIZE(L); + } + + nscolor color; + + if (spotLight) { + float S[3]; + S[0] = pointsAt[0] - lightPos[0]; + S[1] = pointsAt[1] - lightPos[1]; + S[2] = pointsAt[2] - lightPos[2]; + NORMALIZE(S); + float dot = -DOT(L, S); + if (dot < cosConeAngle) { + color = NS_RGB(0, 0, 0); + } else { + float tmp = pow(dot, specularExponent); + color = NS_RGB(PRUint8(NS_GET_R(lightColor) * tmp), + PRUint8(NS_GET_G(lightColor) * tmp), + PRUint8(NS_GET_B(lightColor) * tmp)); + } + } else { + color = lightColor; + } + + LightPixel(N, L, color, targetData + index); + } + } + + FinishScalingFilter(&fr, &info); + + return NS_OK; +} + + +//---------------------DiffuseLighting------------------------ + +typedef nsSVGFELightingElement nsSVGFEDiffuseLightingElementBase; + +class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase, + public nsIDOMSVGFEDiffuseLightingElement +{ +protected: + friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult, + nsINodeInfo *aNodeInfo); + nsSVGFEDiffuseLightingElement(nsINodeInfo* aNodeInfo); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + + // DiffuseLighting + NS_DECL_NSIDOMSVGFEDIFFUSELIGHTINGELEMENT + + NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEDiffuseLightingElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEDiffuseLightingElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEDiffuseLightingElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFEDiffuseLightingElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + +protected: + virtual void LightPixel(const float *N, const float *L, + nscolor color, PRUint8 *targetData); + +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting) + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFEDiffuseLightingElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsIDOMElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement) + NS_INTERFACE_MAP_ENTRY(nsISVGFilter) + NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDiffuseLightingElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFEDiffuseLightingElement::nsSVGFEDiffuseLightingElement(nsINodeInfo *aNodeInfo) + : nsSVGFEDiffuseLightingElementBase(aNodeInfo) +{ +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDiffuseLightingElement) + +//---------------------------------------------------------------------- +// nsSVGFEDiffuseLightingElement methods + +NS_IMETHODIMP +nsSVGFEDiffuseLightingElement::GetIn1(nsIDOMSVGAnimatedString * *aIn) +{ + *aIn = mIn1; + NS_IF_ADDREF(*aIn); + return NS_OK; +} + +NS_IMETHODIMP +nsSVGFEDiffuseLightingElement::GetSurfaceScale(nsIDOMSVGAnimatedNumber **aScale) +{ + return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(aScale, + this); +} + +NS_IMETHODIMP +nsSVGFEDiffuseLightingElement::GetDiffuseConstant(nsIDOMSVGAnimatedNumber **aConstant) +{ + return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(aConstant, + this); +} + +NS_IMETHODIMP +nsSVGFEDiffuseLightingElement::GetKernelUnitLengthX(nsIDOMSVGAnimatedNumber **aKernelX) +{ + return mNumberAttributes[KERNEL_UNIT_LENGTH_X].ToDOMAnimatedNumber(aKernelX, + this); +} + +NS_IMETHODIMP +nsSVGFEDiffuseLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKernelY) +{ + return mNumberAttributes[KERNEL_UNIT_LENGTH_Y].ToDOMAnimatedNumber(aKernelY, + this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +void +nsSVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L, + nscolor color, PRUint8 *targetData) +{ + float diffuseNL = + mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L); + + if (diffuseNL > 0) { + targetData[GFX_ARGB32_OFFSET_B] = + PR_MIN(PRUint32(diffuseNL * NS_GET_B(color)), 255); + targetData[GFX_ARGB32_OFFSET_G] = + PR_MIN(PRUint32(diffuseNL * NS_GET_G(color)), 255); + targetData[GFX_ARGB32_OFFSET_R] = + PR_MIN(PRUint32(diffuseNL * NS_GET_R(color)), 255); + } else { + targetData[GFX_ARGB32_OFFSET_B] = 0; + targetData[GFX_ARGB32_OFFSET_G] = 0; + targetData[GFX_ARGB32_OFFSET_R] = 0; + } + + targetData[GFX_ARGB32_OFFSET_A] = 255; +} + +//---------------------SpecularLighting------------------------ + +typedef nsSVGFELightingElement nsSVGFESpecularLightingElementBase; + +class nsSVGFESpecularLightingElement : public nsSVGFESpecularLightingElementBase, + public nsIDOMSVGFESpecularLightingElement +{ +protected: + friend nsresult NS_NewSVGFESpecularLightingElement(nsIContent **aResult, + nsINodeInfo *aNodeInfo); + nsSVGFESpecularLightingElement(nsINodeInfo* aNodeInfo); + +public: + // interfaces: + NS_DECL_ISUPPORTS_INHERITED + + // DiffuseLighting + NS_DECL_NSIDOMSVGFESPECULARLIGHTINGELEMENT + + NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFESpecularLightingElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFESpecularLightingElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFESpecularLightingElementBase::) + NS_FORWARD_NSIDOMELEMENT(nsSVGFESpecularLightingElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + // nsISVGFilter + NS_IMETHOD Filter(nsSVGFilterInstance *instance); + +protected: + virtual void LightPixel(const float *N, const float *L, + nscolor color, PRUint8 *targetData); + +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(FESpecularLighting) + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGFESpecularLightingElement,nsSVGFESpecularLightingElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGFESpecularLightingElement,nsSVGFESpecularLightingElementBase) + +NS_INTERFACE_MAP_BEGIN(nsSVGFESpecularLightingElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsIDOMElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) + NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement) + NS_INTERFACE_MAP_ENTRY(nsISVGFilter) + NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpecularLightingElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpecularLightingElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGFESpecularLightingElement::nsSVGFESpecularLightingElement(nsINodeInfo *aNodeInfo) + : nsSVGFESpecularLightingElementBase(aNodeInfo) +{ +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFESpecularLightingElement) + +//---------------------------------------------------------------------- +// nsSVGFESpecularLightingElement methods + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetIn1(nsIDOMSVGAnimatedString * *aIn) +{ + *aIn = mIn1; + NS_IF_ADDREF(*aIn); + return NS_OK; +} + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetSurfaceScale(nsIDOMSVGAnimatedNumber **aScale) +{ + return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(aScale, + this); +} + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetSpecularConstant(nsIDOMSVGAnimatedNumber **aConstant) +{ + return mNumberAttributes[SPECULAR_CONSTANT].ToDOMAnimatedNumber(aConstant, + this); +} + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetSpecularExponent(nsIDOMSVGAnimatedNumber **aExponent) +{ + return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(aExponent, + this); +} + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetKernelUnitLengthX(nsIDOMSVGAnimatedNumber **aKernelX) +{ + return mNumberAttributes[KERNEL_UNIT_LENGTH_X].ToDOMAnimatedNumber(aKernelX, + this); +} + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKernelY) +{ + return mNumberAttributes[KERNEL_UNIT_LENGTH_Y].ToDOMAnimatedNumber(aKernelY, + this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +NS_IMETHODIMP +nsSVGFESpecularLightingElement::Filter(nsSVGFilterInstance *instance) +{ + float specularExponent = mNumberAttributes[SPECULAR_EXPONENT].GetAnimValue(); + + // specification defined range (15.22) + if (specularExponent < 1 || specularExponent > 128) + return NS_ERROR_FAILURE; + + return nsSVGFESpecularLightingElementBase::Filter(instance); +} + + +void +nsSVGFESpecularLightingElement::LightPixel(const float *N, const float *L, + nscolor color, PRUint8 *targetData) +{ + float H[3]; + H[0] = L[0]; + H[1] = L[1]; + H[2] = L[2] + 1; + NORMALIZE(H); + + float kS = mNumberAttributes[SPECULAR_CONSTANT].GetAnimValue(); + float dotNH = DOT(N, H); + + if (dotNH > 0 && kS > 0) { + float specularNH = + kS * pow(dotNH, mNumberAttributes[SPECULAR_EXPONENT].GetAnimValue()); + + targetData[GFX_ARGB32_OFFSET_B] = + PR_MIN(PRUint32(specularNH * NS_GET_B(color)), 255); + targetData[GFX_ARGB32_OFFSET_G] = + PR_MIN(PRUint32(specularNH * NS_GET_G(color)), 255); + targetData[GFX_ARGB32_OFFSET_R] = + PR_MIN(PRUint32(specularNH * NS_GET_R(color)), 255); + + targetData[GFX_ARGB32_OFFSET_A] = + PR_MAX(targetData[GFX_ARGB32_OFFSET_B], + PR_MAX(targetData[GFX_ARGB32_OFFSET_G], + targetData[GFX_ARGB32_OFFSET_R])); + } else { + targetData[GFX_ARGB32_OFFSET_B] = 0; + targetData[GFX_ARGB32_OFFSET_G] = 0; + targetData[GFX_ARGB32_OFFSET_R] = 0; + targetData[GFX_ARGB32_OFFSET_A] = 255; + } +} + //---------------------UnimplementedMOZ------------------------ typedef nsSVGFE nsSVGFEUnimplementedMOZElementBase; diff --git a/content/svg/content/src/nsSVGFilters.h b/content/svg/content/src/nsSVGFilters.h index e2dac7cd03b4..5210b48b23a7 100644 --- a/content/svg/content/src/nsSVGFilters.h +++ b/content/svg/content/src/nsSVGFilters.h @@ -40,6 +40,9 @@ #include "nsSVGStylableElement.h" #include "nsSVGLength2.h" +class nsSVGFilterResource; +class nsIDOMSVGAnimatedString; + typedef nsSVGStylableElement nsSVGFEBase; class nsSVGFE : public nsSVGFEBase @@ -59,6 +62,25 @@ protected: nsSVGFilterInstance::ColorModel GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel); + struct ScaleInfo { + nsRefPtr mRealSource; + nsRefPtr mRealTarget; + nsRefPtr mSource; + nsRefPtr mTarget; + nsRect mRect; + PRPackedBool mRescaling; + }; + + nsresult SetupScalingFilter(nsSVGFilterInstance *aInstance, + nsSVGFilterResource *aResource, + nsIDOMSVGAnimatedString *aIn, + nsSVGNumber2 *aUnitX, nsSVGNumber2 *aUnitY, + ScaleInfo *aScaleInfo); + + void FinishScalingFilter(nsSVGFilterResource *aResource, + ScaleInfo *aScaleInfo); + + public: // interfaces: NS_DECL_ISUPPORTS_INHERITED diff --git a/content/svg/content/src/nsSVGForeignObjectElement.cpp b/content/svg/content/src/nsSVGForeignObjectElement.cpp index b2c4b0b33b28..0ffccc39cf2a 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.cpp +++ b/content/svg/content/src/nsSVGForeignObjectElement.cpp @@ -115,6 +115,7 @@ nsSVGForeignObjectElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGGElement.cpp b/content/svg/content/src/nsSVGGElement.cpp index 43365f58db74..2ae9b9c4317d 100644 --- a/content/svg/content/src/nsSVGGElement.cpp +++ b/content/svg/content/src/nsSVGGElement.cpp @@ -115,6 +115,7 @@ nsSVGGElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGMarkerElement.cpp b/content/svg/content/src/nsSVGMarkerElement.cpp index 5388b71899f4..084dd3cd566d 100644 --- a/content/svg/content/src/nsSVGMarkerElement.cpp +++ b/content/svg/content/src/nsSVGMarkerElement.cpp @@ -293,6 +293,7 @@ nsSVGMarkerElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGPatternElement.cpp b/content/svg/content/src/nsSVGPatternElement.cpp index 985dee12c006..c1469afd3fbe 100644 --- a/content/svg/content/src/nsSVGPatternElement.cpp +++ b/content/svg/content/src/nsSVGPatternElement.cpp @@ -282,6 +282,7 @@ nsSVGPatternElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index 35c4f27e533a..1445772eadfd 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -1089,6 +1089,7 @@ nsSVGSVGElement::IsAttributeMapped(const nsIAtom* name) const sFontSpecificationMap, sGradientStopMap, sGraphicsMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGSwitchElement.cpp b/content/svg/content/src/nsSVGSwitchElement.cpp index e0c42ffb97e2..9309c688cc2f 100644 --- a/content/svg/content/src/nsSVGSwitchElement.cpp +++ b/content/svg/content/src/nsSVGSwitchElement.cpp @@ -113,6 +113,7 @@ nsSVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGSymbolElement.cpp b/content/svg/content/src/nsSVGSymbolElement.cpp index 462b58b04467..ce7d51e7a4b8 100644 --- a/content/svg/content/src/nsSVGSymbolElement.cpp +++ b/content/svg/content/src/nsSVGSymbolElement.cpp @@ -180,6 +180,7 @@ nsSVGSymbolElement::IsAttributeMapped(const nsIAtom* name) const sFontSpecificationMap, sGradientStopMap, sGraphicsMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/content/svg/content/src/nsSVGUseElement.cpp b/content/svg/content/src/nsSVGUseElement.cpp index 08c496a7bfc6..70b8825ce8a9 100644 --- a/content/svg/content/src/nsSVGUseElement.cpp +++ b/content/svg/content/src/nsSVGUseElement.cpp @@ -499,6 +499,7 @@ nsSVGUseElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sLightingEffectsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/dom/public/idl/svg/nsIDOMSVGFilters.idl b/dom/public/idl/svg/nsIDOMSVGFilters.idl index 63bc61928979..9bf49beab465 100644 --- a/dom/public/idl/svg/nsIDOMSVGFilters.idl +++ b/dom/public/idl/svg/nsIDOMSVGFilters.idl @@ -249,6 +249,52 @@ interface nsIDOMSVGFEConvolveMatrixElement : nsIDOMSVGFilterPrimitiveStandardAtt readonly attribute nsIDOMSVGAnimatedBoolean preserveAlpha; }; +[scriptable, uuid(2e9eb422-2398-4be9-a9b8-b1cc7aa9dd6f)] +interface nsIDOMSVGFEDiffuseLightingElement : nsIDOMSVGFilterPrimitiveStandardAttributes +{ + readonly attribute nsIDOMSVGAnimatedString in1; + readonly attribute nsIDOMSVGAnimatedNumber surfaceScale; + readonly attribute nsIDOMSVGAnimatedNumber diffuseConstant; + readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthX; + readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthY; +}; + +[scriptable, uuid(49c38287-a7c2-4895-a630-86d2b45df23c)] +interface nsIDOMSVGFESpecularLightingElement : nsIDOMSVGFilterPrimitiveStandardAttributes +{ + readonly attribute nsIDOMSVGAnimatedString in1; + readonly attribute nsIDOMSVGAnimatedNumber surfaceScale; + readonly attribute nsIDOMSVGAnimatedNumber specularConstant; + readonly attribute nsIDOMSVGAnimatedNumber specularExponent; + readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthX; + readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthY; +}; + +[scriptable, uuid(02141672-7f2c-412a-a7d7-4caa194842e9)] +interface nsIDOMSVGFEDistantLightElement : nsIDOMSVGElement { + readonly attribute nsIDOMSVGAnimatedNumber azimuth; + readonly attribute nsIDOMSVGAnimatedNumber elevation; +}; + +[scriptable, uuid(557f128a-026b-4fa8-a44c-605df7bfd62e)] +interface nsIDOMSVGFEPointLightElement : nsIDOMSVGElement { + readonly attribute nsIDOMSVGAnimatedNumber x; + readonly attribute nsIDOMSVGAnimatedNumber y; + readonly attribute nsIDOMSVGAnimatedNumber z; +}; + +[scriptable, uuid(5515dd05-3d9d-4d6c-8460-a04aaf5afe15)] +interface nsIDOMSVGFESpotLightElement : nsIDOMSVGElement { + readonly attribute nsIDOMSVGAnimatedNumber x; + readonly attribute nsIDOMSVGAnimatedNumber y; + readonly attribute nsIDOMSVGAnimatedNumber z; + readonly attribute nsIDOMSVGAnimatedNumber pointsAtX; + readonly attribute nsIDOMSVGAnimatedNumber pointsAtY; + readonly attribute nsIDOMSVGAnimatedNumber pointsAtZ; + readonly attribute nsIDOMSVGAnimatedNumber specularExponent; + readonly attribute nsIDOMSVGAnimatedNumber limitingConeAngle; +}; + [scriptable, uuid(8698c635-26c7-468b-905e-494e8825d56b)] interface nsIDOMSVGFEUnimplementedMOZElement : nsIDOMSVGFilterPrimitiveStandardAttributes { diff --git a/dom/public/nsDOMClassInfoID.h b/dom/public/nsDOMClassInfoID.h index 5df56af37a86..96d68a83c6b5 100644 --- a/dom/public/nsDOMClassInfoID.h +++ b/dom/public/nsDOMClassInfoID.h @@ -247,6 +247,8 @@ enum nsDOMClassInfoID { eDOMClassInfo_SVGDescElement_id, eDOMClassInfo_SVGEllipseElement_id, eDOMClassInfo_SVGFEBlendElement_id, + eDOMClassInfo_SVGFEDiffuseLightingElement_id, + eDOMClassInfo_SVGFEDistantLightElement_id, eDOMClassInfo_SVGFEColorMatrixElement_id, eDOMClassInfo_SVGFEComponentTransferElement_id, eDOMClassInfo_SVGFECompositeElement_id, @@ -261,6 +263,9 @@ enum nsDOMClassInfoID { eDOMClassInfo_SVGFEMergeNodeElement_id, eDOMClassInfo_SVGFEMorphologyElement_id, eDOMClassInfo_SVGFEOffsetElement_id, + eDOMClassInfo_SVGFEPointLightElement_id, + eDOMClassInfo_SVGFESpecularLightingElement_id, + eDOMClassInfo_SVGFESpotLightElement_id, eDOMClassInfo_SVGFETurbulenceElement_id, eDOMClassInfo_SVGFEUnimplementedMOZElement_id, eDOMClassInfo_SVGFilterElement_id, diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index a947d2ba2040..2cbf92ee66ec 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -919,6 +919,10 @@ static nsDOMClassInfoData sClassInfoData[] = { ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFEBlendElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH, + ELEMENT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGFEDistantLightElement, nsElementSH, + ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFEColorMatrixElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFEComponentTransferElement, nsElementSH, @@ -947,6 +951,12 @@ static nsDOMClassInfoData sClassInfoData[] = { ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFEOffsetElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGFEPointLightElement, nsElementSH, + ELEMENT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGFESpecularLightingElement, nsElementSH, + ELEMENT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH, + ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFEUnimplementedMOZElement, nsElementSH, @@ -2645,6 +2655,18 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGFEDiffuseLightingElement, nsIDOMSVGFEDiffuseLightingElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + + DOM_CLASSINFO_MAP_BEGIN(SVGFEDistantLightElement, nsIDOMSVGFEDistantLightElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDistantLightElement) + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGFEColorMatrixElement, nsIDOMSVGFEColorMatrixElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEColorMatrixElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) @@ -2733,6 +2755,23 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGFEPointLightElement, nsIDOMSVGFEPointLightElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEPointLightElement) + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + + DOM_CLASSINFO_MAP_BEGIN(SVGFESpecularLightingElement, nsIDOMSVGFESpecularLightingElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + + DOM_CLASSINFO_MAP_BEGIN(SVGFESpotLightElement, nsIDOMSVGFESpotLightElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpotLightElement) + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 6ac4995cd400..86ab9df3dcea 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -4739,6 +4739,8 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode, return ParseVariant(aErrorCode, aValue, VARIANT_HC, nsnull); case eCSSProperty_flood_opacity: return ParseVariant(aErrorCode, aValue, VARIANT_HN, nsnull); + case eCSSProperty_lighting_color: + return ParseVariant(aErrorCode, aValue, VARIANT_HC, nsnull); case eCSSProperty_marker_end: case eCSSProperty_marker_mid: case eCSSProperty_marker_start: diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 822f5b66f932..fa7ffe55e97d 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -532,6 +532,7 @@ CSS_PROP_SVG(fill-rule, fill_rule, FillRule, SVG, mFillRule, eCSSType_Value, kFi CSS_PROP_SVGRESET(filter, filter, Filter, SVG, mFilter, eCSSType_Value, nsnull) CSS_PROP_SVGRESET(flood-color, flood_color, FloodColor, SVG, mFloodColor, eCSSType_Value, nsnull) CSS_PROP_SVGRESET(flood-opacity, flood_opacity, FloodOpacity, SVG, mFloodOpacity, eCSSType_Value, nsnull) +CSS_PROP_SVGRESET(lighting-color, lighting_color, LightingColor, SVG, mLightingColor, eCSSType_Value, nsnull) CSS_PROP_SHORTHAND(marker, marker, Marker) CSS_PROP_SVG(marker-end, marker_end, MarkerEnd, SVG, mMarkerEnd, eCSSType_Value, nsnull) CSS_PROP_SVG(marker-mid, marker_mid, MarkerMid, SVG, mMarkerMid, eCSSType_Value, nsnull) diff --git a/layout/style/nsCSSStruct.h b/layout/style/nsCSSStruct.h index f4b91ed5daa7..87785520a230 100644 --- a/layout/style/nsCSSStruct.h +++ b/layout/style/nsCSSStruct.h @@ -586,6 +586,7 @@ struct nsCSSSVG : public nsCSSStruct { nsCSSValue mFilter; nsCSSValue mFloodColor; nsCSSValue mFloodOpacity; + nsCSSValue mLightingColor; nsCSSValue mMarkerEnd; nsCSSValue mMarkerMid; nsCSSValue mMarkerStart; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 7ca4db198787..64b6d01841cb 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -3524,12 +3524,12 @@ nsComputedDOMStyle::GetTextRendering(nsIDOMCSSValue** aValue) } nsresult -nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue** aValue) +nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue** aValue) { nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); - nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mStopColor); + nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mFloodColor); if (NS_FAILED(rv)) { delete val; return rv; @@ -3539,12 +3539,27 @@ nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue** aValue) } nsresult -nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue** aValue) +nsComputedDOMStyle::GetLightingColor(nsIDOMCSSValue** aValue) { nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); - nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mFloodColor); + nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mLightingColor); + if (NS_FAILED(rv)) { + delete val; + return rv; + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mStopColor); if (NS_FAILED(rv)) { delete val; return rv; @@ -3807,6 +3822,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) COMPUTED_STYLE_MAP_ENTRY(filter, Filter), COMPUTED_STYLE_MAP_ENTRY(flood_color, FloodColor), COMPUTED_STYLE_MAP_ENTRY(flood_opacity, FloodOpacity), + COMPUTED_STYLE_MAP_ENTRY(lighting_color, LightingColor), COMPUTED_STYLE_MAP_ENTRY(mask, Mask), COMPUTED_STYLE_MAP_ENTRY(marker_end, MarkerEnd), COMPUTED_STYLE_MAP_ENTRY(marker_mid, MarkerMid), diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 5af04fff8376..ba9782460ac9 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -307,8 +307,9 @@ private: nsresult GetShapeRendering(nsIDOMCSSValue** aValue); nsresult GetTextRendering(nsIDOMCSSValue** aValue); - nsresult GetStopColor(nsIDOMCSSValue** aValue); nsresult GetFloodColor(nsIDOMCSSValue** aValue); + nsresult GetLightingColor(nsIDOMCSSValue** aValue); + nsresult GetStopColor(nsIDOMCSSValue** aValue); nsresult GetClipPath(nsIDOMCSSValue** aValue); nsresult GetFilter(nsIDOMCSSValue** aValue); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index be37ee789b78..7b9c5c2d694f 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4668,6 +4668,14 @@ nsRuleNode::ComputeSVGResetData(nsStyleStruct* aStartStruct, mPresContext, aContext, svgReset->mFloodColor, inherited); } + // lighting-color: + if (eCSSUnit_Initial == SVGData.mLightingColor.GetUnit()) { + svgReset->mLightingColor = NS_RGB(255, 255, 255); + } else { + SetColor(SVGData.mLightingColor, parentSVGReset->mLightingColor, + mPresContext, aContext, svgReset->mLightingColor, inherited); + } + // clip-path: url, none, inherit if (eCSSUnit_URL == SVGData.mClipPath.GetUnit()) { svgReset->mClipPath = SVGData.mClipPath.GetURLValue(); diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index a9172a17ab09..0dd1228c73c1 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -888,6 +888,8 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out, fprintf(out, "%ld ", (long)svgReset->mFloodColor); + fprintf(out, "%ld ", (long)svgReset->mLightingColor); + fprintf(out, "%s %s %s %f %f %d\" />\n", URICString(svgReset->mClipPath).get(), URICString(svgReset->mFilter).get(), diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index f6596dfad1eb..f0fbdbcebd0a 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -772,6 +772,7 @@ nsStyleSVGReset::nsStyleSVGReset() { mStopColor = NS_RGB(0,0,0); mFloodColor = NS_RGB(0,0,0); + mLightingColor = NS_RGB(255,255,255); mClipPath = nsnull; mFilter = nsnull; mMask = nsnull; @@ -788,6 +789,7 @@ nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource) { mStopColor = aSource.mStopColor; mFloodColor = aSource.mFloodColor; + mLightingColor = aSource.mLightingColor; mClipPath = aSource.mClipPath; mFilter = aSource.mFilter; mMask = aSource.mMask; @@ -798,13 +800,14 @@ nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource) nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) const { - if (mStopColor != aOther.mStopColor || - mFloodColor != aOther.mFloodColor || - !EqualURIs(mClipPath, aOther.mClipPath) || - !EqualURIs(mFilter, aOther.mFilter) || - !EqualURIs(mMask, aOther.mMask) || - mStopOpacity != aOther.mStopOpacity || - mFloodOpacity != aOther.mFloodOpacity || + if (mStopColor != aOther.mStopColor || + mFloodColor != aOther.mFloodColor || + mLightingColor != aOther.mLightingColor || + !EqualURIs(mClipPath, aOther.mClipPath) || + !EqualURIs(mFilter, aOther.mFilter) || + !EqualURIs(mMask, aOther.mMask) || + mStopOpacity != aOther.mStopOpacity || + mFloodOpacity != aOther.mFloodOpacity || mDominantBaseline != aOther.mDominantBaseline) return NS_STYLE_HINT_VISUAL; diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 208233b4a860..025790d4215d 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1308,6 +1308,7 @@ struct nsStyleSVGReset : public nsStyleStruct { nscolor mStopColor; // [reset] nscolor mFloodColor; // [reset] + nscolor mLightingColor; // [reset] nsCOMPtr mClipPath; // [reset] nsCOMPtr mFilter; // [reset] nsCOMPtr mMask; // [reset] diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 81fb2d2757b5..940ca2707083 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -1695,6 +1695,14 @@ var gCSSProperties = { other_values: [ "0", "0.3", "-7.3" ], invalid_values: [] }, + "lighting-color": { + domProp: null, + inherited: false, + type: CSS_TYPE_LONGHAND, + initial_values: [ "white", "#fff", "#ffffff", "rgb(255,255,255)", "rgba(255,255,255,1.0)", "rgba(255,255,255,42.0)" ], + other_values: [ "green", "#fc3" ], + invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] + }, "marker": { domProp: null, inherited: true,