# Global Metrics

path: .metrics.nexits.sum
old: 0.0
new: 6.0
path: .metrics.nexits.average
old: 0.0
new: 0.75
path: .metrics.halstead.volume
old: 743.9635863812016
new: 3891.3627314638993
path: .metrics.halstead.n1
old: 13.0
new: 14.0
path: .metrics.halstead.N1
old: 64.0
new: 281.0
path: .metrics.halstead.length
old: 127.0
new: 524.0
path: .metrics.halstead.estimated_program_length
old: 295.2391056706696
new: 1207.3003271207888
path: .metrics.halstead.level
old: 0.10989010989010987
new: 0.09288653733098176
path: .metrics.halstead.purity_ratio
old: 2.324717367485587
new: 2.304008257864101
path: .metrics.halstead.effort
old: 6770.068636068934
new: 41893.72155835501
path: .metrics.halstead.time
old: 376.1149242260519
new: 2327.4289754641673
path: .metrics.halstead.difficulty
old: 9.1
new: 10.765822784810126
path: .metrics.halstead.bugs
old: 0.11929093970504422
new: 0.4020789834120934
path: .metrics.halstead.vocabulary
old: 58.0
new: 172.0
path: .metrics.halstead.N2
old: 63.0
new: 243.0
path: .metrics.halstead.n2
old: 45.0
new: 158.0
path: .metrics.nom.functions
old: 1.0
new: 8.0
path: .metrics.nom.total
old: 1.0
new: 8.0
path: .metrics.cyclomatic.sum
old: 5.0
new: 12.0
path: .metrics.loc.blank
old: 18.0
new: 19.0
path: .metrics.loc.lloc
old: 0.0
new: 8.0
path: .metrics.loc.ploc
old: 36.0
new: 136.0
path: .metrics.loc.cloc
old: 7.0
new: 23.0
path: .metrics.loc.sloc
old: 61.0
new: 178.0
path: .metrics.mi.mi_original
old: 68.87148452927588
new: 41.30923008771235
path: .metrics.mi.mi_visual_studio
old: 40.275721946944955
new: 24.157444495738215
path: .metrics.mi.mi_sei
old: 49.22057844647619
new: 11.544503383184336
path: .metrics.nargs.sum
old: 0.0
new: 8.0
path: .metrics.nargs.average
old: 0.0
new: 1.0

# Spaces Data

## Minimal test - lines (38, 176)

path: .spaces[0].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 8.0
path: .spaces[0].metrics.nargs.average
old: null
new: 1.0
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 147.0
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 10.61904761904762
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 500.0
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.3828435405033625
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 2162.4265394438617
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 277.0
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 223.0
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 38923.67770998951
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 161.0
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 14.0
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 2.223309607199504
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 3665.458439057308
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 1111.654803599752
path: .spaces[0].metrics.halstead.level
old: null
new: 0.09417040358744395
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 26.816746832689656
path: .spaces[0].metrics.mi.mi_original
old: null
new: 45.856637083899315
path: .spaces[0].metrics.mi.mi_sei
old: null
new: 16.663064283210467
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 6.0
path: .spaces[0].metrics.nexits.average
old: null
new: 0.75
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 11.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 8.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 8.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 16.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 15.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 139.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 8.0
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 108.0

