inDOMView.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 __inDOMView_h__
  5. #define __inDOMView_h__
  6. #include "inIDOMView.h"
  7. #include "inIDOMUtils.h"
  8. #include "nsITreeView.h"
  9. #include "nsITreeSelection.h"
  10. #include "nsStubMutationObserver.h"
  11. #include "nsIDOMNode.h"
  12. #include "nsIDOMDocument.h"
  13. #include "nsTArray.h"
  14. #include "nsCOMArray.h"
  15. #include "nsCOMPtr.h"
  16. class inDOMViewNode;
  17. class nsIDOMMozNamedAttrMap;
  18. class inDOMView : public inIDOMView,
  19. public nsITreeView,
  20. public nsStubMutationObserver
  21. {
  22. public:
  23. NS_DECL_ISUPPORTS
  24. NS_DECL_INIDOMVIEW
  25. NS_DECL_NSITREEVIEW
  26. inDOMView();
  27. // nsIMutationObserver
  28. NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
  29. NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
  30. NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
  31. NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
  32. NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
  33. protected:
  34. virtual ~inDOMView();
  35. nsCOMPtr<nsITreeBoxObject> mTree;
  36. nsCOMPtr<nsITreeSelection> mSelection;
  37. nsCOMPtr<inIDOMUtils> mDOMUtils;
  38. bool mShowAnonymous;
  39. bool mShowSubDocuments;
  40. bool mShowWhitespaceNodes;
  41. bool mShowAccessibleNodes;
  42. uint32_t mWhatToShow;
  43. nsCOMPtr<nsIDOMNode> mRootNode;
  44. nsCOMPtr<nsIDOMDocument> mRootDocument;
  45. nsTArray<inDOMViewNode*> mNodes;
  46. inDOMViewNode* GetNodeAt(int32_t aIndex);
  47. int32_t GetRowCount();
  48. int32_t NodeToRow(inDOMViewNode* aNode);
  49. bool RowOutOfBounds(int32_t aRow, int32_t aCount);
  50. inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent);
  51. void AppendNode(inDOMViewNode* aNode);
  52. void InsertNode(inDOMViewNode* aNode, int32_t aIndex);
  53. void RemoveNode(int32_t aIndex);
  54. void ReplaceNode(inDOMViewNode* aNode, int32_t aIndex);
  55. void InsertNodes(nsTArray<inDOMViewNode*>& aNodes, int32_t aIndex);
  56. void RemoveNodes(int32_t aIndex, int32_t aCount);
  57. void RemoveAllNodes();
  58. void ExpandNode(int32_t aRow);
  59. void CollapseNode(int32_t aRow);
  60. nsresult RowToNode(int32_t aRow, inDOMViewNode** aNode);
  61. nsresult NodeToRow(nsIDOMNode* aNode, int32_t* aRow);
  62. void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter);
  63. void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore);
  64. void RemoveLink(inDOMViewNode* aNode);
  65. void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
  66. nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult);
  67. nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
  68. nsresult AppendAttrsToArray(nsIDOMMozNamedAttrMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
  69. nsresult GetFirstDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
  70. nsresult GetLastDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
  71. nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling);
  72. };
  73. // {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E}
  74. #define IN_DOMVIEW_CID \
  75. { 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } }
  76. #endif // __inDOMView_h__