mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 21:49:42 +00:00
LibWeb: Implement HTMLElement.draggable()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
615034433b
commit
c2fc4b25cd
Notes:
github-actions[bot]
2025-08-12 16:16:14 +00:00
Author: https://github.com/lukasxcs 🔰
Commit: c2fc4b25cd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5836
Reviewed-by: https://github.com/tcl3 ✅
7 changed files with 282 additions and 1 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <LibWeb/HTML/HTMLDialogElement.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/HTMLLabelElement.h>
|
||||
#include <LibWeb/HTML/HTMLObjectElement.h>
|
||||
#include <LibWeb/HTML/HTMLParagraphElement.h>
|
||||
#include <LibWeb/HTML/PopoverInvokerElement.h>
|
||||
#include <LibWeb/HTML/ToggleEvent.h>
|
||||
|
@ -2093,4 +2094,41 @@ String HTMLElement::access_key_label() const
|
|||
return String {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#dom-draggable
|
||||
bool HTMLElement::draggable() const
|
||||
{
|
||||
auto attribute = get_attribute(HTML::AttributeNames::draggable);
|
||||
|
||||
// If an element's draggable content attribute has the state True, the draggable IDL attribute must return true.
|
||||
if (attribute.has_value() && attribute->equals_ignoring_ascii_case("true"sv)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If an element's draggable content attribute has the state False, the draggable IDL attribute must return false.
|
||||
if (attribute.has_value() && attribute->equals_ignoring_ascii_case("false"sv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, the element's draggable content attribute has the state Auto.
|
||||
|
||||
// If the element is an img element, the draggable IDL attribute must return true.
|
||||
if (is<HTML::HTMLImageElement>(*this)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the element is an object element that represents an image, the draggable IDL attribute must return true.
|
||||
if (is<HTML::HTMLObjectElement>(*this)) {
|
||||
if (auto type_attribute = get_attribute(HTML::AttributeNames::type); type_attribute.has_value() && type_attribute->equals_ignoring_ascii_case("image"sv))
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the element is an a element with an href content attribute, the draggable IDL attribute must return true.
|
||||
if (is<HTML::HTMLAnchorElement>(*this) && has_attribute(HTML::AttributeNames::href)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, the draggable IDL attribute must return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue