Instead of having N functions all implement the same practice of looping
until an async event has arrived, this templatizes the bulk of the work.
(cherry picked from commit 922837f31b4cc66f6a3acd875962b54c6d547f65)
These aren't required to comply with the UIEvents spec, but they are
required by WebDriver.
(cherry picked from commit 5b2633d90f81d0098d5d7cea1274b98c91851fae;
amended to change `MOD_KEYPAD` to 32 to match serenity's `Mod_Keypad`
in Kernel/API/KeyCode.h)
Multi-byte code point presses do not have a UIEvents::KeyCode value, so
we would previously set the event's key field to "Unidentified".
(cherry picked from commit a11e5055c7f225da3b96571e892042868fd2af18)
We have support for using (shift+)tab to move focus to the next/previous
element on the page. However, there were several ways for this to crash
as written. This updates our implementation to check if we did not find
a node to move focus to, and to reset focus to the first/last node in
the document.
This doesn't seem to work when wrapping around from the first to the
last node. A FIXME has been added for that, as this would already not
work before this patch (the main focus here is not crashing).
(cherry picked from commit 96b5646fc116a98dac80559b9a4be2c149f2e157)
The spec says we don't need to await navigations if we navigate to the
same URL that we are already on, but at least in our implementation, we
should still await the page load. Otherwise, we will invoke WebDriver
endpoints on the wrong page.
(cherry picked from commit 13fe3477ab8ac253bd7346d50b3224baf891872e)
Our handling of left vs. right modifiers keys (shift, ctrl, etc.) was
largely not to spec. This patch adds explicit UIEvents::KeyCode values
for these keys, and updates the UI to match native key events to these
keys (as best as we are able).
(cherry picked from commit 4fcaeabe1a6acd9f4d5fd811a36f2e86748b2a72;
amended to make the rest of the system build and to keep `Mod_AltGr`
around in addition to adding it as a key)
Co-authored-by: Nico Weber <thakis@chromium.org>
For example, pressing just the shift key should not producde a keypress
event.
(cherry picked from commit 448754d95dc797b44d9b066c1e37dabec79d79e6;
amended to not use ICU in CharacterTypes.cpp)
Fire the events before handling any close requests or selection changes.
Pages must have an opportunity to cancel the events.
(cherry picked from commit 3925317c118e23a9b87b65ca792c5d94a92c98a7)
If the user only presses the shift key, for example, we are required to
still send that event to WebContent and generate the corresponding JS
events. Unfortunately, NSApp does not inform us of these events via the
keyDown/keyUp methods. We have to implement the flagsChanged interface,
and track for ourselves what modifier keys were pressed or released.
(cherry picked from commit eabd5b0f2271e7a89727daf80dd28623711f3416)
We only set the grapheme segmenter's text once after creating a new
segmenter, so we also need to clear it whenever we invalidate the text.
(cherry picked from commit 25516e351e46104ff445216e7835aaab9f9b9535)
The expensive part of creating a segmenter is doing the locale and UCD
data lookups at creation time. Instead of doing this once per text node,
cache the segmenters on the document, and clone them as needed (cloning
is much, much cheaper).
On a profile loading Ladybird's GitHub repo, the following hot methods
changed as follows:
ChunkIterator ctor: 6.08% -> 0.21%
Segmenter factory: 5.86% -> 0%
Segmenter clone: N/A -> 0.09%
(cherry picked from commit 5d7175874258f00763adcced230149dd1379e4a6;
mended as usual for Unicode::Segmenter -> Locale::Segmenter, and also
to resolve minor conflicts due to serenity not yet having
LadybirdBrowser/ladybird#1106. Also, due to serenity not using ICU,
this doesn't have a big performance effect over here, but it still
makes future cherry-picks easier)
Our current text iterator is not aware of multi-code point graphemes.
Instead of simply incrementing an iterator one code point at a time, use
our Unicode grapheme segmenter to break text into fragments.
(cherry picked from commit f0105b473b9cc3446ec36359b559db9a8e78446d;
amended as usual for Unicode::Segmenter -> Locale::Segmenter, and to
tweak expected/multi-code-point-graphemes.txt for serenity's superior
emoji glyphs)
Instead of recomputing boundaries on every iteration, this now
computes boundaries once and then searches that vector.
This is still O(n^2) for now, but already much faster (at the expense
of using O(n) memory): `BenchmarkSegmenter.for_each_boundary` stays
at around 3ms, but `forward` and `backward` go from ~13s to ~60ms
on my system.
This fixes the typo in `HTMLFieldSetElement` and adds valid local names
for `<meta>`, `<ol>` and `<optgroup>`.
(cherry picked from commit 06863479bed8d99865b40e10df1c2fbc3a43e090)
Implements the cite attribute of `q`, `blockqoute`, `ins` and `del`
elements according to spec by returning a valid URL.
(cherry picked from commit 74645facae366d62ee4c44bd4a96d02df345a5d4)
...Including a couple of steps in
obtain_a_browsing_context_to_use_for_a_navigation_response() which
didn't have FIXMEs.
No apparent changes on WPT.
(cherry picked from commit 310cdc35f05946be15cb16ccc2f32e4f1e43efe3)
We currently use a naive word segmentation, looking for ASCII spaces to
mark a word boundary. Use LibUnicode's complete implementation instead.
(cherry picked from commit 430c9d3e3fb6ec9e2aa3d962381672b70957c395;
amended to use Locale::Segmenter instead of Unicode::Segmenter due
to LibLocale and LibUnicode being two distinct libraries in serenity)
In text documents, pressing the left/right arrow keys with the cmd key
pressed should be treated as home/end key presses.
(cherry picked from commit bf9d05d97a570e8d4ebd83ca7e757938c2b504b3)
This implementation is based on the same feature I added to Serenity's
TextEditor:
https://github.com/SerenityOS/serenity/pull/17477
(cherry picked from commit ecf2cc600bea8f8396061f5fe6aba8358a033bbb;
amended to change Unicode::Segmenter to Locale::Segmenter due to
LibLocale and LibUnicode being separate libraries in serenity)
We will be adding a word segmenter as well, so this is to disambiguate
the two.
(cherry picked from commit eece7697fdcaf50eed98fff069c5e678ac425784;
amended to fix conflict due to Serenity's Segmenter still being in
LibLocale, while upstream combined LibLocale and LibUnicode)
On Linux/Windows, the ctrl key is used in conjunction with arrow keys to
jump word-by-word in text documents. On macOS, the option key is used
(which is mapped to the alt key code).
(cherry picked from commit feecf89d65b3f76a4fe090daa01928439efb9fce;
amended to fix minor conflict)
The spec does not define activation behavior of ctrl/cmd clicks, so we
have to go a bit ad-hoc here. When an anchor element is clicked with the
cmd (on macOS) or ctrl (on other platforms) modifier pressed, we will
skip activation of that element and pass the event on to the chrome. We
still dispatch the event to allow scripts to cancel the event.
(cherry picked from commit 40b2d24d5585a94f09f521bb0ceb055dcae7b6e9)