mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 847120: Convert SVGFEFloodElement to WebIDL r=Ms2ger
--HG-- rename : content/svg/content/src/nsSVGFilters.cpp => content/svg/content/src/SVGFEFloodElement.cpp rename : content/svg/content/src/nsSVGFilters.cpp => content/svg/content/src/SVGFEFloodElement.h
This commit is contained in:
parent
cfdd9c0f5b
commit
72eae41dfc
@ -80,6 +80,7 @@ CPPSRCS = \
|
||||
SVGElementFactory.cpp \
|
||||
SVGEllipseElement.cpp \
|
||||
SVGFEBlendElement.cpp \
|
||||
SVGFEFloodElement.cpp \
|
||||
SVGFEMergeElement.cpp \
|
||||
SVGFEMergeNodeElement.cpp \
|
||||
SVGFilterElement.cpp \
|
||||
@ -174,6 +175,7 @@ EXPORTS_mozilla/dom = \
|
||||
SVGDescElement.h \
|
||||
SVGEllipseElement.h \
|
||||
SVGFEBlendElement.h \
|
||||
SVGFEFloodElement.h \
|
||||
SVGFEMergeElement.h \
|
||||
SVGFEMergeNodeElement.h \
|
||||
SVGFilterElement.h \
|
||||
|
96
content/svg/content/src/SVGFEFloodElement.cpp
Normal file
96
content/svg/content/src/SVGFEFloodElement.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/dom/SVGFEFloodElement.h"
|
||||
#include "mozilla/dom/SVGFEFloodElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFlood)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
SVGFEFloodElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGFEFloodElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
nsSVGElement::StringInfo SVGFEFloodElement::sStringInfo[1] =
|
||||
{
|
||||
{ &nsGkAtoms::result, kNameSpaceID_None, true }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(SVGFEFloodElement,SVGFEFloodElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(SVGFEFloodElement,SVGFEFloodElementBase)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(SVGFEFloodElement)
|
||||
NS_NODE_INTERFACE_TABLE3(SVGFEFloodElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(SVGFEFloodElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFloodElement)
|
||||
|
||||
nsresult
|
||||
SVGFEFloodElement::Filter(nsSVGFilterInstance *instance,
|
||||
const nsTArray<const Image*>& aSources,
|
||||
const Image* aTarget,
|
||||
const nsIntRect& aDataRect)
|
||||
{
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame) return NS_ERROR_FAILURE;
|
||||
nsStyleContext* style = frame->StyleContext();
|
||||
|
||||
nscolor floodColor = style->StyleSVGReset()->mFloodColor;
|
||||
float floodOpacity = style->StyleSVGReset()->mFloodOpacity;
|
||||
|
||||
gfxContext ctx(aTarget->mImage);
|
||||
ctx.SetColor(gfxRGBA(NS_GET_R(floodColor) / 255.0,
|
||||
NS_GET_G(floodColor) / 255.0,
|
||||
NS_GET_B(floodColor) / 255.0,
|
||||
NS_GET_A(floodColor) / 255.0 * floodOpacity));
|
||||
ctx.Rectangle(aTarget->mFilterPrimitiveSubregion);
|
||||
ctx.Fill();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIntRect
|
||||
SVGFEFloodElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
|
||||
const nsSVGFilterInstance& aInstance)
|
||||
{
|
||||
return GetMaxRect();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
SVGFEFloodElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sFEFloodMap
|
||||
};
|
||||
|
||||
return FindAttributeDependence(name, map) ||
|
||||
SVGFEFloodElementBase::IsAttributeMapped(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
nsSVGElement::StringAttributesInfo
|
||||
SVGFEFloodElement::GetStringInfo()
|
||||
{
|
||||
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
||||
ArrayLength(sStringInfo));
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
71
content/svg/content/src/SVGFEFloodElement.h
Normal file
71
content/svg/content/src/SVGFEFloodElement.h
Normal file
@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_SVGFEFloodElement_h
|
||||
#define mozilla_dom_SVGFEFloodElement_h
|
||||
|
||||
#include "nsSVGFilters.h"
|
||||
|
||||
nsresult NS_NewSVGFEFloodElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef nsSVGFE SVGFEFloodElementBase;
|
||||
|
||||
class SVGFEFloodElement : public SVGFEFloodElementBase,
|
||||
public nsIDOMSVGElement
|
||||
{
|
||||
friend nsresult (::NS_NewSVGFEFloodElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo));
|
||||
protected:
|
||||
SVGFEFloodElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: SVGFEFloodElementBase(aNodeInfo)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
virtual bool SubregionIsUnionOfRegions() { return false; }
|
||||
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<const Image*>& aSources,
|
||||
const Image* aTarget,
|
||||
const nsIntRect& aDataRect);
|
||||
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
|
||||
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
|
||||
const nsSVGFilterInstance& aInstance);
|
||||
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(SVGFEFloodElementBase::)
|
||||
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
protected:
|
||||
virtual bool OperatesOnSRGB(nsSVGFilterInstance*,
|
||||
int32_t, Image*) { return true; }
|
||||
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
|
||||
enum { RESULT };
|
||||
nsSVGString mStringAttributes[1];
|
||||
static StringInfo sStringInfo[1];
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SVGFEFloodElement_h
|
@ -2192,149 +2192,6 @@ nsSVGFEOffsetElement::GetStringInfo()
|
||||
ArrayLength(sStringInfo));
|
||||
}
|
||||
|
||||
//---------------------Flood------------------------
|
||||
|
||||
typedef nsSVGFE nsSVGFEFloodElementBase;
|
||||
|
||||
class nsSVGFEFloodElement : public nsSVGFEFloodElementBase,
|
||||
public nsIDOMSVGFEFloodElement
|
||||
{
|
||||
friend nsresult NS_NewSVGFEFloodElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
protected:
|
||||
nsSVGFEFloodElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsSVGFEFloodElementBase(aNodeInfo) {}
|
||||
|
||||
public:
|
||||
virtual bool SubregionIsUnionOfRegions() { return false; }
|
||||
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// FE Base
|
||||
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEFloodElementBase::)
|
||||
|
||||
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<const Image*>& aSources,
|
||||
const Image* aTarget,
|
||||
const nsIntRect& aDataRect);
|
||||
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
|
||||
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
|
||||
const nsSVGFilterInstance& aInstance);
|
||||
|
||||
// Flood
|
||||
NS_DECL_NSIDOMSVGFEFLOODELEMENT
|
||||
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEFloodElementBase::)
|
||||
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
protected:
|
||||
virtual bool OperatesOnSRGB(nsSVGFilterInstance*,
|
||||
int32_t, Image*) { return true; }
|
||||
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
|
||||
enum { RESULT };
|
||||
nsSVGString mStringAttributes[1];
|
||||
static StringInfo sStringInfo[1];
|
||||
};
|
||||
|
||||
nsSVGElement::StringInfo nsSVGFEFloodElement::sStringInfo[1] =
|
||||
{
|
||||
{ &nsGkAtoms::result, kNameSpaceID_None, true }
|
||||
};
|
||||
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT(FEFlood)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGFEFloodElement,nsSVGFEFloodElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGFEFloodElement,nsSVGFEFloodElementBase)
|
||||
|
||||
DOMCI_NODE_DATA(SVGFEFloodElement, nsSVGFEFloodElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGFEFloodElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGFEFloodElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGFilterPrimitiveStandardAttributes,
|
||||
nsIDOMSVGFEFloodElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFEFloodElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEFloodElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFloodElement)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGFEFloodElement methods
|
||||
|
||||
nsresult
|
||||
nsSVGFEFloodElement::Filter(nsSVGFilterInstance *instance,
|
||||
const nsTArray<const Image*>& aSources,
|
||||
const Image* aTarget,
|
||||
const nsIntRect& aDataRect)
|
||||
{
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame) return NS_ERROR_FAILURE;
|
||||
nsStyleContext* style = frame->StyleContext();
|
||||
|
||||
nscolor floodColor = style->StyleSVGReset()->mFloodColor;
|
||||
float floodOpacity = style->StyleSVGReset()->mFloodOpacity;
|
||||
|
||||
gfxContext ctx(aTarget->mImage);
|
||||
ctx.SetColor(gfxRGBA(NS_GET_R(floodColor) / 255.0,
|
||||
NS_GET_G(floodColor) / 255.0,
|
||||
NS_GET_B(floodColor) / 255.0,
|
||||
NS_GET_A(floodColor) / 255.0 * floodOpacity));
|
||||
ctx.Rectangle(aTarget->mFilterPrimitiveSubregion);
|
||||
ctx.Fill();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIntRect
|
||||
nsSVGFEFloodElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
|
||||
const nsSVGFilterInstance& aInstance)
|
||||
{
|
||||
return GetMaxRect();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsSVGFEFloodElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sFEFloodMap
|
||||
};
|
||||
|
||||
return FindAttributeDependence(name, map) ||
|
||||
nsSVGFEFloodElementBase::IsAttributeMapped(name);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
nsSVGElement::StringAttributesInfo
|
||||
nsSVGFEFloodElement::GetStringInfo()
|
||||
{
|
||||
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
||||
ArrayLength(sStringInfo));
|
||||
}
|
||||
|
||||
//---------------------Tile------------------------
|
||||
|
||||
typedef nsSVGFE nsSVGFETileElementBase;
|
||||
|
@ -830,8 +830,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGFEDistantLightElement, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGFEFloodElement, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGFEGaussianBlurElement, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGFEImageElement, nsElementSH,
|
||||
@ -2310,12 +2308,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(SVGFEFloodElement, nsIDOMSVGFEFloodElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFloodElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
|
||||
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(SVGFEGaussianBlurElement, nsIDOMSVGFEGaussianBlurElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEGaussianBlurElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
|
||||
|
@ -128,7 +128,6 @@ DOMCI_CLASS(SVGFEConvolveMatrixElement)
|
||||
DOMCI_CLASS(SVGFEDiffuseLightingElement)
|
||||
DOMCI_CLASS(SVGFEDisplacementMapElement)
|
||||
DOMCI_CLASS(SVGFEDistantLightElement)
|
||||
DOMCI_CLASS(SVGFEFloodElement)
|
||||
DOMCI_CLASS(SVGFEGaussianBlurElement)
|
||||
DOMCI_CLASS(SVGFEImageElement)
|
||||
DOMCI_CLASS(SVGFEMorphologyElement)
|
||||
|
@ -125,11 +125,6 @@ interface nsIDOMSVGFEOffsetElement : nsIDOMSVGFilterPrimitiveStandardAttributes
|
||||
readonly attribute nsIDOMSVGAnimatedNumber dy;
|
||||
};
|
||||
|
||||
[scriptable, uuid(F1635489-F34F-4554-8284-C848500FE0DD)]
|
||||
interface nsIDOMSVGFEFloodElement : nsIDOMSVGFilterPrimitiveStandardAttributes
|
||||
{
|
||||
};
|
||||
|
||||
[scriptable, uuid(C587EFE9-0A22-44E6-9964-B68DA564804A)]
|
||||
interface nsIDOMSVGFETileElement : nsIDOMSVGFilterPrimitiveStandardAttributes
|
||||
{
|
||||
|
16
dom/webidl/SVGFEFloodElement.webidl
Normal file
16
dom/webidl/SVGFEFloodElement.webidl
Normal file
@ -0,0 +1,16 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/SVG2/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface SVGFEFloodElement : SVGElement {
|
||||
};
|
||||
|
||||
SVGFEMergeElement implements SVGFilterPrimitiveStandardAttributes;
|
@ -161,6 +161,7 @@ webidl_files = \
|
||||
SVGFilterElement.webidl \
|
||||
SVGFilterPrimitiveStandardAttributes.webidl \
|
||||
SVGFEBlendElement.webidl \
|
||||
SVGFEFloodElement.webidl \
|
||||
SVGFEFuncAElement.webidl \
|
||||
SVGFEFuncBElement.webidl \
|
||||
SVGFEFuncGElement.webidl \
|
||||
|
Loading…
x
Reference in New Issue
Block a user