Bug 1044736 - Part 1. Add BrowserElement.webidl and stub implementation. r=bz
authorKan-Ru Chen (陳侃如) <kanru@kanru.info>
Wed, 12 Nov 2014 19:27:31 +0800
changeset 215145 78aacc35b4e7bb3d5221634f315621b298d88f05
parent 215144 e203b87d8ce36a1c23361f0aadbeeb66fcd66485
child 215146 c7c9170ab299698df5fa4ea53e98d39795efeaac
push id12091
push userkchen@mozilla.com
push dateWed, 12 Nov 2014 11:27:55 +0000
treeherderb2g-inbound@b1a6ecfca674 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1044736
milestone36.0a1
Bug 1044736 - Part 1. Add BrowserElement.webidl and stub implementation. r=bz
dom/html/moz.build
dom/html/nsBrowserElement.cpp
dom/html/nsBrowserElement.h
dom/html/nsGenericHTMLFrameElement.h
dom/webidl/BrowserElement.webidl
dom/webidl/HTMLIFrameElement.webidl
dom/webidl/moz.build
--- a/dom/html/moz.build
+++ b/dom/html/moz.build
@@ -107,16 +107,17 @@ EXPORTS.mozilla.dom += [
     'HTMLTextAreaElement.h',
     'HTMLTimeElement.h',
     'HTMLTitleElement.h',
     'HTMLTrackElement.h',
     'HTMLUnknownElement.h',
     'HTMLVideoElement.h',
     'ImageDocument.h',
     'MediaError.h',
+    'nsBrowserElement.h',
     'RadioNodeList.h',
     'TextTrackManager.h',
     'TimeRanges.h',
     'UndoManager.h',
     'ValidityState.h',
 ]
 
 UNIFIED_SOURCES += [
@@ -185,16 +186,17 @@ UNIFIED_SOURCES += [
     'HTMLTimeElement.cpp',
     'HTMLTitleElement.cpp',
     'HTMLTrackElement.cpp',
     'HTMLUnknownElement.cpp',
     'HTMLVideoElement.cpp',
     'ImageDocument.cpp',
     'MediaDocument.cpp',
     'MediaError.cpp',
+    'nsBrowserElement.cpp',
     'nsDOMStringMap.cpp',
     'nsFormSubmission.cpp',
     'nsGenericHTMLElement.cpp',
     'nsGenericHTMLFrameElement.cpp',
     'nsHTMLContentSink.cpp',
     'nsHTMLDNSPrefetch.cpp',
     'nsHTMLDocument.cpp',
     'nsIConstraintValidation.cpp',
new file mode 100644
--- /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<dom::DOMRequest>
+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<uint32_t>& aIdentifiers,
+                                 const dom::Sequence<int32_t>& aXs,
+                                 const dom::Sequence<int32_t>& aYs,
+                                 const dom::Sequence<uint32_t>& aRxs,
+                                 const dom::Sequence<uint32_t>& aRys,
+                                 const dom::Sequence<float>& aRotationAngles,
+                                 const dom::Sequence<float>& 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<dom::DOMRequest>
+nsBrowserElement::Download(const nsAString& aUrl,
+                           const dom::BrowserElementDownloadOptions& aOptions,
+                           ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return nullptr;
+}
+
+already_AddRefed<dom::DOMRequest>
+nsBrowserElement::PurgeHistory(ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return nullptr;
+}
+
+already_AddRefed<dom::DOMRequest>
+nsBrowserElement::GetScreenshot(uint32_t aWidth,
+                                uint32_t aHeight,
+                                const dom::Optional<nsAString>& 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<dom::DOMRequest>
+nsBrowserElement::GetCanGoBack(ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return nullptr;
+}
+
+already_AddRefed<dom::DOMRequest>
+nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return nullptr;
+}
+
+already_AddRefed<dom::DOMRequest>
+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<dom::DOMRequest>
+nsBrowserElement::SetInputMethodActive(bool aIsActive,
+                                       ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+  return nullptr;
+}
+
+} // namespace mozilla
new file mode 100644
--- /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<dom::DOMRequest> 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<uint32_t>& aIdentifiers,
+                      const dom::Sequence<int32_t>& aX,
+                      const dom::Sequence<int32_t>& aY,
+                      const dom::Sequence<uint32_t>& aRx,
+                      const dom::Sequence<uint32_t>& aRy,
+                      const dom::Sequence<float>& aRotationAngles,
+                      const dom::Sequence<float>& 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<dom::DOMRequest>
+  Download(const nsAString& aUrl,
+           const dom::BrowserElementDownloadOptions& options,
+           ErrorResult& aRv);
+
+  already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv);
+
+  already_AddRefed<dom::DOMRequest>
+  GetScreenshot(uint32_t aWidth,
+                uint32_t aHeight,
+                const dom::Optional<nsAString>& aMimeType,
+                ErrorResult& aRv);
+
+  void Zoom(float aZoom, ErrorResult& aRv);
+
+  already_AddRefed<dom::DOMRequest> GetCanGoBack(ErrorResult& aRv);
+  already_AddRefed<dom::DOMRequest> GetCanGoForward(ErrorResult& aRv);
+  already_AddRefed<dom::DOMRequest> GetContentDimensions(ErrorResult& aRv);
+
+  void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
+                            ErrorResult& aRv);
+  void RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
+                               ErrorResult& aRv);
+
+  already_AddRefed<dom::DOMRequest> SetInputMethodActive(bool isActive,
+                                                         ErrorResult& aRv);
+};
+
+} // namespace mozilla
+
+#endif // nsBrowserElement_h
--- a/dom/html/nsGenericHTMLFrameElement.h
+++ b/dom/html/nsGenericHTMLFrameElement.h
@@ -4,32 +4,34 @@
 /* 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 nsGenericHTMLFrameElement_h
 #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;
 
 /**
  * A helper class for frame elements
  */
 class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
                                   public nsElementFrameLoaderOwner,
