Commit Graph

29 Commits

Author SHA1 Message Date
Andreas Kling
f4bdf56212 LibWeb: Rename Element::shadow_root_internal() to shadow_root()
And let the old shadow_root(), which was only supposed to be used by
bindings, be called shadow_root_for_bindings() instead.

This makes it much easier to read DOM code, and we don't have to worry
about when to use shadow_root_internal() or why.
2024-06-25 19:22:35 +02:00
Andreas Kling
c7d9c1c0b2 LibWeb: Update DOM cloning algorithm for declarative shadow DOM 2024-06-25 19:22:35 +02:00
Shannon Booth
bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
MacDue
0a061a6a63 LibWeb: Allow references via xlink:href for SVG <use> elements 2024-03-29 21:59:56 +01:00
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
MacDue
15e3b0ebde LibWeb: Use SVGGraphicsBox for <symbol> and <use> elements
This allows various SVG properties (like masking) to be applied to these
elements.
2024-03-12 08:51:50 +01:00
Andreas Kling
9aefc5c927 LibWeb: Return a dummy value from various SVG getters
Instead of crashing with a TODO() on half of the test cases generated by
Domato, let's just return a zeroed-out SVGAnimatedLength or
SVGAnimatedNumber from getters that return them.

We'll eventually have to implement these correctly, but crashing is not
productive since it blocks us from finding other issues.
2024-03-11 18:29:10 +01:00
Bastiaan van der Plaat
a681429dff LibWeb: Remove DOM element deprecated_get_attribute() 2024-01-19 13:12:54 -07:00
Shannon Booth
f32185420d LibWeb: Use FlyString where possible in NamedNodeMap
We cannot port over Optional<FlyString> until the IDL generator supports
passing that through as an argument (as opposed to an Optional<String>).

Change to FlyString where possible, and resolve any fallout as a result.
2024-01-03 10:13:47 +01:00
Luke Wilde
54972e3ceb LibWeb: Implement SVGUseElement#href
Required by Ruffle.
b196c8d1bc/web/packages/core/src/shadow-template.ts (L601-L602)
2023-12-30 18:50:29 +01:00
Shannon Booth
7909475b14 LibWeb: Port SVGUseElement from ByteString 2023-12-24 13:26:50 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Shannon Booth
96af80acd1 LibWeb: Port Intrinsics from DeprecatedString 2023-11-28 17:15:27 -05:00
Andreas Kling
bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00
Shannon Booth
eca9874e56 LibWeb: Port Element::attribute_changed from DeprecatedString to String
Which as you would expect has a bunch of fallout, but also results in a
whole lot of awkward conversions falling away.
2023-11-19 08:16:34 +00:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Timothy Flynn
33443190d0 LibWeb: Store the SVG <use> element's referenced ID as a FlyString
We currently store a StringView into the DeprecatedString provided to
SVGUseElement::attribute_changed. This is a temporary string created by
String::to_deprecated_string, so this StringView is always a dangling
pointer.

Instead, since this string value is an ID and is primarily used as a
FlyString, store it as a FlyString from the get-go.
2023-10-12 07:39:37 +02:00
Shannon Booth
48f367adbb LibWeb: Port get_element_by_id from DeprecatedFlyString
We needed to keep the old versions of these functions around before all
of the IDL interfaces were ported over to new AK String, but now that is
done, we can remove the deprecated versions of these functions.
2023-10-08 08:11:48 -04:00
Shannon Booth
e4f8c59210 LibWeb: Port AttributeNames to FlyString 2023-10-08 08:11:48 -04:00
Aliaksandr Kalenik
cad2d2c85b LibWeb: Use JS::HeapFunction for DocumentObserver callbacks
If GC-allocated object wants to own a function it should use
HeapFunction because using SafeFunction will almost always lead to a
leak.
2023-09-27 19:39:57 +02:00
Shannon Booth
0f6782fae6 LibWeb: Rename Element::attribute to Element::deprecated_attribute
This should allow us to add a Element::attribute which returns an
Optional<String>. Eventually all callers should be ported to switch from
the DeprecatedString version, but in the meantime, this should allow us
to port some more IDL interfaces away from DeprecatedString.
2023-09-05 20:36:09 -04:00
MacDue
720c27efbd LibWeb: Ensure transform of SVG <use> updates with x and y attributes
Rather than modify the transform of the parent (which could change
independently), this adds a new override element_transform() where
element specific tranfroms can be applied. This will always stay in
sync with the attributes.

A ref test comparing a .svg and .html version of the same file is
added as due to differences in attribute parsing order, the .svg version
was previously drawn incorrectly.

Fixes #20859
2023-08-31 11:10:30 +02:00
0GreenClover0
f165d2e7ec LibWeb: Update <use> visuals after changing the referenced element 2023-08-23 11:55:24 +01:00
Andreas Kling
1e0ea45fe5 LibWeb: Make sure that SVG use and symbol elements get paintables
I'm about to make StackingContext traverse the paintable tree instead of
actually traversing the layout tree, and it turns out we were not
creating paintables for these SVG elements.

Also switch them to Layout::Box instead of the default InlineNode to
make the trees look a bit less weird. Ultimately, we should do something
specialized for these subtrees, but for now this'll do.
2023-08-20 05:02:59 +02:00
Andreas Kling
72c9f56c66 LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
2023-08-13 15:38:42 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Sebastian Zaha
d24667a1b6 LibWeb: Rename loaded observer event to match spec
The `document_fully_loaded` event should use the adjective "completely"
so as to match the spec and code convention. See
`Document::is_completely_loaded` and `m_completely_loaded_time`.
2023-07-12 13:16:23 +02:00
Andreas Kling
5a74486b59 LibWeb: Rename DOM::Element::parse_attribute() => attribute_changed()
This is a first step towards merging attribute change and removal
notifications into a single function.
2023-07-03 19:04:45 +02:00
PrestonLTaylor
c7c3043aa2 LibWeb: Implement the <use> SVG element
The SVG <use> element is used to be able to reuse other SVG graphics
without having to re-write the svg element.

We now support this feature! :^)
2023-06-03 05:58:00 +02:00