Commit Graph

97 Commits

Author SHA1 Message Date
Timothy Flynn
986ff984cc LibUnicode: Replace code point general categories with ICU 2024-06-22 14:56:39 +02:00
Andrew Kaster
d90a9ab70c LibWeb: Add Web::UIEvents::KeyCode and KeyModifier enums, drop Kernel
This was the last Kernel header we had. Move the definitions we need
into a UIEvents header similar to MouseButton.
2024-06-07 09:44:41 +02:00
Andreas Kling
09980af4ea LibWeb: Add Web::UIEvents::MouseButton enum, drop dependency on LibGUI
This was the only thing LibWeb needed from LibGUI, and we can just
duplicate the enum in LibWeb and get rid of a bogus dependency.
2024-06-02 20:24:42 +02:00
Tim Ledbetter
a6d6729034 LibWeb: Implement the MouseEvent.relatedTarget attribute
This returns the secondary target of a mouse event. For `onmouseenter`
and `onmouseover` events, this is the EventTarget the mouse exited
from. For `onmouseleave` and `onmouseout` events, this is the
EventTarget the mouse entered to.
2024-05-20 08:21:41 +02:00
Shannon Booth
4fe0cbcf85 LibWeb: Use 'FIXME' extended attribute where possible
This improves the debuggability of many live web pages :^)
2024-05-19 16:24:11 +02:00
Shannon Booth
2e1316507f LibWeb: Fix missing initialization of delta_z in WheelEvent 2024-05-12 14:24:18 +00:00
Shannon Booth
42e3ba409e LibWeb: Add constructor for WheelEvent
This makes https://profiler.firefox.com/ progress much further in
loading :^)
2024-05-12 14:24:18 +00:00
Shannon Booth
0c799b23cb LibWeb: Use WebIDL::UnsignedLong for deltaMode in WheelEvent
This matches the IDL definition. Without this we experience a compile
time error when adding the WheelEvent constructor due to a mimatched
type between the enum class and UnsignedLong that the prototype is
passing through to the event init struct for the constructor.
2024-05-12 14:24:18 +00: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
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
7121539576 LibWeb: Add fast_is<T> for UIEvents::MouseEvent 2024-03-16 16:35:54 +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
Bastiaan van der Plaat
c41b359ca5 LibWeb: Use WebIDL types where possible instead of C types 2024-02-26 19:26:13 +00:00
Bastiaan van der Plaat
e2bc606eeb LibWeb: Add MouseEvent JavaScript constructor 2024-01-20 08:57:37 +01:00
Bastiaan van der Plaat
9aadc6c8c9 LibWeb: Add missing EventModifierInit fields and getModifierState 2024-01-20 08:57:37 +01:00
Andrew Kaster
32fe7db69f LibWeb: Make UIEvents from the chrome the only default trusted Events 2024-01-19 11:47:59 +01:00
Liav A
c8f27d7cb8 Kernel+Userland: Implement support for PS2 scan code set 2
This scan code set is more advanced than the basic scan code set 1, and
is required to be supported for some bare metal hardware that might not
properly enable the PS2 first port translation in the i8042 controller.

LibWeb can now also generate bindings for keyboard events like the Pause
key, as well as other function keys (such as Right Alt, etc).

The logic for handling scan code sets is implemented by the PS2 keyboard
driver and is abstracted from the main HID KeyboardDevice code which
only handles "standard" KeyEvent(s).
2024-01-04 10:38:03 -07:00
Andrew Kaster
d3025668a4 Revert "Kernel+Userland: Implement support for PS2 scan code set 2"
This reverts commit 61a385fc01.

The commit broke the shift and caps lock key from working.
2023-12-29 22:02:19 +01:00
Liav A
61a385fc01 Kernel+Userland: Implement support for PS2 scan code set 2
This scan code set is more advanced than the basic scan code set 1, and
is required to be supported for some bare metal hardware that might not
properly enable the PS2 first port translation in the i8042 controller.

LibWeb can now also generate bindings for keyboard events like the Pause
key, as well as other function keys (such as Right Alt, etc).

The logic for handling scan code sets is implemented by the PS2 keyboard
driver and is abstracted from the main HID KeyboardDevice code which
only handles "standard" KeyEvent(s).
2023-12-29 16:40:59 +01:00
Bastiaan van der Plaat
1f171cb60b LibWeb: Add support for the meta key modifier 2023-12-15 23:19:23 +00:00
Timothy Flynn
060807e3da LibWeb: Set correct keyCode for number keys and optional virtual keys
The spec states that if an input key would insert a numerical character
if it were pressed without a modifier, then the keyCode should be that
of the numerical character. For example, the keyCode for a dollar sign
should be that of the number 4.

