# Global Metrics

path: .metrics.nom.functions
old: 2.0
new: 7.0
path: .metrics.nom.total
old: 2.0
new: 7.0
path: .metrics.mi.mi_sei
old: 52.13828287688525
new: 29.707765210724492
path: .metrics.mi.mi_original
old: 69.47831611496296
new: 52.56936537830472
path: .metrics.mi.mi_visual_studio
old: 40.63059421927659
new: 30.742318934681123
path: .metrics.loc.blank
old: 9.0
new: 19.0
path: .metrics.loc.lloc
old: 11.0
new: 25.0
path: .metrics.loc.cloc
old: 7.0
new: 15.0
path: .metrics.loc.sloc
old: 53.0
new: 105.0
path: .metrics.loc.ploc
old: 37.0
new: 71.0
path: .metrics.nexits.average
old: 1.5
new: 1.0
path: .metrics.nexits.sum
old: 3.0
new: 7.0
path: .metrics.halstead.difficulty
old: 13.512820512820513
new: 19.551724137931036
path: .metrics.halstead.estimated_program_length
old: 275.61755483688347
new: 432.0015635957531
path: .metrics.halstead.n2
old: 39.0
new: 58.0
path: .metrics.halstead.level
old: 0.07400379506641366
new: 0.05114638447971781
path: .metrics.halstead.purity_ratio
old: 1.8622807759248885
new: 1.6059537680139522
path: .metrics.halstead.vocabulary
old: 56.0
new: 79.0
path: .metrics.halstead.n1
old: 17.0
new: 21.0
path: .metrics.halstead.volume
old: 859.4885284645253
new: 1695.717021259641
path: .metrics.halstead.N1
old: 86.0
new: 161.0
path: .metrics.halstead.bugs
old: 0.1709501451093669
new: 0.34400997762099744
path: .metrics.halstead.N2
old: 62.0
new: 108.0
path: .metrics.halstead.time
old: 645.2285676649641
new: 1841.8995230923683
path: .metrics.halstead.effort
old: 11614.114217969354
new: 33154.19141566263
path: .metrics.halstead.length
old: 148.0
new: 269.0
path: .metrics.nargs.average
old: 4.0
new: 0.2857142857142857
path: .metrics.nargs.sum
old: 8.0
new: 2.0
path: .metrics.cognitive.average
old: 2.5
new: 1.2857142857142858
path: .metrics.cognitive.sum
old: 5.0
new: 9.0
path: .metrics.cyclomatic.average
old: 3.0
new: 1.9
path: .metrics.cyclomatic.sum
old: 9.0
new: 19.0

# Spaces Data

## Minimal test - lines (22, 105)

path: .spaces[0].metrics.nexits.average
old: 2.0
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 2.0
new: 7.0
path: .spaces[0].metrics.halstead.level
old: 0.07747489239598279
new: 0.04563492063492063
path: .spaces[0].metrics.halstead.difficulty
old: 12.907407407407408
new: 21.91304347826087
path: .spaces[0].metrics.halstead.length
old: 104.0
new: 257.0
path: .spaces[0].metrics.halstead.N1
old: 63.0
new: 161.0
path: .spaces[0].metrics.halstead.bugs
old: 0.125764655092684
new: 0.35094723259901084
path: .spaces[0].metrics.halstead.volume
old: 567.7808883382789
new: 1558.9849219476473
path: .spaces[0].metrics.halstead.N2
old: 41.0
new: 96.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.9025849121122056
new: 1.3475584274590529
path: .spaces[0].metrics.halstead.vocabulary
old: 44.0
new: 67.0
path: .spaces[0].metrics.halstead.n1
old: 17.0
new: 21.0
path: .spaces[0].metrics.halstead.time
old: 407.1432913289922
new: 1897.8946875884403
path: .spaces[0].metrics.halstead.estimated_program_length
old: 197.8688308596694
new: 346.32251585697657
path: .spaces[0].metrics.halstead.n2
old: 27.0
new: 46.0
path: .spaces[0].metrics.halstead.effort
old: 7328.579243921859
new: 34162.104376591924
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 7.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 7.0
path: .spaces[0].metrics.loc.blank
old: 4.0
new: 16.0
path: .spaces[0].metrics.loc.cloc
old: 3.0
new: 10.0
path: .spaces[0].metrics.loc.sloc
old: 28.0
new: 84.0
path: .spaces[0].metrics.loc.lloc
old: 8.0
new: 25.0
path: .spaces[0].metrics.loc.ploc
old: 21.0
new: 58.0
path: .spaces[0].metrics.mi.mi_original
old: 82.43126189665183
new: 56.85145883229433
path: .spaces[0].metrics.mi.mi_sei
old: 68.21694620507374
new: 33.62273265849389
path: .spaces[0].metrics.mi.mi_visual_studio
old: 48.20541631383148
new: 33.246467153388494
path: .spaces[0].metrics.cognitive.sum
old: 5.0
new: 9.0
path: .spaces[0].metrics.cognitive.average
old: 5.0
new: 1.2857142857142858
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 2.0
path: .spaces[0].metrics.nargs.average
old: 4.0
new: 0.2857142857142857
path: .spaces[0].metrics.cyclomatic.average
old: 7.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.sum
old: 7.0
new: 18.0

