Tim Ledbetter
a0b0e91d4f
LibWeb: Disallow Editing API calls on non-HTML documents
...
This is not directly mentioned in the Editing API spec, but all major
browsers do this and there is a WPT for this behavior.
2025-01-21 19:08:37 +01:00
Jelle Raaijmakers
fbc0d40d2c
LibWeb: Implement the "justifyCenter/Full/Left/Right" editing commands
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
26cadf06d2
LibWeb: Implement the "insertText" editing command
...
Minus the autolinking algorithm.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
199eaf0d3e
LibWeb: Implement the "insertOrderedList" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
a12d887eb4
LibWeb: Implement the "formatBlock" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
aee8a75c40
LibWeb: Implement the "removeFormat" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1d2500e31f
LibWeb: Implement the "fontSize" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
fef02036dd
LibWeb: Implement the "set the selection's value" editing algorithm
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
aeec57a440
LibWeb: Implement the "indent" and "outdent" editing algorithms
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
9750896af3
LibWeb: Implement the "push down values" editing algorithm
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
9bcf2fc0f5
LibWeb: Implement last remaining FIXME for wrap editing algorithm
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
148e465131
LibWeb: Implement remaining FIXMEs in "specified command value" algo
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
5e7a31bf60
LibWeb: Implement "move node preserving ranges" editing algorithm
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2b6a14c5ee
LibWeb: Implement "preserves overrides" property of editing commands
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e21ee10b3c
LibWeb: Add command state & value overrides to DOM::Document
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
67800091c5
LibWeb: Check for editability and visibility of "formattable nodes"
...
The associated spec was only partially implemented.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
85abad30b0
LibWeb: Add explicit "active range" editing algorithm
...
This makes some of the spec implementations easier to follow and makes
it extra clear that the range is optional.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2987dd1060
LibWeb: Fix node insertion in split_the_parent_of_nodes()
...
If we are to insert nodes _before_ the original parent, we need to
insert them at the original parent's index, not the index before that.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
83f48a07d4
LibWeb: Make normalize_sublists_in_node() take a Node instead of Element
...
This prevents some unnecessary casting to DOM::Element.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
d08febcf67
LibWeb: Add Node::for_each(_inclusive)_ancestor()
...
Allows for easy iteration over the chain of ancestors for a node.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
4323669939
LibWeb: Add Range::for_each_contained()
...
This centralizes the logic for iterating over a Range's contained nodes.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2466021e55
LibWeb: Rename argument to split_the_parent_of_nodes() to reflect spec
...
The spec calls it a "node list", not "nodes".
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
f4c822ee38
LibWeb: Simplify fix_disallowed_ancestors_of_node()'s usage of node
...
Commit 98df4c2b
changes the node argument to a GC::Ref<DOM::Node>, but
not all usages were updated accordingly.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
bd2488a468
LibWeb: Make block_extend_a_range() take a GC::Ref for the range
...
This makes it more consistent with the other signatures.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e5b107b6b6
LibWeb: Fix typo in spec comment for non-list single line containers
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
acef5a34de
LibWeb: Remove useless move from remove_node_preserving_its_descendants
2025-01-10 23:33:35 +01: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
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
30ec8c1d4d
LibWeb: Implement "delete the selection" for the editing API
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
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
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
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
Jelle Raaijmakers
bb618736e9
LibWeb: Use default paragraph separator in delete command
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