content/base/src/DocumentType.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/DocumentType.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Implementation of DOM Core's nsIDOMDocumentType node.
    1.11 + */
    1.12 +
    1.13 +#ifndef DocumentType_h
    1.14 +#define DocumentType_h
    1.15 +
    1.16 +#include "mozilla/Attributes.h"
    1.17 +#include "nsCOMPtr.h"
    1.18 +#include "nsIDOMDocumentType.h"
    1.19 +#include "nsIContent.h"
    1.20 +#include "nsGenericDOMDataNode.h"
    1.21 +#include "nsString.h"
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace dom {
    1.25 +
    1.26 +// XXX DocumentType is currently implemented by inheriting the generic
    1.27 +// CharacterData object, even though DocumentType is not character
    1.28 +// data. This is done simply for convenience and should be changed if
    1.29 +// this restricts what should be done for character data.
    1.30 +
    1.31 +class DocumentTypeForward : public nsGenericDOMDataNode,
    1.32 +                            public nsIDOMDocumentType
    1.33 +{
    1.34 +public:
    1.35 +  DocumentTypeForward(already_AddRefed<nsINodeInfo>& aNodeInfo)
    1.36 +    : nsGenericDOMDataNode(aNodeInfo)
    1.37 +  {
    1.38 +  }
    1.39 +
    1.40 +  // nsIDOMNode
    1.41 +  NS_FORWARD_NSIDOMNODE_TO_NSINODE
    1.42 +};
    1.43 +
    1.44 +class DocumentType MOZ_FINAL : public DocumentTypeForward
    1.45 +{
    1.46 +public:
    1.47 +  DocumentType(already_AddRefed<nsINodeInfo>& aNodeInfo,
    1.48 +               const nsAString& aPublicId,
    1.49 +               const nsAString& aSystemId,
    1.50 +               const nsAString& aInternalSubset);
    1.51 +
    1.52 +  virtual ~DocumentType();
    1.53 +
    1.54 +  // nsISupports
    1.55 +  NS_DECL_ISUPPORTS_INHERITED
    1.56 +
    1.57 +  // nsIDOMNode
    1.58 +  // Forwarded by base class
    1.59 +
    1.60 +  // nsIDOMDocumentType
    1.61 +  NS_DECL_NSIDOMDOCUMENTTYPE
    1.62 +
    1.63 +  // nsINode
    1.64 +  virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
    1.65 +  virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE
    1.66 +  {
    1.67 +    SetDOMStringToNull(aNodeValue);
    1.68 +  }
    1.69 +  virtual void SetNodeValueInternal(const nsAString& aNodeValue,
    1.70 +                                    mozilla::ErrorResult& aError) MOZ_OVERRIDE
    1.71 +  {
    1.72 +  }
    1.73 +
    1.74 +  // nsIContent overrides
    1.75 +  virtual const nsTextFragment* GetText() MOZ_OVERRIDE;
    1.76 +
    1.77 +  virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
    1.78 +                                              bool aCloneText) const MOZ_OVERRIDE;
    1.79 +
    1.80 +  virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }
    1.81 +
    1.82 +protected:
    1.83 +  virtual JSObject* WrapNode(JSContext *cx) MOZ_OVERRIDE;
    1.84 +
    1.85 +  nsString mPublicId;
    1.86 +  nsString mSystemId;
    1.87 +  nsString mInternalSubset;
    1.88 +};
    1.89 +
    1.90 +} // namespace dom
    1.91 +} // namespace mozilla
    1.92 +
    1.93 +already_AddRefed<mozilla::dom::DocumentType>
    1.94 +NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
    1.95 +                      nsIAtom *aName,
    1.96 +                      const nsAString& aPublicId,
    1.97 +                      const nsAString& aSystemId,
    1.98 +                      const nsAString& aInternalSubset,
    1.99 +                      mozilla::ErrorResult& rv);
   1.100 +
   1.101 +nsresult
   1.102 +NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
   1.103 +                      nsNodeInfoManager* aNodeInfoManager,
   1.104 +                      nsIAtom *aName,
   1.105 +                      const nsAString& aPublicId,
   1.106 +                      const nsAString& aSystemId,
   1.107 +                      const nsAString& aInternalSubset);
   1.108 +
   1.109 +#endif // DocumentType_h

mercurial