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 #ifndef XULFrameElement_h__
8 #define XULFrameElement_h__
9 
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/Nullable.h"
12 #include "mozilla/dom/WindowProxyHolder.h"
13 #include "js/TypeDecls.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsIOpenWindowInfo.h"
16 #include "nsWrapperCache.h"
17 #include "nsString.h"
18 #include "nsXULElement.h"
19 #include "nsFrameLoaderOwner.h"
20 
21 class nsIWebNavigation;
22 class nsFrameLoader;
23 
24 namespace mozilla {
25 class ErrorResult;
26 
27 namespace dom {
28 
29 class BrowsingContext;
30 
31 class XULFrameElement final : public nsXULElement, public nsFrameLoaderOwner {
32  public:
XULFrameElement(already_AddRefed<mozilla::dom::NodeInfo> && aNodeInfo)33   explicit XULFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
34       : nsXULElement(std::move(aNodeInfo)) {}
35 
36   NS_DECL_ISUPPORTS_INHERITED
37   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULFrameElement, nsXULElement)
38 
39   // XULFrameElement.webidl
40   nsDocShell* GetDocShell();
41   already_AddRefed<nsIWebNavigation> GetWebNavigation();
42   Nullable<WindowProxyHolder> GetContentWindow();
43   Document* GetContentDocument();
44   uint64_t BrowserId();
45   nsIOpenWindowInfo* GetOpenWindowInfo() const;
46   void SetOpenWindowInfo(nsIOpenWindowInfo* aInfo);
47 
48   void SwapFrameLoaders(mozilla::dom::HTMLIFrameElement& aOtherLoaderOwner,
49                         mozilla::ErrorResult& rv);
50   void SwapFrameLoaders(XULFrameElement& aOtherLoaderOwner,
51                         mozilla::ErrorResult& rv);
52   void SwapFrameLoaders(nsFrameLoaderOwner* aOtherLoaderOwner,
53                         mozilla::ErrorResult& rv);
54 
55   // nsIContent
56   virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
57   virtual void UnbindFromTree(bool aNullParent) override;
58   virtual void DestroyContent() override;
59 
60   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
61                                 const nsAttrValue* aValue,
62                                 const nsAttrValue* aOldValue,
63                                 nsIPrincipal* aSubjectPrincipal,
64                                 bool aNotify) override;
65 
66   NS_IMPL_FROMNODE_HELPER(XULFrameElement,
67                           IsAnyOfXULElements(nsGkAtoms::iframe,
68                                              nsGkAtoms::browser,
69                                              nsGkAtoms::editor))
70 
71  protected:
72   virtual ~XULFrameElement() = default;
73 
74   JSObject* WrapNode(JSContext* aCx,
75                      JS::Handle<JSObject*> aGivenProto) override;
76 
77   void LoadSrc();
78 
79  private:
80   nsCOMPtr<nsIOpenWindowInfo> mOpenWindowInfo;
81 };
82 
83 }  // namespace dom
84 }  // namespace mozilla
85 
86 #endif  // XULFrameElement_h
87