Commit graph

155 commits

Author SHA1 Message Date
Andreas Kling
5b5fbecb38 LibWeb: Don't include DOM/Attr.h from DOM/Element.h
This required moving Element::for_each_attribute() out of line, but that
seems harmless enough.
2023-05-08 09:29:44 +02:00
Andreas Kling
eff783a6d2 LibWeb: Invalidate style *and* layout when removing a DOM node
It's not enough to invalidate only layout, since changes to the DOM tree
may also cause different selectors to apply.

This brings Acid3 back to a score of 100/100. The problem was that a
:last-child selector wasn't rechecked after removing a node that was
previously the last child of its parent.

Regression from f36cbd3b65.
2023-05-06 10:27:48 +02:00
Aliaksandr Kalenik
22572c39e0 LibWeb: Implement Node::navigable()
https://html.spec.whatwg.org/multipage/document-sequences.html#node-navigable
2023-04-23 15:41:05 +02:00
Linus Groh
d58b671ff6 LibWeb/DOM: Rename Node::{paint => paintable}_box()
It returns a PaintableBox, not a 'PaintBox'.
2023-04-20 20:43:30 +02:00
Linus Groh
754e458d0a LibWeb/Layout: Rename Box::{paint => paintable}_box()
It returns a PaintableBox, not a 'PaintBox'.
2023-04-20 20:43:30 +02:00
Andreas Kling
d8ccc2d54e LibWeb: Rename BrowsingContextContainer => NavigableContainer
The "browsing context container" concept in the HTML spec has been
replaced with "navigable container". Renaming this is the first step of
many towards implementing the new world.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2023-04-19 18:26:45 +02:00
Luke Wilde
034aaf3f51 LibWeb: Introduce CustomElementRegistry and creating custom elements
The main missing feature here is form associated custom elements.
2023-04-06 11:36:56 +02:00
Andreas Kling
d4b2544dc5 LibWeb: Make the Node.compareDocumentPosition() return value enum public
This will allow other parts of LibWeb to understand these values.
2023-03-30 14:12:07 +02:00
Simon Wanner
a5a3913e39 LibWeb+LibWebView: Show shadow roots in the DOM inspector 2023-03-18 20:14:52 +01:00
Timothy Flynn
8a8340b3cd LibWeb: Port MutationRecord types to FlyString
Co-authored-by: Luke Wilde <lukew@serenityos.org>
2023-03-18 19:50:45 +01:00
Matthew Olsson
7c0c1c8f49 LibJS+LibWeb: Wrap raw JS::Cell*/& fields in GCPtr/NonnullGCPtr 2023-03-15 08:48:49 +01:00
Matthew Olsson
c0b2fa74ac LibWeb: Fix a few const-ness issues 2023-03-06 13:05:43 +00:00
Andreas Kling
7e76a51cb0 LibWeb: Rename Layout::InitialContainingBlock to Layout::Viewport
The name "initial containing block" was wrong for this, as it doesn't
correspond to the HTML element, and that's specifically what it's
supposed to do! :^)
2023-02-28 12:21:56 +01:00
Kenneth Myhra
ff92324fa5 LibWeb: Make factory method of DOM::ElementFactory fallible 2023-02-22 09:55:33 +01:00
Jonah
da5c9189b2 LibWeb: Implement Accessible Name and Description Calculation
This is an initial implementation of the accname standard. There is
still some of the algorithm left unimplemented that we will need
to implement in the future. However, as is, this implementation is
sufficient for basic pages.
2023-02-19 15:58:20 +01:00
Kenneth Myhra
2411dadc35 LibWeb: Make factory method of DOM::StaticNodeList fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
ce18dfc417 LibWeb: Make factory method of DOM::MutationRecord fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
24d7e688fc LibWeb: Make factory method of DOM::LiveNodeList fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
0d9076c9f5 LibWeb: Make factory methods of DOM::Document fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
1e03aa0ece LibWeb: Make factory method of DOM::AccessibilityTreeNode fallible 2023-02-18 00:52:47 +01:00
Karol Kosek
2cc108a15e LibWeb: Rename DOM::shadow_root() to shadow_root_internal()
The shadowRoot property getter that will be added in subsequent commits
has an additional check that checks whether the shadow root is opened.
I didn't update the function logic to match with the IDL interface,
because it's very likely we don't want that check in the existing code,
so that for example closed shadow root elements can still be updated.
2023-02-02 14:43:29 +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
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00: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
Jonah
a469bbd178 LibWeb: Add Functionality to Dump to Accessibility Tree
This will be used to display the accessibility tree in the inspector.
2023-01-07 10:51:53 +00:00
MacDue
88e50869f1 LibWeb: Fix crash when serializing nodes for DOM inspector
Noticed this trying to inspect GitHub, you'd get a segfault due to the
parent node being null here.
2022-12-19 11:37:56 -05:00
Andreas Kling
b005e816a3 LibWeb: Implement Node.isEqualNode() for ProcessingInstruction nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
de2c302cdb LibWeb: Implement Node.isEqualNode() for Attr nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
a004d3043f LibWeb: Implement Node.cloneNode for Attr nodes 2022-12-14 15:21:48 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01: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
Andreas Kling
15c324a70b Userland+Tests: Remove a few more LibJS/{AST.h,Parser.h} includes 2022-11-23 16:05:59 +00:00
Baitinq
0758bc457e LibWeb: Replace some unnecessary ShadowRoot verify_cast with static_cast
These two occurrences of verify_cast happened right after a check on the
type of converted reference, making the verify_cast redundant.
2022-11-06 12:13:32 +00:00
Andreas Kling
87b0ddb354 LibWeb: Add DOM::Node::parent_or_shadow_host_element()
This will be used in style computation to inherit style across shadow
tree boundaries.
2022-11-05 18:54:39 +01:00
Timothy Flynn
13b8eeff54 LibWeb: Fully implement the fragment serializing algorithm
Rather than assuming the node's node document is an HTML document,
handle XML documents as well.
2022-11-03 14:48:04 +00:00
Linus Groh
acfb546048 LibWeb: Handle currently ignored WebIDL::ExceptionOr<T>s 2022-10-31 14:12:44 +00:00
Andreas Kling
c7489e7665 LibWeb: Don't invalidate style for entire document on Node insertion
Like for attribute changes, we now only invalidate the insertion parent
and all of its descendants. Again, this is very aggressive, but also
way less than doing the entire document.

