1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 13:37:10 +09:00
Commit graph

20 commits

Author SHA1 Message Date
Shannon Booth
556acd82ee LibWeb/Editing: Handle no active range in queryCommandState
Fixes a crash when this is invoked if no range is active for the
document.
2025-05-26 23:36:44 +02:00
Shannon Booth
7c7fec5e00 LibWeb/Editing: Pass normalized command name to editing AOs
As the internal algorithms perform case sensitive matching.
Fixes a crash in the included test, seen on gmail.com.
2025-05-26 23:36:44 +02:00
Jelle Raaijmakers
a1467c22d3 LibWeb: Add new whitespace-preserving editing command
Major browsers seem to preserve `white-space: pre/pre-wrap` styles in a
`<div>` when deleting the current selection through an editing command.
The idiomatic way to support this is to have a command with a "relevant
CSS property" to make sure the value is recorded and restored where
appropriate, however, no such command exists.

Create a custom command (internal to Ladybird) that implements this
behavior.
2025-05-17 00:29:19 +02:00
Jelle Raaijmakers
e941965b01 LibWeb: Use TemporaryChange instead of ScopeGuard
This is a more idiomatic way to temporarily change a value. No
functional changes.
2025-05-17 00:29:19 +02:00
Jelle Raaijmakers
ac46ec0b2e LibWeb: Start integrating the editing API with user keyboard input
This reworks EventHandler so text insertion, backspace, delete and
return actions are now handled by the Editing API. This was the whole
point of the execCommand spec, to provide an implementation of both
editing commands and the expected editing behavior on user input.

Responsibility of firing the `input` event is moved from EventHandler to
the Editing API, which also gets rid of duplicate events whenever
dealing with `<input>` or `<textarea>` events.

The `beforeinput` event still needs to be fired by `EventHandler`
however, since that is never fired by `execCommand()`.
2025-05-17 00:29:19 +02:00
Tim Ledbetter
dccb374876 LibWeb: Treat execCommand command names as case insensitive 2025-02-08 07:30:27 -05:00
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
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
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
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
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
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
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