mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
use inputGetType and add buttonGetType
This commit is contained in:
@@ -2834,3 +2834,11 @@ pub fn inputSetValue(input: *Input, value: []const u8) !void {
|
|||||||
const err = c.dom_html_input_element_set_value(input, try strFromData(value));
|
const err = c.dom_html_input_element_set_value(input, try strFromData(value));
|
||||||
try DOMErr(err);
|
try DOMErr(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn buttonGetType(button: *Button) ![]const u8 {
|
||||||
|
var s_: ?*String = null;
|
||||||
|
const err = c.dom_html_button_element_get_type(button, &s_);
|
||||||
|
try DOMErr(err);
|
||||||
|
const s = s_ orelse return "button";
|
||||||
|
return strToData(s);
|
||||||
|
}
|
||||||
|
|||||||
@@ -582,14 +582,14 @@ pub const Page = struct {
|
|||||||
},
|
},
|
||||||
.input => {
|
.input => {
|
||||||
const element: *parser.Element = @ptrCast(node);
|
const element: *parser.Element = @ptrCast(node);
|
||||||
const input_type = (try parser.elementGetAttribute(element, "type")) orelse return;
|
const input_type = try parser.inputGetType(@ptrCast(element));
|
||||||
if (std.ascii.eqlIgnoreCase(input_type, "submit")) {
|
if (std.ascii.eqlIgnoreCase(input_type, "submit")) {
|
||||||
return self.elementSubmitForm(element);
|
return self.elementSubmitForm(element);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.button => {
|
.button => {
|
||||||
const element: *parser.Element = @ptrCast(node);
|
const element: *parser.Element = @ptrCast(node);
|
||||||
const button_type = (try parser.elementGetAttribute(element, "type")) orelse return;
|
const button_type = try parser.buttonGetType(@ptrCast(element));
|
||||||
if (std.ascii.eqlIgnoreCase(button_type, "submit")) {
|
if (std.ascii.eqlIgnoreCase(button_type, "submit")) {
|
||||||
return self.elementSubmitForm(element);
|
return self.elementSubmitForm(element);
|
||||||
}
|
}
|
||||||
@@ -661,7 +661,7 @@ pub const Page = struct {
|
|||||||
switch (tag) {
|
switch (tag) {
|
||||||
.input => {
|
.input => {
|
||||||
const element: *parser.Element = @ptrCast(node);
|
const element: *parser.Element = @ptrCast(node);
|
||||||
const input_type = (try parser.elementGetAttribute(element, "type")) orelse "text";
|
const input_type = try parser.inputGetType(@ptrCast(element));
|
||||||
if (std.mem.eql(u8, input_type, "text")) {
|
if (std.mem.eql(u8, input_type, "text")) {
|
||||||
if (std.mem.eql(u8, new_key, "Enter")) {
|
if (std.mem.eql(u8, new_key, "Enter")) {
|
||||||
const form = (try self.formForElement(element)) orelse return;
|
const form = (try self.formForElement(element)) orelse return;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ fn collectForm(form: *parser.Form, submitter_: ?*parser.ElementHTML, page: *Page
|
|||||||
const tag = try parser.elementHTMLGetTagType(@as(*parser.ElementHTML, @ptrCast(element)));
|
const tag = try parser.elementHTMLGetTagType(@as(*parser.ElementHTML, @ptrCast(element)));
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
.input => {
|
.input => {
|
||||||
const tpe = try parser.elementGetAttribute(element, "type") orelse "";
|
const tpe = try parser.inputGetType(@ptrCast(element));
|
||||||
if (std.ascii.eqlIgnoreCase(tpe, "image")) {
|
if (std.ascii.eqlIgnoreCase(tpe, "image")) {
|
||||||
if (submitter_name_) |submitter_name| {
|
if (submitter_name_) |submitter_name| {
|
||||||
if (std.mem.eql(u8, submitter_name, name)) {
|
if (std.mem.eql(u8, submitter_name, name)) {
|
||||||
@@ -249,7 +249,7 @@ fn getSubmitterName(submitter_: ?*parser.ElementHTML) !?[]const u8 {
|
|||||||
switch (tag) {
|
switch (tag) {
|
||||||
.button => return name,
|
.button => return name,
|
||||||
.input => {
|
.input => {
|
||||||
const tpe = (try parser.elementGetAttribute(element, "type")) orelse "";
|
const tpe = try parser.inputGetType(@ptrCast(element));
|
||||||
// only an image type can be a sumbitter
|
// only an image type can be a sumbitter
|
||||||
if (std.ascii.eqlIgnoreCase(tpe, "image") or std.ascii.eqlIgnoreCase(tpe, "submit")) {
|
if (std.ascii.eqlIgnoreCase(tpe, "image") or std.ascii.eqlIgnoreCase(tpe, "submit")) {
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
Reference in New Issue
Block a user