mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
input element properties
This commit is contained in:
@@ -626,6 +626,85 @@ pub const HTMLInputElement = struct {
|
|||||||
pub const Self = parser.Input;
|
pub const Self = parser.Input;
|
||||||
pub const prototype = *HTMLElement;
|
pub const prototype = *HTMLElement;
|
||||||
pub const subtype = .node;
|
pub const subtype = .node;
|
||||||
|
|
||||||
|
pub fn get_defaultValue(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetDefaultValue(self);
|
||||||
|
}
|
||||||
|
pub fn set_defaultValue(self: *parser.Input, default_value: []const u8) !void {
|
||||||
|
try parser.inputSetDefaultValue(self, default_value);
|
||||||
|
}
|
||||||
|
pub fn get_defaultChecked(self: *parser.Input) !bool {
|
||||||
|
return try parser.inputGetDefaultChecked(self);
|
||||||
|
}
|
||||||
|
pub fn set_defaultChecked(self: *parser.Input, default_checked: bool) !void {
|
||||||
|
try parser.inputSetDefaultChecked(self, default_checked);
|
||||||
|
}
|
||||||
|
pub fn get_from(self: *parser.Input) !?*parser.Form {
|
||||||
|
return try parser.inputGetForm(self);
|
||||||
|
}
|
||||||
|
pub fn get_accept(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetAccept(self);
|
||||||
|
}
|
||||||
|
pub fn set_accept(self: *parser.Input, accept: []const u8) !void {
|
||||||
|
try parser.inputSetAccept(self, accept);
|
||||||
|
}
|
||||||
|
pub fn get_alt(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetAlt(self);
|
||||||
|
}
|
||||||
|
pub fn set_alt(self: *parser.Input, alt: []const u8) !void {
|
||||||
|
try parser.inputSetAlt(self, alt);
|
||||||
|
}
|
||||||
|
pub fn get_checked(self: *parser.Input) !bool {
|
||||||
|
return try parser.inputGetChecked(self);
|
||||||
|
}
|
||||||
|
pub fn set_checked(self: *parser.Input, checked: bool) !void {
|
||||||
|
try parser.inputSetChecked(self, checked);
|
||||||
|
}
|
||||||
|
pub fn get_disabled(self: *parser.Input) !bool {
|
||||||
|
return try parser.inputGetDisabled(self);
|
||||||
|
}
|
||||||
|
pub fn set_disabled(self: *parser.Input, disabled: bool) !void {
|
||||||
|
try parser.inputSetDisabled(self, disabled);
|
||||||
|
}
|
||||||
|
pub fn get_maxLength(self: *parser.Input) !i32 {
|
||||||
|
return try parser.inputGetMaxLength(self);
|
||||||
|
}
|
||||||
|
pub fn set_maxLength(self: *parser.Input, max_length: u32) !void {
|
||||||
|
try parser.inputSetMaxLength(self, max_length);
|
||||||
|
}
|
||||||
|
pub fn get_name(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetName(self);
|
||||||
|
}
|
||||||
|
pub fn set_name(self: *parser.Input, name: []const u8) !void {
|
||||||
|
try parser.inputSetName(self, name);
|
||||||
|
}
|
||||||
|
pub fn get_readOnly(self: *parser.Input) !bool {
|
||||||
|
return try parser.inputGetReadOnly(self);
|
||||||
|
}
|
||||||
|
pub fn set_readOnly(self: *parser.Input, read_only: bool) !void {
|
||||||
|
try parser.inputSetReadOnly(self, read_only);
|
||||||
|
}
|
||||||
|
pub fn get_size(self: *parser.Input) !u32 {
|
||||||
|
return try parser.inputGetSize(self);
|
||||||
|
}
|
||||||
|
pub fn set_size(self: *parser.Input, size: u32) !void {
|
||||||
|
try parser.inputSetSize(self, size);
|
||||||
|
}
|
||||||
|
pub fn get_src(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetSrc(self);
|
||||||
|
}
|
||||||
|
pub fn set_src(self: *parser.Input, src: []const u8) !void {
|
||||||
|
try parser.inputSetSrc(self, src);
|
||||||
|
}
|
||||||
|
pub fn get_type(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetType(self);
|
||||||
|
}
|
||||||
|
pub fn get_value(self: *parser.Input) ![]const u8 {
|
||||||
|
return try parser.inputGetValue(self);
|
||||||
|
}
|
||||||
|
pub fn set_value(self: *parser.Input, value: []const u8) !void {
|
||||||
|
try parser.inputSetValue(self, value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HTMLLIElement = struct {
|
pub const HTMLLIElement = struct {
|
||||||
|
|||||||
@@ -2498,14 +2498,6 @@ pub fn optionSetSelected(option: *Option, selected: bool) !void {
|
|||||||
try DOMErr(err);
|
try DOMErr(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input
|
|
||||||
pub fn inputGetChecked(input: *Input) !bool {
|
|
||||||
var b: bool = false;
|
|
||||||
const err = c.dom_html_input_element_get_checked(input, &b);
|
|
||||||
try DOMErr(err);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HtmlCollection
|
// HtmlCollection
|
||||||
pub fn htmlCollectionGetLength(collection: *HTMLCollection) !u32 {
|
pub fn htmlCollectionGetLength(collection: *HTMLCollection) !u32 {
|
||||||
var len: u32 = 0;
|
var len: u32 = 0;
|
||||||
@@ -2601,3 +2593,166 @@ pub fn imageSetIsMap(image: *Image, is_map: bool) !void {
|
|||||||
const err = c.dom_html_image_element_set_is_map(image, is_map);
|
const err = c.dom_html_image_element_set_is_map(image, is_map);
|
||||||
try DOMErr(err);
|
try DOMErr(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Input
|
||||||
|
// - Input.align is deprecated
|
||||||
|
// - Input.useMap is deprecated
|
||||||
|
// - HTMLElement.access_key
|
||||||
|
// - HTMLElement.tabIndex
|
||||||
|
// TODO methods:
|
||||||
|
// - HTMLElement.blur
|
||||||
|
// - HTMLElement.focus
|
||||||
|
// - select
|
||||||
|
// - HTMLElement.click
|
||||||
|
|
||||||
|
pub fn inputGetDefaultValue(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_default_value(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetDefaultValue(input: *Input, default_value: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_default_value(input, try strFromData(default_value));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetDefaultChecked(input: *Input) !bool {
|
||||||
|
var default_checked: bool = false;
|
||||||
|
const err = c.dom_html_input_element_get_default_checked(input, &default_checked);
|
||||||
|
try DOMErr(err);
|
||||||
|
return default_checked;
|
||||||
|
}
|
||||||
|
pub fn inputSetDefaultChecked(input: *Input, default_checked: bool) !void {
|
||||||
|
const err = c.dom_html_input_element_set_default_checked(input, default_checked);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetForm(input: *Input) !?*Form {
|
||||||
|
var form: ?*Form = null;
|
||||||
|
const err = c.dom_html_input_element_get_form(input, &form);
|
||||||
|
try DOMErr(err);
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetAccept(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_accept(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetAccept(input: *Input, accept: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_accept(input, try strFromData(accept));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetAlt(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_alt(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetAlt(input: *Input, alt: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_alt(input, try strFromData(alt));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetChecked(input: *Input) !bool {
|
||||||
|
var checked: bool = false;
|
||||||
|
const err = c.dom_html_input_element_get_checked(input, &checked);
|
||||||
|
try DOMErr(err);
|
||||||
|
return checked;
|
||||||
|
}
|
||||||
|
pub fn inputSetChecked(input: *Input, checked: bool) !void {
|
||||||
|
const err = c.dom_html_input_element_set_checked(input, checked);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetDisabled(input: *Input) !bool {
|
||||||
|
var disabled: bool = false;
|
||||||
|
const err = c.dom_html_input_element_get_disabled(input, &disabled);
|
||||||
|
try DOMErr(err);
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
pub fn inputSetDisabled(input: *Input, disabled: bool) !void {
|
||||||
|
const err = c.dom_html_input_element_set_disabled(input, disabled);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetMaxLength(input: *Input) !i32 {
|
||||||
|
var max_length: i32 = 0;
|
||||||
|
const err = c.dom_html_input_element_get_max_length(input, &max_length);
|
||||||
|
try DOMErr(err);
|
||||||
|
return max_length;
|
||||||
|
}
|
||||||
|
pub fn inputSetMaxLength(input: *Input, max_length: u32) !void {
|
||||||
|
const err = c.dom_html_input_element_set_max_length(input, max_length);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetName(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_name(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetName(input: *Input, name: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_name(input, try strFromData(name));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
pub fn inputGetReadOnly(input: *Input) !bool {
|
||||||
|
var read_only: bool = false;
|
||||||
|
const err = c.dom_html_input_element_get_read_only(input, &read_only);
|
||||||
|
try DOMErr(err);
|
||||||
|
return read_only;
|
||||||
|
}
|
||||||
|
pub fn inputSetReadOnly(input: *Input, read_only: bool) !void {
|
||||||
|
const err = c.dom_html_input_element_set_read_only(input, read_only);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
pub fn inputGetSize(input: *Input) !u32 {
|
||||||
|
var size: u32 = 0;
|
||||||
|
const err = c.dom_html_input_element_get_size(input, &size);
|
||||||
|
try DOMErr(err);
|
||||||
|
if (size == ulongNegativeOne) return 20; // 20
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
pub fn inputSetSize(input: *Input, size: u32) !void {
|
||||||
|
const err = c.dom_html_input_element_set_size(input, size);
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetSrc(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_src(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetSrc(input: *Input, src: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_src(input, try strFromData(src));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetType(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_type(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inputGetValue(input: *Input) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_input_element_get_value(input, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
pub fn inputSetValue(input: *Input, value: []const u8) !void {
|
||||||
|
const err = c.dom_html_input_element_set_value(input, try strFromData(value));
|
||||||
|
try DOMErr(err);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user