Commit graph

36 commits

Author SHA1 Message Date
Timothy Flynn
27478ec7d4 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-19 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2024-12-28 05:39:32 -08:00
Jelle Raaijmakers
c0285f4a7e LibWeb: Do not require visible nodes in the wrap editing algorithm
The spec doesn't say they should exist, so we should not
`VERIFY_NOT_REACHED()` when they don't. Prevents a crash in the WPT
`editing/event.html` tests.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
c093c895da LibWeb: Implement step 15 of the editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
30a3fe8387 LibWeb: Remove unnecessary condition from editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
ff25d66dae LibWeb: Prevent potential null deref in editing delete action 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
e6631a4216 LibWeb: Add concept of boundary point to DOM::AbstractRange
This makes comparing the relative position of boundary points a bit
nicer when one of the boundary points is the range's start or end.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
a3b3f2f30d LibWeb: Prevent null deref in the "restore the values of nodes" algo 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
c90c5aad29 LibWeb: Implement the "record current states and values" Editing algo 2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
2c51ed8dec LibWeb: Rework obtaining resolved styles in the Editing API
The algorithm referenced to in the Editing spec whenever they talk about
obtaining the "resolved" style or value is actually implemented in
ResolvedCSSStyleDeclaration, so use that instead of going directly to
the computed styles.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
433c19c1ed LibWeb: Lay out CommandDefinitions for Editing API a bit nicer
No functional changes.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
2d130ffad4 LibWeb: Make new_container in insertParagraph command a GC::Ref
This value will never be null.
2024-12-21 19:15:58 +01:00
Jelle Raaijmakers
5e2cb00f75 LibWeb: Update active range after updating selection in insertParagraph
We were using an old range after collapsing the selection. Fixes 3 WPT
subtests in `editing/run`.
2024-12-21 19:15:58 +01:00
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