Bug 1536174 - Part 2: Add nsDOMWindowUtils API for enabling window recording. r=mstange
authorBas Schouten <bschouten@mozilla.com>
Mon, 18 Mar 2019 19:23:14 +0100
changeset 466525 ffb2e68a6445f991cc6802f0d01ddc209dff51dc
parent 466524 8186704e6d0301fc99812195fe9ecc737298344c
child 466526 fd1779ce4ec71151b3b7a4e0287e5209817024f8
push id35769
push useropoprus@mozilla.com
push dateThu, 28 Mar 2019 10:12:29 +0000
treeherdermozilla-central@d2c82f845bfc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1536174
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1536174 - Part 2: Add nsDOMWindowUtils API for enabling window recording. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D23914
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDOMWindowUtils.h
dom/interfaces/base/nsIDOMWindowUtils.idl
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -256,16 +256,27 @@ WebRenderBridgeChild* nsDOMWindowUtils::
       if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) {
         return wrlm->WrBridge();
       }
     }
   }
   return nullptr;
 }
 
+CompositorBridgeChild* nsDOMWindowUtils::GetCompositorBridge() {
+  if (nsIWidget* widget = GetWidget()) {
+    if (LayerManager* lm = widget->GetLayerManager()) {
+      if (CompositorBridgeChild* cbc = lm->GetCompositorBridgeChild()) {
+        return cbc;
+      }
+    }
+  }
+  return nullptr;
+}
+
 NS_IMETHODIMP
 nsDOMWindowUtils::SyncFlushCompositor() {
   if (nsIWidget* widget = GetWidget()) {
     if (LayerManager* lm = widget->GetLayerManager()) {
       if (KnowsCompositor* kc = lm->AsKnowsCompositor()) {
         kc->SyncWithCompositor();
       }
     }
@@ -4095,16 +4106,28 @@ NS_IMETHODIMP
 nsDOMWindowUtils::WrCapture() {
   if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) {
     wrbc->Capture();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsDOMWindowUtils::SetCompositionRecording(bool aValue) {
+  if (CompositorBridgeChild* cbc = GetCompositorBridge()) {
+    if (aValue) {
+      cbc->SendBeginRecording(TimeStamp::Now());
+    } else {
+      cbc->SendEndRecording();
+    }
+  }
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDOMWindowUtils::SetSystemFont(const nsACString& aFontName) {
   nsIWidget* widget = GetWidget();
   if (!widget) {
     return NS_OK;
   }
 
   nsAutoCString fontName(aFontName);
   return widget->SetSystemFont(fontName);
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -77,16 +77,17 @@ class nsDOMWindowUtils final : public ns
   nsIWidget* GetWidget(nsPoint* aOffset = nullptr);
   nsIWidget* GetWidgetForElement(mozilla::dom::Element* aElement);
 
   nsIPresShell* GetPresShell();
   nsPresContext* GetPresContext();
   mozilla::dom::Document* GetDocument();
   mozilla::layers::LayerTransactionChild* GetLayerTransaction();
   mozilla::layers::WebRenderBridgeChild* GetWebRenderBridge();
+  mozilla::layers::CompositorBridgeChild* GetCompositorBridge();
 
   // Until callers are annotated.
   MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD SendMouseEventCommon(
       const nsAString& aType, float aX, float aY, int32_t aButton,
       int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame,
       float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier,
       bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized,
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1928,16 +1928,21 @@ interface nsIDOMWindowUtils : nsISupport
 
   /**
    * Capture the contents of the current WebRender frame and
    * save them to a folder relative to the current working directory.
    */
   void wrCapture();
 
   /**
+   * Toggle recording of composition on and off.
+   */
+  void setCompositionRecording(in boolean aValue);
+
+  /**
    * Returns whether the document we're associated to has recorded a given CSS
    * property via the use counter mechanism.
    *
    * Throws if there's no document or the property is invalid.
    */
   bool isCssPropertyRecordedInUseCounter(in ACString aProperty);
 
   /**