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