Commit Graph

13040 Commits

Author SHA1 Message Date
Gunnar Beutner
1b13d52a87 LibC: Make 'attributes' parameter for pthread_create const 2022-10-24 15:49:39 +02:00
Linus Groh
9ad6031bca LibWeb: Move internal response in FilteredResponse create() functions 2022-10-24 09:26:16 +01:00
Linus Groh
02a4cba086 LibWeb: Use MUST() for infallible ByteBuffer::copy() invocations
ByteBuffer has an inline capacity of 32 bytes, so when we provide a
string smaller than that, it cannot fail.
2022-10-24 09:26:16 +01:00
Linus Groh
65f5c7adbc LibWeb: Add Fetch::Infrastructure::Header::from_string_pair() helper
This allows us to use this:

```cpp
auto header = TRY_OR_RETURN_OOM(realm,
    Infrastructure::Header::from_string_pair(name, value));
```

Instead of the somewhat unwieldly:

```cpp
auto header = Infrastructure::Header {
    .name = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(name.bytes())),
    .value = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(value.bytes())),
};
```
2022-10-24 09:26:16 +01:00
Linus Groh
c12c6fd5ea LibWeb: Fix typo in Fetch::Infrastructure::Request::add_range_header() 2022-10-24 09:24:15 +01:00
Andreas Kling
8aab33de5f LibWeb: Skip positioned children in paint_descendants()
Positioned descendants are now handled entirely by paint_internal()
so we can just skip over positioned children in paint_descendants().
This avoids drawing the same boxes multiple times.
2022-10-23 23:32:42 +02:00
Andreas Kling
8bf0e71c0c LibWeb: Paint non-positioned stacking contexts with z-index 0 or auto
As I understand it, these have to be painted interleaved with positioned
descendants in the same z-index category, in tree order.
2022-10-23 23:32:42 +02:00
Andreas Kling
447519f678 LibWeb: Paint positioned descendants with z-index: auto
This "worked" before because all positioned elements would create their
own stacking context. When we stopped doing this, there was nobody to
actually paint positioned descendants with `z-index: auto`.

This patch splits up steps 8 and 9 of the paint order algorithm and
implements step 8 as a paint tree traversal. There's more to step 8 than
I've implemented here, so I've left a FIXME for our future selves.
2022-10-23 23:32:42 +02:00
Andreas Kling
8a0e40c5b0 LibWeb: Update StackingContext::paint_descendants() for new rule
Since positioned elements no longer automatically create stacking
contexts, we can't rely on this assumption when painting descendants of
a stacking context.

In this commit, we fix an issue that manifested as a failure to
Gfx::Painter::restore() in the "Overlay" paint phase. What happened was
that a CSS clip was being applied in the "Background" paint phase, and
then unapplied in the "Overlay" phase. Due to bogus checks in
paint_descendants(), the "Background" phase never ran for positioned
elements, but the "Overlay" phase did.

The check for positioned elements was bogus in the first place and had
never actually worked before, since we would always skip over positioned
descendants due to them having stacking contexts.
2022-10-23 23:32:42 +02:00
Andreas Kling
055a1998c1 LibWeb: StackingContext::paint_descendants() can take const layout node
It doesn't mutate the layout tree in any way.
2022-10-23 23:32:42 +02:00
Andreas Kling
faba3ebfca LibWeb: Don't create stacking contexts for all positioned elements
We were mistakenly creating stacking contexts for all elements with
non-static CSS position.

For `absolute` and `relative`, we should only create stacking contexts
if the `z-index` value is something other than `auto`.

This makes it possible to click the cookie on Cookie Clicker. :^)
2022-10-23 23:32:42 +02:00
Andreas Kling
29c6aabf49 LibWeb: Try harder to find a suitable DOM node for mouse event dispatch
Since our hit testing mechanism gives you the Paintable under the mouse
cursor, we can't just give up if that paintable doesn't have a
corresponding DOM node. That meant that generated content like pseudo-
elements didn't generate mouse events at all.

