Commit Graph

110 Commits

Author SHA1 Message Date
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
Andreas Kling
0ebfc0a4c4 LibWeb: Move event handling & cursor from BrowsingContext to Navigable
This was a long standing FIXME since the introduction of navigables.
2024-04-26 20:01:58 +02:00
Andreas Kling
4c921e17b7 LibWeb: Allocate dataset lazily for HTML/SVG/MathML elements
Most elements never need a dataset object, so we can avoid creating lots
of objects by making them lazy.
2024-04-25 09:30:30 +02:00
Andreas Kling
4cc972a8ae LibWeb: Stub out HTMLElement.outerText 2024-04-14 22:08:22 +02:00
Andreas Kling
afea8ccd43 LibWeb: Stub out HTMLElement.accessKeyLabel 2024-04-14 22:08:22 +02:00
Shannon Booth
db0519ddc1 LibWeb: Fire a pointer event on synthetic clicks 2024-04-08 14:25:08 +02:00
Shannon Booth
b873e5bc1d LibWeb: Implement the PointerEvent interface
As defined in: https://w3c.github.io/pointerevents

With the exception of the getCoalescedEvents and getPredictedEvents
APIs.

There are still many other parts of that spec (such as the event
handlers) left to implement, but this does get us at least some of the
way.
2024-04-08 14:25:08 +02: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
Tim Ledbetter
5b4533cab8 LibWeb: Don't crash in offset_parent() if no ancestor element found
The specification says the final step of this algorithm is to return
null. Previously, the browser would crash if the content of an iframe
was appended to the document before its offsetParent property was
queried.
2024-02-29 21:54:53 -05:00
Aliaksandr Kalenik
e3c75d7b6f LibWeb: Add HTMLElement::is_content_editable() 2024-02-25 10:17:25 +01:00
Aliaksandr Kalenik
5d76fa72e9 LibWeb: Add HTMLElement::did_receive_focus() 2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
05d5e11966 LibWeb: Allow HTMLElement with contenteditable=true to be focusable 2024-02-24 00:19:55 +01:00
Bastiaan van der Plaat
a681429dff LibWeb: Remove DOM element deprecated_get_attribute() 2024-01-19 13:12:54 -07:00
Aliaksandr Kalenik
814bed33b4 LibWeb: Move box_type_agnostic_position() from layout node to paintable
For this method, there is no need to go through the layout node when we
can directly reach the paintable.
2024-01-15 09:00:35 +01:00
Andreas Kling
f4fa37afd2 LibJS+LibWeb: Add missing JS_DEFINE_ALLOCATOR() for a bunch of classes 2023-12-23 23:02:10 +01:00
Andreas Kling
cfe9577b48 LibWeb: Bring HTMLElement.offset{Left,Top,Parent} closer to spec
(Or rather, bring offsetLeft and offsetTop closer to spec, and implement
the previously-missing offsetParent)

This makes mouse inputs on https://nerget.com/fluidSim/ work properly.
2023-12-10 16:30:21 +01:00
Shannon Booth
96af80acd1 LibWeb: Port Intrinsics from DeprecatedString 2023-11-28 17:15:27 -05:00
Shannon Booth
0a4586d510 LibWeb: Port HTMLHyperlinkElementUtils from DeprecatedString to String 2023-11-20 15:00:19 +01: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
Shannon Booth
6a2a7cad61 LibWeb/LibJS: Avoid GC visit of raw pointers where possible
This is mostly motivated for aesthetics, but also helps avoid some null
checks when we have a NonnullGCPtr<T> or in some cases a T&.
2023-11-19 08:05:45 +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
Shannon Booth
e4f8c59210 LibWeb: Port AttributeNames to FlyString 2023-10-08 08:11:48 -04:00
Shannon Booth
8ce9e51c97 LibWeb: Port Node interface from DeprecatedString to String
Which is fortunately quite straight forward :^)
2023-09-17 20:29:18 +02:00
Shannon Booth
e74031a396 LibWeb: Port Document interface from DeprecatedString to String 2023-09-16 11:17:19 +02:00
Shannon Booth
41928c2902 LibWeb: Port DOMException interface from DeprecatedString to String 2023-09-06 11:44:45 -04:00
Shannon Booth
2c69f273a0 LibWeb: Port HTMLElement interface from DeprecatedString to String 2023-09-05 20:36:09 -04: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
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
2eaa528a0e LibJS: Rip out the AST interpreter :^)
This has been superseded by the bytecode VM, which is both faster
and more capable.
2023-08-08 13:07:13 +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
Andreas Kling
21260ea2ef LibWeb: Merge did_remove_attribute() into attribute_changed()
Instead of having two virtuals for attribute change notifications,
there is now only one. When the attribute is removed, the value is null.
2023-07-03 19:04:45 +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
Luke Wilde
995df8f565 LibWeb: Move get_an_elements_{target,noopener} to HTMLElement
This will be used by form submission on `<form>` elements.
2023-06-19 06:12:26 +02:00
Aliaksandr Kalenik
147c3b3d97 LibWeb+WebContent: Forbid access to underlying type of CSSPixels
Although DistinctNumeric, which is supposed to abstract the underlying
type, was used to represent CSSPixels, we have a whole bunch of places
in the layout code that assume CSSPixels::value() returns a
floating-point type. This assumption makes it difficult to replace the
underlying type in CSSPixels with a non-floating type.

