mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 823394 Part 2: Add WebIDL API to SVGElement and enable binding r=bz
This commit is contained in:
parent
29dc901587
commit
cd3a226611
@ -59,6 +59,7 @@
|
||||
#include "nsAttrValueOrString.h"
|
||||
#include "nsSMILAnimationController.h"
|
||||
#include "nsDOMCSSDeclaration.h"
|
||||
#include "mozilla/dom/SVGElementBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -81,26 +82,42 @@ nsSVGElement::nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
nsSVGElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return SVGElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedString className; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetClassName(nsIDOMSVGAnimatedString** aClassName)
|
||||
{
|
||||
return mClassAttribute.ToDOMAnimatedString(aClassName, this);
|
||||
*aClassName = ClassName().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMCSSStyleDeclaration style; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
{
|
||||
nsresult rv;
|
||||
*aStyle = nsSVGElementBase::GetStyle(&rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
ErrorResult rv;
|
||||
NS_ADDREF(*aStyle = GetStyle(rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsICSSDeclaration*
|
||||
nsSVGElement::GetStyle(ErrorResult& rv)
|
||||
{
|
||||
nsresult res;
|
||||
nsICSSDeclaration* style = nsSVGElementBase::GetStyle(&res);
|
||||
if (NS_FAILED(res)) {
|
||||
rv.Throw(res);
|
||||
return nullptr;
|
||||
}
|
||||
NS_ADDREF(*aStyle);
|
||||
return NS_OK;
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/* nsIDOMCSSValue getPresentationAttribute (in DOMString name); */
|
||||
@ -115,6 +132,13 @@ nsSVGElement::GetPresentationAttribute(const nsAString& aName,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsSVGElement::GetPresentationAttribute(const nsAString& aName, ErrorResult& rv)
|
||||
{
|
||||
rv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsSVGElement methods
|
||||
|
||||
@ -1127,24 +1151,52 @@ NS_IMETHODIMP nsSVGElement::SetId(const nsAString & aId)
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
|
||||
{
|
||||
NS_IF_ADDREF(*aOwnerSVGElement = GetCtx());
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aOwnerSVGElement = GetOwnerSVGElement(rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
if (*aOwnerSVGElement || Tag() == nsGkAtoms::svg) {
|
||||
// If we found something or we're the outermost SVG element, that's OK.
|
||||
return NS_OK;
|
||||
nsSVGSVGElement*
|
||||
nsSVGElement::GetOwnerSVGElement(ErrorResult& rv)
|
||||
{
|
||||
nsSVGSVGElement* ownerSVGElement = GetCtx();
|
||||
|
||||
// If we didn't find anything and we're not the outermost SVG element,
|
||||
// we've got an invalid structure
|
||||
if (!ownerSVGElement && Tag() != nsGkAtoms::svg) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
// Otherwise, we've got an invalid structure
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return ownerSVGElement;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement viewportElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
||||
{
|
||||
*aViewportElement = SVGContentUtils::GetNearestViewportElement(this).get();
|
||||
nsCOMPtr<nsSVGElement> elem = GetViewportElement();
|
||||
nsCOMPtr<nsIDOMSVGElement> svgElem = do_QueryInterface(elem);
|
||||
svgElem.forget(aViewportElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsSVGElement>
|
||||
nsSVGElement::GetViewportElement()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGElement> elem =
|
||||
SVGContentUtils::GetNearestViewportElement(this);
|
||||
nsCOMPtr<nsSVGElement> svgElem = do_QueryInterface(elem);
|
||||
return svgElem.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGAnimatedString>
|
||||
nsSVGElement::ClassName()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedString> className;
|
||||
mClassAttribute.ToDOMAnimatedString(getter_AddRefs(className), this);
|
||||
return className.forget();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Helper class: MappedAttrParser, for parsing values of mapped attributes
|
||||
|
||||
|
@ -37,6 +37,10 @@ class nsSVGSVGElement;
|
||||
class nsSVGViewBox;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class CSSValue;
|
||||
}
|
||||
|
||||
class SVGAnimatedNumberList;
|
||||
class SVGNumberList;
|
||||
class SVGAnimatedLengthList;
|
||||
@ -294,7 +298,15 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// WebIDL
|
||||
nsSVGSVGElement* GetOwnerSVGElement(mozilla::ErrorResult& rv);
|
||||
already_AddRefed<nsSVGElement> GetViewportElement();
|
||||
already_AddRefed<nsIDOMSVGAnimatedString> ClassName();
|
||||
nsICSSDeclaration* GetStyle(mozilla::ErrorResult& rv);
|
||||
already_AddRefed<mozilla::dom::CSSValue> GetPresentationAttribute(const nsAString& aName, mozilla::ErrorResult& rv);
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap);
|
||||
|
||||
#ifdef DEBUG
|
||||
// We define BeforeSetAttr here and mark it MOZ_FINAL to ensure it is NOT used
|
||||
// by SVG elements.
|
||||
|
@ -463,6 +463,13 @@ DOMInterfaces = {
|
||||
'headerFile': 'DOMSVGAnimatedTransformList.h'
|
||||
},
|
||||
|
||||
'SVGElement': {
|
||||
'nativeType': 'nsSVGElement',
|
||||
'hasXPConnectImpls': True,
|
||||
'hasInstanceInterface': 'nsIDOMSVGElement',
|
||||
'resultNotAddRefed': ['ownerSVGElement', 'style']
|
||||
},
|
||||
|
||||
'SVGLengthList': {
|
||||
'nativeType': 'mozilla::DOMSVGLengthList',
|
||||
'headerFile': 'DOMSVGLengthList.h',
|
||||
@ -1000,8 +1007,10 @@ addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction
|
||||
addExternalIface('Range', nativeType='nsRange')
|
||||
addExternalIface("Rect")
|
||||
addExternalIface('StyleSheetList')
|
||||
addExternalIface('SVGAnimatedString')
|
||||
addExternalIface('SVGLength')
|
||||
addExternalIface('SVGNumber')
|
||||
addExternalIface('SVGSVGElement', nativeType='nsSVGSVGElement')
|
||||
addExternalIface('Text', nativeType='nsTextNode')
|
||||
addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('TreeWalker')
|
||||
|
36
dom/webidl/SVGElement.webidl
Normal file
36
dom/webidl/SVGElement.webidl
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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 SVGSVGElement;
|
||||
interface SVGAnimatedString;
|
||||
|
||||
interface SVGElement : Element {
|
||||
attribute DOMString id;
|
||||
/* [SetterThrows]
|
||||
attribute DOMString xmlbase; */
|
||||
|
||||
readonly attribute SVGAnimatedString className;
|
||||
[Throws]
|
||||
readonly attribute CSSStyleDeclaration style;
|
||||
|
||||
[Throws] // because not implemented
|
||||
CSSValue? getPresentationAttribute(DOMString name);
|
||||
|
||||
/*[SetterThrows]
|
||||
attribute DOMString xmllang;
|
||||
[SetterThrows]
|
||||
attribute DOMString xmlspace;*/
|
||||
|
||||
[Throws]
|
||||
readonly attribute SVGSVGElement? ownerSVGElement;
|
||||
readonly attribute SVGElement? viewportElement;
|
||||
};
|
@ -76,6 +76,7 @@ webidl_files = \
|
||||
SVGAnimatedNumberList.webidl \
|
||||
SVGAnimatedPreserveAspectRatio.webidl \
|
||||
SVGAnimatedTransformList.webidl \
|
||||
SVGElement.webidl \
|
||||
SVGLengthList.webidl \
|
||||
SVGMatrix.webidl \
|
||||
SVGNumberList.webidl \
|
||||
|
@ -388,7 +388,8 @@ customIncludes = [
|
||||
'mozilla/dom/NodeBinding.h',
|
||||
'mozilla/dom/ElementBinding.h',
|
||||
'mozilla/dom/HTMLElementBinding.h',
|
||||
'mozilla/dom/DocumentBinding.h'
|
||||
'mozilla/dom/DocumentBinding.h',
|
||||
'mozilla/dom/SVGElementBinding.h'
|
||||
]
|
||||
|
||||
customReturnInterfaces = [
|
||||
@ -497,5 +498,6 @@ newBindingProperties = {
|
||||
'nsIDOMNode': 'mozilla::dom::NodeBinding::sNativePropertyHooks.mNativeProperties.regular',
|
||||
'nsIDOMElement': 'mozilla::dom::ElementBinding::sNativePropertyHooks.mNativeProperties.regular',
|
||||
'nsIDOMHTMLElement': 'mozilla::dom::HTMLElementBinding::sNativePropertyHooks.mNativeProperties.regular',
|
||||
'nsIDOMDocument': 'mozilla::dom::DocumentBinding::sNativePropertyHooks.mNativeProperties.regular'
|
||||
'nsIDOMDocument': 'mozilla::dom::DocumentBinding::sNativePropertyHooks.mNativeProperties.regular',
|
||||
'nsIDOMSVGElement': 'mozilla::dom::SVGElementBinding::sNativePropertyHooks.mNativeProperties.regular'
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mozilla/dom/ElementBinding.h"
|
||||
#include "mozilla/dom/HTMLElementBinding.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
#include "mozilla/dom/SVGElementBinding.h"
|
||||
|
||||
template<class T>
|
||||
struct ProtoIDAndDepth
|
||||
@ -48,6 +49,7 @@ NEW_BINDING(mozilla::dom::Element, Element);
|
||||
NEW_BINDING(nsGenericHTMLElement, HTMLElement);
|
||||
NEW_BINDING(nsIDocument, Document);
|
||||
NEW_BINDING(nsDocument, Document);
|
||||
NEW_BINDING(nsSVGElement, SVGElement);
|
||||
|
||||
#define DEFINE_UNWRAP_CAST(_interface, _base, _bit) \
|
||||
template <> \
|
||||
|
Loading…
Reference in New Issue
Block a user