Fix this by making a dom_node_for_event_dispatch() helper function that
finds a suitable DOM node when given a paintable. This first cut is very
naive, and there's probably more we should do, but we have to start
somewhere. :^)
2022-10-23 23:32:42 +02:00
Aliaksandr Kalenik
9cbf031b6d LibWeb: Add button property in MouseEvent 2022-10-23 15:58:16 +02:00
Aliaksandr Kalenik
501fb1cccb LibWeb: Dispatch "wheel" event 2022-10-23 15:58:16 +02:00
davidot
1ab6cb1ee9 LibWeb: Make SVG::AttributeParser use the new double parser
Because the result will be a float anyway get rid of the int parsing.
Also the grammar of SVG numbers matches the double parser grammar except
it can't have a sign but that should have been checked by the caller.
2022-10-23 15:48:45 +02:00
davidot
051134a21e LibGfx: Make parse_rgba_color use the new double parser
Since this is used by LibWeb when parsing CSS colors we should not use
strtod here.
2022-10-23 15:48:45 +02:00
davidot
62fc3e50f3 LibJS: Make parseFloat use the new double parser
This means it no longer is locale dependent and doesn't incorrectly
accept hex floats anymore.
2022-10-23 15:48:45 +02:00
davidot
29a96b1304 LibWeb: Make HTMLProgressElement use the new double parser 2022-10-23 15:48:45 +02:00
davidot
6e9969ded0 LibWeb: Make HTMLInputElement of type number use the new double parser 2022-10-23 15:48:45 +02:00
davidot
8abd4f6102 LibWeb: Make the CSS parser use the new double parser
This could potentially be sped up by tracking the up to three different
ranges of characters known to be digits. This would save the double
parser from checking whether these are digits and because it has the
size it can use the fast parsing method.
2022-10-23 15:48:45 +02:00
davidot
783b1a479d LibJS: Make string_to_double use the new double parser 2022-10-23 15:48:45 +02:00
davidot
6805ded21d LibJS: Make canonical_numeric_index_string use the new double parser 2022-10-23 15:48:45 +02:00
davidot
3dc99af3dc LibJS: Make parse_temporal_duration use the new double parser 2022-10-23 15:48:45 +02:00
davidot
d66bfcc3f4 LibJS: Make PluralRules use the new double parser 2022-10-23 15:48:45 +02:00
davidot
7db59124e8 LibJS: Make Token use the new double parser 2022-10-23 15:48:45 +02:00
davidot
9921f80817 LibJS: Fix that non-double numbers from JSON were truncated to i32 2022-10-23 15:48:45 +02:00
davidot
1986b8b066 LibC: Make strtod use the new exact number parser
Because strtod need to set ERANGE and track the last character we have
to check the resulting value. We also have to check for nan and inf in
strtod itself as the new double parser doesn't accept that as floating
points.
2022-10-23 15:48:45 +02:00
davidot
66d07a452f LibJS: Make a TypedArray test actually run on all different types 2022-10-23 15:48:45 +02:00
davidot
80f23abd0a LibJS: Add descriptive output to test-commons expect().toThrow()
This (and still some other methods) just say Expectation error leaving
the user completely in the dark whether the method threw at all.
And since we have nice function printing now we can just toString the
function since most are lambda's.
2022-10-23 15:48:45 +02:00
Moustafa Raafat
5edd4bd512 LibJS: Require NanosecondsToDays remainder less than dayLength
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/ac69b63
2022-10-22 19:14:14 +02:00
Moustafa Raafat
b1c8029c2b LibJS: Require that NanosecondsToDays doesn't flip sign
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/e13c52d
2022-10-22 19:14:14 +02:00
Moustafa Raafat
cfd684dc2f LibCrypto: Add SignedBigInteger::is_positive() 2022-10-22 19:14:14 +02:00
Sam Atkins
e5a25171fe LibGfx: Mark AffineTransform<T>::map() as only working for numeric T
The implementations for these methods is manually defined in the .cpp
file for `int` and `float`, meaning that other `T` values would fail -
but only once we got to the linking stage. This patch makes the error
happen much earlier, so it's more obvious.
2022-10-22 18:17:58 +02:00
Sam Atkins
732aa2c5c7 LibGfx: Make Rect<T> methods work when T is not int or float
Putting the implementations in the .cpp file meant that they only
existed for `IntRect` and `FloatRect`, since those were instantiated at
the bottom of the file. Now they work for other types. :^)

A couple of places in WindowServer had to be modified to disambiguate
between the two `Rect::intersected()` overloads.

Co-authored-by: davidot <davidot@serenityos.org>
2022-10-22 18:17:58 +02:00
Smrtnyk
b08ae57b23 LibWeb: Parse SameSite cookie attribute 2022-10-22 18:17:01 +02:00
Tobias Christiansen
be6bbdaa3b WebContent+Friends: Add get_element_tag_name IPC and plumbing 2022-10-22 13:44:49 +02:00
Andreas Kling
8ebbb6a2f3 Revert "LibWeb: Prevent world leak when activating event handler"
This reverts commit 8875cd0c83.