To make it easier to transition CSSPixels to fixed-point math, one step
we can take is to prevent access to the underlying type using value()
and instead use explicit conversions with the to_float(), to_double(),
and to_int() methods.
2023-06-13 06:08:27 +02:00
Andreas Kling
20e2c9a7dd LibWeb: Cache state of the contenteditable attribute on HTMLElement
Instead of recomputing the state whenever someone asks for it, we now
cache it when the attribute is added/changed/removed.

Before this change, HTMLElement::is_editable() was 6.5% of CPU time
when furiously resizing Hacker News. After, it's less than 0.5%. :^)
2023-05-15 14:08:20 +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
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
Kenneth Myhra
8f4d7f2854 LibWeb: Port fire_a_synthetic_pointer_event() to new FlySring 2023-04-09 17:27:27 +02:00
Kenneth Myhra
2091a11488 LibWeb: Port EventTarget to new {Fly}String 2023-04-09 17:27:27 +02:00
Kenneth Myhra
ad5cbdc51b LibWeb: Port {Mouse,UI,Wheel,}Event to new String
This ports MouseEvent, UIEvent, WheelEvent, and Event to new String.
They all had a dependency to T::create() in
WebDriverConnection::fire_an_event() and therefore had to be ported in
the same commit.
2023-04-07 22:41:01 +02:00
Kenneth Myhra
4d87072201 LibWeb: Port {HTML,UIEvents,XHR}::EventNames to new String 2023-04-06 23:49:08 +02: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
Kenneth Myhra
b604bbaf29 LibWeb: Make factory method of HTML::DOMStringMap fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
c120c46acc LibWeb: Make factory methods of DOM::Event fallible
Because of interdependencies between DOM::Event and UIEvents::MouseEvent
to template function fire_an_event() in WebDriverConnection.cpp, the
commit: 'LibWeb: Make factory methods of UIEvents::MouseEvent fallible'
have been squashed into this commit.
2023-02-18 00:52:47 +01:00
Linus Groh
8556d47240 LibWeb: Move ARIA-related code into the Web::ARIA namespace
ARIA has its own spec and is not part of the DOM spec, which is what the
Web::DOM namespace is for (https://www.w3.org/TR/wai-aria-1.2/).

This allows us to stay closer to the spec with function names and don't
have to add the word "ARIA" to identifiers constantly - the namespace
now provides that clarity.
2023-01-29 00:02:55 +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
MacDue
890b4d7980 LibWeb: Replace ARIA role static FlyStrings with an enum
This replaces the FlyStrings for ARIA roles that were constructed in
a [[gnu::constructor]] with a single enum. I came across this as the
DOM inspector was crashing due to a null FlyString for an ARIA role.

After fixing that, I was confused as to why these roles were not an
enum. Looking at the spec there's a fixed list of roles and switching
from references to static strings to an enum was pretty much an
exercise in find and replace :).

No functional changes (outside of fixing the mentioned crash).
2023-01-28 22:09:18 +00:00
Timothy Flynn
834202aeb9 LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be
made lazy. Otherwise, GC could run during the C++ constructor and try to
collect the object currently being created.
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