Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_ProcessingInstruction_h
8 : #define mozilla_dom_ProcessingInstruction_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsIDOMProcessingInstruction.h"
12 : #include "nsGenericDOMDataNode.h"
13 : #include "nsAString.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class ProcessingInstruction : public nsGenericDOMDataNode,
19 : public nsIDOMProcessingInstruction
20 : {
21 : public:
22 : ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
23 : const nsAString& aData);
24 :
25 : // nsISupports
26 : NS_DECL_ISUPPORTS_INHERITED
27 :
28 : // nsIDOMNode
29 0 : NS_FORWARD_NSIDOMNODE_TO_NSINODE
30 :
31 : // nsIDOMCharacterData
32 12 : NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
33 : using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
34 :
35 : // nsIDOMProcessingInstruction
36 : NS_DECL_NSIDOMPROCESSINGINSTRUCTION
37 :
38 : // nsINode
39 : virtual bool IsNodeOfType(uint32_t aFlags) const override;
40 :
41 : virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
42 : bool aCloneText) const override;
43 :
44 : #ifdef DEBUG
45 : virtual void List(FILE* out, int32_t aIndent) const override;
46 : virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override;
47 : #endif
48 :
49 8 : virtual nsIDOMNode* AsDOMNode() override { return this; }
50 :
51 : // WebIDL API
52 0 : void GetTarget(nsString& aTarget)
53 : {
54 0 : aTarget = NodeName();
55 0 : }
56 : protected:
57 : virtual ~ProcessingInstruction();
58 :
59 : /**
60 : * This will parse the content of the PI, to extract the value of the pseudo
61 : * attribute with the name specified in aName. See
62 : * http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification
63 : * which is used to parse the content of the PI.
64 : *
65 : * @param aName the name of the attribute to get the value for
66 : * @param aValue [out] the value for the attribute with name specified in
67 : * aAttribute. Empty if the attribute isn't present.
68 : */
69 : bool GetAttrValue(nsIAtom *aName, nsAString& aValue);
70 :
71 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
72 : };
73 :
74 : } // namespace dom
75 : } // namespace mozilla
76 :
77 : /**
78 : * aNodeInfoManager must not be null.
79 : */
80 : already_AddRefed<mozilla::dom::ProcessingInstruction>
81 : NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
82 : const nsAString& aTarget,
83 : const nsAString& aData);
84 :
85 : #endif // mozilla_dom_ProcessingInstruction_h
|