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"
18 class HTMLInputElement
;
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
{
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.
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
48 * Triggered when the same @list ID identifies a different element than
51 void ElementChanged(dom::Element
* aFrom
, dom::Element
* aTo
) override
;
53 void Attach(bool aRepaint
= true);
55 void AddObserverIfNeeded();
56 void RemoveObserverIfNeeded(dom::Element
* aList
);
57 void RemoveObserverIfNeeded() { RemoveObserverIfNeeded(get()); }
58 dom::HTMLInputElement
& InputElement() const;
61 ~ListMutationObserver();
63 nsIFrame
* mOwningElementFrame
;
65 } // namespace mozilla
67 #endif // mozilla_ListMutationObserver_h