From 81a829d8ee58e0ebfa55e1f30fa56825dd8fb401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Fri, 21 Nov 2014 18:56:27 +0800 Subject: [PATCH] Bug 1044736 - Part 1. Add BrowserElement.webidl and stub implementation. r=bz --- dom/html/moz.build | 2 + dom/html/nsBrowserElement.cpp | 168 +++++++++++++++++++++++++++ dom/html/nsBrowserElement.h | 88 ++++++++++++++ dom/html/nsGenericHTMLFrameElement.h | 10 +- dom/webidl/BrowserElement.webidl | 142 ++++++++++++++++++++++ dom/webidl/HTMLIFrameElement.webidl | 1 + dom/webidl/moz.build | 1 + 7 files changed, 408 insertions(+), 4 deletions(-) create mode 100644 dom/html/nsBrowserElement.cpp create mode 100644 dom/html/nsBrowserElement.h create mode 100644 dom/webidl/BrowserElement.webidl diff --git a/dom/html/moz.build b/dom/html/moz.build index 5b0ea5aec670..cd725e70d2a4 100644 --- a/dom/html/moz.build +++ b/dom/html/moz.build @@ -112,6 +112,7 @@ EXPORTS.mozilla.dom += [ 'HTMLVideoElement.h', 'ImageDocument.h', 'MediaError.h', + 'nsBrowserElement.h', 'RadioNodeList.h', 'TextTrackManager.h', 'TimeRanges.h', @@ -190,6 +191,7 @@ UNIFIED_SOURCES += [ 'ImageDocument.cpp', 'MediaDocument.cpp', 'MediaError.cpp', + 'nsBrowserElement.cpp', 'nsDOMStringMap.cpp', 'nsFormSubmission.cpp', 'nsGenericHTMLElement.cpp', diff --git a/dom/html/nsBrowserElement.cpp b/dom/html/nsBrowserElement.cpp new file mode 100644 index 000000000000..fc14ad3e92f0 --- /dev/null +++ b/dom/html/nsBrowserElement.cpp @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsBrowserElement.h" + +#include "mozilla/dom/BrowserElementBinding.h" +#include "mozilla/dom/DOMRequest.h" +#include "mozilla/Preferences.h" + +namespace mozilla { + +void +nsBrowserElement::SetVisible(bool aVisible, ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +already_AddRefed +nsBrowserElement::GetVisible(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +void +nsBrowserElement::SetActive(bool aVisible, ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +bool +nsBrowserElement::GetActive(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return false; +} + +void +nsBrowserElement::SendMouseEvent(const nsAString& aType, + uint32_t aX, + uint32_t aY, + uint32_t aButton, + uint32_t aClickCount, + uint32_t aModifiers, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::SendTouchEvent(const nsAString& aType, + const dom::Sequence& aIdentifiers, + const dom::Sequence& aXs, + const dom::Sequence& aYs, + const dom::Sequence& aRxs, + const dom::Sequence& aRys, + const dom::Sequence& aRotationAngles, + const dom::Sequence& aForces, + uint32_t aCount, + uint32_t aModifiers, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::GoBack(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::GoForward(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::Reload(bool aHardReload, ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::Stop(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +already_AddRefed +nsBrowserElement::Download(const nsAString& aUrl, + const dom::BrowserElementDownloadOptions& aOptions, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +already_AddRefed +nsBrowserElement::PurgeHistory(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +already_AddRefed +nsBrowserElement::GetScreenshot(uint32_t aWidth, + uint32_t aHeight, + const dom::Optional& aMimeType, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +void +nsBrowserElement::Zoom(float aZoom, ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +already_AddRefed +nsBrowserElement::GetCanGoBack(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +already_AddRefed +nsBrowserElement::GetCanGoForward(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +already_AddRefed +nsBrowserElement::GetContentDimensions(ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +void +nsBrowserElement::AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& aListener, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +void +nsBrowserElement::RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& aListener, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); +} + +already_AddRefed +nsBrowserElement::SetInputMethodActive(bool aIsActive, + ErrorResult& aRv) +{ + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +} + +} // namespace mozilla diff --git a/dom/html/nsBrowserElement.h b/dom/html/nsBrowserElement.h new file mode 100644 index 000000000000..ce5772cd044d --- /dev/null +++ b/dom/html/nsBrowserElement.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsBrowserElement_h +#define nsBrowserElement_h + +#include "mozilla/dom/BindingDeclarations.h" + +#include "nsCOMPtr.h" + +namespace mozilla { + +namespace dom { +struct BrowserElementDownloadOptions; +class BrowserElementNextPaintEventCallback; +class DOMRequest; +} // namespace dom + +class ErrorResult; + +/** + * A helper class for browser-element frames + */ +class nsBrowserElement +{ +public: + void SetVisible(bool aVisible, ErrorResult& aRv); + already_AddRefed GetVisible(ErrorResult& aRv); + void SetActive(bool aActive, ErrorResult& aRv); + bool GetActive(ErrorResult& aRv); + + void SendMouseEvent(const nsAString& aType, + uint32_t aX, + uint32_t aY, + uint32_t aButton, + uint32_t aClickCount, + uint32_t aModifiers, + ErrorResult& aRv); + void SendTouchEvent(const nsAString& aType, + const dom::Sequence& aIdentifiers, + const dom::Sequence& aX, + const dom::Sequence& aY, + const dom::Sequence& aRx, + const dom::Sequence& aRy, + const dom::Sequence& aRotationAngles, + const dom::Sequence& aForces, + uint32_t aCount, + uint32_t aModifiers, + ErrorResult& aRv); + void GoBack(ErrorResult& aRv); + void GoForward(ErrorResult& aRv); + void Reload(bool aHardReload, ErrorResult& aRv); + void Stop(ErrorResult& aRv); + + already_AddRefed + Download(const nsAString& aUrl, + const dom::BrowserElementDownloadOptions& options, + ErrorResult& aRv); + + already_AddRefed PurgeHistory(ErrorResult& aRv); + + already_AddRefed + GetScreenshot(uint32_t aWidth, + uint32_t aHeight, + const dom::Optional& aMimeType, + ErrorResult& aRv); + + void Zoom(float aZoom, ErrorResult& aRv); + + already_AddRefed GetCanGoBack(ErrorResult& aRv); + already_AddRefed GetCanGoForward(ErrorResult& aRv); + already_AddRefed GetContentDimensions(ErrorResult& aRv); + + void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener, + ErrorResult& aRv); + void RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener, + ErrorResult& aRv); + + already_AddRefed SetInputMethodActive(bool isActive, + ErrorResult& aRv); +}; + +} // namespace mozilla + +#endif // nsBrowserElement_h diff --git a/dom/html/nsGenericHTMLFrameElement.h b/dom/html/nsGenericHTMLFrameElement.h index de3fe18a3936..ce89fa8e875b 100644 --- a/dom/html/nsGenericHTMLFrameElement.h +++ b/dom/html/nsGenericHTMLFrameElement.h @@ -9,14 +9,15 @@ #define nsGenericHTMLFrameElement_h #include "mozilla/Attributes.h" +#include "mozilla/ErrorResult.h" +#include "mozilla/dom/nsBrowserElement.h" + #include "nsElementFrameLoaderOwner.h" +#include "nsFrameLoader.h" #include "nsGenericHTMLElement.h" +#include "nsIDOMEventListener.h" #include "nsIFrameLoader.h" #include "nsIMozBrowserFrame.h" -#include "nsIDOMEventListener.h" -#include "mozilla/ErrorResult.h" - -#include "nsFrameLoader.h" class nsXULElement; @@ -25,6 +26,7 @@ class nsXULElement; */ class nsGenericHTMLFrameElement : public nsGenericHTMLElement, public nsElementFrameLoaderOwner, + public mozilla::nsBrowserElement, public nsIMozBrowserFrame { public: diff --git a/dom/webidl/BrowserElement.webidl b/dom/webidl/BrowserElement.webidl new file mode 100644 index 000000000000..a569d8e55ceb --- /dev/null +++ b/dom/webidl/BrowserElement.webidl @@ -0,0 +1,142 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +callback BrowserElementNextPaintEventCallback = void (); + +dictionary BrowserElementDownloadOptions { + DOMString? filename; +}; + +[NoInterfaceObject] +interface BrowserElement { +}; + +BrowserElement implements BrowserElementCommon; +BrowserElement implements BrowserElementPrivileged; + +[NoInterfaceObject] +interface BrowserElementCommon { + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + void setVisible(boolean visible); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + DOMRequest getVisible(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + void setActive(boolean active); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + boolean getActive(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + void addNextPaintListener(BrowserElementNextPaintEventCallback listener); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser embed-widgets"] + void removeNextPaintListener(BrowserElementNextPaintEventCallback listener); +}; + +[NoInterfaceObject] +interface BrowserElementPrivileged { + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void sendMouseEvent(DOMString type, + unsigned long x, + unsigned long y, + unsigned long button, + unsigned long clickCount, + unsigned long modifiers); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + Func="TouchEvent::PrefEnabled", + CheckPermissions="browser"] + void sendTouchEvent(DOMString type, + sequence identifiers, + sequence x, + sequence y, + sequence rx, + sequence ry, + sequence rotationAngles, + sequence forces, + unsigned long count, + unsigned long modifiers); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void goBack(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void goForward(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void reload(optional boolean hardReload = false); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void stop(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest download(DOMString url, + optional BrowserElementDownloadOptions options); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest purgeHistory(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest getScreenshot([EnforceRange] unsigned long width, + [EnforceRange] unsigned long height, + optional DOMString mimeType); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + void zoom(float zoom); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest getCanGoBack(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest getCanGoForward(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest getContentDimensions(); + + [Throws, + Pref="dom.mozBrowserFramesEnabled", + CheckPermissions="browser"] + DOMRequest setInputMethodActive(boolean isActive); +}; diff --git a/dom/webidl/HTMLIFrameElement.webidl b/dom/webidl/HTMLIFrameElement.webidl index a663f7b883d4..ec8e7676f038 100644 --- a/dom/webidl/HTMLIFrameElement.webidl +++ b/dom/webidl/HTMLIFrameElement.webidl @@ -63,3 +63,4 @@ partial interface HTMLIFrameElement { }; HTMLIFrameElement implements MozFrameLoaderOwner; +HTMLIFrameElement implements BrowserElement; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 8b9012ff42d1..52fed21dc962 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -55,6 +55,7 @@ WEBIDL_FILES = [ 'BiquadFilterNode.webidl', 'Blob.webidl', 'BoxObject.webidl', + 'BrowserElement.webidl', 'BrowserElementDictionaries.webidl', 'CallsList.webidl', 'CameraCapabilities.webidl',