Jelle Raaijmakers
0bb0061915
LibWeb: Fire input
events in .execCommand()
...
We do not fire `beforeinput` events since other browsers do not seem to
do so either.
The spec asks us to check whether a command's action modified the DOM
tree. This means adding or removing nodes and attributes, or changing
character data anywhere in the tree. We have
`Document::dom_tree_version()` for node updates, but for character data
a new version number is introduced that allows us to easily keep track
of any text changes in the entire tree.
2025-01-24 23:53:26 +01:00
Jelle Raaijmakers
0c854f9afc
LibWeb: Return true if invalid color was provided to an editing command
...
Both Chrome and Firefox return `true` whenever the value string provided
is an invalid color or the current color. Spec issue raised:
https://github.com/w3c/editing/issues/476
2025-01-24 23:53:26 +01:00
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
2cee6aeba3
LibWeb: Use as_if
in Editing API where useful
...
This arguably improves readability in a couple of places. No functional
changes.
2025-01-21 17:50:13 +00:00
Timothy Flynn
85b424464a
AK+Everywhere: Rename verify_cast
to as
...
Follow-up to fc20e61e72
.
2025-01-21 11:34:06 -05:00
Jelle Raaijmakers
98ec1825de
LibWeb: Implement the "useCSS" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
70af48c18b
LibWeb: Implement the "selectAll" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
03bcfb9b8c
LibWeb: Implement the "outdent" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
fbc0d40d2c
LibWeb: Implement the "justifyCenter/Full/Left/Right" editing commands
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1c3251e2d5
LibWeb: Implement the "insertUnorderedList" editing command
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
01ce9cb151
LibWeb: Implement the "insertImage" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
20fb7b1a49
LibWeb: Implement the "insertHTML" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
cb05ab6515
LibWeb: Implement the "insertHorizontalRule" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
c6cde85534
LibWeb: Implement the "indent" 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
e686328cbd
LibWeb: Implement the "unlink" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
043a28baeb
LibWeb: Implement the "underline" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
679fbb5eda
LibWeb: Implement the "superscript" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
ef8af01e1d
LibWeb: Implement the "subscript" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
8c51d6863f
LibWeb: Implement the "strikethrough" 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
ae12f7036b
LibWeb: Implement the "italic" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
228c66f2e1
LibWeb: Implement the "foreColor" 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
9366a50dd3
LibWeb: Implement the "fontName" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1b02e0dea3
LibWeb: Implement the "createLink" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
05386fe99c
LibWeb: Implement the "backColor" and "hiliteColor" editing commands
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
7736d63290
LibWeb: Implement the "forwardDelete" editing command
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
a71e999ac8
LibWeb: Implement the "bold" editing command
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
2b6a14c5ee
LibWeb: Implement "preserves overrides" property of editing commands
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
e64766d54d
LibWeb: Add spec links to editing command definitions
2025-01-10 23:33:35 +01:00
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
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
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