Bug 1756164: part 2) Document the order of the external clipboard formats and remove...
[gecko.git] / dom / xml / XMLStylesheetProcessingInstruction.h
blob197358c091bd4d88028d96c20af015524e28ea40
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/. */
7 #ifndef mozilla_dom_XMLStylesheetProcessingInstruction_h
8 #define mozilla_dom_XMLStylesheetProcessingInstruction_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/Unused.h"
12 #include "mozilla/dom/LinkStyle.h"
13 #include "mozilla/dom/ProcessingInstruction.h"
14 #include "nsIURI.h"
16 namespace mozilla {
17 namespace dom {
19 class XMLStylesheetProcessingInstruction final : public ProcessingInstruction,
20 public LinkStyle {
21 public:
22 XMLStylesheetProcessingInstruction(
23 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
24 const nsAString& aData)
25 : ProcessingInstruction(std::move(aNodeInfo), aData) {}
27 XMLStylesheetProcessingInstruction(nsNodeInfoManager* aNodeInfoManager,
28 const nsAString& aData)
29 : ProcessingInstruction(
30 aNodeInfoManager->GetNodeInfo(
31 nsGkAtoms::processingInstructionTagName, nullptr,
32 kNameSpaceID_None, PROCESSING_INSTRUCTION_NODE,
33 nsGkAtoms::xml_stylesheet),
34 aData) {}
36 // CC
37 NS_DECL_ISUPPORTS_INHERITED
38 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLStylesheetProcessingInstruction,
39 ProcessingInstruction)
41 // nsINode
42 virtual void SetNodeValueInternal(const nsAString& aNodeValue,
43 mozilla::ErrorResult& aError) override;
45 // nsIContent
46 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
47 virtual void UnbindFromTree(bool aNullParent = true) override;
49 /**
50 * Tells this processing instruction to use a different base URI. This is used
51 * for proper loading of xml-stylesheet processing instructions in XUL
52 * overlays and is only currently used by nsXMLStylesheetPI.
54 * @param aNewBaseURI the new base URI, nullptr to use the default base URI.
56 void OverrideBaseURI(nsIURI* aNewBaseURI);
58 // LinkStyle
59 void GetCharset(nsAString& aCharset) override;
61 virtual void SetData(const nsAString& aData,
62 mozilla::ErrorResult& rv) override {
63 CharacterData::SetData(aData, rv);
64 if (rv.Failed()) {
65 return;
67 Unused << UpdateStyleSheetInternal(nullptr, nullptr, ForceUpdate::Yes);
70 protected:
71 virtual ~XMLStylesheetProcessingInstruction();
73 nsCOMPtr<nsIURI> mOverriddenBaseURI;
75 nsIContent& AsContent() final { return *this; }
76 const LinkStyle* AsLinkStyle() const final { return this; }
77 Maybe<SheetInfo> GetStyleSheetInfo() final;
79 already_AddRefed<CharacterData> CloneDataNode(
80 mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const final;
83 } // namespace dom
84 } // namespace mozilla
86 #endif // mozilla_dom_XMLStylesheetProcessingInstruction_h