inDeepTreeWalker.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef __inDeepTreeWalker_h___
  5. #define __inDeepTreeWalker_h___
  6. #include "inIDeepTreeWalker.h"
  7. #include "nsCOMPtr.h"
  8. #include "nsIDOMNode.h"
  9. #include "nsTArray.h"
  10. class nsINodeList;
  11. class inIDOMUtils;
  12. class inDeepTreeWalker final : public inIDeepTreeWalker
  13. {
  14. public:
  15. NS_DECL_ISUPPORTS
  16. NS_DECL_INIDEEPTREEWALKER
  17. inDeepTreeWalker();
  18. nsresult SetCurrentNode(nsIDOMNode* aCurrentNode,
  19. nsINodeList* aSiblings);
  20. protected:
  21. virtual ~inDeepTreeWalker();
  22. already_AddRefed<nsIDOMNode> GetParent();
  23. nsresult EdgeChild(nsIDOMNode** _retval, bool aReverse);
  24. bool mShowAnonymousContent;
  25. bool mShowSubDocuments;
  26. bool mShowDocumentsAsNodes;
  27. // The root node. previousNode and parentNode will return
  28. // null from here.
  29. nsCOMPtr<nsIDOMNode> mRoot;
  30. nsCOMPtr<nsIDOMNode> mCurrentNode;
  31. nsCOMPtr<inIDOMUtils> mDOMUtils;
  32. // We cache the siblings of mCurrentNode as a list of nodes.
  33. // Notes: normally siblings are all the children of the parent
  34. // of mCurrentNode (that are interesting for use for the walk)
  35. // and mCurrentIndex is the index of mCurrentNode in that list
  36. // But if mCurrentNode is a (sub) document then instead of
  37. // storing a list that has only one element (the document)
  38. // and setting mCurrentIndex to null, we set mSibilings to null.
  39. // The reason for this is purely technical, since nsINodeList is
  40. // nsIContent based hence we cannot use it to store a document node.
  41. nsCOMPtr<nsINodeList> mSiblings;
  42. // Index of mCurrentNode in the mSiblings list.
  43. int32_t mCurrentIndex;
  44. // Currently unused. Should be a filter for nodes.
  45. uint32_t mWhatToShow;
  46. };
  47. // {BFCB82C2-5611-4318-90D6-BAF4A7864252}
  48. #define IN_DEEPTREEWALKER_CID \
  49. { 0xbfcb82c2, 0x5611, 0x4318, { 0x90, 0xd6, 0xba, 0xf4, 0xa7, 0x86, 0x42, 0x52 } }
  50. #endif // __inDeepTreeWalker_h___