It broke Twitter (tweets would no longer load). Reverting until we can
understand why. :^(
2022-10-21 13:32:13 +02:00
Linus Groh
950d2fccf0 LibWeb: Remove workaround for nested BodyInit IDL union type 2022-10-21 12:11:24 +02:00
Linus Groh
775c12f60f LibIDL: Resolve typedefs in UnionType members recursively 2022-10-21 12:11:24 +02:00
Tobias Christiansen
202b2be1f2 WebContent+Friends: Add IPC and plumbing for WebDriver endpoint
To use the `GET /session/{id}/element/{id}/css/{property name}`
WebDriver endpoint, two new IPC calls through the Browser are
implemented:
    - get_active_documents_type returns the type of the active document,
      which is either "xml" or "html"
    - get_computed_value_for_element returns the computed CSS value (as
      String) for the given element and CSS property name
2022-10-20 21:26:10 +02:00
Andreas Kling
eda566d112 LibWeb: Add GC finalizer to DOM::NodeIterator
It's potentially unsafe to access `m_root` in the destructor since it
may have been swept, so move unregistration of the NodeIterator into a
GC finalizer instead.
2022-10-20 19:46:39 +02:00
Andreas Kling
e7da96acaf LibWeb: Call superclass GC finalizer in DOM::Node::finalize()
There isn't actually anything important happening in the superclasses
right now, but let's be good citizens and call up.
2022-10-20 19:45:17 +02:00
Andreas Kling
1885fe529f LibWeb: Add GC finalizer to Layout::ImageBox
It's not safe to unregister ImageBox from the browsing context in the
destructor (since the browsing context may have already been swept and
destroyed).
2022-10-20 19:36:59 +02:00
Andreas Kling
c877eb47a2 LibWeb: Add GC finalizer for DOM::Node
Now that the layout tree is also GC-allocated, we can't be messing with
it from the DOM::Node destructor. Move everything to a GC finalizer
so we know it runs before the GC sweep phase.
2022-10-20 19:36:59 +02:00
Andreas Kling
07a36c8f80 LibJS: Add a finalization pass to the garbage collector
Doing things in the destructor of a GC-allocated object isn't always
safe, in case it involves accessing other GC-allocated objects.
If they were already swept by GC, we'd be poking into freed memory.

This patch adds a separate finalization pass where GC calls finalize()
on every unmarked cell that's about to be deleted.

It's safe to access other GC objects in finalize(), even if they're
also unmarked.
2022-10-20 19:36:59 +02:00
Andreas Kling
6d830e6335 LibWeb: Tie layout tree to a specific browsing context
Now that both the layout tree and browsing context are GC-allocated,
we can formalize their relationship a bit better by having layout
nodes keep a NonnullGCPtr to the browsing context.

This makes the previously-indirect link direct, removing an unpleasant
"how do we know the browsing context is alive" question when accessing
it from the layout tree.
2022-10-20 19:36:59 +02:00
Aliaksandr Kalenik
66e424a084 LibWeb: Fix pointer-events check in hit_test 2022-10-20 17:58:16 +02:00
Kenneth Myhra
ebd93c8d57 LibWeb: Revert support for DOM::Document in XHR::send()
This is a manual revert of commit: 7831e62

Let's revert this until we got nested union support in our IDL
generator/parser.
2022-10-20 17:57:52 +02:00
Luke Wilde
645a64ef0f LibWeb: Don't get impl in document_tree_child_browsing_context_count
This caused `Object.getOwnPropertyNames(window)` to throw, as the
`this` value is `Object`.

All users of document_tree_child_browsing_context_count call it on an
existing Window impl, including WP::internal_own_property_keys, so
getting the impl from the JS VM is not necessary.
2022-10-20 17:57:45 +02:00
Andreas Kling
9abe3b0db5 LibWeb: Unbreak layout tree dumps after layout tree GC changes
Layout::Node::class_name() no longer includes the `Web::Layout::` prefix
and thus we don't need to be substringing them in dumps.
2022-10-20 16:06:26 +02:00
Andreas Kling
58522f5088 LibWeb: Make window.{window,self,frames} return the WindowProxy
These now follow the spec and return the WindowProxy rather than the
Window itself.
2022-10-20 16:01:26 +02:00
Andreas Kling
8fd59fce9c LibWeb: Remove unnecessary hack in HTML::Window::initialize()
We don't need to force-set the realm's global object during
initialization anymore, now that intrinsics are set up elsewhere.
2022-10-20 15:31:12 +02:00
Andreas Kling
dc15cacfc3 LibWeb: Use OrderedHashMap to store pending idle callbacks
This removes the need for a separate IdleCallback object per
registration, since the handles are now used as map keys.
2022-10-20 15:16:23 +02:00
Andreas Kling
8875cd0c83 LibWeb: Prevent world leak when activating event handler
Since SafeFunction strongly protects all of its captures, we can't
capture `this` when activating an event handler since that creates a
reference cycle and we end up leaking the entire world.
2022-10-20 15:16:23 +02:00
Andreas Kling
268b9c5d90 LibWeb: Make the layout tree GC-allocated
This removes a set of complex reference cycles between DOM, layout tree
and browsing context.

It also makes lifetimes much easier to reason about, as the DOM and
layout trees are now free to keep each other alive.
2022-10-20 15:16:23 +02:00
Andreas Kling
83c5ff57d8 LibWeb: Make BrowsingContext GC-allocated
(And BrowsingContextGroup had to come along for the ride as well.)
This solves a number of nasty reference cycles between browsing
contexts, history items, and their documents.
2022-10-20 15:16:23 +02:00
Andreas Kling
2898701459 LibWeb: Hang on to the internal realm with a JS::Handle
This fixes an issue where GC would kill the internal realm if it ran at
the wrong time during startup. Found by aggressively GC'ing between
every allocation.
2022-10-20 15:16:23 +02:00
Andreas Kling
6e0f80fbe0 LibWeb: Make the HTMLParser GC-allocated
This prevents a reference cycle between a HTMLParser opened via
document.open() and the document. It was one of many things keeping
some documents alive indefinitely.
2022-10-20 15:16:23 +02:00
Andreas Kling
68452c749a LibWeb: Prevent GC from running during intrinsics allocation
Due to the way we lazily construct prototypes and constructors for web
platform interfaces, it's possible for nested GC allocation to occur
while GC objects have been allocated but not fully constructed.

If the garbage collector ends up running in this state, it may attempt
to call JS::Cell::visit_edges() on an object whose vtable pointer hasn't
been set up yet.

This patch works around the issue by deferring GC while intrinsics are
being brought up. Furthermore, we also create a dummy global object for
the internal realm, and populate it with intrinsics. This works around
the same issue happening when allocating something (like the default UA
stylesheets) in the internal realm.

These solutions are pretty hacky and sad, so I've left FIXMEs about
finding a nicer way.
2022-10-20 15:16:23 +02:00
Andreas Kling
8412206cb4 LibWeb: Cache pseudo element layout nodes weakly on DOM::Element
Having the cache be strong created a reference cycle between DOM nodes
and their pseudo elements.
2022-10-20 15:16:23 +02:00
Andreas Kling
e23fe8cf87 LibJS: Make define_native_foo() take SafeFunctions
We were taking AK::Function and then passing them along to
NativeFunction, which takes a SafeFunction. This works, since
SafeFunction will transparently wrap AK::Function in a CallableWrapper
when assigned, but it was causing us to accumulate thousands of
pointless wrappers around direct function pointers.

By using SafeFunction at every step of the setup call chain, we no
longer create any CallableWrappers for the majority of native functions
in LibJS. Also, the number of heap-registered SafeFunctions in a new
realm goes down from ~5000 to 5. :^)
2022-10-20 15:16:23 +02:00
Andreas Kling
202cc025e5 LibJS: Don't register SafeFunction-to-function-pointer with JS::Heap
Direct function pointers don't have captures, so we don't need to
register the SafeFunction with the Heap when it's just wrapping a
function pointer.
2022-10-20 15:16:23 +02:00
Andreas Kling
be5a39657e LibWeb: Only store one DOM pointer per Layout::Node
Instead of storing two JS::Handles into the DOM, we can combine them
into a single one.

