mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 824603 Part 1: Enable binding for DocumentType r=bz
This commit is contained in:
parent
1f8808f4be
commit
67c3a2144d
@ -8,7 +8,7 @@
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsDOMDocumentType.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -50,16 +50,33 @@ DOMImplementation::HasFeature(const nsAString& aFeature,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMDocumentType>
|
||||
already_AddRefed<nsDOMDocumentType>
|
||||
DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocumentType> doctype;
|
||||
aRv = CreateDocumentType(aQualifiedName, aPublicId, aSystemId,
|
||||
getter_AddRefs(doctype));
|
||||
return doctype.forget();
|
||||
if (!mOwner) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aRv = nsContentUtils::CheckQName(aQualifiedName);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aQualifiedName);
|
||||
if (!name) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Indicate that there is no internal subset (not just an empty one)
|
||||
nsRefPtr<nsDOMDocumentType> docType =
|
||||
NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId,
|
||||
aSystemId, NullString(), aRv);
|
||||
return docType.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -68,19 +85,9 @@ DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
|
||||
const nsAString& aSystemId,
|
||||
nsIDOMDocumentType** aReturn)
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
NS_ENSURE_STATE(mOwner);
|
||||
|
||||
nsresult rv = nsContentUtils::CheckQName(aQualifiedName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aQualifiedName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Indicate that there is no internal subset (not just an empty one)
|
||||
return NS_NewDOMDocumentType(aReturn, mOwner->NodeInfoManager(),
|
||||
name, aPublicId,
|
||||
aSystemId, NullString());
|
||||
ErrorResult rv;
|
||||
*aReturn = CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).get();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentType;
|
||||
class nsDOMDocumentType;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -61,7 +61,7 @@ public:
|
||||
|
||||
bool HasFeature(const nsAString& aFeature, const nsAString& aVersion);
|
||||
|
||||
already_AddRefed<nsIDOMDocumentType>
|
||||
already_AddRefed<nsDOMDocumentType>
|
||||
CreateDocumentType(const nsAString& aQualifiedName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
|
@ -17,6 +17,15 @@
|
||||
#include "nsIXPConnect.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/dom/DocumentTypeBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
JSObject*
|
||||
nsDOMDocumentType::WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
return dom::DocumentTypeBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
@ -27,20 +36,38 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
const nsAString& aInternalSubset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocType);
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
ErrorResult rv;
|
||||
*aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
|
||||
aSystemId, aInternalSubset, rv).get();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<nsDOMDocumentType>
|
||||
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
|
||||
nsIAtom *aName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
if (!aName) {
|
||||
rv.Throw(NS_ERROR_INVALID_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni =
|
||||
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
aName);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!ni) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*aDocType = new nsDOMDocumentType(ni.forget(), aPublicId, aSystemId,
|
||||
aInternalSubset);
|
||||
NS_ADDREF(*aDocType);
|
||||
|
||||
return NS_OK;
|
||||
nsRefPtr<nsDOMDocumentType> docType =
|
||||
new nsDOMDocumentType(ni.forget(), aPublicId, aSystemId, aInternalSubset);
|
||||
return docType.forget();
|
||||
}
|
||||
|
||||
nsDOMDocumentType::nsDOMDocumentType(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
@ -52,6 +79,7 @@ nsDOMDocumentType::nsDOMDocumentType(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
mSystemId(aSystemId),
|
||||
mInternalSubset(aInternalSubset)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
@ -73,12 +73,23 @@ public:
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap);
|
||||
|
||||
protected:
|
||||
nsString mPublicId;
|
||||
nsString mSystemId;
|
||||
nsString mInternalSubset;
|
||||
};
|
||||
|
||||
already_AddRefed<nsDOMDocumentType>
|
||||
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
|
||||
nsIAtom *aName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
nsNodeInfoManager* aNodeInfoManager,
|
||||
|
@ -206,6 +206,11 @@ DOMInterfaces = {
|
||||
'resultNotAddRefed': [ 'querySelector' ]
|
||||
},
|
||||
|
||||
'DocumentType': {
|
||||
'nativeType': 'nsDOMDocumentType',
|
||||
'hasInstanceInterface': 'nsIDOMDocumentType'
|
||||
},
|
||||
|
||||
'DOMSettableTokenList': {
|
||||
'nativeType': 'nsDOMSettableTokenList',
|
||||
'binaryNames': {
|
||||
@ -1010,7 +1015,6 @@ addExternalIface('ClientRect')
|
||||
addExternalIface('Comment', nativeType='mozilla::dom::Comment')
|
||||
addExternalIface("Counter")
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DocumentType', headerFile="nsDOMDocumentType.h")
|
||||
addExternalIface('DOMRequest')
|
||||
addExternalIface('DOMStringList')
|
||||
addExternalIface('File')
|
||||
|
@ -75,18 +75,8 @@
|
||||
"EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling dispatchEvent(Event) on xmlDoc with too few arguments must throw TypeError": true,
|
||||
"DocumentType interface: existence and properties of interface object": true,
|
||||
"DocumentType interface: existence and properties of interface prototype object": true,
|
||||
"DocumentType interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
"DocumentType interface: attribute name": true,
|
||||
"DocumentType interface: attribute publicId": true,
|
||||
"DocumentType interface: attribute systemId": true,
|
||||
"DocumentType interface: operation remove()": true,
|
||||
"Stringification of document.doctype": "debug",
|
||||
"DocumentType interface: document.doctype must inherit property \"remove\" with the proper type (3)": true,
|
||||
"EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on document.doctype with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on document.doctype with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling dispatchEvent(Event) on document.doctype with too few arguments must throw TypeError": true,
|
||||
"Element interface: attribute namespaceURI": true,
|
||||
"Element interface: attribute prefix": true,
|
||||
"Element interface: attribute localName": true,
|
||||
|
@ -11,8 +11,6 @@
|
||||
* related or neighboring rights to this work.
|
||||
*/
|
||||
|
||||
interface DocumentType;
|
||||
|
||||
interface DOMImplementation {
|
||||
boolean hasFeature(DOMString feature,
|
||||
[TreatNullAs=EmptyString] DOMString version);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/2012/WD-dom-20120105/
|
||||
* http://dom.spec.whatwg.org/#documenttype
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
@ -15,9 +15,14 @@ interface DocumentType : Node {
|
||||
readonly attribute DOMString publicId;
|
||||
readonly attribute DOMString systemId;
|
||||
|
||||
/* Not implemented
|
||||
// NEW
|
||||
void before((Node or DOMString)... nodes);
|
||||
void after((Node or DOMString)... nodes);
|
||||
void replace((Node or DOMString)... nodes);
|
||||
void remove();
|
||||
*/
|
||||
|
||||
// Mozilla extension
|
||||
readonly attribute DOMString? internalSubset;
|
||||
};
|
||||
|
@ -30,6 +30,7 @@ webidl_files = \
|
||||
DelayNode.webidl \
|
||||
Document.webidl \
|
||||
DocumentFragment.webidl \
|
||||
DocumentType.webidl \
|
||||
DOMImplementation.webidl \
|
||||
DOMParser.webidl \
|
||||
DOMSettableTokenList.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user