diff --git a/Base/res/html/misc/select.html b/Base/res/html/misc/select.html index d60addcd172..7cb7e856b00 100644 --- a/Base/res/html/misc/select.html +++ b/Base/res/html/misc/select.html @@ -72,19 +72,16 @@ Lecture 01: Powers of Ten Lecture 02: 1D Kinematics Lecture 03: Vectors - Lecture 04: Random - + Lecture 01: What holds our world together? Lecture 02: Electric Field Lecture 03: Electric Flux - Lecture 04: Random Lecture 01: Periodic Phenomenon Lecture 02: Beats Lecture 03: Forced Oscillations with Damping - Lecture 04: Random Value: ? diff --git a/Ladybird/AppKit/UI/LadybirdWebView.mm b/Ladybird/AppKit/UI/LadybirdWebView.mm index 1c7ceb2b18b..cbd7119635b 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.mm +++ b/Ladybird/AppKit/UI/LadybirdWebView.mm @@ -714,7 +714,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_ auto add_menu_item = [self](Web::HTML::SelectItemOption const& item_option) { NSMenuItem* menuItem = [[NSMenuItem alloc] initWithTitle:Ladybird::string_to_ns_string(item_option.label) - action:@selector(selectDropdownAction:) + action:item_option.disabled ? nil : @selector(selectDropdownAction:) keyEquivalent:@""]; menuItem.representedObject = [NSNumber numberWithUnsignedInt:item_option.id]; menuItem.state = item_option.selected ? NSControlStateValueOn : NSControlStateValueOff; diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index be693e60b75..350f8e88d23 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -336,6 +336,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St QAction* action = new QAction(qstring_from_ak_string(item_option.label), this); action->setCheckable(true); action->setChecked(item_option.selected); + action->setDisabled(item_option.disabled); action->setData(QVariant(static_cast(item_option.id))); QObject::connect(action, &QAction::triggered, this, &Tab::select_dropdown_action); m_select_dropdown->addAction(action); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 9f8ca136214..840a3830694 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -661,6 +661,7 @@ Tab::Tab(BrowserWindow& window) }); action->set_checkable(true); action->set_checked(item_option.selected); + action->set_enabled(!item_option.disabled); m_select_dropdown->add_action(action); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index e3bc9277d68..0f26de16f24 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -290,7 +290,7 @@ void HTMLSelectElement::activation_behavior(DOM::Event const&) for (auto const& child : opt_group_element.children_as_vector()) { if (is(*child)) { auto& option_element = verify_cast(*child); - option_group_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element }); + option_group_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element.disabled(), option_element }); } } m_select_items.append(SelectItemOptionGroup { opt_group_element.get_attribute(AttributeNames::label).value_or(String {}), option_group_items }); @@ -298,7 +298,7 @@ void HTMLSelectElement::activation_behavior(DOM::Event const&) if (is(*child)) { auto& option_element = verify_cast(*child); - m_select_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element }); + m_select_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element.disabled(), option_element }); } if (is(*child)) diff --git a/Userland/Libraries/LibWeb/HTML/SelectItem.cpp b/Userland/Libraries/LibWeb/HTML/SelectItem.cpp index c5bb67a1350..d0f6d5307a6 100644 --- a/Userland/Libraries/LibWeb/HTML/SelectItem.cpp +++ b/Userland/Libraries/LibWeb/HTML/SelectItem.cpp @@ -15,6 +15,7 @@ ErrorOr IPC::encode(Encoder& encoder, Web::HTML::SelectItemOption const& i TRY(encoder.encode(item.label)); TRY(encoder.encode(item.value)); TRY(encoder.encode(item.selected)); + TRY(encoder.encode(item.disabled)); return {}; } @@ -25,7 +26,8 @@ ErrorOr IPC::decode(Decoder& decoder) auto label = TRY(decoder.decode()); auto value = TRY(decoder.decode()); auto selected = TRY(decoder.decode()); - return Web::HTML::SelectItemOption { id, move(label), move(value), selected }; + auto disabled = TRY(decoder.decode()); + return Web::HTML::SelectItemOption { id, move(label), move(value), selected, disabled }; } template<> diff --git a/Userland/Libraries/LibWeb/HTML/SelectItem.h b/Userland/Libraries/LibWeb/HTML/SelectItem.h index dddd3491d13..8278876501c 100644 --- a/Userland/Libraries/LibWeb/HTML/SelectItem.h +++ b/Userland/Libraries/LibWeb/HTML/SelectItem.h @@ -17,6 +17,7 @@ struct SelectItemOption { String label {}; String value {}; bool selected { false }; + bool disabled { false }; JS::GCPtr option_element {}; };