If the layout node is anonymous, m_dom_node points to the DOM::Document.
Otherwise, m_dom_node points to the associated DOM node.

The anonymous state is moved to an m_anonymous boolean member.

This cuts the number of JS::Handles created by the layout tree in half
(and shrinks Layout::Node by 8 bytes).
2022-10-20 15:16:23 +02:00
Andreas Kling
18a5c56f14 LibWeb: Don't store JS::Handle<JS::Promise> in EnvironmentSettingsObject
Now that the ESO is a JS::Cell, we can just store them as NonnullGCPtr
and mark them in visit_edges().
2022-10-20 15:16:23 +02:00
Andreas Kling
dbee75af19 LibWeb: Tear down old layout tree when new document becomes active
When a new document becomes the active document of a browsing context,
we now notify the old document, allowing it to tear down its layout
tree. In the future, there might be more cleanups we'd like to do here.
2022-10-20 15:16:23 +02:00
Andreas Kling
94f0c34dfe LibWeb: Remove unnecessary WeakPtr in queue_microtask_impl()
Capturing a WeakPtr to a GC-allocated object in a JS::SafeFunction is
basically pointless, since the SafeFunction mechanism will then keep
the object alive anyway.
2022-10-20 15:16:23 +02:00
Andreas Kling
57f508f048 LibWeb: Use JS::SafeFunction in run_timer_initialization_steps() 2022-10-20 15:16:23 +02:00
Andreas Kling
a8bdf866d9 LibWeb: Discard old browsing context after obtaining a new one
Cleaning up an old FIXME from before discard was implemented.
2022-10-20 15:16:23 +02:00
Andreas Kling
24510b0845 LibWeb: Make window.parent and window.top return WindowProxy
These functions were previously ad-hoc and returned the active
document's window. They now correctly teturn the browsing context's
WindowProxy instead.
2022-10-20 15:16:23 +02:00
Andreas Kling
3c548adf9c LibWeb: Create and hook up a WindowProxy for each BrowsingContext
All the machinery for this was already in place, we just never created
the actual WindowProxy and installed it.
2022-10-20 15:16:23 +02:00
Andreas Kling
738e770fce LibJS: Remove unnecessary operator==() for ({Nonnull,}GCPtr<T>, T*)
These aren't necessary in the first place since {Nonnull,}GCPtr has
operator T*()
2022-10-20 15:16:23 +02:00
Moustafa Raafat
8f964604f0 LibJS: Refactor CalendarFields for better linearity
This is a normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/9b139a1
2022-10-20 00:53:44 +02:00
Idan Horowitz
d38aeddd77 LibJS: Simplify ParseTemporalTimeZoneString
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/eec8efab
2022-10-20 00:47:42 +02:00
Idan Horowitz
0c61552b81 LibJS: Refactor ToRelativeTemporalObject
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/895854d9
2022-10-20 00:47:42 +02:00
Moustafa Raafat
092b33c96e LibJS: Remove trivial operations ISO{Year,Month,Day}
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/606d8a2
2022-10-19 22:39:33 +02:00
Moustafa Raafat
69d5368b2a LibJS: Remove trivial operation IsValidISOMonth
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/a08330a
2022-10-19 22:39:33 +02:00
Moustafa Raafat
48cc557dfa LibJS: Merge ISOMonthCode and BuildISOMonthCode
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/a4d17b1
2022-10-19 22:39:33 +02:00
Moustafa Raafat
b69ceae10c LibJS: Improve alias names in ResolveISOMonth
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/01d5fbe
2022-10-19 22:39:33 +02:00
Moustafa Raafat
d758566996 LibJS: Simplify ResolveISOMonth
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/1b83226
2022-10-19 22:39:33 +02:00
Tobias Christiansen
3db92885cd WebContent+Friends: Add get_element_property IPC and plumbing 2022-10-19 22:30:06 +02:00
Jelle Raaijmakers
91cec51b99 LibGL: Correctly normalize different vertex attribute type pointers
According to the OpenGL 2.0 spec § 2.8, the data for each attribute type
pointer is normalized according to the type. The only exception to this
is `glVertexAttribPointer` which accepts a `normalized` parameter, but
we have not yet implemented that API.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
00b21fba57 LibGL: Return GLboolean value in glIsEnabled 2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
fe5419da0f LibGL: Implement state for all pixel store parameters
This implements the state and context parameters for all packing and
unpacking parameters accepted by `glPixelStore*`.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
e2b151812e LibGL: Don't repeat ourselves in read_from_vertex_attribute_pointer 2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
5def168f14 LibGL: Implement missing glDeleteLists error conditions 2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
2d59c9b6b6 LibGL: Make read_from_vertex_attribute_pointer static 2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
01a4d58432 LibGL: Do not return early if client-side vertex array is disabled
According to the spec, enabling the client-side vertex array should
behave as if `glVertex` is executed after all other states such as the
normal, color, etc. have changed. We were not changing these states if
the client-side vertex array was disabled which probably does not affect
a lot of applications, but this seems like the correct thing to do. :^)
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
03258f4c96 LibGL: Add buffer API stubs
No implemented functionality, but this makes it easier to see if
software is using this family of functions.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
1c32d93a12 LibSoftGPU: Call floor_int_range only once in sample_2d_lod
We were invoking `frac_int_range` twice to get the `alpha` and `beta`
values to interpolate between 4 texels, but these call into
`floor_int_range` again. Let's not repeat the work.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
88ca72aa79 LibSoftGPU: Extract argb32_color value in rasterization
This makes it easier to correlate slow instructions in the disassembly
view of ProfileViewer.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
681695a07a LibSoftGPU: Make alpha testing a static function
There is no need to access the Device's members for alpha testing; pass
in the required alpha function and reference value.
2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
4e63ce231f LibSoftGPU: Clean up Sampler imports 2022-10-19 22:22:58 +02:00
Jelle Raaijmakers
1774fde37c LibSoftGPU: Drop texel Z coordinate from Sampler
We only support 2D indexing into textures at the moment, so don't
perform any work trying to support the Z coordinate.
2022-10-19 22:22:58 +02:00
cflip
abc0c44f0b LibGL+LibGPU+LibSoftGPU: Report maximum texture size 2022-10-19 22:07:05 +02:00
Etienne Rodriguez
e5a9f030f2 LibGUI: Insert first displayed emoji on return
This enables users to insert emojis without using the mouse by searching
for it in the EmojiInputDialog and then hitting return.
2022-10-19 14:05:42 -04:00
Andreas Kling
178f0b9971 LibJS: Support non-base-10 BigInt literals in bytecode VM
Fixes 39 tests in test262 and a handful in test-js. :^)
2022-10-19 19:58:15 +02:00
Andreas Kling
29935fe943 LibJS: Support for (x in obj) iteration in bytecode VM
We were mistakenly treating these as `for (x of obj)`. By reorganizing
the code a little bit, we actually support both kinds of iteration with
less duplication. :^)

