Repository: LadybirdBrowser/ladybird
File: Services/WebContent/PageClient.h (C/C++)

Code before:
    virtual u64 id() const override { return m_id; }

    enum class UseSkiaPainter {
        CPUBackend,
        GPUBackendIfAvailable,
    };
    static void set_use_skia_painter(UseSkiaPainter);

    virtual bool is_headless() const override;
    static void set_is_headless(bool);

    virtual Web::Page& page() override { return *m_page; }
    virtual Web::Page const& page() const override { return *m_page; }

    ErrorOr<void> connect_to_webdriver(ByteString const& webdriver_ipc_path);
    ErrorOr<void> connect_to_web_ui(IPC::File);

    virtual Queue<Web::QueuedInputEvent>& input_event_queue() override;
    virtual void report_finished_handling_input_event(u64 page_id, Web::EventResult event_was_handled) override;

    void set_palette_impl(Gfx::PaletteImpl&);
    void set_viewport_size(Web::DevicePixelSize const&);
    void set_screen_rects(Vector<Web::DevicePixelRect, 4> const& rects, size_t main_screen_index)
    {
        m_screen_rect = rects[main_screen_index];
        m_screen_count = rects.size();
    }
    void set_device_pixels_per_css_pixel(float device_pixels_per_css_pixel) { m_device_pixels_per_css_pixel = device_pixels_per_css_pixel; }
    void set_maximum_frames_per_second(u64 maximum_frames_per_second);
    void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
    void set_preferred_contrast(Web::CSS::PreferredContrast);
    void set_preferred_motion(Web::CSS::PreferredMotion);
    void set_has_focus(bool);
    void set_is_scripting_enabled(bool);
    void set_window_position(Web::DevicePixelPoint);
    void set_window_size(Web::DevicePixelSize);

    void toggle_media_play_state();
    void toggle_media_mute_state();
    void toggle_media_loop_state();
    void toggle_media_controls_state();

    void alert_closed();
    void confirm_closed(bool accepted);
    void prompt_closed(Optional<String> response);
    void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state);
    void select_dropdown_closed(Optional<u32> const& selected_item_id);

    void set_user_style(String source);

    void ready_to_paint();

Review comment (suggestion):
Both the old and new implementations of this feel a bit weird - we're passing in a vector of screen rects and an index, only to throw away everything but the main screen rect.

Maybe we should store all the screen rects that are passed in _and_ create a new field to keep track of the main screen? That way, we don't have to keep track of the screen count and are future proofing `PageClient` for when we do need to handle multiple screen rects.

Code after:
    virtual u64 id() const override { return m_id; }

    enum class UseSkiaPainter {
        CPUBackend,
        GPUBackendIfAvailable,
    };
    static void set_use_skia_painter(UseSkiaPainter);

    virtual bool is_headless() const override;
    static void set_is_headless(bool);

    virtual Web::Page& page() override { return *m_page; }
    virtual Web::Page const& page() const override { return *m_page; }

    ErrorOr<void> connect_to_webdriver(ByteString const& webdriver_ipc_path);
    ErrorOr<void> connect_to_web_ui(IPC::File);

    virtual Queue<Web::QueuedInputEvent>& input_event_queue() override;
    virtual void report_finished_handling_input_event(u64 page_id, Web::EventResult event_was_handled) override;

    void set_palette_impl(Gfx::PaletteImpl&);
    void set_viewport_size(Web::DevicePixelSize const&);
    void set_screen_rects(Vector<Web::DevicePixelRect> const& rects, size_t main_screen_index)
    {
        m_all_screen_rects = rects;
        m_main_screen_index = main_screen_index;
    }
    void set_device_pixel_ratio(double device_pixel_ratio) { m_device_pixel_ratio = device_pixel_ratio; }
    void set_zoom_level(double zoom_level) { m_zoom_level = zoom_level; }
    void set_maximum_frames_per_second(u64 maximum_frames_per_second);
    void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
    void set_preferred_contrast(Web::CSS::PreferredContrast);
    void set_preferred_motion(Web::CSS::PreferredMotion);
    void set_has_focus(bool);
    void set_is_scripting_enabled(bool);
    void set_window_position(Web::DevicePixelPoint);
    void set_window_size(Web::DevicePixelSize);

    void toggle_media_play_state();
    void toggle_media_mute_state();
    void toggle_media_loop_state();
    void toggle_media_controls_state();

    void alert_closed();
    void confirm_closed(bool accepted);
    void prompt_closed(Optional<String> response);
    void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state);
    void select_dropdown_closed(Optional<u32> const& selected_item_id);

    void set_user_style(String source);
    void did_connect_devtools_client();