diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 4f22b04a34..df7378da44 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -55,7 +55,7 @@ static String snake_name(const StringView& title_name) static String make_input_acceptable_cpp(const String& input) { - if (input == "class" || input == "template" || input == "for") { + if (input == "class" || input == "template" || input == "for" || input == "default") { StringBuilder builder; builder.append(input); builder.append('_'); @@ -755,9 +755,15 @@ JS_DEFINE_NATIVE_GETTER(@wrapper_class@::@attribute.getter_callback@) } if (attribute.extended_attributes.contains("Reflect")) { - attribute_generator.append(R"~~~( + if (attribute.type.name != "boolean") { + attribute_generator.append(R"~~~( auto retval = impl->attribute(HTML::AttributeNames::@attribute.reflect_name@); )~~~"); + } else { + attribute_generator.append(R"~~~( + auto retval = impl->has_attribute(HTML::AttributeNames::@attribute.reflect_name@); +)~~~"); + } } else { attribute_generator.append(R"~~~( auto retval = impl->@attribute.name:snakecase@(); @@ -782,9 +788,18 @@ JS_DEFINE_NATIVE_SETTER(@wrapper_class@::@attribute.setter_callback@) generate_to_cpp(attribute, "value", "", "cpp_value", true); if (attribute.extended_attributes.contains("Reflect")) { - attribute_generator.append(R"~~~( + if (attribute.type.name != "boolean") { + attribute_generator.append(R"~~~( impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, cpp_value); )~~~"); + } else { + attribute_generator.append(R"~~~( + if (!cpp_value) + impl->remove_attribute(HTML::AttributeNames::@attribute.reflect_name@); + else + impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, String::empty()); +)~~~"); + } } else { attribute_generator.append(R"~~~( impl->set_@attribute.name:snakecase@(cpp_value); diff --git a/Libraries/LibWeb/HTML/AttributeNames.cpp b/Libraries/LibWeb/HTML/AttributeNames.cpp index 575b92e789..2964e06b1f 100644 --- a/Libraries/LibWeb/HTML/AttributeNames.cpp +++ b/Libraries/LibWeb/HTML/AttributeNames.cpp @@ -51,6 +51,7 @@ ENUMERATE_HTML_ATTRIBUTES // NOTE: Special case for the class and for attributes since they're C++ keywords. class_ = "class"; for_ = "for"; + default_ = "default"; // NOTE: Special cases for attributes with dashes in them. accept_charset = "accept-charset"; diff --git a/Libraries/LibWeb/HTML/AttributeNames.h b/Libraries/LibWeb/HTML/AttributeNames.h index 0a71a8af46..0ff091f0bc 100644 --- a/Libraries/LibWeb/HTML/AttributeNames.h +++ b/Libraries/LibWeb/HTML/AttributeNames.h @@ -39,8 +39,10 @@ namespace AttributeNames { __ENUMERATE_HTML_ATTRIBUTE(action) \ __ENUMERATE_HTML_ATTRIBUTE(align) \ __ENUMERATE_HTML_ATTRIBUTE(allow) \ + __ENUMERATE_HTML_ATTRIBUTE(allowfullscreen) \ __ENUMERATE_HTML_ATTRIBUTE(alt) \ __ENUMERATE_HTML_ATTRIBUTE(async) \ + __ENUMERATE_HTML_ATTRIBUTE(autoplay) \ __ENUMERATE_HTML_ATTRIBUTE(behaviour) \ __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ __ENUMERATE_HTML_ATTRIBUTE(checked) \ @@ -51,18 +53,23 @@ namespace AttributeNames { __ENUMERATE_HTML_ATTRIBUTE(colspan) \ __ENUMERATE_HTML_ATTRIBUTE(content) \ __ENUMERATE_HTML_ATTRIBUTE(contenteditable) \ + __ENUMERATE_HTML_ATTRIBUTE(controls) \ __ENUMERATE_HTML_ATTRIBUTE(data) \ __ENUMERATE_HTML_ATTRIBUTE(datetime) \ + __ENUMERATE_HTML_ATTRIBUTE(default_) \ + __ENUMERATE_HTML_ATTRIBUTE(defer) \ __ENUMERATE_HTML_ATTRIBUTE(disabled) \ __ENUMERATE_HTML_ATTRIBUTE(download) \ - __ENUMERATE_HTML_ATTRIBUTE(defer) \ __ENUMERATE_HTML_ATTRIBUTE(direction) \ __ENUMERATE_HTML_ATTRIBUTE(dirname) \ __ENUMERATE_HTML_ATTRIBUTE(face) \ __ENUMERATE_HTML_ATTRIBUTE(for_) \ + __ENUMERATE_HTML_ATTRIBUTE(formnovalidate) \ + __ENUMERATE_HTML_ATTRIBUTE(formtarget) \ __ENUMERATE_HTML_ATTRIBUTE(frameborder) \ __ENUMERATE_HTML_ATTRIBUTE(headers) \ __ENUMERATE_HTML_ATTRIBUTE(height) \ + __ENUMERATE_HTML_ATTRIBUTE(hidden) \ __ENUMERATE_HTML_ATTRIBUTE(href) \ __ENUMERATE_HTML_ATTRIBUTE(hreflang) \ __ENUMERATE_HTML_ATTRIBUTE(http_equiv) \ @@ -70,21 +77,32 @@ namespace AttributeNames { __ENUMERATE_HTML_ATTRIBUTE(imagesizes) \ __ENUMERATE_HTML_ATTRIBUTE(imagesrcset) \ __ENUMERATE_HTML_ATTRIBUTE(integrity) \ + __ENUMERATE_HTML_ATTRIBUTE(ismap) \ __ENUMERATE_HTML_ATTRIBUTE(label) \ __ENUMERATE_HTML_ATTRIBUTE(lang) \ __ENUMERATE_HTML_ATTRIBUTE(longdesc) \ + __ENUMERATE_HTML_ATTRIBUTE(loop) \ __ENUMERATE_HTML_ATTRIBUTE(max) \ __ENUMERATE_HTML_ATTRIBUTE(media) \ __ENUMERATE_HTML_ATTRIBUTE(method) \ __ENUMERATE_HTML_ATTRIBUTE(min) \ + __ENUMERATE_HTML_ATTRIBUTE(multiple) \ __ENUMERATE_HTML_ATTRIBUTE(name) \ + __ENUMERATE_HTML_ATTRIBUTE(nomodule) \ + __ENUMERATE_HTML_ATTRIBUTE(novalidate) \ + __ENUMERATE_HTML_ATTRIBUTE(open) \ __ENUMERATE_HTML_ATTRIBUTE(pattern) \ __ENUMERATE_HTML_ATTRIBUTE(ping) \ __ENUMERATE_HTML_ATTRIBUTE(placeholder) \ + __ENUMERATE_HTML_ATTRIBUTE(playsinline) \ __ENUMERATE_HTML_ATTRIBUTE(poster) \ + __ENUMERATE_HTML_ATTRIBUTE(readonly) \ __ENUMERATE_HTML_ATTRIBUTE(rel) \ + __ENUMERATE_HTML_ATTRIBUTE(required) \ + __ENUMERATE_HTML_ATTRIBUTE(reversed) \ __ENUMERATE_HTML_ATTRIBUTE(rows) \ __ENUMERATE_HTML_ATTRIBUTE(scrolling) \ + __ENUMERATE_HTML_ATTRIBUTE(selected) \ __ENUMERATE_HTML_ATTRIBUTE(size) \ __ENUMERATE_HTML_ATTRIBUTE(sizes) \ __ENUMERATE_HTML_ATTRIBUTE(src) \ diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.idl b/Libraries/LibWeb/HTML/HTMLButtonElement.idl index 744176f18c..d9608e2490 100644 --- a/Libraries/LibWeb/HTML/HTMLButtonElement.idl +++ b/Libraries/LibWeb/HTML/HTMLButtonElement.idl @@ -1,5 +1,8 @@ interface HTMLButtonElement : HTMLElement { + [Reflect=formnovalidate] attribute boolean formNoValidate; + [Reflect=formtarget] attribute DOMString formTarget; + [Reflect] attribute DOMString name; [Reflect] attribute DOMString value; } diff --git a/Libraries/LibWeb/HTML/HTMLDetailsElement.idl b/Libraries/LibWeb/HTML/HTMLDetailsElement.idl index ea04cf280b..36466990b7 100644 --- a/Libraries/LibWeb/HTML/HTMLDetailsElement.idl +++ b/Libraries/LibWeb/HTML/HTMLDetailsElement.idl @@ -1,5 +1,5 @@ interface HTMLDetailsElement : HTMLElement { - + [Reflect] attribute boolean open; } diff --git a/Libraries/LibWeb/HTML/HTMLDialogElement.idl b/Libraries/LibWeb/HTML/HTMLDialogElement.idl index b63ff85cc6..7ef4e71c66 100644 --- a/Libraries/LibWeb/HTML/HTMLDialogElement.idl +++ b/Libraries/LibWeb/HTML/HTMLDialogElement.idl @@ -1,5 +1,5 @@ interface HTMLDialogElement : HTMLElement { - + [Reflect] attribute boolean open; } diff --git a/Libraries/LibWeb/HTML/HTMLElement.idl b/Libraries/LibWeb/HTML/HTMLElement.idl index 9991a76b78..4966f0af18 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.idl +++ b/Libraries/LibWeb/HTML/HTMLElement.idl @@ -3,6 +3,8 @@ interface HTMLElement : Element { [Reflect] attribute DOMString title; [Reflect] attribute DOMString lang; + [Reflect] attribute boolean hidden; + attribute DOMString contentEditable; } diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.idl b/Libraries/LibWeb/HTML/HTMLFormElement.idl index 810b167de1..833910914d 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.idl +++ b/Libraries/LibWeb/HTML/HTMLFormElement.idl @@ -3,5 +3,6 @@ interface HTMLFormElement : HTMLElement { [Reflect] attribute DOMString name; [Reflect] attribute DOMString rel; [Reflect=accept-charset] attribute DOMString acceptCharset; + [Reflect=novalidate] attribute boolean noValidate; } diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.idl b/Libraries/LibWeb/HTML/HTMLIFrameElement.idl index 5a9e2bf186..74d572ee30 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.idl +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.idl @@ -6,6 +6,7 @@ interface HTMLIFrameElement : HTMLElement { [Reflect] attribute DOMString allow; [Reflect] attribute DOMString width; [Reflect] attribute DOMString height; + [Reflect=allowfullscreen] attribute boolean allowFullscreen; [ReturnNullIfCrossOrigin] readonly attribute Document? contentDocument; } diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.idl b/Libraries/LibWeb/HTML/HTMLImageElement.idl index f1ffbbcfe4..6de12db118 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.idl +++ b/Libraries/LibWeb/HTML/HTMLImageElement.idl @@ -5,5 +5,6 @@ interface HTMLImageElement : HTMLElement { [Reflect] attribute DOMString srcset; [Reflect] attribute DOMString sizes; [Reflect=usemap] attribute DOMString useMap; + [Reflect=ismap] attribute boolean isMap; } diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Libraries/LibWeb/HTML/HTMLInputElement.idl index fa77917cc7..b62010f7e7 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -12,4 +12,13 @@ interface HTMLInputElement : HTMLElement { [Reflect=value] attribute DOMString defaultValue; attribute boolean checked; + + [Reflect] attribute boolean disabled; + [Reflect=checked] attribute boolean defaultChecked; + [Reflect=formnovalidate] attribute boolean formNoValidate; + [Reflect=formtarget] attribute DOMString formTarget; + [Reflect] attribute boolean multiple; + [Reflect=readonly] attribute boolean readOnly; + [Reflect] attribute boolean required; + } diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.idl b/Libraries/LibWeb/HTML/HTMLLinkElement.idl index f96c5e8bd9..0299f36c04 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.idl +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.idl @@ -8,5 +8,6 @@ interface HTMLLinkElement : HTMLElement { [Reflect] attribute DOMString type; [Reflect=imagesrcset] attribute DOMString imageSrcset; [Reflect=imagesizes] attribute DOMString imageSizes; + [Reflect] attribute boolean disabled; } diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.idl b/Libraries/LibWeb/HTML/HTMLMediaElement.idl index a720767851..7894c87ef6 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.idl +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.idl @@ -2,4 +2,9 @@ interface HTMLMediaElement : HTMLElement { [Reflect] attribute DOMString src; + [Reflect] attribute boolean autoplay; + [Reflect] attribute boolean loop; + + [Reflect] attribute boolean controls; + } diff --git a/Libraries/LibWeb/HTML/HTMLOListElement.idl b/Libraries/LibWeb/HTML/HTMLOListElement.idl index 21bc9ac60b..d5fa081ebf 100644 --- a/Libraries/LibWeb/HTML/HTMLOListElement.idl +++ b/Libraries/LibWeb/HTML/HTMLOListElement.idl @@ -1,5 +1,6 @@ interface HTMLOListElement : HTMLElement { + [Reflect] attribute boolean reversed; [Reflect] attribute DOMString type; } diff --git a/Libraries/LibWeb/HTML/HTMLOptGroupElement.idl b/Libraries/LibWeb/HTML/HTMLOptGroupElement.idl index 67d111bc1d..815b1d4e28 100644 --- a/Libraries/LibWeb/HTML/HTMLOptGroupElement.idl +++ b/Libraries/LibWeb/HTML/HTMLOptGroupElement.idl @@ -1,5 +1,6 @@ interface HTMLOptGroupElement : HTMLElement { + [Reflect] attribute boolean disabled; [Reflect] attribute DOMString label; } diff --git a/Libraries/LibWeb/HTML/HTMLOptionElement.idl b/Libraries/LibWeb/HTML/HTMLOptionElement.idl index 37533893c0..0aa8f4e114 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionElement.idl +++ b/Libraries/LibWeb/HTML/HTMLOptionElement.idl @@ -1,5 +1,6 @@ interface HTMLOptionElement : HTMLElement { - + [Reflect] attribute boolean disabled; + [Reflect=selected] attribute boolean defaultSelected; } diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.idl b/Libraries/LibWeb/HTML/HTMLScriptElement.idl index 93675f7219..b82d8d0aa4 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.idl +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.idl @@ -2,6 +2,8 @@ interface HTMLScriptElement : HTMLElement { [Reflect] attribute DOMString src; [Reflect] attribute DOMString type; + [Reflect=nomodule] attribute boolean noModule; + [Reflect] attribute boolean defer; [Reflect] attribute DOMString integrity; } diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.idl b/Libraries/LibWeb/HTML/HTMLSelectElement.idl index 9164c2b9a5..832773a805 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.idl +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.idl @@ -1,5 +1,7 @@ interface HTMLSelectElement : HTMLElement { - + [Reflect] attribute boolean disabled; + [Reflect] attribute boolean multiple; + [Reflect] attribute boolean required; } diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl b/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl index 3ae722afed..58d785d094 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl @@ -1,7 +1,12 @@ interface HTMLTextAreaElement : HTMLElement { [Reflect] attribute DOMString placeholder; + [Reflect] attribute DOMString name; [Reflect] attribute DOMString wrap; readonly attribute DOMString type; + [Reflect] attribute boolean disabled; + [Reflect=readonly] attribute boolean readOnly; + [Reflect] attribute boolean required; + } diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.idl b/Libraries/LibWeb/HTML/HTMLTrackElement.idl index f61856050f..a8e2cac9a7 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.idl +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.idl @@ -3,5 +3,6 @@ interface HTMLTrackElement : HTMLElement { [Reflect] attribute DOMString src; [Reflect] attribute DOMString srclang; [Reflect] attribute DOMString label; + [Reflect] attribute boolean default; } diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.idl b/Libraries/LibWeb/HTML/HTMLVideoElement.idl index 2fce09047e..2a43e60457 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.idl +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.idl @@ -1,5 +1,6 @@ interface HTMLVideoElement : HTMLMediaElement { [Reflect] attribute DOMString poster; + [Reflect=playsinline] attribute boolean playsInline; }