tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FrameUniformityData.cpp (1260B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "FrameUniformityData.h"
      8 
      9 #include "mozilla/TimeStamp.h"
     10 #include "mozilla/dom/APZTestDataBinding.h"
     11 #include "mozilla/dom/ToJSValue.h"
     12 #include "nsTArray.h"
     13 
     14 namespace mozilla {
     15 namespace layers {
     16 
     17 using namespace gfx;
     18 
     19 bool FrameUniformityData::ToJS(JS::MutableHandle<JS::Value> aOutValue,
     20                               JSContext* aContext) {
     21  dom::FrameUniformityResults results;
     22  dom::Sequence<dom::FrameUniformity>& layers =
     23      results.mLayerUniformities.Construct();
     24 
     25  for (const auto& [layerAddr, uniformity] : mUniformities) {
     26    // FIXME: Make this infallible after bug 968520 is done.
     27    MOZ_ALWAYS_TRUE(layers.AppendElement(fallible));
     28    dom::FrameUniformity& entry = layers.LastElement();
     29 
     30    entry.mLayerAddress.Construct() = layerAddr;
     31    entry.mFrameUniformity.Construct() = uniformity;
     32  }
     33 
     34  return dom::ToJSValue(aContext, results, aOutValue);
     35 }
     36 
     37 }  // namespace layers
     38 }  // namespace mozilla