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 "mozilla/dom/CharacterData.h" 12 #include "nsAString.h" 13 14 class nsIPrincipal; 15 class nsIURI; 16 17 namespace mozilla { 18 19 class StyleSheet; 20 21 namespace dom { 22 23 class ProcessingInstruction : public CharacterData { 24 public: 25 ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, 26 const nsAString& aData); 27 28 virtual already_AddRefed<CharacterData> CloneDataNode( 29 dom::NodeInfo* aNodeInfo, bool aCloneText) const override; 30 31 #ifdef MOZ_DOM_LIST 32 virtual void List(FILE* out, int32_t aIndent) const override; 33 virtual void DumpContent(FILE* out, int32_t aIndent, 34 bool aDumpAll) const override; 35 #endif 36 37 // WebIDL API GetTarget(nsAString & aTarget)38 void GetTarget(nsAString& aTarget) { aTarget = NodeName(); } 39 // This is the WebIDL API for LinkStyle, even though only 40 // XMLStylesheetProcessingInstruction actually implements LinkStyle. 41 StyleSheet* GetSheetForBindings() const; 42 43 NS_IMPL_FROMNODE_HELPER(ProcessingInstruction, IsProcessingInstruction()) 44 45 protected: 46 virtual ~ProcessingInstruction(); 47 48 /** 49 * This will parse the content of the PI, to extract the value of the pseudo 50 * attribute with the name specified in aName. See 51 * http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification 52 * which is used to parse the content of the PI. 53 * 54 * @param aName the name of the attribute to get the value for 55 * @param aValue [out] the value for the attribute with name specified in 56 * aAttribute. Empty if the attribute isn't present. 57 */ 58 bool GetAttrValue(nsAtom* aName, nsAString& aValue); 59 60 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override; 61 }; 62 63 } // namespace dom 64 } // namespace mozilla 65 66 /** 67 * aNodeInfoManager must not be null. 68 */ 69 already_AddRefed<mozilla::dom::ProcessingInstruction> 70 NS_NewXMLProcessingInstruction(nsNodeInfoManager* aNodeInfoManager, 71 const nsAString& aTarget, 72 const nsAString& aData); 73 74 #endif // mozilla_dom_ProcessingInstruction_h 75