Fixes 17 tests in test262.
2022-10-19 19:03:57 +02:00
Tobias Christiansen
3f5a620b5d WebContent+Friends: Add get_element_attribute IPC and plumbing 2022-10-19 17:30:58 +02:00
Aliaksandr Kalenik
dfc3a4772b LibWeb: Ignore "pointer-events: none" elements in hit_test 2022-10-19 16:11:15 +02:00
Andreas Kling
f39b6ae3c6 LibJS: Avoid expensive UTF-8/16 conversion in legacy RegExp properties
Let's not incur the cost of a synchronous conversion to UTF-8 for all
the legacy static properties after running a regular expression.

The SunSpider subtest regexp-dna goes from taking ~25 sec to ~0.7 sec
on my machine.
2022-10-19 16:10:42 +02:00
Andreas Kling
d9b543da68 LibJS: Disable bytecode optimizations by default
The optimization passes are not stable, which makes test262 flaky.
Address this by introducing a new OptimizationLevel::None and making it
the default.

This removes all the flakiness from test262 in my testing.

We can enable optimizations by default again once they have been made
stable. :^)
2022-10-19 14:37:57 +02:00
MacDue
c6fbeb5845 LibWeb: Don't attempt to paint text shadows for empty text fragments
This avoids the debug spam that happens then the shadow painting fails
to allocate a zero sized bitmap.
2022-10-18 23:18:53 +02:00
MacDue
89e308726e LibWeb: Print requested bitmap sizes in shadow painting debug logs
Also replace "box-shadow" with "text-shadow" in the text shadow
painting debug logs.
2022-10-18 23:18:53 +02:00
Luke Wilde
41d6307c17 LibHTTP: Fix not consuming the last byte of body in from_raw_request
`index + 1` was not correct. For example, if the body has two bytes, we
would consume the first byte and increment the index. We then add one
to the index and see it's equal to the size, so we take this one byte
and set the body result to it. The while loop would still continue and
we consume the second byte, adding it to the temporary buffer. We see
that the index is above the size, so we don't update the body, dropping
the last byte on the floor.
2022-10-18 23:18:20 +02:00
Tobias Christiansen
5d762bd448 WebDriver+Friends: Add IPC and plumbing for Element-getting
This extends the IPC calls `get_document_element` and
`query_selector_all` to be usable by the WebDriver. For this the
`WebDriverConnection` provides the same interfaces and takes care of
routing the data through the Browser.
2022-10-18 19:18:33 +02:00
Timothy Flynn
27737f613c LibTimeZone+LibJS: Update to TZDB version 2022e
https://mm.icann.org/pipermail/tz-announce/2022-October/000074.html

