Commit graph

24 commits

Author SHA1 Message Date
Jelle Raaijmakers
495006ddb5 LibWeb: Implement document.execCommand('insertLinebreak') 2024-12-10 19:34:38 +01:00
Jelle Raaijmakers
30ec8c1d4d LibWeb: Implement "delete the selection" for the editing API 2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
bfb87b24a3 LibWeb: Use verify_cast in insertParagraph command
No functional changes.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
1c55153d43 LibWeb: Refactor "editable" and "editing host" concepts
The DOM spec defines what it means for an element to be an "editing
host", and the Editing spec does the same for the "editable" concept.
Replace our `Node::is_editable()` implementation with these
spec-compliant algorithms.

An editing host is an element that has the properties to make its
contents effectively editable. Editable elements are descendants of an
editing host. Concepts like the inheritable contenteditable attribute
are propagated through the editable algorithm.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
f88c13a58c LibWeb: Prevent null deref in collapsed whitespace check
The spec even warned us about the reference potentially being null.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
d5143db081 LibWeb: Skip node trees outside of range in insertParagraph
Instead of recursively iterating all descendants of the common ancestor
of the new line range that are not contained by that range, skip the
entire node tree as soon as we determine they're not.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
90d884a150 LibWeb: Prevent crash when editing outside of <body>
Step 9 of this algorithm might end up at the document node, which does
not have a parent.
2024-12-04 17:18:00 +01:00
Jelle Raaijmakers
9b446df7f5 LibWeb: Replace local name checks with simpler is<T> in editing API 2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
e308a3fd3f LibWeb: Be more defensive while traversing ancestors in editing API
In all these cases there should be an ancestor available, but it
definitely cannot hurt to be a bit more defensive about this and prevent
nullptr dereferences.
2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
b6939c8035 LibWeb: Use wrap algorithm in "fix disallowed ancestors"
We have the wrap algorithm implemented now, so resolve the FIXME.
2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
4f76cec096 LibWeb: Implement document.execCommand("insertParagraph") 2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
2e29d3fb57 LibWeb: Fix is_allowed_child_of_node() for non-element parent node
When passing a DOM::Node that is not a DOM::Element, this method would
always try to cast to a DOM::Element.
2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
a62b664d0d LibWeb: Put editing command "styleWithCSS" in alphabetical order 2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
98df4c2b3c LibWeb: Make Editing::fix_disallowed_ancestors_of_node() take a GC::Ref 2024-12-04 06:51:59 +01:00
Jelle Raaijmakers
6a85677f70 LibWeb: Expose HTMLElement's content editable state 2024-12-03 00:18:03 +01:00
Jelle Raaijmakers
c9a6bac57f LibWeb: Fix always-enabled copy command in queryCommandEnabled()
The "copy" command is not in the Miscellaneous commands section. The
"defaultParagraphSeparator" command is, however. Let the accompanying
comment reflect that.
2024-12-03 00:18:03 +01:00
Jelle Raaijmakers
3f1523b16c LibWeb: Disable execCommand() commands in plaintext-only editing state 2024-12-03 00:18:03 +01:00
Jelle Raaijmakers
217567981a LibWeb: Implement "plaintext-only" state for contenteditable 2024-12-03 00:18:03 +01:00
Jelle Raaijmakers
7e406ac668 LibWeb: Simplify editing algorithm for "ends in space" condition
Checking if a string ends in a space does not require converting UTF-8
to UTF-16 and reading out its code points.
2024-12-03 00:18:03 +01:00
0x4261756D
124a4f12e4 LibWeb/Editing: Fix small copy-paste error
Was introduced in https://github.com/LadybirdBrowser/ladybird/pull/2655
2024-11-30 17:05:01 -05:00
Jelle Raaijmakers
4b0d8cbfad LibWeb: Implement document.execCommand("styleWithCSS") 2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
bb618736e9 LibWeb: Use default paragraph separator in delete command 2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
4a64557876 LibWeb: Implement document.execCommand("defaultParagraphSeparator") 2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
7bb865052a LibWeb: Implement document.execCommand("delete")
To facilitate the implementation of "delete" and all associated
algorithms, split off this piece of `Document` into a separate
directory.

This sets up the infrastructure for arbitrary commands to be supported.
2024-11-30 17:35:45 +01:00