mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1622 from egrs/wpt-fixes-batch-3
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
fix WPT: document.implementation identity, file input value
This commit is contained in:
@@ -53,6 +53,7 @@ _elements_by_id: std.StringHashMapUnmanaged(*Element) = .empty,
|
|||||||
_removed_ids: std.StringHashMapUnmanaged(void) = .empty,
|
_removed_ids: std.StringHashMapUnmanaged(void) = .empty,
|
||||||
_active_element: ?*Element = null,
|
_active_element: ?*Element = null,
|
||||||
_style_sheets: ?*StyleSheetList = null,
|
_style_sheets: ?*StyleSheetList = null,
|
||||||
|
_implementation: ?*DOMImplementation = null,
|
||||||
_fonts: ?*FontFaceSet = null,
|
_fonts: ?*FontFaceSet = null,
|
||||||
_write_insertion_point: ?*Node = null,
|
_write_insertion_point: ?*Node = null,
|
||||||
_script_created_parser: ?Parser.Streaming = null,
|
_script_created_parser: ?Parser.Streaming = null,
|
||||||
@@ -274,8 +275,11 @@ pub fn querySelectorAll(self: *Document, input: String, page: *Page) !*Selector.
|
|||||||
return Selector.querySelectorAll(self.asNode(), input.str(), page);
|
return Selector.querySelectorAll(self.asNode(), input.str(), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getImplementation(_: *const Document) DOMImplementation {
|
pub fn getImplementation(self: *Document, page: *Page) !*DOMImplementation {
|
||||||
return .{};
|
if (self._implementation) |impl| return impl;
|
||||||
|
const impl = try page._factory.create(DOMImplementation{});
|
||||||
|
self._implementation = impl;
|
||||||
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createDocumentFragment(self: *Document, page: *Page) !*Node.DocumentFragment {
|
pub fn createDocumentFragment(self: *Document, page: *Page) !*Node.DocumentFragment {
|
||||||
@@ -737,6 +741,7 @@ pub fn open(self: *Document, page: *Page) !*Document {
|
|||||||
self._elements_by_id.clearAndFree(page.arena);
|
self._elements_by_id.clearAndFree(page.arena);
|
||||||
self._active_element = null;
|
self._active_element = null;
|
||||||
self._style_sheets = null;
|
self._style_sheets = null;
|
||||||
|
self._implementation = null;
|
||||||
self._ready_state = .loading;
|
self._ready_state = .loading;
|
||||||
|
|
||||||
self._script_created_parser = Parser.Streaming.init(page.arena, doc_node, page);
|
self._script_created_parser = Parser.Streaming.init(page.arena, doc_node, page);
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ pub fn setType(self: *Input, typ: []const u8, page: *Page) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getValue(self: *const Input) []const u8 {
|
pub fn getValue(self: *const Input) []const u8 {
|
||||||
|
if (self._input_type == .file) return "";
|
||||||
return self._value orelse self._default_value orelse switch (self._input_type) {
|
return self._value orelse self._default_value orelse switch (self._input_type) {
|
||||||
.checkbox, .radio => "on",
|
.checkbox, .radio => "on",
|
||||||
else => "",
|
else => "",
|
||||||
@@ -132,8 +133,9 @@ pub fn getValue(self: *const Input) []const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn setValue(self: *Input, value: []const u8, page: *Page) !void {
|
pub fn setValue(self: *Input, value: []const u8, page: *Page) !void {
|
||||||
// File inputs cannot have their value set programmatically for security reasons
|
// File inputs: setting to empty string is a no-op, anything else throws
|
||||||
if (self._input_type == .file) {
|
if (self._input_type == .file) {
|
||||||
|
if (value.len == 0) return;
|
||||||
return error.InvalidStateError;
|
return error.InvalidStateError;
|
||||||
}
|
}
|
||||||
// This should _not_ call setAttribute. It updates the current state only
|
// This should _not_ call setAttribute. It updates the current state only
|
||||||
@@ -866,9 +868,17 @@ pub const JsApi = struct {
|
|||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Handles [LegacyNullToEmptyString]: null → "" per HTML spec.
|
||||||
|
fn setValueFromJS(self: *Input, js_value: js.Value, page: *Page) !void {
|
||||||
|
if (js_value.isNull()) {
|
||||||
|
return self.setValue("", page);
|
||||||
|
}
|
||||||
|
return self.setValue(try js_value.toZig([]const u8), page);
|
||||||
|
}
|
||||||
|
|
||||||
pub const onselectionchange = bridge.accessor(Input.getOnSelectionChange, Input.setOnSelectionChange, .{});
|
pub const onselectionchange = bridge.accessor(Input.getOnSelectionChange, Input.setOnSelectionChange, .{});
|
||||||
pub const @"type" = bridge.accessor(Input.getType, Input.setType, .{});
|
pub const @"type" = bridge.accessor(Input.getType, Input.setType, .{});
|
||||||
pub const value = bridge.accessor(Input.getValue, Input.setValue, .{ .dom_exception = true });
|
pub const value = bridge.accessor(Input.getValue, setValueFromJS, .{ .dom_exception = true });
|
||||||
pub const defaultValue = bridge.accessor(Input.getDefaultValue, Input.setDefaultValue, .{});
|
pub const defaultValue = bridge.accessor(Input.getDefaultValue, Input.setDefaultValue, .{});
|
||||||
pub const checked = bridge.accessor(Input.getChecked, Input.setChecked, .{});
|
pub const checked = bridge.accessor(Input.getChecked, Input.setChecked, .{});
|
||||||
pub const defaultChecked = bridge.accessor(Input.getDefaultChecked, Input.setDefaultChecked, .{});
|
pub const defaultChecked = bridge.accessor(Input.getDefaultChecked, Input.setDefaultChecked, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user