This version changes America/Chicago's transtion from LMT to CST from
1883 Nov 18 12:09:24 to 1883 Nov 18 18:00.
2022-10-18 16:01:44 +02:00
Liav A
74a080fb68 LibC: Use proper casting in fgetc and fgetc_unlocked functions
In the fgetc function, a fix was already in place but was clunky. A real
proper solution is to use an unsigned char instead of a char when
returning the value, so an implicit cast is happening based on the
assumption that the value is unsigned, so if the variable contained 0xff
it won't be treated as -1, but as unsigned 0xff, so the result int will
be 0xff and not -1.

The same solution is applied to the fgetc_unlocked function as well.
2022-10-18 13:21:38 +02:00
Zaggy1024
f0420def78 LibWeb: Implement HTMLSelectElement length, item() and namedItem()
These are simple calls through to the HTMLOptionsCollection functions
the same names, as with HTMLSelectElement.add().
2022-10-18 12:57:40 +02:00
Johannes Laudenberg
2547e0b966 LibWeb: Use calculate_min_content_height() for sizing of grid children
When sizing grid children we now also check whether
calculate_min_content_height() adds to the computed height. Previously
we were using the result of layout_inner() which led to zero height of
not specifically sized block level children.

This fixes a height issue with our GitHub page. The footer is now at
its place and is not hovering over other content anymore.
2022-10-18 12:55:34 +02:00
Linus Groh
a6ba82fc49 LibTimeZone: Resolve /etc/localtime with realpath(), not readlink()
On Fedora Silverblue and other OSTree-based systems, /etc/localtime is
a symlink to /run/host/etc/localtime, which then points to the expected
zoneinfo file, e.g. ../usr/share/zoneinfo/Europe/Berlin.
By using realpath() instead of readlink() we can resolve the symlink
recursively and avoid falling back to UTC.
2022-10-17 22:19:50 +02:00
Timothy Flynn
b1b17f286f LibC: Retrieve the current time zone from LibTimeZone
This ensures we have just one location for determining the time zone, so
that LibC and LibTimeZone will behave the same.

(Note the FIXME removed here is also in TimeZone::current_time_zone.)
2022-10-17 21:50:55 +02:00
Timothy Flynn
ed612d835d LibTimeZone: Default to UTC if parsing the TZ environment variable fails
Commit c3fd455 changed LibTimeZone to fall back to the system time zone
when we fail to parse the TZ environment variable. This behavior differs
from both our LibC and glibc; they abort parsing and default to UTC.