Once we implement the CSS :has() selector, we'll need to become more
sophisticated about invalidation.
2022-10-29 15:16:57 +02:00
Andreas Kling
e7da96acaf LibWeb: Call superclass GC finalizer in DOM::Node::finalize()
There isn't actually anything important happening in the superclasses
right now, but let's be good citizens and call up.
2022-10-20 19:45:17 +02:00
Andreas Kling
c877eb47a2 LibWeb: Add GC finalizer for DOM::Node
Now that the layout tree is also GC-allocated, we can't be messing with
it from the DOM::Node destructor. Move everything to a GC finalizer
so we know it runs before the GC sweep phase.
2022-10-20 19:36:59 +02:00
Andreas Kling
268b9c5d90 LibWeb: Make the layout tree GC-allocated
This removes a set of complex reference cycles between DOM, layout tree
and browsing context.

It also makes lifetimes much easier to reason about, as the DOM and
layout trees are now free to keep each other alive.
2022-10-20 15:16:23 +02:00
Andrew Kaster
45838579c3 LibWeb: Remove unused DOM::Node::window helper method
This was a crutch for the initial GC conversion that we can get rid of
thanks to moving web prototypes and constructors off of Window.
2022-10-01 21:05:32 +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
f36cbd3b65 LibWeb: Invalidate layout when a DOM node is removed from the tree 2022-09-25 02:26:36 +02:00
Andreas Kling
a5bb30d2ba LibWeb: Make Node.childNodes vend the same NodeList every time 2022-09-21 13:51:58 +02:00
Andreas Kling
1903dff365 LibWeb: Support getting and setting Attr.textContent 2022-09-18 02:08:01 +02: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
4b9c5635b3 LibWeb: Make :link selector behave according to spec
It should match any `a` or `area` element that has an `href` attribute,
not any element *inside* an enclosing linked element.
2022-09-14 14:43:17 +02:00
Andreas Kling
497ead37bc LibWeb: Make DOMException GC-allocated 2022-09-06 00:27:09 +02:00