Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/HTML/Window.h (C/C++)

Code before:
    void cancel_idle_callback(u32 handle);

    GC::Ptr<Selection::Selection> get_selection() const;

    void capture_events();
    void release_events();

    [[nodiscard]] GC::Ref<External> external();

    [[nodiscard]] GC::Ref<CustomElementRegistry> custom_elements();

    HighResolutionTime::DOMHighResTimeStamp last_activation_timestamp() const { return m_last_activation_timestamp; }
    void set_last_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_activation_timestamp = timestamp; }

    void consume_user_activation();

    HighResolutionTime::DOMHighResTimeStamp last_history_action_activation_timestamp() const { return m_last_history_action_activation_timestamp; }
    void set_last_history_action_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_history_action_activation_timestamp = timestamp; }

    void consume_history_action_user_activation();

    static void set_enable_test_mode(bool);
    static bool in_test_mode();

    static void set_experimental_interfaces_exposed(bool);
    static bool are_experimental_interfaces_exposed();

    static void set_internals_object_exposed(bool);
    static bool is_internals_object_exposed();

    [[nodiscard]] OrderedHashMap<FlyString, GC::Ref<Navigable>> document_tree_child_navigable_target_name_property_set();

    [[nodiscard]] Vector<FlyString> supported_property_names() const override;
    [[nodiscard]] JS::Value named_item_value(FlyString const&) const override;

    bool find(String const& string);

private:
    explicit Window(JS::Realm&);

    virtual bool is_universal_global_scope_mixin() const final { return true; }

    virtual void visit_edges(Cell::Visitor&) override;
    virtual void finalize() override;

    virtual bool is_html_window() const override { return true; }

    // ^HTML::GlobalEventHandlers
    virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }

    // ^HTML::WindowEventHandlers

Review comment (refactor):
Given that this flag works for Workers too, we should probably move this to UniversalGlobalScope (or similar) as a better home. This is in converse to some of the other flags here like `in_test_mode` which don't work in Workers since it's not passed along

Code after:
    void cancel_idle_callback(u32 handle);

    GC::Ptr<Selection::Selection> get_selection() const;

    void capture_events();
    void release_events();

    [[nodiscard]] GC::Ref<External> external();

    [[nodiscard]] GC::Ref<CustomElementRegistry> custom_elements();

    HighResolutionTime::DOMHighResTimeStamp last_activation_timestamp() const { return m_last_activation_timestamp; }
    void set_last_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_activation_timestamp = timestamp; }

    void consume_user_activation();

    HighResolutionTime::DOMHighResTimeStamp last_history_action_activation_timestamp() const { return m_last_history_action_activation_timestamp; }
    void set_last_history_action_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_history_action_activation_timestamp = timestamp; }

    void consume_history_action_user_activation();

    static bool in_test_mode();
    static void set_enable_test_mode(bool);
    static void set_internals_object_exposed(bool);
    static bool is_internals_object_exposed();

    [[nodiscard]] OrderedHashMap<FlyString, GC::Ref<Navigable>> document_tree_child_navigable_target_name_property_set();

    [[nodiscard]] Vector<FlyString> supported_property_names() const override;
    [[nodiscard]] JS::Value named_item_value(FlyString const&) const override;

    bool find(String const& string);

private:
    explicit Window(JS::Realm&);

    virtual bool is_universal_global_scope_mixin() const final { return true; }

    virtual void visit_edges(Cell::Visitor&) override;
    virtual void finalize() override;

    virtual bool is_html_window() const override { return true; }

    // ^HTML::GlobalEventHandlers
    virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }

    // ^HTML::WindowEventHandlers
    virtual GC::Ptr<DOM::EventTarget> window_event_handlers_to_event_target() override { return *this; }

    void invoke_idle_callbacks();