Timothy Flynn
e7b08cf291
LibWeb: Add a DOM::Element::set_attribute override for UTF-16 strings
...
This just transcodes to UTF-8 for now, but primarily serves to to keep
compatibility with generated IDL definitions.
2025-07-28 12:25:11 +02:00
Timothy Flynn
3a072f66e3
LibWeb: Pass Utf16String around directly in Editing APIs
...
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Noticed while working adjacent to these APIs that we take a Utf16String
and pass it around as a Utf16View, only to re-allocate the Utf16String
in many commands. Let's just pass the string itself around.
2025-07-26 00:40:06 +02:00
Timothy Flynn
8b6e3cb735
LibWeb+LibUnicode+WebContent: Port DOM:CharacterData to UTF-16
...
This replaces the underlying storage of CharacterData with Utf16String
and deals with the fallout.
2025-07-24 19:00:20 +02:00
Jelle Raaijmakers
b1c3ce807b
AK: Rename Utf16View::trim_whitespace() to ::trim_ascii_whitespace()
...
This reflects the naming of String::trim_ascii_whitespace() and better
indicates what exactly we're trimming.
2025-07-24 07:18:25 -04:00
Jelle Raaijmakers
e029e785d2
LibWeb: Convert Editing API internals to UTF-16
...
Both sides of the Editing internals now have to deal with some awkward
converting between UTF-8 and UTF-16, but the upside is that it
immediately exposed an issue with the `insertText` command: instead of
dealing with code units, it was iterating over code points causing the
selection to be updated only once instead of twice. This resulted in the
final selection potentially ending up in between a surrogate pair.
Fixes #5547 (pasting/typing surrogate pairs).
2025-07-24 07:18:25 -04:00
Jelle Raaijmakers
fd066d2b58
LibWeb: Update two stray "take the action for command" invocations
...
This is the more idiomatic (although functionally equivalent) way of
taking the action for any command.
2025-07-24 07:18:25 -04:00
Callum Law
94f5a51820
LibWeb: Convert white-space
CSS property to shorthand
...
This exposed a few bugs which caused the following tests to behave
incorrectly:
- `tab-size-text-wrap.html`: This previously relied on a bug where we
incorrectly treated `white-space: pre` as allowing text wrapping. The
fix here is to implement the text-wrap CSS shorthand property.
- `execCommand-preserveWhitespace.html`: We don't correctly serialize
shorthand properties. This is covered by an existing FIXME in
`CSSStyleProperties::serialized()`
- `white-space-shorthand.html`: The last 5 subtests here fail as we
don't correctly handle shorthand properties in
`CSSStyleProperties::remove_property()`. This is covered by an
existing FIXME in said function.
2025-05-29 12:04:28 +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
d424dc1b32
LibWeb: Assign new wrapped node list to container for insertParagraph
...
Forgot to implement this part of the spec.
2025-05-07 16:11:31 +02: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
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