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 public: nsBrowserElement()35 nsBrowserElement() {} ~nsBrowserElement()36 virtual ~nsBrowserElement() {} 37 38 void SendMouseEvent(const nsAString& aType, uint32_t aX, uint32_t aY, 39 uint32_t aButton, uint32_t aClickCount, 40 uint32_t aModifiers, ErrorResult& aRv); 41 void SendTouchEvent(const nsAString& aType, 42 const dom::Sequence<uint32_t>& aIdentifiers, 43 const dom::Sequence<int32_t>& aX, 44 const dom::Sequence<int32_t>& aY, 45 const dom::Sequence<uint32_t>& aRx, 46 const dom::Sequence<uint32_t>& aRy, 47 const dom::Sequence<float>& aRotationAngles, 48 const dom::Sequence<float>& aForces, uint32_t aCount, 49 uint32_t aModifiers, ErrorResult& aRv); 50 void GoBack(ErrorResult& aRv); 51 void GoForward(ErrorResult& aRv); 52 void Reload(bool aHardReload, ErrorResult& aRv); 53 void Stop(ErrorResult& aRv); 54 55 already_AddRefed<dom::DOMRequest> Download( 56 const nsAString& aUrl, const dom::BrowserElementDownloadOptions& options, 57 ErrorResult& aRv); 58 59 already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv); 60 61 already_AddRefed<dom::DOMRequest> GetScreenshot(uint32_t aWidth, 62 uint32_t aHeight, 63 const nsAString& aMimeType, 64 ErrorResult& aRv); 65 66 void Zoom(float aZoom, ErrorResult& aRv); 67 68 already_AddRefed<dom::DOMRequest> GetCanGoBack(ErrorResult& aRv); 69 already_AddRefed<dom::DOMRequest> GetCanGoForward(ErrorResult& aRv); 70 already_AddRefed<dom::DOMRequest> GetContentDimensions(ErrorResult& aRv); 71 72 void FindAll(const nsAString& aSearchString, 73 dom::BrowserFindCaseSensitivity aCaseSensitivity, 74 ErrorResult& aRv); 75 void FindNext(dom::BrowserFindDirection aDirection, ErrorResult& aRv); 76 void ClearMatch(ErrorResult& aRv); 77 78 void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener, 79 ErrorResult& aRv); 80 void RemoveNextPaintListener( 81 dom::BrowserElementNextPaintEventCallback& listener, ErrorResult& aRv); 82 83 already_AddRefed<dom::DOMRequest> ExecuteScript( 84 const nsAString& aScript, 85 const dom::BrowserElementExecuteScriptOptions& aOptions, 86 ErrorResult& aRv); 87 88 already_AddRefed<dom::DOMRequest> GetWebManifest(ErrorResult& aRv); 89 90 protected: 91 NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0; 92 93 void InitBrowserElementAPI(); 94 void DestroyBrowserElementFrameScripts(); 95 nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI; 96 97 private: 98 bool IsBrowserElementOrThrow(ErrorResult& aRv); 99 }; 100 101 } // namespace mozilla 102 103 #endif // nsBrowserElement_h 104