BoxObject.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_BoxObject_h__
  6. #define mozilla_dom_BoxObject_h__
  7. #include "mozilla/Attributes.h"
  8. #include "mozilla/ErrorResult.h"
  9. #include "nsCOMPtr.h"
  10. #include "nsIBoxObject.h"
  11. #include "nsPIBoxObject.h"
  12. #include "nsPoint.h"
  13. #include "nsAutoPtr.h"
  14. #include "nsHashKeys.h"
  15. #include "nsInterfaceHashtable.h"
  16. #include "nsCycleCollectionParticipant.h"
  17. #include "nsWrapperCache.h"
  18. #include "nsRect.h"
  19. class nsIFrame;
  20. class nsIPresShell;
  21. namespace mozilla {
  22. namespace dom {
  23. class Element;
  24. class BoxObject : public nsPIBoxObject,
  25. public nsWrapperCache
  26. {
  27. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  28. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BoxObject)
  29. NS_DECL_NSIBOXOBJECT
  30. public:
  31. BoxObject();
  32. // nsPIBoxObject
  33. virtual nsresult Init(nsIContent* aContent) override;
  34. virtual void Clear() override;
  35. virtual void ClearCachedValues() override;
  36. nsIFrame* GetFrame(bool aFlushLayout);
  37. nsIPresShell* GetPresShell(bool aFlushLayout);
  38. nsresult GetOffsetRect(nsIntRect& aRect);
  39. nsresult GetScreenPosition(nsIntPoint& aPoint);
  40. // Given a parent frame and a child frame, find the frame whose
  41. // next sibling is the given child frame and return its element
  42. static nsresult GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
  43. nsIDOMElement** aResult);
  44. // WebIDL (wraps old impls)
  45. nsIContent* GetParentObject() const;
  46. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  47. Element* GetElement() const;
  48. int32_t X();
  49. int32_t Y();
  50. int32_t GetScreenX(ErrorResult& aRv);
  51. int32_t GetScreenY(ErrorResult& aRv);
  52. int32_t Width();
  53. int32_t Height();
  54. already_AddRefed<nsISupports> GetPropertyAsSupports(const nsAString& propertyName);
  55. void SetPropertyAsSupports(const nsAString& propertyName, nsISupports* value);
  56. void GetProperty(const nsAString& propertyName, nsString& aRetVal, ErrorResult& aRv);
  57. void SetProperty(const nsAString& propertyName, const nsAString& propertyValue);
  58. void RemoveProperty(const nsAString& propertyName);
  59. already_AddRefed<Element> GetParentBox();
  60. already_AddRefed<Element> GetFirstChild();
  61. already_AddRefed<Element> GetLastChild();
  62. already_AddRefed<Element> GetNextSibling();
  63. already_AddRefed<Element> GetPreviousSibling();
  64. protected:
  65. virtual ~BoxObject();
  66. nsAutoPtr<nsInterfaceHashtable<nsStringHashKey,nsISupports> > mPropertyTable; //[OWNER]
  67. nsIContent* mContent; // [WEAK]
  68. };
  69. } // namespace dom
  70. } // namespace mozilla
  71. #endif