Commit graph

96 commits

Author SHA1 Message Date
Sam Atkins
2d220a8bbc LibWeb: Return CSSStyleProperties as a GC::Ref 2025-03-19 13:53:00 +00:00
Sam Atkins
83bb92c4e0 LibWeb/CSS: Merge style declaration subclasses into CSSStyleProperties
We previously had PropertyOwningCSSStyleDeclaration and
ResolvedCSSStyleDeclaration, representing the current style properties
and resolved style respectively. Both of these were the
CSSStyleDeclaration type in the CSSOM. (We also had
ElementInlineCSSStyleDeclaration but I removed that in a previous
commit.)

In the meantime, the spec has changed so that these should now be a new
CSSStyleProperties type in the CSSOM. Also, we need to subclass
CSSStyleDeclaration for things like CSSFontFaceRule's list of
descriptors, which means it wouldn't hold style properties.

So, this commit does the fairly messy work of combining these two types
into a new CSSStyleProperties class. A lot of what previously was done
as separate methods in the two classes, now follows the spec steps of
"if the readonly flag is set, do X" instead, which is hopefully easier
to follow too.

There is still some functionality in CSSStyleDeclaration that belongs in
CSSStyleProperties, but I'll do that next. To avoid a huge diff for
"CSSStyleDeclaration-all-supported-properties-and-default-values.txt"
both here and in the following commit, we don't apply the (currently
empty) CSSStyleProperties prototype yet.
2025-03-19 13:53:00 +00:00
Sam Atkins
7668f91b60 LibWeb/Editing: Allow text-decoration-foo to be a CSSKeywordValue 2025-02-28 16:34:08 +00: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
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