
This change adds checking for the following spec requirements: - https://html.spec.whatwg.org/#number-state-(type=number):value-sanitization-algorithm - https://html.spec.whatwg.org/#range-state-(type=range):value-sanitization-algorithm That is, it adds checking that HTMLInputElement.value is what the spec defines as a “valid floating-point number” when the “type” attribute for the HTMLInputElement is either “number” or “range”. This change causes Ladybird to pass all the failing tests at https://wpt.fyi/results/html/semantics/forms/the-input-element/number.html?run_id=5080423051034624 and to match the relevant behavior in Webkit, Blink, and Gecko. Otherwise, without this change, Ladybird fails those tests, and the relevant Ladybird behavior isn’t interoperable with other engines.
26 lines
609 B
C++
26 lines
609 B
C++
/*
|
|
* Copyright (c) 2023, Jonatan Klemets <jonatan.r.klemets@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <AK/String.h>
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
|
#include <LibWeb/WebIDL/Types.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
Optional<i32> parse_integer(StringView string);
|
|
|
|
Optional<u32> parse_non_negative_integer(StringView string);
|
|
|
|
Optional<double> parse_floating_point_number(StringView string);
|
|
|
|
bool is_valid_floating_point_number(StringView string);
|
|
|
|
WebIDL::ExceptionOr<String> convert_non_negative_integer_to_string(JS::Realm&, WebIDL::Long);
|
|
|
|
}
|