### Code

    namespace mozilla {
    namespace widget {

    using namespace mozilla::gfx;
    using namespace mozilla;

    WinCompositorWidget::WinCompositorWidget(
        const WinCompositorWidgetInitData& aInitData,
        const layers::CompositorOptions& aOptions)
        : CompositorWidget(aOptions),
          mSetParentCompleted(false),
          mWidgetKey(aInitData.widgetKey()),
          mWnd(reinterpret_cast(aInitData.hWnd())),
          mCompositorWnds(nullptr, nullptr) {
      MOZ_ASSERT(mWnd && ::IsWindow(mWnd));
    }

    WinCompositorWidget::~WinCompositorWidget() { DestroyCompositorWindow(); }

    uintptr_t WinCompositorWidget::GetWidgetKey() { return mWidgetKey; }

    void WinCompositorWidget::EnsureCompositorWindow() {
      if (mCompositorWnds.mCompositorWnd || mCompositorWnds.mInitialParentWnd) {
        return;
      }

      mCompositorWnds = WinCompositorWindowThread::CreateCompositorWindow();
      UpdateCompositorWnd(mCompositorWnds.mCompositorWnd, mWnd);

      MOZ_ASSERT(mCompositorWnds.mCompositorWnd);
      MOZ_ASSERT(mCompositorWnds.mInitialParentWnd);
    }

    void WinCompositorWidget::DestroyCompositorWindow() {
      if (!mCompositorWnds.mCompositorWnd && !mCompositorWnds.mInitialParentWnd) {
        return;
      }
      WinCompositorWindowThread::DestroyCompositorWindow(mCompositorWnds);
      mCompositorWnds = WinCompositorWnds(nullptr, nullptr);
    }

    void WinCompositorWidget::UpdateCompositorWndSizeIfNecessary() {
      if (!mCompositorWnds.mCompositorWnd) {
        return;
      }

      LayoutDeviceIntSize size = GetClientSize();
      if (mLastCompositorWndSize == size) {
        return;
      }

      // This code is racing with the compositor, which needs to reparent
      // the compositor surface to the actual window (mWnd). To avoid racing
      // mutations, we refuse to proceed until ::SetParent() is called in parent
      // process. After the ::SetParent() call, composition is scheduled in
      // CompositorWidgetParent::UpdateCompositorWnd().
      if (!mSetParentCompleted) {
        // ::SetParent() is not completed yet.
        return;
      }

      MOZ_ASSERT(mWnd == ::GetParent(mCompositorWnds.mCompositorWnd));

      // Force a resize and redraw (but not a move, activate, etc.).
      if (!::SetWindowPos(
              mCompositorWnds.mCompositorWnd, nullptr, 0, 0, size.width,
              size.height,
              SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_NOZORDER)) {
        return;
      }

      mLastCompositorWndSize = size;
    }

    // Creates a new instance of FxROutputHandler so that this compositor widget
    // can send its output to Firefox Reality for Desktop.
    void WinCompositorWidget::RequestFxrOutput() {
      MOZ_ASSERT(mFxrHandler == nullptr);

      mFxrHandler.reset(new FxROutputHandler());
    }

    }  // namespace widget
    }  // namespace mozilla