### Code

    namespace mozilla {
    namespace widget {

    class HeadlessWidget : public nsBaseWidget {
     public:
      HeadlessWidget();

      NS_INLINE_DECL_REFCOUNTING_INHERITED(HeadlessWidget, nsBaseWidget)

      void* GetNativeData(uint32_t aDataType) override {
        // Headless widgets have no native data.
        return nullptr;
      }

      virtual nsresult Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
                              const LayoutDeviceIntRect& aRect,
                              nsWidgetInitData* aInitData = nullptr) override;
      using nsBaseWidget::Create;  // for Create signature not overridden here
      virtual already_AddRefed CreateChild(
          const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr,
          bool aForceUseIWidgetParent = false) override;

      virtual nsIWidget* GetTopLevelWidget() override;

      virtual void GetCompositorWidgetInitData(
          mozilla::widget::CompositorWidgetInitData* aInitData) override;

      virtual void Destroy() override;
      virtual void Show(bool aState) override;
      virtual bool IsVisible() const override;
      virtual void Move(double aX, double aY) override;
      virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
      virtual void Resize(double aX, double aY, double aWidth, double aHeight,
                          bool aRepaint) override;
      virtual void SetSizeMode(nsSizeMode aMode) override;
      virtual nsresult MakeFullScreen(bool aFullScreen,
                                      nsIScreen* aTargetScreen = nullptr) override;
      virtual void Enable(bool aState) override;
      virtual bool IsEnabled() const override;
      virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
      virtual nsresult ConfigureChildren(
          const nsTArray& aConfigurations) override {
        MOZ_ASSERT_UNREACHABLE(
            "Headless widgets do not support configuring children.");
        return NS_ERROR_FAILURE;
      }
      virtual void Invalidate(const LayoutDeviceIntRect& aRect) override {
        // TODO: see if we need to do anything here.
      }
      virtual nsresult SetTitle(const nsAString& title) override {
        // Headless widgets have no title, so just ignore it.
        return NS_OK;
      }
      virtual nsresult SetNonClientMargins(
          LayoutDeviceIntMargin& margins) override {
        // Headless widgets have no chrome margins, so just ignore the call.
        return NS_OK;
      }
      virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
      virtual void SetInputContext(const InputContext& aContext,
                                   const InputContextAction& aAction) override {
        mInputContext = aContext;
      }
      virtual InputContext GetInputContext() override { return mInputContext; }

      virtual LayerManager* GetLayerManager(
          PLayerTransactionChild* aShadowManager = nullptr,
          LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
          LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;

      void SetCompositorWidgetDelegate(CompositorWidgetDelegate* delegate) override;

      [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
          WidgetKeyboardEvent& aEvent) override;
      MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
          NativeKeyBindingsType aType, const WidgetKeyboardEvent& aEvent,
          nsTArray& aCommands) override;

      virtual nsresult DispatchEvent(WidgetGUIEvent* aEvent,
                                     nsEventStatus& aStatus) override;

      virtual nsresult SynthesizeNativeMouseEvent(
          LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
          mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
          nsIObserver* aObserver) override;
      virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
                                                 nsIObserver* aObserver) override {
        return SynthesizeNativeMouseEvent(
            aPoint, NativeMouseMessage::Move, mozilla::MouseButton::eNotPressed,
            nsIWidget::Modifiers::NO_MODIFIERS, aObserver);
      };

      virtual nsresult SynthesizeNativeMouseScrollEvent(
          LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
          double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
          uint32_t aAdditionalFlags, nsIObserver* aObserver) override;

      virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
                                                  TouchPointerState aPointerState,
                                                  LayoutDeviceIntPoint aPoint,
                                                  double aPointerPressure,
                                                  uint32_t aPointerOrientation,
                                                  nsIObserver* aObserver) override;

      virtual nsresult SynthesizeNativeTouchPadPinch(
          TouchpadPinchPhase aEventPhase, float aScale, LayoutDeviceIntPoint aPoint,
          int32_t aModifierFlags) override;

     private:
      ~HeadlessWidget();
      bool mEnabled;
      bool mVisible;
      bool mDestroyed;
      nsIWidget* mTopLevel;
      HeadlessCompositorWidget* mCompositorWidget;
      // The size mode before entering fullscreen mode.
      nsSizeMode mLastSizeMode;
      // The last size mode set while the window was visible.
      nsSizeMode mEffectiveSizeMode;
      mozilla::ScreenCoord mLastPinchSpan;
      InputContext mInputContext;
      mozilla::UniquePtr mSynthesizedTouchInput;
      // In headless there is no window manager to track window bounds
      // across size mode changes, so we must track it to emulate.
      LayoutDeviceIntRect mRestoreBounds;
      void ApplySizeModeSideEffects();
      // Similarly, we must track the active window ourselves in order
      // to dispatch (de)activation events properly.
      void RaiseWindow();
      // The top level widgets are tracked for window ordering. They are
      // stored in order of activation where the last element is always the
      // currently active widget.
      static StaticAutoPtr> sActiveWindows;
      // Get the most recently activated widget or null if there are none.
      static already_AddRefed GetActiveWindow();
    };

    }  // namespace widget
    }  // namespace mozilla