+                                  public mozilla::nsBrowserElement,
                                   public nsIMozBrowserFrame
 {
 public:
   nsGenericHTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                             mozilla::dom::FromParser aFromParser)
     : nsGenericHTMLElement(aNodeInfo)
     , nsElementFrameLoaderOwner(aFromParser)
   {
new file mode 100644
--- /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<unsigned long> identifiers,
+                      sequence<long> x,
+                      sequence<long> y,
+                      sequence<unsigned long> rx,
+                      sequence<unsigned long> ry,
+                      sequence<float> rotationAngles,
+                      sequence<float> 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);
+};
--- a/dom/webidl/HTMLIFrameElement.webidl
+++ b/dom/webidl/HTMLIFrameElement.webidl
@@ -58,8 +58,9 @@ partial interface HTMLIFrameElement {
 
 partial interface HTMLIFrameElement {
   // nsIMozBrowserFrame
   [ChromeOnly]
   readonly attribute DOMString appManifestURL;
 };
 
 HTMLIFrameElement implements MozFrameLoaderOwner;
+HTMLIFrameElement implements BrowserElement;
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -50,16 +50,17 @@ WEBIDL_FILES = [
     'AutocompleteInfo.webidl',
     'BarProp.webidl',
     'BatteryManager.webidl',
     'BeforeAfterKeyboardEvent.webidl',
     'BeforeUnloadEvent.webidl',
     'BiquadFilterNode.webidl',
     'Blob.webidl',
     'BoxObject.webidl',
+    'BrowserElement.webidl',
     'BrowserElementDictionaries.webidl',
     'CallsList.webidl',
     'CameraCapabilities.webidl',
     'CameraControl.webidl',
     'CameraManager.webidl',
     'CameraUtil.webidl',
     'CanvasRenderingContext2D.webidl',
     'CaretPosition.webidl',