Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / page / page_1.lucb

#==============================================================================================
#
#   page_1 - Web::Page: the focused navigable, loading, the client's palette and screen,
#   pixel conversions, input events, the top-level traversable and blocking dialogs
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/Page/Page.cpp lines 68-450 (focused_navigable through
#       on_pending_dialog_closed) with the inline accessors of Page.h. Page::create,
#       Page::Page, visit_edges and preferred_color_scheme are in page.lucb.
#
#       Copyright (c) 2020-2022, Andreas Kling <andreas@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: The client and the focused navigable ====================================================

## Ported from Page.h:70 Web::Page::client.
pub func page_client(this: Page*) -> PageClient*:
    return this.m_client

## Ported from Page.h:71 Web::Page::client.
pub func page_client_const(this: Page*) -> PageClient*:
    return this.m_client

## Ported from Page.cpp:69 Web::Page::focused_navigable.
pub func page_focused_navigable(this: Page*) -> HtmlNavigable*:
    if let navigable = gc.weak_ptr(&this.m_focused_navigable):
        return navigable
    return page_top_level_traversable(this).html_navigable()

## Ported from Page.h:84 Web::Page::focused_navigable.
pub func page_focused_navigable_const(this: Page*) -> HtmlNavigable*:
    return page_focused_navigable(this)

## Ported from Page.cpp:76 Web::Page::set_focused_navigable.
pub func page_set_focused_navigable(this: Page*, navigable: HtmlNavigable*):
    this.m_focused_navigable = gc.make_weak(navigable)

## Ported from Page.cpp:81 Web::Page::navigable_document_destroyed.
pub func page_navigable_document_destroyed(this: Page*, navigable: HtmlNavigable*):
    if (HtmlNavigable*?)navigable == gc.weak_ptr(&this.m_focused_navigable):
        this.m_focused_navigable = gc.make_weak[HtmlNavigable](none)

# mark: Loading =================================================================================

## Ported from Page.cpp:87 Web::Page::load.
pub func page_load(this: Page*, url: web_url.Url):
    let traversable = page_top_level_traversable(this).html_navigable()
    html_navigable_navigate(traversable, HtmlNavigableNavigateParams(url = url, source_document = html_navigable_active_document(traversable) else trap("no active document"), user_involvement = HtmlUserNavigationInvolvement.browser_ui)) catch:
        # (void): the C++ drops the result.
        _ = idl_take_pending_exception()
        recover ()

## Ported from Page.cpp:92 Web::Page::load_html.
pub func page_load_html(this: Page*, html: ak.StringView):
    # FIXME: #23909 Figure out why GC threshold does not stay low when repeatedly loading html from the WebView
    gc.heap_collect_garbage(gc.cell_heap(this.cell()))

    let traversable = page_top_level_traversable(this).html_navigable()
    let document_resource = ak.string_from_utf8(html) else trap("String::from_utf8: release_value_but_fixme_should_propagate_errors")
    html_navigable_navigate(traversable, HtmlNavigableNavigateParams(url = web_url.about_srcdoc(), source_document = html_navigable_active_document(traversable) else trap("no active document"), document_resource = EmptyOrStringOrHtmlPostResource.string(document_resource), user_involvement = HtmlUserNavigationInvolvement.browser_ui)) catch:
        # (void): the C++ drops the result.
        _ = idl_take_pending_exception()
        recover ()

## Ported from Page.cpp:103 Web::Page::reload.
pub func page_reload(this: Page*):
    html_navigable_reload(page_top_level_traversable(this).html_navigable())

## Ported from Page.cpp:108 Web::Page::traverse_the_history_by_delta.
pub func page_traverse_the_history_by_delta(this: Page*, delta: i32):
    html_traversable_navigable_traverse_the_history_by_delta(page_top_level_traversable(this), delta)

# mark: The client's palette and screen =========================================================

## Ported from Page.cpp:113 Web::Page::palette.
pub func page_palette(this: Page*) -> gfx.Palette:
    return page_client_palette(this.m_client)

## `{ x, y, width, height }` of a device pixel rect as a CSS pixel rect (each an int).
func page_device_rect_as_css_rect(device_pixel_rect: gfx.DevicePixelRect) -> gfx.CssPixelRect:
    var rect: gfx.CssPixelRect = ---
    gfx.css_pixel_rect_construct_int(&rect, (i64)gfx.device_pixel_rect_x(&device_pixel_rect), (i64)gfx.device_pixel_rect_y(&device_pixel_rect), (i64)gfx.device_pixel_rect_width(&device_pixel_rect), (i64)gfx.device_pixel_rect_height(&device_pixel_rect))
    return rect

## Ported from Page.cpp:119 Web::Page::web_exposed_screen_area.
# https://drafts.csswg.org/cssom-view-1/#web-exposed-screen-area
pub func page_web_exposed_screen_area(this: Page*) -> gfx.CssPixelRect:
    # FIXME: 1. Let target be this’s relevant global object’s browsing context.
    # FIXME: 2. Let emulated screen area be the WebDriver BiDi emulated total screen area of target.
    # FIXME: 3. If emulated screen area is not null, return emulated screen area.

    # 4. Otherwise, return one of the following:
    #    - The area of the output device, in CSS pixels.
    #    - The area of the viewport, in CSS pixels.
    # NB: This is the area of the output device, but in device pixels.
    # See: https://github.com/LadybirdBrowser/ladybird/pull/4084
    return page_device_rect_as_css_rect(page_client_screen_rect(this.m_client))

## Ported from Page.cpp:140 Web::Page::web_exposed_available_screen_area.
# https://drafts.csswg.org/cssom-view-1/#web-exposed-available-screen-area
pub func page_web_exposed_available_screen_area(this: Page*) -> gfx.CssPixelRect:
    # FIXME: 1. Let target be this’s relevant global object’s browsing context.
    # FIXME: 2. Let emulated screen area be the WebDriver BiDi emulated total screen area of target.
    # FIXME: 3. If emulated screen area is not null, return emulated screen area.

    # 4. Otherwise, return one of the following:
    #    - The available area of the rendering surface of the output device, in CSS pixels.
    #    - The area of the output device, in CSS pixels.
    #    - The area of the viewport, in CSS pixels.
    # NB: This is the area of the output device, but in device pixels. See note in web_exposed_screen_area()
    return page_device_rect_as_css_rect(page_client_screen_rect(this.m_client))

## Ported from Page.cpp:170 Web::Page::preferred_contrast.
pub func page_preferred_contrast(this: Page*) -> CssPreferredContrast:
    return page_client_preferred_contrast(this.m_client)

## Ported from Page.cpp:175 Web::Page::preferred_motion.
pub func page_preferred_motion(this: Page*) -> CssPreferredMotion:
    return page_client_preferred_motion(this.m_client)

# mark: Pixel conversions =======================================================================

## Ported from Page.cpp:180 Web::Page::device_to_css_point.
pub func page_device_to_css_point(this: Page*, point: gfx.IntPoint) -> gfx.CssPixelPoint:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    return gfx.CssPixelPoint(m_x = gfx.CssPixels.from_f64((f64)point.m_x / scale), m_y = gfx.CssPixels.from_f64((f64)point.m_y / scale))

## `CSSPixels * double` (CSSPixels(right) times left, PixelUnits.h:296) as DevicePixels: the
## product's value, truncated to an int.
func page_css_pixels_times_scale_as_device_pixels(value: gfx.CssPixels, scale: f64) -> i32:
    return (i32)value.mul(gfx.CssPixels.from_f64(scale)).to_double()

## Ported from Page.cpp:188 Web::Page::css_to_device_point.
pub func page_css_to_device_point(this: Page*, point: gfx.CssPixelPoint) -> gfx.IntPoint:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    return gfx.IntPoint(m_x = page_css_pixels_times_scale_as_device_pixels(point.m_x, scale), m_y = page_css_pixels_times_scale_as_device_pixels(point.m_y, scale))

## Ported from Page.cpp:196 Web::Page::css_to_device_rect.
pub func page_css_to_device_rect(this: Page*, rect: gfx.CssPixelRect) -> gfx.DevicePixelRect:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    # rect.location().to_type<double>() * scale and rect.size().to_type<double>() * scale, made
    # DevicePixels (ints) by truncation.
    var result: gfx.DevicePixelRect = ---
    gfx.device_pixel_rect_construct_i32(&result, (i32)(rect.m_location.m_x.to_double() * scale), (i32)(rect.m_location.m_y.to_double() * scale), (i32)(rect.m_size.m_width.to_double() * scale), (i32)(rect.m_size.m_height.to_double() * scale))
    return result

## Ported from Page.cpp:204 Web::Page::device_to_css_rect.
pub func page_device_to_css_rect(this: Page*, rect: gfx.DevicePixelRect) -> gfx.CssPixelRect:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    var result: gfx.CssPixelRect = ---
    gfx.css_pixel_rect_construct_css_pixels(&result, gfx.css_pixels_nearest_value_for_f64((f64)gfx.device_pixel_rect_x(&rect) / scale), gfx.css_pixels_nearest_value_for_f64((f64)gfx.device_pixel_rect_y(&rect) / scale), gfx.css_pixels_floored_value_for_f64((f64)gfx.device_pixel_rect_width(&rect) / scale), gfx.css_pixels_floored_value_for_f64((f64)gfx.device_pixel_rect_height(&rect) / scale))
    return result

## Ported from Page.cpp:215 Web::Page::device_to_css_size.
pub func page_device_to_css_size(this: Page*, size: gfx.IntSize) -> gfx.CssPixelSize:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    return gfx.CssPixelSize(m_width = gfx.css_pixels_floored_value_for_f64((f64)size.m_width / scale), m_height = gfx.css_pixels_floored_value_for_f64((f64)size.m_height / scale))

## Ported from Page.cpp:224 Web::Page::enclosing_device_rect.
pub func page_enclosing_device_rect(this: Page*, rect: gfx.CssPixelRect) -> gfx.DevicePixelRect:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    var result: gfx.DevicePixelRect = ---
    gfx.device_pixel_rect_construct_i32(&result, (i32)math.floor(rect.m_location.m_x.to_double() * scale), (i32)math.floor(rect.m_location.m_y.to_double() * scale), (i32)math.ceil(rect.m_size.m_width.to_double() * scale), (i32)math.ceil(rect.m_size.m_height.to_double() * scale))
    return result

## Ported from Page.cpp:234 Web::Page::rounded_device_rect.
pub func page_rounded_device_rect(this: Page*, rect: gfx.CssPixelRect) -> gfx.DevicePixelRect:
    let scale = page_client_device_pixels_per_css_pixel(page_client_const(this))
    # roundf: each product is made a float and rounded half away from zero.
    var result: gfx.DevicePixelRect = ---
    gfx.device_pixel_rect_construct_i32(&result, (i32)math.round((f64)(f32)(rect.m_location.m_x.to_double() * scale)), (i32)math.round((f64)(f32)(rect.m_location.m_y.to_double() * scale)), (i32)math.round((f64)(f32)(rect.m_size.m_width.to_double() * scale)), (i32)math.round((f64)(f32)(rect.m_size.m_height.to_double() * scale)))
    return result

## Ported from Page.cpp:245 Web::Page::chrome_metrics.
pub func page_chrome_metrics(this: Page*) -> ChromeMetrics:
    var metrics: ChromeMetrics = ---
    chrome_metrics_construct(&metrics, page_client_zoom_level(this.m_client))
    return metrics

# mark: Input events ============================================================================

## The top-level traversable's event handler.
func page_top_level_event_handler(this: Page*) -> EventHandler*:
    return html_navigable_event_handler(page_top_level_traversable(this).html_navigable())

## Ported from Page.cpp:250 Web::Page::handle_mouseup.
pub func page_handle_mouseup(this: Page*, position: gfx.IntPoint, screen_position: gfx.IntPoint, button: u32, buttons: u32, modifiers: u32) -> EventResult:
    return event_handler_handle_mouseup(page_top_level_event_handler(this), page_device_to_css_point(this, position), page_device_to_css_point(this, screen_position), button, buttons, modifiers)

## Ported from Page.cpp:255 Web::Page::handle_mousedown.
pub func page_handle_mousedown(this: Page*, position: gfx.IntPoint, screen_position: gfx.IntPoint, button: u32, buttons: u32, modifiers: u32, click_count: i32) -> EventResult:
    return event_handler_handle_mousedown(page_top_level_event_handler(this), page_device_to_css_point(this, position), page_device_to_css_point(this, screen_position), button, buttons, modifiers, click_count)

## Ported from Page.cpp:260 Web::Page::handle_mousemove.
pub func page_handle_mousemove(this: Page*, position: gfx.IntPoint, screen_position: gfx.IntPoint, buttons: u32, modifiers: u32) -> EventResult:
    return event_handler_handle_mousemove(page_top_level_event_handler(this), page_device_to_css_point(this, position), page_device_to_css_point(this, screen_position), buttons, modifiers)

## Ported from Page.cpp:265 Web::Page::handle_mouseleave.
pub func page_handle_mouseleave(this: Page*) -> EventResult:
    return event_handler_handle_mouseleave(page_top_level_event_handler(this))

## Ported from Page.cpp:270 Web::Page::handle_mousewheel.
pub func page_handle_mousewheel(this: Page*, position: gfx.IntPoint, screen_position: gfx.IntPoint, button: u32, buttons: u32, modifiers: u32, wheel_delta_x: i32, wheel_delta_y: i32) -> EventResult:
    return event_handler_handle_mousewheel(page_top_level_event_handler(this), page_device_to_css_point(this, position), page_device_to_css_point(this, screen_position), button, buttons, modifiers, wheel_delta_x, wheel_delta_y)

## Ported from Page.cpp:275 Web::Page::handle_drag_and_drop_event.
pub func page_handle_drag_and_drop_event(this: Page*, type_: DragEventType, position: gfx.IntPoint, screen_position: gfx.IntPoint, button: u32, buttons: u32, modifiers: u32, files: ak.Vector[HtmlSelectedFile]) -> EventResult:
    return event_handler_handle_drag_and_drop_event(page_top_level_event_handler(this), type_, page_device_to_css_point(this, position), page_device_to_css_point(this, screen_position), button, buttons, modifiers, files)

## Ported from Page.cpp:280 Web::Page::handle_pinch_event.
pub func page_handle_pinch_event(this: Page*, position: gfx.IntPoint, scale: f64) -> EventResult:
    return event_handler_handle_pinch_event(page_top_level_event_handler(this), page_device_to_css_point(this, position), scale)

## Ported from Page.cpp:285 Web::Page::handle_keydown.
pub func page_handle_keydown(this: Page*, key: UiEventsKeyCode, modifiers: u32, code_point: u32, repeat: bool) -> EventResult:
    return event_handler_handle_keydown(html_navigable_event_handler(page_focused_navigable(this)), key, modifiers, code_point, repeat)

## Ported from Page.cpp:290 Web::Page::handle_keyup.
pub func page_handle_keyup(this: Page*, key: UiEventsKeyCode, modifiers: u32, code_point: u32, repeat: bool) -> EventResult:
    return event_handler_handle_keyup(html_navigable_event_handler(page_focused_navigable(this)), key, modifiers, code_point, repeat)

## Ported from Page.cpp:295 Web::Page::handle_sdl_input_events.
pub func page_handle_sdl_input_events(this: Page*):
    event_handler_handle_sdl_input_events(page_top_level_event_handler(this))

# mark: The top-level traversable ===============================================================

## Ported from Page.cpp:300 Web::Page::set_top_level_traversable.
pub func page_set_top_level_traversable(this: Page*, navigable: HtmlTraversableNavigable*):
    assert(this.m_top_level_traversable == none)  # Replacement is not allowed!
    assert(html_navigable_page(navigable.html_navigable()) == this)
    this.m_top_level_traversable = navigable

## Ported from Page.cpp:307 Web::Page::top_level_traversable_is_initialized.
pub func page_top_level_traversable_is_initialized(this: Page*) -> bool:
    return this.m_top_level_traversable != none

## Ported from Page.cpp:312 Web::Page::top_level_browsing_context.
pub func page_top_level_browsing_context(this: Page*) -> HtmlBrowsingContext*:
    let traversable = this.m_top_level_traversable else trap("no top-level traversable")
    return html_navigable_active_browsing_context(traversable.html_navigable()) else trap("no active browsing context")

## Ported from Page.cpp:317 Web::Page::top_level_browsing_context.
pub func page_top_level_browsing_context_const(this: Page*) -> HtmlBrowsingContext*:
    return page_top_level_browsing_context(this)

## Ported from Page.cpp:322 Web::Page::top_level_traversable.
pub func page_top_level_traversable(this: Page*) -> HtmlTraversableNavigable*:
    return this.m_top_level_traversable else trap("no top-level traversable")

## Ported from Page.cpp:327 Web::Page::did_update_window_rect.
pub func page_did_update_window_rect(this: Page*):
    if let observer = this.m_window_rect_observer:
        var rect: gfx.DevicePixelRect = ---
        gfx.device_pixel_rect_construct_int_point(&rect, page_window_position(this), page_window_size(this))
        ak.function1_call(&observer.function, rect)

# mark: Blocking dialogs ========================================================================

## The goal of spin_event_loop_until_dialog_closed's spin_until (`[&]() { return
## response.has_value() || !client.is_connection_open(); }`).
struct PageDialogClosedGoal:
    var client: PageClient*
    var has_response: func(void*?) -> bool
    var response: void*?

## The spin_until goal.
func page_dialog_closed_goal(context: void*?) -> bool:
    let goal = (PageDialogClosedGoal*)(context else trap("no goal"))
    return goal.has_response(goal.response) or not page_client_is_connection_open(goal.client)

## Ported from Page.cpp:334 Web::spin_event_loop_until_dialog_closed, without the response:
## the event loop spins until `has_response(response)` (C++'s `response.has_value()`) or the
## client disconnects; each caller then takes its response.
func page_spin_event_loop_until_dialog_closed(client: PageClient*, has_response: func(void*?) -> bool, response: void*?):
    let event_loop = html_environment_settings_object_responsible_event_loop(html_current_settings_object())
    let this_heap_cell = event_loop.cell()
    var pause_handle = html_event_loop_pause(event_loop)
    defer html_event_loop_pause_handle_destruct(&pause_handle)

    let goal = new PageDialogClosedGoal(client = client, has_response = has_response, response = response) else trap("out of memory")
    platform_event_loop_plugin_spin_until(platform_event_loop_plugin_the(), gc.create_function0(gc.cell_heap(this_heap_cell), ak.Function0[bool](call = page_dialog_closed_goal, context = goal)))

    if not page_client_is_connection_open(client):
        ak.dbgln("WebContent client disconnected during spin_event_loop_until_dialog_closed. Exiting peacefully.")
        os.exit(0)

## Whether the alert response (Optional<Empty>) has a value.
func page_has_alert_response(response: void*?) -> bool:
    return *(const (ak.Empty?)*)(response else trap("no response")) != none

## Whether the confirm response (Optional<bool>) has a value.
func page_has_confirm_response(response: void*?) -> bool:
    return *(const (bool?)*)(response else trap("no response")) != none

## Whether the prompt response (Optional<Optional<String>>) has a value: here the prompt is
## answered once prompt_closed runs (m_pending_dialog leaves Prompt).
func page_has_prompt_response(response: void*?) -> bool:
    let this = (Page*)(response else trap("no page"))
    return this.m_pending_prompt_response_set

## Ported from Page.cpp:351 Web::Page::did_request_alert.
pub func page_did_request_alert(this: Page*, message: ak.String):
    this.m_pending_dialog = PagePendingDialog.alert
    page_client_page_did_request_alert(this.m_client, message)

    if not ak.string_is_empty(&message):
        this.m_pending_dialog_text = message

    page_spin_event_loop_until_dialog_closed(this.m_client, page_has_alert_response, &this.m_pending_alert_response)
    this.m_pending_alert_response = none

## Ported from Page.cpp:362 Web::Page::alert_closed.
pub func page_alert_closed(this: Page*):
    if this.m_pending_dialog == PagePendingDialog.alert:
        this.m_pending_alert_response = ak.Empty()
        page_on_pending_dialog_closed(this)

## Ported from Page.cpp:370 Web::Page::did_request_confirm.
pub func page_did_request_confirm(this: Page*, message: ak.String) -> bool:
    this.m_pending_dialog = PagePendingDialog.confirm
    page_client_page_did_request_confirm(this.m_client, message)

    if not ak.string_is_empty(&message):
        this.m_pending_dialog_text = message

    page_spin_event_loop_until_dialog_closed(this.m_client, page_has_confirm_response, &this.m_pending_confirm_response)
    let response = this.m_pending_confirm_response else trap("Optional::release_value() on an empty optional")
    this.m_pending_confirm_response = none
    return response

## Ported from Page.cpp:381 Web::Page::confirm_closed.
pub func page_confirm_closed(this: Page*, accepted: bool):
    if this.m_pending_dialog == PagePendingDialog.confirm:
        this.m_pending_confirm_response = accepted
        page_on_pending_dialog_closed(this)

## Ported from Page.cpp:389 Web::Page::did_request_prompt.
pub func page_did_request_prompt(this: Page*, message: ak.String, default_: ak.String) -> ak.String?:
    this.m_pending_dialog = PagePendingDialog.prompt
    page_client_page_did_request_prompt(this.m_client, message, default_)

    if not ak.string_is_empty(&message):
        this.m_pending_dialog_text = message

    page_spin_event_loop_until_dialog_closed(this.m_client, page_has_prompt_response, this)
    let response = this.m_pending_prompt_response
    this.m_pending_prompt_response = none
    this.m_pending_prompt_response_set = false
    return response

## Ported from Page.cpp:400 Web::Page::prompt_closed.
pub func page_prompt_closed(this: Page*, response: ak.String?):
    if this.m_pending_dialog == PagePendingDialog.prompt:
        this.m_pending_prompt_response = response
        this.m_pending_prompt_response_set = true
        page_on_pending_dialog_closed(this)

## Ported from Page.cpp:408 Web::Page::dismiss_dialog.
pub func page_dismiss_dialog(this: Page*, on_dialog_closed: gc.Function0[unit]*):
    this.m_on_pending_dialog_closed = on_dialog_closed

    match this.m_pending_dialog:
        .none_:
            _ = 0
        .alert:
            page_client_page_did_request_accept_dialog(this.m_client)
        .confirm, .prompt:
            page_client_page_did_request_dismiss_dialog(this.m_client)
        _:
            _ = 0

## Ported from Page.cpp:425 Web::Page::accept_dialog.
pub func page_accept_dialog(this: Page*, on_dialog_closed: gc.Function0[unit]*):
    this.m_on_pending_dialog_closed = on_dialog_closed

    match this.m_pending_dialog:
        .none_:
            _ = 0
        .alert, .confirm, .prompt:
            page_client_page_did_request_accept_dialog(this.m_client)
        _:
            _ = 0

## Ported from Page.cpp:440 Web::Page::on_pending_dialog_closed.
func page_on_pending_dialog_closed(this: Page*):
    this.m_pending_dialog = PagePendingDialog.none_
    this.m_pending_dialog_text = none

    if let on_closed = this.m_on_pending_dialog_closed:
        ak.function0_call(&on_closed.function)
        this.m_on_pending_dialog_closed = none

# mark: Page.h accessors ========================================================================

## Ported from Page.h:127 Web::Page::is_scripting_enabled.
pub func page_is_scripting_enabled(this: Page*) -> bool:
    return this.m_is_scripting_enabled

## Ported from Page.h:128 Web::Page::set_is_scripting_enabled.
pub func page_set_is_scripting_enabled(this: Page*, b: bool):
    this.m_is_scripting_enabled = b

## Ported from Page.h:130 Web::Page::should_block_pop_ups.
pub func page_should_block_pop_ups(this: Page*) -> bool:
    return this.m_should_block_pop_ups

## Ported from Page.h:131 Web::Page::set_should_block_pop_ups.
pub func page_set_should_block_pop_ups(this: Page*, b: bool):
    this.m_should_block_pop_ups = b

## Ported from Page.h:133 Web::Page::enable_autoscroll.
pub func page_enable_autoscroll(this: Page*) -> bool:
    return this.m_enable_autoscroll

## Ported from Page.h:134 Web::Page::set_enable_autoscroll.
pub func page_set_enable_autoscroll(this: Page*, b: bool):
    this.m_enable_autoscroll = b

## Ported from Page.h:136 Web::Page::is_webdriver_active.
pub func page_is_webdriver_active(this: Page*) -> bool:
    return this.m_is_webdriver_active

## Ported from Page.h:137 Web::Page::set_is_webdriver_active.
pub func page_set_is_webdriver_active(this: Page*, b: bool):
    this.m_is_webdriver_active = b

## Ported from Page.h:139 Web::Page::is_hovering_link.
pub func page_is_hovering_link(this: Page*) -> bool:
    return this.m_is_hovering_link

## Ported from Page.h:140 Web::Page::set_is_hovering_link.
pub func page_set_is_hovering_link(this: Page*, b: bool):
    this.m_is_hovering_link = b

## Ported from Page.h:142 Web::Page::is_in_tooltip_area.
pub func page_is_in_tooltip_area(this: Page*) -> bool:
    return this.m_is_in_tooltip_area

## Ported from Page.h:143 Web::Page::set_is_in_tooltip_area.
pub func page_set_is_in_tooltip_area(this: Page*, b: bool):
    this.m_is_in_tooltip_area = b

## Ported from Page.h:145 Web::Page::current_cursor.
pub func page_current_cursor(this: Page*) -> gfx.Cursor:
    return this.m_current_cursor

## Ported from Page.h:146 Web::Page::set_current_cursor.
pub func page_set_current_cursor(this: Page*, cursor: gfx.Cursor):
    this.m_current_cursor = cursor

## Ported from Page.h:148 Web::Page::window_position.
pub func page_window_position(this: Page*) -> gfx.IntPoint:
    return this.m_window_position

## Ported from Page.h:149 Web::Page::set_window_position.
pub func page_set_window_position(this: Page*, position: gfx.IntPoint):
    this.m_window_position = position

## Ported from Page.h:151 Web::Page::window_size.
pub func page_window_size(this: Page*) -> gfx.IntSize:
    return this.m_window_size

## Ported from Page.h:152 Web::Page::set_window_size.
pub func page_set_window_size(this: Page*, size: gfx.IntSize):
    this.m_window_size = size

## Ported from Page.h:155 Web::Page::set_window_rect_observer.
pub func page_set_window_rect_observer(this: Page*, window_rect_observer: gc.Function1[gfx.DevicePixelRect, unit]*?):
    this.m_window_rect_observer = window_rect_observer

## Ported from Page.h:172 Web::Page::has_pending_dialog.
pub func page_has_pending_dialog(this: Page*) -> bool:
    return this.m_pending_dialog != PagePendingDialog.none_

## Ported from Page.h:173 Web::Page::pending_dialog.
pub func page_pending_dialog(this: Page*) -> PagePendingDialog:
    return this.m_pending_dialog

## Ported from Page.h:174 Web::Page::pending_dialog_text.
pub func page_pending_dialog_text(this: Page*) -> ak.String?:
    return this.m_pending_dialog_text