no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / forms / ListMutationObserver.h
blob8c81077fb63ac09bbbf5bebf81b49111295c7f70
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_ListMutationObserver_h
8 #define mozilla_ListMutationObserver_h
10 #include "IDTracker.h"
11 #include "nsStubMutationObserver.h"
13 class nsIFrame;
15 namespace mozilla {
17 namespace dom {
18 class HTMLInputElement;
19 } // namespace dom
21 /**
22 * ListMutationObserver
23 * This class invalidates paint for the input element's frame when the content
24 * of its @list changes, or when the @list ID identifies a different element. It
25 * does *not* invalidate paint when the @list attribute itself changes.
28 class ListMutationObserver final : public nsStubMutationObserver,
29 public dom::IDTracker {
30 public:
31 explicit ListMutationObserver(nsIFrame& aOwningElementFrame,
32 bool aRepaint = false)
33 : mOwningElementFrame(&aOwningElementFrame) {
34 // We can skip invalidating paint if the frame is still being initialized.
35 Attach(aRepaint);
38 NS_DECL_ISUPPORTS
40 // We need to invalidate paint when the list or its options change.
41 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
42 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
43 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
44 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
45 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
47 /**
48 * Triggered when the same @list ID identifies a different element than
49 * before.
51 void ElementChanged(dom::Element* aFrom, dom::Element* aTo) override;
53 void Attach(bool aRepaint = true);
54 void Detach();
55 void AddObserverIfNeeded();
56 void RemoveObserverIfNeeded(dom::Element* aList);
57 void RemoveObserverIfNeeded() { RemoveObserverIfNeeded(get()); }
58 dom::HTMLInputElement& InputElement() const;
60 private:
61 ~ListMutationObserver();
63 nsIFrame* mOwningElementFrame;
65 } // namespace mozilla
67 #endif // mozilla_ListMutationObserver_h