This changes LibTimeZone to behave the same way to avoid a very awkward
situation where some parts of the codebase thinks the timezone is UTC,
and others think the timezone is whatever /etc/timezone indicates.
2022-10-17 21:50:55 +02:00
leeight
0d96468e9b LibJS: Implement RegExp legacy static properties
RegExp legacy static properties Spec url is https://github.com/tc39/proposal-regexp-legacy-features
2022-10-17 17:08:33 +02:00
Andrew Kaster
b8e51425e9 Lagom+CMake: Propagate dependencies for generated custom targets
We have logic for serenity_generated_sources which works well for source
files that are specified in GENERATED_SOURCES prior to calling
serenity_lib or serenity_bin. However, code generated with
invoke_generator, and the LibWeb generators do not always follow the
pattern of the IDL and GML files.

For the LibWeb generators, we can just add_dependencies to LibWeb at the
time we declare the generate_Foo custom target. However for LibLocale,
LibTimeZone, and LibUnicode, we don't have the name of the target
available, so export the name in a variable to set into
GENERATED_SOURCES.

To make this work for Lagom, we need to make sure that lagom_lib and
serenity_bin in Lagom/CMakeLists.txt call serenity_generated_sources on
the target.

This enables the Xcode generator on macOS hosts, at least for Lagom.
2022-10-17 15:55:55 +02:00
Linus Groh
b79b78a5cc LibJS: Sync the set of rounding modes
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/9613358
- https://github.com/tc39/proposal-temporal/commit/4c45464
2022-10-17 13:31:22 +02:00
Linus Groh
3d4ce3cc6d LibJS: Add missing validation to remaining Calendar operations
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c2a0cea
2022-10-17 12:56:05 +02:00
Linus Groh
4567ded8e4 LibJS: Reject relativeTo string such as "2022-08-18T17:01Z"
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2dc20bf
2022-10-17 12:56:05 +02:00
Linus Groh
57162ad510 LibJS: Rename IsValidTimeZoneName to IsAvailableTimeZoneName
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/873313b
2022-10-17 12:56:05 +02:00
Linus Groh
72997c6b77 LibJS: Define IsValidTimeZoneName in terms of AvailableTimeZones
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d83dcf0

Note that even though we already implement AvailableTimeZones for Intl,
I kept the existing implementation calling into LibTimeZone directly.
2022-10-17 12:56:05 +02:00
cflip
05e7b338ad LibDesktop+Taskbar: Add 'WorkingDirectory' property to app files 2022-10-17 01:37:58 +02:00
cflip
953520df49 LibCore: Add argument to specify working directory in Process::spawn 2022-10-17 01:37:58 +02:00
Hendiadyoin1
490c097bc4 LibJS: Forward a string aproximation of the CallExpression to Call Ops
This gives us better debug output when analysing calls to `undefined`
and also fixes multiple test-js cases expecting an
`(evaluated from $Expression)` in the error message.

This also refactors out the generation of that string, to avoid code
duplication with the AST interpreter.
2022-10-17 01:36:41 +02:00
Liav A
db45e242c4 LibC: Do an explicit static_cast in the fgetc function
We assumed that by returning a char in the fgetc function that an
implicit cast is sufficient, but apparently if that char contains 0xff,
the result int will be -1 (0xFFFFFFFF). To ensure this does not happen,
let's do an explicit casting.
2022-10-17 01:08:22 +02:00
Andrew Kaster
2f439327ac LibThreading: Only set pthread name on Serenity
pthread_setname_np is a can of worms for portability. Linux, macOS,
and the BSDs all do it differently.

Also skip adding the tid as an inspectable Core::Object property on
systems where pthread_t is known to be a pointer.
2022-10-16 15:39:00 -06:00
Jelle Raaijmakers
0cf3cb6279 LibGL: Immediately dereference vertex attribute data in display lists
According to the spec, pointers to client data need to be dereferenced
immediately when adding calls such as `glDrawElements` or
`glArrayElement` to a display list. We were trying to support display
lists for these calls but since they only invoke _other_ calls that also
support display lists, we can simply defer the display list
functionality to them.

This fixes the rendering of the ClassiCube port by cflip.
2022-10-16 21:12:15 +02:00
Linus Groh
0ea4d228e6 LibWeb: Add missing body has_value() check in XMLHttpRequest::send() 2022-10-16 18:04:46 +02:00
Julian Offenhäuser
b14f0950a5 LibPDF: Add very basic support for Adobe Type 1 font rendering
Previously we would draw all text, no matter what font type, as
Liberation Serif, which results in things like ugly character spacing.

We now have partial support for drawing Type 1 glyphs, which are part of
a PostScript font program. We completely ignore hinting for now, which
results in ugly looking characters at low resolutions, but gain support
for a large number of typefaces, including most of the default fonts
used in TeX.
2022-10-16 17:44:54 +02:00
Julian Offenhäuser
e6f29302a7 LibPDF: Add glyph drawing and type info methods to PDFFont
A PDFFont can now be asked for its specific type and whether it is part
of the standard 14 fonts. It now also contains a method to draw a
glyph, which is stubbed-out for now.

