UnbindContext.h (1546B)
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 /* State that is passed down to UnbindToTree. */ 8 9 #ifndef mozilla_dom_UnbindContext_h__ 10 #define mozilla_dom_UnbindContext_h__ 11 12 #include "mozilla/Attributes.h" 13 #include "nsINode.h" 14 15 namespace mozilla::dom { 16 17 struct MOZ_STACK_CLASS UnbindContext final { 18 // The root of the subtree being unbound. 19 nsINode& Root() const { return mRoot; } 20 // Whether we're the root of the subtree being unbound. 21 bool IsUnbindRoot(const nsINode* aNode) const { return &mRoot == aNode; } 22 // The parent node of the subtree we're unbinding from. 23 nsINode* GetOriginalSubtreeParent() const { return mOriginalParent; } 24 25 explicit UnbindContext(nsINode& aRoot, const BatchRemovalState* aBatchState) 26 : mRoot(aRoot), 27 mOriginalParent(aRoot.GetParentNode()), 28 mBatchState(aBatchState) {} 29 30 void SetIsMove(bool aIsMove) { mIsMove = aIsMove; } 31 32 bool IsMove() const { return mIsMove; } 33 34 const BatchRemovalState* GetBatchRemovalState() const { return mBatchState; } 35 36 private: 37 nsINode& mRoot; 38 nsINode* const mOriginalParent; 39 const BatchRemovalState* const mBatchState = nullptr; 40 41 // If set, we're moving the shadow-including inclusive ancestor. 42 bool mIsMove = false; 43 }; 44 45 } // namespace mozilla::dom 46 47 #endif