Line data Source code
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 :
6 : #ifndef mozilla_dom_BoxObject_h__
7 : #define mozilla_dom_BoxObject_h__
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "mozilla/ErrorResult.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsIBoxObject.h"
13 : #include "nsPIBoxObject.h"
14 : #include "nsPoint.h"
15 : #include "nsAutoPtr.h"
16 : #include "nsHashKeys.h"
17 : #include "nsInterfaceHashtable.h"
18 : #include "nsCycleCollectionParticipant.h"
19 : #include "nsWrapperCache.h"
20 : #include "nsRect.h"
21 :
22 : class nsIFrame;
23 : class nsIPresShell;
24 :
25 : namespace mozilla {
26 : namespace dom {
27 :
28 : class Element;
29 :
30 : class BoxObject : public nsPIBoxObject,
31 : public nsWrapperCache
32 : {
33 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
34 222 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BoxObject)
35 : NS_DECL_NSIBOXOBJECT
36 :
37 : public:
38 : BoxObject();
39 :
40 : // nsPIBoxObject
41 : virtual nsresult Init(nsIContent* aContent) override;
42 : virtual void Clear() override;
43 : virtual void ClearCachedValues() override;
44 :
45 : nsIFrame* GetFrame(bool aFlushLayout);
46 : nsIPresShell* GetPresShell(bool aFlushLayout);
47 : nsresult GetOffsetRect(nsIntRect& aRect);
48 : nsresult GetScreenPosition(nsIntPoint& aPoint);
49 :
50 : // Given a parent frame and a child frame, find the frame whose
51 : // next sibling is the given child frame and return its element
52 : static nsresult GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
53 : nsIDOMElement** aResult);
54 :
55 : // WebIDL (wraps old impls)
56 : nsIContent* GetParentObject() const;
57 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
58 :
59 : Element* GetElement() const;
60 :
61 : int32_t X();
62 : int32_t Y();
63 : int32_t GetScreenX(ErrorResult& aRv);
64 : int32_t GetScreenY(ErrorResult& aRv);
65 : int32_t Width();
66 : int32_t Height();
67 :
68 : already_AddRefed<nsISupports> GetPropertyAsSupports(const nsAString& propertyName);
69 : void SetPropertyAsSupports(const nsAString& propertyName, nsISupports* value);
70 : void GetProperty(const nsAString& propertyName, nsString& aRetVal, ErrorResult& aRv);
71 : void SetProperty(const nsAString& propertyName, const nsAString& propertyValue);
72 : void RemoveProperty(const nsAString& propertyName);
73 :
74 : already_AddRefed<Element> GetParentBox();
75 : already_AddRefed<Element> GetFirstChild();
76 : already_AddRefed<Element> GetLastChild();
77 : already_AddRefed<Element> GetNextSibling();
78 : already_AddRefed<Element> GetPreviousSibling();
79 :
80 : protected:
81 : virtual ~BoxObject();
82 :
83 : nsAutoPtr<nsInterfaceHashtable<nsStringHashKey,nsISupports> > mPropertyTable; //[OWNER]
84 :
85 : nsIContent* mContent; // [WEAK]
86 : };
87 :
88 : } // namespace dom
89 : } // namespace mozilla
90 :
91 : #endif
|