Commit Graph

895 Commits

Author SHA1 Message Date
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
MacDue
afb84df290 LibWeb: Add a few extra spec links to CanvasGradient 2023-01-28 00:26:48 +00:00
MacDue
f86b66dc2d LibWeb: Throw exception if any canvas radial gradient radius is < 0
As per the specification:
https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createradialgradient
2023-01-28 00:26:48 +00:00
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Sam Atkins
7891ad2a28 LibWeb: Remove declarations for non-existent methods 2023-01-27 20:33:18 +00:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
MacDue
27a3e11f02 LibWeb: Implement the canvas gradients
This gets:

- CanvasRenderingContext2D.createLinearGradient()
- CanvasRenderingContext2D.createConicGradient()
- CanvasRenderingContext2D.createRadialGradient()

Actually working as fill styles for paths and rectangles :^)
Getting them working for strokes is left as an exercise is
left as an exercise for the reader.
2023-01-22 18:15:52 +01:00
MacDue
24cb57ac88 LibWeb: Update CRC2D .fillStyle and .strokeStyle to accept gradients
While doing add some structures to hold these new fill styles and
plumb them over to the painter.
2023-01-22 18:15:52 +01:00
Linus Groh
afc055c088 LibWeb: Convert the Location object to IDL
This includes:

- Moving it from Bindings/ to HTML/
- Renaming it from LocationObject to Location
- Removing the manual definitions of the constructor and prototype
- Removing special handling of the Location interface from the bindings
  generator
- Converting the JS_DEFINE_NATIVE_FUNCTIONs to regular functions
  returning DeprecatedString instead of PrimitiveString
- Adding missing (no-op) setters for the various attributes, which are
  expected to exist by the bindings generator
2023-01-18 17:36:39 -05:00
Cameron Youell
204257526c LibWeb: Define window.isSecureContext 2023-01-18 09:52:47 +00:00
Timothy Flynn
afeb7273cc LibJS+Everywhere: Rename Value::to_string to to_deprecated_string 2023-01-15 01:00:20 +00:00
Timothy Flynn
8a88d4434f LibJS+LibWeb: Rename number_to_string to number_to_deprecated_string 2023-01-15 01:00:20 +00:00
Andreas Kling
1c4328902d LibWeb: Implement BrowsingContext::select_all() in terms of Selection
We do what other browsers do and create a selection anchored at the
document's body element.
2023-01-12 19:55:10 +01:00
Andreas Kling
bf69f4370e LibWeb: Implement BrowsingContext::selected_text() in terms of Selection
Instead of sifting through the layout tree to extract the selected text,
look at the DOM selection instead.

Note that we can't just stringify the DOM Range, as that would include
non-visible things (like the content of <style> elements, etc.) so we
run it through an ad-hoc variant of the range stringification algorithm.
This can probably be factored better, but it's a start. :^)
2023-01-12 19:55:10 +01:00
Arda Cinar
283187afc5 AK+LibWeb: Move decode forgiving base64 under Web::Infra namespace
Since the forgiving base64 is part of the web infra standard
2023-01-10 17:54:01 +00:00
Timothy Flynn
6e93d89ee3 LibWeb: Generate exposed Window/Worker interfaces as lazy objects
We now lazily create these instances on-demand rather than all at once
when a Window/Worker object is created.
2023-01-10 16:08:14 +01:00
Timothy Flynn
af75493883 LibWeb: Move passing of Web object prototypes out of constructors 2023-01-10 16:08:14 +01: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
Andreas Kling
a915fee5f3 LibWeb: Only log HTML parser errors when HTML_PARSER_DEBUG is enabled
At this point, the parser is reliable enough that we don't need to spam
the debug log about minor parsing issues on every websites.
2023-01-09 14:00:26 +01:00
Srikavin Ramkumar
1c2e7b1e47 LibWeb: Run object representation steps on specified attribute updates 2023-01-09 10:58:22 +01:00
Srikavin Ramkumar
83cb35b60f LibWeb: Run object representation steps on element creation
Prior to this change, fallback content inside an object tag would not
be rendered on page load.
2023-01-09 10:58:22 +01:00
Timothy Flynn
d8044c5358 LibJS+LibWeb: Move the macro to convert ENOMEM to an exception to LibJS
Move the macro to LibJS and change it to return a throw completion
instead of a WebIDL exception. This will let us use this macro within
LibJS to handle OOM conditions.
2023-01-08 12:13:15 +01:00
Jonah
e63d9d4925 LibWeb: Add Support for the ARIA Element Properties
Element now supports getting and setting ARIA properties from
JS and HTML.
2023-01-07 10:51:53 +00:00
VayuDev
fab8ef3dfc LibWeb: Pass FloatRect to Painter::draw_text in fill_text
Don't round float values to int values in
CanvasRenderingContext2D::fill_text when passing them to
Painter::draw_text.

