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
10d011c75f
LibWeb: Disable formatBlock
editing command for plaintext-only
...
This is a spec issue:
https://github.com/w3c/editing/issues/478
2025-01-24 23:53:26 +01:00
Jelle Raaijmakers
f731cffbd8
LibWeb: Refuse to recursively execute .execCommand()
...
Spec issue:
https://github.com/w3c/editing/issues/477
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
Jelle Raaijmakers
2b7ff194f8
LibWeb: Only record overrides for editing commands that require it
...
I forgot to implement the "If a command preserves overrides" part of the
spec.
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
d967f56936
LibWeb: Require existing Selection for .execCommand("selectAll")
...
Disable the command if no selection is available. This is a spec bug:
https://github.com/w3c/editing/issues/475
Fixes #3325
2025-01-21 02:27:50 +00:00
Timothy Flynn
a4324ee6e9
LibWeb: Remove the initialize_strings methods
...
We added these methods to propagate OOM errors at process startup, but
we longer fret about these tiny OOM failures. Requiring that these init
methods be called prohibits using these strings in processes that have
not set up a MainThreadVM. So let's just remove them and initialize the
strings in a sane manner.
In doing so, this also standardizes how we initialize strings whose C++
variable name differs from their string value. Instead of special-casing
these strings, we just include their string value in the x-macro list.
2025-01-12 00:35:58 +01: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
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