Further, we should implement the optional fixed virtual key codes.
Otherwise, our implementation would give e.g. the double quote a keyCode
value of 38, which is the same as the up arrow key.
2023-12-02 10:34:22 +01:00
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
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
Matthew Olsson
1a94241f58 IDL: Add missing #imports 2023-11-11 08:51:51 +01:00
Bastiaan van der Plaat
169d24ae2e LibWeb: Add comments and missing items of various IDL files 2023-10-25 19:45:41 +02:00
Bastiaan van der Plaat
e267f8e68f LibWeb: Add modifier keys to MouseEvent 2023-09-15 22:12:56 +02:00
Bastiaan van der Plaat
836a7b00dd Ladybird+LibWeb: Add MouseEvent screenX and screenY support 2023-09-15 22:12:56 +02:00
Bastiaan van der Plaat
e584189b8f LibWeb: Reorder MouseEvent items to follow spec more 2023-09-15 22:12:56 +02:00
Shannon Booth
d4a890080d LibWeb: Switch IDL from UseNewAKString to UseDeprecatedAKString
NewAKString is effectively the default for any new IDL interface, so
let's mark this as the default behavior. It also makes it much easier to
figure out whatever interfaces are still left to port over to new AK
String.
2023-09-02 19:23:41 +01:00
circl
e0e67a2b27 LibWeb: Partially implement MouseEvent.movementX/movementY
Currently doesn't handle the mouse leaving and entering the window per
the spec, and uses clientX/Y instead of screenX/Y. See FIXMEs.
2023-08-30 10:21:30 +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
Andreas Kling
25eee91811 AK: Make "foo"_fly_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Timothy Flynn
cd995d113b LibWeb: Implement KeyboardEvent.location closer to the spec 2023-07-09 06:32:20 +02:00
Timothy Flynn
71bf9f1d0d LibWeb: Implement KeyboardEvent.key according to the spec
This implementation only includes key codes marked as required by the
spec, as those are the only keys we have in our kernel.
2023-07-09 06:32:20 +02:00
Timothy Flynn
64022031c4 LibWeb: Implement KeyboardEvent.code according to the spec
This implementation only includes key codes marked as required by the
spec, as those are the only keys we have in our kernel.
2023-07-09 06:32:20 +02:00
Timothy Flynn
2945e4b8e9 LibWeb: Add spec links for the KeyboardEvent IDL
Mostly for convenience.
2023-07-09 06:32:20 +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
Andi Gallo
1bbfe4630d LibWeb: Preserve case for key events
Case-preserving behavior matches observed behavior of other browsers and
the specification.
2023-05-23 06:02:00 +02:00
Luke Wilde
e038901555 LibWeb: Fire the contextmenu event on right click (if not holding shift)
This now allows websites such as Discord, YouTube and your favourite
"Right Click" xkcd comic to open a custom context menu when you right
click. You can bypass this by holding shift, just like Firefox.
2023-05-22 06:07:05 +02:00
Luke Wilde
8bacd569ff LibWeb: Make the dblclick event bubble, cancelable and composed 2023-05-14 13:51:05 +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
Kenneth Myhra
3aa485aa09 LibWeb: Move string literals to {HTML,UIEvents}::EventNames.h
This moves the reamining string literals from GlobalEventHandlers.h to
{HTML,UIEvents}::EventNames.h.
2023-04-06 23:49:08 +02:00
Kenneth Myhra
03d6cb88ff LibWeb: Port KeyboardEvent to new String 2023-04-06 08:41:43 +02:00
Kenneth Myhra
e14be3927a LibWeb: Port FocusEvent to new String 2023-04-06 08:41:43 +02:00
Timothy Flynn
db2ba5f1d9 LibWeb: Initialize static web strings during main-thread VM creation
These are currently initialized in a [[gnu::constructor]], which has a
weird initialization order. These constructors are invoked before main()
and, incidentally, before any user-defined default constructors of the
static strings they are initializing.

This will become an issue when these strings are ported to FlyString,
which has a user-defined default constructor. In that scenario, when the
FlyString constructor is executed after the [[gnu::constructor]], the
strings will be "reset" to the empty string.

Instead of relying on a non-standard compiler extension here, let's just
initialize these strings explicitly during main-thread VM creation, as
this now happens in WebContent's main().
2023-03-18 19:50:45 +01:00
Kenneth Myhra
e57461b89e LibWeb: Make factory methods of UIEvents::WheelEvent fallible 2023-02-22 09:55:33 +01:00