This will be useful for the renderer to take into consideration when
drawing text, since we don't include replacements for the standard set
of fonts yet, but still want to make use of embedded fonts when
available.
2022-10-16 17:44:54 +02:00
Julian Offenhäuser
36f83cecab LibPDF: Allow page objects to inherit the MediaBox and Resources entries 2022-10-16 17:44:54 +02:00
Julian Offenhäuser
2f71e0f09a LibPDF: Allow text operator sequences to start with whitespace 2022-10-16 17:44:54 +02:00
Julian Offenhäuser
7ecd420b03 LibPDF: Parse floating point numbers that omit a leading zero correctly 2022-10-16 17:44:54 +02:00
Linus Groh
9e6475d76d LibJS: Add spec comments to RegExpObject
Also fix the evaluation order of ToString for pattern and flags while
we're here, and improve some of the variable names.
2022-10-16 17:32:02 +02:00
Linus Groh
eb5be649a5 LibJS: Add spec comments to RegExpConstructor 2022-10-16 17:32:02 +02:00
Linus Groh
1da66b5879 LibJS: Implement the RegExpAlloc AO 2022-10-16 17:32:02 +02:00
Andrew Kaster
1ae0cfd08b CMake+Userland: Use CMakeLists from Userland to build Lagom Libraries
Also do this for Shell.

This greatly simplifies the CMakeLists in Lagom, replacing many glob
patterns with a big list of libraries. There are still a few special
libraries that need some help to conform to the pattern, like LibELF and
LibWebView.

It also lets us remove essentially all of the Serenity or Lagom binary
directory detection logic from code generators, as now both projects
directories enter the generator logic from the same place.
2022-10-16 16:36:39 +02:00
Andrew Kaster
f7f92f104f Lagom+LibCore: Build LibCore, AK, and LibMain with add_subdirectory
By deferring to the CMakeLists in each of these libraries' directories,
we can get rid of a lot of curious GLOB patterns and list removals in
the Lagom CMakeLists.
2022-10-16 16:36:39 +02:00
Andrew Kaster
1ca48a2aec AK+Userland: Use a CMake variable for AK_SOURCES instead of GLOB
This lets us remove a glob pattern from LibC, the DynamicLoader, and,
later, Lagom. The Kernel already has its own separate list of AK files
that it wants, which is only a subset of all AK files.
2022-10-16 16:36:39 +02:00
Linus Groh
b6f101f1c0 LibJS: Fix TemporalCalendarString ambiguity
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/278d238
- https://github.com/tc39/proposal-temporal/commit/b73aea7
2022-10-16 15:20:23 +02:00
Linus Groh
484c66125d LibJS: Rename Get{IANA => Named}TimeZonePreviousTransition
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6b759d1
2022-10-16 14:45:09 +02:00
Linus Groh
8cc260107d LibJS: Rename Get{IANA => Named}TimeZoneNextTransition
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4b0246a
2022-10-16 14:45:09 +02:00
Idan Horowitz
d795f9c6cf LibJS: Change dateAdd to a required parameter of MoveRelativeDate
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/45d9079
2022-10-16 13:45:56 +02:00
Idan Horowitz
3c55643283 LibJS: Add dateAdd to all remaining MoveRelativeDate calls
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a48838a
2022-10-16 13:45:56 +02:00
Idan Horowitz
4e79ce4e7a LibJS: Add optional dateAdd parameter to MoveRelativeDate
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/891060f
2022-10-16 13:45:56 +02:00
Luke Wilde
35c9e324b4 LibJS: Add fast path TimeZone conversion to PlainDate#toZonedDateTime
This is a normative chane in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fcab1af
2022-10-16 13:40:21 +02:00
Luke Wilde
707f12f927 LibJS: Remove extra property check from Instant#toZonedDateTimeISO
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7dfbd80
2022-10-16 13:40:21 +02:00
Luke Wilde
f7bb79d6d1 LibJS: Fast-path ToTemporalTimeZone when the argument is a TimeZone
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/54cea53
2022-10-16 13:40:21 +02:00
Luke Wilde
8c3512d6ce LibJS: Fast-path ToTemporalCalendar when the argument is a Calendar
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2a43b39
2022-10-16 13:40:21 +02:00
Kenneth Myhra
f09e256328 LibWeb: Let LoadRequest::set_body() take by value
This changes the signature of LoadRequest::set_body() to take by value
and then use move semantics to move the contents of the ByteBuffer.

This is done to avoid the fallible copy constructor of ByteBuffer.
2022-10-16 02:06:29 +03:30
Kenneth Myhra
7831e62955 LibWeb: Add support for DOM::Document to XHR::send()
This patch adds support for posting a DOM::Document using XHR::send().
2022-10-16 02:06:29 +03:30
Kenneth Myhra
d5247ae33e LibWeb: Let lambdas return WebIDL::ExceptionOr in XHR::send()
Instead of ErrorOr let these lambdas return WebIdL::ExceptionOr. This
patch also cleans up this part so it's a bit more readable.
2022-10-16 02:06:29 +03:30