Line data Source code
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 file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef nsBrowserElement_h
8 : #define nsBrowserElement_h
9 :
10 : #include "mozilla/dom/BindingDeclarations.h"
11 :
12 : #include "nsCOMPtr.h"
13 : #include "nsIBrowserElementAPI.h"
14 :
15 : class nsFrameLoader;
16 :
17 : namespace mozilla {
18 :
19 : namespace dom {
20 : struct BrowserElementDownloadOptions;
21 : struct BrowserElementExecuteScriptOptions;
22 : class BrowserElementNextPaintEventCallback;
23 : class DOMRequest;
24 : enum class BrowserFindCaseSensitivity: uint8_t;
25 : enum class BrowserFindDirection: uint8_t;
26 : } // namespace dom
27 :
28 : class ErrorResult;
29 :
30 : /**
31 : * A helper class for browser-element frames
32 : */
33 : class nsBrowserElement
34 : {
35 : public:
36 0 : nsBrowserElement() {}
37 0 : virtual ~nsBrowserElement() {}
38 :
39 : void SendMouseEvent(const nsAString& aType,
40 : uint32_t aX,
41 : uint32_t aY,
42 : uint32_t aButton,
43 : uint32_t aClickCount,
44 : uint32_t aModifiers,
45 : ErrorResult& aRv);
46 : void SendTouchEvent(const nsAString& aType,
47 : const dom::Sequence<uint32_t>& aIdentifiers,
48 : const dom::Sequence<int32_t>& aX,
49 : const dom::Sequence<int32_t>& aY,
50 : const dom::Sequence<uint32_t>& aRx,
51 : const dom::Sequence<uint32_t>& aRy,
52 : const dom::Sequence<float>& aRotationAngles,
53 : const dom::Sequence<float>& aForces,
54 : uint32_t aCount,
55 : uint32_t aModifiers,
56 : ErrorResult& aRv);
57 : void GoBack(ErrorResult& aRv);
58 : void GoForward(ErrorResult& aRv);
59 : void Reload(bool aHardReload, ErrorResult& aRv);
60 : void Stop(ErrorResult& aRv);
61 :
62 : already_AddRefed<dom::DOMRequest>
63 : Download(const nsAString& aUrl,
64 : const dom::BrowserElementDownloadOptions& options,
65 : ErrorResult& aRv);
66 :
67 : already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv);
68 :
69 : already_AddRefed<dom::DOMRequest>
70 : GetScreenshot(uint32_t aWidth,
71 : uint32_t aHeight,
72 : const nsAString& aMimeType,
73 : ErrorResult& aRv);
74 :
75 : void Zoom(float aZoom, ErrorResult& aRv);
76 :
77 : already_AddRefed<dom::DOMRequest> GetCanGoBack(ErrorResult& aRv);
78 : already_AddRefed<dom::DOMRequest> GetCanGoForward(ErrorResult& aRv);
79 : already_AddRefed<dom::DOMRequest> GetContentDimensions(ErrorResult& aRv);
80 :
81 : void FindAll(const nsAString& aSearchString, dom::BrowserFindCaseSensitivity aCaseSensitivity,
82 : ErrorResult& aRv);
83 : void FindNext(dom::BrowserFindDirection aDirection, ErrorResult& aRv);
84 : void ClearMatch(ErrorResult& aRv);
85 :
86 : void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
87 : ErrorResult& aRv);
88 : void RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
89 : ErrorResult& aRv);
90 :
91 : already_AddRefed<dom::DOMRequest> ExecuteScript(const nsAString& aScript,
92 : const dom::BrowserElementExecuteScriptOptions& aOptions,
93 : ErrorResult& aRv);
94 :
95 : already_AddRefed<dom::DOMRequest> GetWebManifest(ErrorResult& aRv);
96 :
97 : protected:
98 : NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
99 :
100 : void InitBrowserElementAPI();
101 : void DestroyBrowserElementFrameScripts();
102 : nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI;
103 :
104 : private:
105 : bool IsBrowserElementOrThrow(ErrorResult& aRv);
106 : };
107 :
108 : } // namespace mozilla
109 :
110 : #endif // nsBrowserElement_h
|