Commit Graph

19 Commits

Author SHA1 Message Date
Karol Kosek
9ed4fe7049 LibWeb: Allow to set a root mode value when constructing a ShadowRoot 2023-02-02 14:43:29 +01:00
Karol Kosek
34913c48d3 LibWeb: Actually initialize ShadowRoot bindings
`mode` and `host` attributes were always undefined.
2023-02-02 14:43:29 +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
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
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
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Linus Groh
46bb547dd6 LibWeb: Convert ShadowRoot to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Andreas Kling
b1096c2ae4 LibWeb: Make Element::set_shadow_root() disconnect any previous root 2022-03-16 00:38:44 +01:00
Andreas Kling
7e1bf4d300 LibWeb: Compute element style in Layout::TreeBuilder
Instead of making each Layout::Node compute style for itself, we now
compute it in TreeBuilder before even calling create_layout_node().

For non-element DOM nodes, we create the style and layout tree node
in TreeBuilder. This allows us to move create_layout_node() from
DOM::Node to DOM::Element.
2022-02-05 22:50:39 +01:00
Ben Wiederhake
7619dbdbb4 LibWeb: Clean up static function in header
'static' for a function means that the symbol shall not be made public
for the result of the current compilation unit. This does not make sense
in a header, especially not if it's a large function that is used in
more than one place and not that performance-sensitive.
2021-10-06 23:52:40 +01:00
Andreas Kling
c4826eae4f LibWeb: Rename Layout::BlockBox => BlockContainer
There's a subtle difference here. A "block box" in the spec is a
block-level box, while a "block container" is a box whose children are
either all inline-level boxes in an IFC, or all block-level boxes
participating in a BFC.

Notably, an "inline-block" box is a "block container" but not a "block
box" since it is itself inline-level.
2021-10-06 20:10:36 +02:00
Andreas Kling
0264ae23bc LibWeb: Make CSS layout lazier
Instead of doing layout synchronously whenever something changes,
we now use a basic event loop timer to defer and coalesce relayouts.

If you did something that requires a relayout of the page, make sure
to call Document::set_needs_layout() and it will get coalesced with all
the other layout updates.

There's lots of room for improvement here, but this already makes many
web pages significantly snappier. :^)

Also, note that this exposes a number of layout bugs where we have been
relying on multiple relayouts to calculate the correct dimensions for
things. Now that we only do a single layout in many cases, these kind of
problems are much more noticeable. That should also make them easier to
figure out and fix. :^)
2021-10-06 17:14:22 +02:00
Luke Wilde
8e0f3436a2 LibWeb: Make the innerHTML setter spec compliant
This adds innerHTML to ShadowRoot in the process.
2021-09-14 02:09:18 +02:00
Luke Wilde
f7f37eaa0f LibWeb: Make Node::root return a reference
The root of a node can never be null, as "the root of an object is
itself, if its parent is null, or else it is the root of its parent."

https://dom.spec.whatwg.org/#concept-tree-root
2021-09-02 22:53:19 +02:00
Andreas Kling
ee3a73ddbb AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24 19:57:01 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
e562819a7e LibWeb: Generate layout nodes for shadow subtrees
Elements with shadow roots will now recurse into those shadow trees
while building the layout tree.

This is the first step towards basic Shadow DOM support. :^)
2021-02-10 19:06:20 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00