ProcessingInstruction.h 2.7 KB

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