Bug 1884032 [wpt PR 44942] - [css-color] add missing colorscheme-aware tests, a=testonly
[gecko.git] / dom / xul / XULPersist.h
blob80cdac5dee4cd71308948ca279384be1bc3c831f
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_XULPersist_h
8 #define mozilla_dom_XULPersist_h
10 #include "nsStubDocumentObserver.h"
12 #ifndef MOZ_NEW_XULSTORE
13 # include "nsCOMPtr.h"
14 class nsIXULStore;
15 #endif
17 template <typename T>
18 class nsCOMArray;
20 namespace mozilla::dom {
22 /**
23 * This class synchronizes element attributes (such as window sizing) with the
24 * live elements in a Document and with the XULStore. The XULStore persists
25 * these attributes to the file system. This class is created and owned by the
26 * Document and must only be created in the parent process. It only presists
27 * chrome document element attributes.
29 class XULPersist final : public nsStubDocumentObserver {
30 public:
31 NS_DECL_ISUPPORTS
33 explicit XULPersist(Document* aDocument);
34 void Init();
35 void DropDocumentReference();
37 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
39 protected:
40 void Persist(mozilla::dom::Element* aElement, nsAtom* aAttribute);
42 private:
43 ~XULPersist();
44 nsresult ApplyPersistentAttributes();
45 nsresult ApplyPersistentAttributesToElements(const nsAString& aID,
46 const nsAString& aDocURI,
47 nsCOMArray<Element>& aElements);
49 nsCOMPtr<nsIXULStore> mLocalStore;
51 // A weak pointer to our document. Nulled out by DropDocumentReference.
52 Document* MOZ_NON_OWNING_REF mDocument;
55 } // namespace mozilla::dom
57 #endif // mozilla_dom_XULPersist_h