This also fixes a fixme.
2023-01-05 15:47:40 -05:00
Sam Atkins
5d8e3f5122 LibWeb: Convert Layout::Node to new pixel units 2023-01-05 17:42:31 +01:00
Sam Atkins
affc8a22ca LibWeb+WebContent: Convert BrowsingContext to new pixel units
This fixes a few glitches. We no longer give the page double the width
it should have, and we mark the correct area of the page as needing
repainting.
2023-01-05 17:42:31 +01:00
implicitfield
51f41ea997 LibWeb: Support more presentational hints from the HTML spec
Specifically, this adds support for the align attribute when applied to
heading, paragraph and caption elements.
2023-01-04 11:50:03 +01:00
Srikavin Ramkumar
56efd60755 LibWeb: Add stub reset algorithm for HTMLOutputElement 2023-01-03 18:09:40 +01:00
Srikavin Ramkumar
119e58a8c1 LibWeb: Add stub reset algorithm for HTMLTextAreaElement 2023-01-03 18:09:40 +01:00
Srikavin Ramkumar
b55c9f36dc LibWeb: Implement reset algorithm for HTMLSelectElement 2023-01-03 18:09:40 +01:00
Srikavin Ramkumar
de44e0faf5 LibWeb: Implement reset algorithm for HTMLInputElement 2023-01-03 18:09:40 +01:00
Srikavin Ramkumar
6032d122c2 LibWeb: Implement reset button behavior 2023-01-03 18:09:40 +01:00
Srikavin Ramkumar
7cc6ffe5b7 LibWeb: Implement HTMLFormElement::reset
This patch sets up the necessary infrastructure for implementing reset
algorithms for form-associated controls.
2023-01-03 18:09:40 +01:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
Ben Wiederhake
6b7ce19161 Everywhere: Remove unused includes of LibC/stdlib.h
These instances were detected by searching for files that include
stdlib.h, but don't match the regex:

\\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_
uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex
it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs|
ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble
n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o
penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo
c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete
nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou
l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use anything from the stdlib.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Ben Wiederhake
8a331d4fa0 Everywhere: Move AK/Debug.h include to using files or remove 2023-01-02 20:27:20 -05:00
Luke Wilde
1011067a60 LibWeb: Stub HTMLInputElement.setSelectionRange
Required by Twitter to move the input caret of the 2FA <input> element
to the start. However, we don't currently handle individual <input>
element selections.
2022-12-30 21:56:54 -05:00
Nico Weber
7bb4cd74b8 LibWeb: Fix a (charming) comment typo 2022-12-30 10:14:22 -05:00
Arda Cinar
598fcfca26 LibWeb: Make the atob JS function compliant with the spec
It is specified to use the "forgiving-base64" decoder instead of the
regular base64 decoder, which is slightly different
2022-12-28 21:15:02 +01:00
Luke Wilde
7e701f6256 LibWeb: Keep unhandledrejection event promises alive when task is queued
This is fixed by making the "about to be notified rejected promises
list" use JS::Handle instead of JS::NonnullGCPtr. This UAF happens
because notify_about_rejected_promises makes a local copy of this list,
empties the member variable list and then moves the local copy into a
JS::SafeFunction lambda. JS::SafeFunction can only see GC pointers that
are in its storage, not external storage.

Example exploit (requires fixed microtask timing by removing the dummy
execution context):
```html
<script>
Promise.reject(new Error);

// Exit the script block, causing a microtask checkpoint and thus
// queuing of a task to fire the unhandled rejection event for the
// above promise.
// During the time after being queued but before being ran, these
// promises are not kept alive. This is because JS::SafeFunction cannot
// see into a Vector, meaning it can't visit the stored NonnullGCPtrs.
</script>

<script defer>
// Cause a garbage collection, destroying the above promise.
const b = [];
for (var i = 0; i < 200000; i++)
    b.push({});

// Some time after this script block, the queued unhandled rejection
// event task will fire, with the event object containing the dead
// promise.
window.onunhandledrejection = (event) => {
    let value = event.promise;
    console.log(value);
}
</script>
```
2022-12-25 15:32:51 +01:00
Jelle Raaijmakers
25f2e4981c AK: Stop using DeprecatedString in Base64 encoding 2022-12-20 10:34:19 +01:00
Keir Davis
f639445456 LibWeb: Fully Implement get_an_elements_noopener
This removes two fix me in HTMLHyperlinkElementUtils
2022-12-19 07:57:44 -05:00
Quentin Ligier
588994bb00 LibWeb: Improve variable name in HTMLTableElement
The variables 'child_to_append_after' are used to specify the child
before which new elements will be inserted, its name is misleading.
These variables are always passed as 'child' to pre_insert.
2022-12-17 18:35:32 +01:00
Andreas Kling
c355e9692d LibWeb: Add spec links to IDL APIs in HTMLTableElement 2022-12-16 09:58:03 +01:00
Andreas Kling
2ded895107 LibWeb: Allow setting HTMLTableElement.tFoot to null value
This annihilates 2 FIXMEs :^)
2022-12-16 09:58:03 +01:00
Andreas Kling
346737701d LibWeb: Allow setting HTMLTableElement.tHead to null value
This deals with 2 FIXMEs :^)
2022-12-16 09:58:03 +01:00
Andreas Kling
2d791cf90f LibWeb: Allow setting HTMLTableElement.caption to null value
This takes care of 2 FIXMEs :^)
2022-12-16 09:58:03 +01:00
Andreas Kling
6e127f62d7 LibWeb: Add spec link and comment to HTMLTableElement::caption() 2022-12-16 09:58:03 +01:00
Linus Groh
22089436ed LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr 2022-12-15 06:56:37 -05:00