Commit Graph

30 Commits

Author SHA1 Message Date
Andreas Kling
fb6d6a985f LibWeb: Implement Element.setAttributeNode{,NS}() 2023-03-10 14:56:29 +01:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
Luke Wilde
54f58e2662 LibWeb: Restore proper functionality of legacy platform objects
With the GC heap conversion, the functionality of legacy platform
objects was broken. This is because the generated implementation of one
of them was used for all of them, removing functionality such as
deletion.

This re-adds all functionality, where questions such as "does the
object support indexed properties?" is instead answered by virtual
functions instead of by the IDL generator checking the presence of
certain keywords/attributes.
2023-02-28 12:36:14 +01:00
Kenneth Myhra
e3e281addd LibWeb: Make factory method of DOM::NamedNodeMap fallible 2023-02-18 00:52:47 +01:00
Timothy Flynn
b75b7f0c0d LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
2023-01-29 00:02:45 +00:00
Timothy Flynn
2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00
Timothy Flynn
af75493883 LibWeb: Move passing of Web object prototypes out of constructors 2023-01-10 16:08:14 +01:00
Timothy Flynn
f3db548a3d AK+Everywhere: Rename FlyString to DeprecatedFlyString
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
2023-01-09 23:00:24 +00:00
Alexander Narsudinov
45525d4f85 LibWeb: Add NamedNodeMap::setNamedItemNS() method
This patch adds implementation of the missing `setNamedItemNS()` method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
530d5adc62 LibWeb: Add NamedNodeMap::removeNamedItemNS() method
This patch adds implementation of the missing `removeNamedItemNS()`
method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
7679d38c5f LibWeb: Fix incorrect behaviour in NamedNodeMap::removeNamedItem()
According to the spec we should return removed attribute, but the old
implementation returned nullptr instead.

Now we return the element's removed attribute.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
f2d7690702 LibWeb: Add NamedNodeMap::getNamedItemNS()
This patch allows us to use method getNamedItemNS() of NamedNodeMap API.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
ce6cf5bab8 LibWeb: Make method NamedNodeMap::set_attribute() closer to the spec
This patch eliminates 1 FIXME that I've got during fixme roulette! :^)
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
1a0fbe1e85 LibWeb: Add internal get_attribute_ns() methods of NamedNodeMap
This patch adds methods for querying element by namespace and
local name.

These methods are defined by the spec for internal
usage, but weren't implemented in LibWeb yet.
2022-12-17 18:27:57 +01:00
Linus Groh
22089436ed LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr 2022-12-15 06:56:37 -05:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Andrew Kaster
8de7e49a56 LibWeb: Remove unecessary dependence on Window from DOM and WebIDL
These classes only needed Window to get at its realm. Pass a realm
directly to construct DOM and WebIDL classes.

This change importantly removes the guarantee that a Document will
always have a non-null Window object. Only Documents created by a
BrowsingContext will have a non-null Window object. Documents created by
for example, DocumentFragment, will not have a Window (soon).

This incremental commit leaves some workarounds in place to keep other
parts of the code building.
2022-10-01 21:05:32 +01:00
Linus Groh
bbaa05fcf9 LibWeb: Move DOMException from DOM/ to WebIDL/ 2022-09-25 19:13:31 +01:00
Linus Groh
ad04d7ac9b LibWeb: Move ExceptionOr from DOM/ to WebIDL/
This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
2022-09-25 19:13:31 +01:00
Andreas Kling
530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Andreas Kling
497ead37bc LibWeb: Make DOMException GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
ffad902c07 LibWeb: Use cached_web_prototype() as much as possible
Unlike ensure_web_prototype<T>(), the cached version doesn't require the
prototype type to be fully formed, so we can use it without including
the FooPrototype.h header. It's also a bit less verbose. :^)
2022-09-06 00:27:09 +02:00
Andreas Kling
6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00
Andreas Kling
a56b3f9862 LibWeb: Make NamedNodeMap GC-allocated 2022-09-06 00:27:09 +02:00
Luke Wilde
a718c62c01 LibWeb: Implement all "attributes" mutation records for MutationObserver 2022-07-11 22:35:08 +02:00
Timothy Flynn
6efbafa6e0 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
Andreas Kling
7fc770cfac LibWeb: Make DOM::NamedNodeMap forward its ref count to DOM::Element
This allows JS to keep an element alive by retaining a reference to
element.attributes
2021-12-09 21:28:52 +01:00
Timothy Flynn
7f223e2290 LibWeb: Do not create lowercase strings in NamedNodeMap::get_attribute
Rather than following the spec exactly and creating lowercase strings,
we can simply do a case-insensitive string comparison. The caveat is
that creating attributes must follow the spec by creating the attribute
name with a lowercase string.
2021-10-28 15:09:06 +02:00
Timothy Flynn
b67f6daf05 LibWeb: Weakly store NamedNodeMap's & Attribute's associated Element
This is similar to how Gecko avoids a reference cycle, where both the
NamedNodeMap and Attribute would otherwise store a strong reference to
their associated Element. Gecko manually clears stored raw references
when an Element is destroyed, whereas we use weak references to do so
automatically.

Attribute's ownerElement getter and setter are moved out of line to
avoid an #include cycle between Element and Attribute.
2021-10-18 09:58:52 +02:00
Timothy Flynn
2a3ac02ef1 LibWeb: Implement (most of) NamedNodeMap to store attributes 2021-10-17 13:51:10 +01:00