Commit Graph

44236 Commits

Author SHA1 Message Date
Andreas Kling
7a51e846b2 Base: Add two HTML test pages for DOM cloneNode() functionality 2022-12-14 15:21:48 +01:00
Andreas Kling
b005e816a3 LibWeb: Implement Node.isEqualNode() for ProcessingInstruction nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
8b0ace6289 LibWeb: Add Document.createProcessingInstruction()
These nodes don't really do anything interesting yet, but let's allow
creating them. :^)
2022-12-14 15:21:48 +01:00
Andreas Kling
bf759ce5e3 LibWeb: Make sure ProcessingInstruction objects have the right prototype 2022-12-14 15:21:48 +01:00
Andreas Kling
de2c302cdb LibWeb: Implement Node.isEqualNode() for Attr nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
a004d3043f LibWeb: Implement Node.cloneNode for Attr nodes 2022-12-14 15:21:48 +01:00
Timothy Flynn
9a9c8460aa Browser: Inject cookies timestamps as integers rather than doubles
Now that LibSQL can store 64-bit integers, let's use them.
2022-12-14 09:21:30 -05:00
Timothy Flynn
72e41a7dbd LibSQL: Support 64-bit integer values and handle overflow errors
Currently, integers are stored in LibSQL as 32-bit signed integers, even
if the provided type is unsigned. This resulted in a series of unchecked
unsigned-to-signed conversions, and prevented storing 64-bit values.
Further, mathematical operations were performed without similar checks,
and without checking for overflow.

This changes SQL::Value to behave like SQLite for INTEGER types. In
SQLite, the INTEGER type does not imply a size or signedness of the
underlying type. Instead, SQLite determines on-the-fly what type is
needed as values are created and updated.

To do so, the SQL::Value variant can now hold an i64 or u64 integer. If
a specific type is requested, invalid conversions are now explictly an
error (e.g. converting a stored -1 to a u64 will fail). When binary
mathematical operations are performed, we now try to coerce the RHS
value to a type that works with the LHS value, failing the operation if
that isn't possible. Any overflow or invalid operation (e.g. bitshifting
a 64-bit value by more than 64 bytes) is an error.
2022-12-14 09:21:30 -05:00
Timothy Flynn
a1007c37a4 LibSQL: Sort the list of SQL error codes alphabetically 2022-12-14 09:21:30 -05:00
Timothy Flynn
264db4fc40 LibSQL: Remove unnecessary values from the ENUMERATE_SQL_TYPES macro
Removing the bitmask-esque values from the enumeration necessitates a
Heap version bump.
2022-12-14 09:21:30 -05:00
Timothy Flynn
b5fd96b7ac LibSQL: Ungracefully handle database version incompatibilities
In the long run, this is obviously a bad way to handle version changes
to the SQL database files. We will want to migrate old databases to new
formats. Until we figure out a good way to do that, wipe old databases
so that we don't crash trying to read incompatible data.
2022-12-14 09:21:30 -05:00
Andreas Kling
d5ed07fdc4 LibJS+LibWeb: Remove NonnullGCPtr<T>::operator=(GCPtr<T>) footgun
GCPtr can be null so it's not safe to assign it to a NonnullGCPtr unless
you know it to be non-null.

This exposed a number of wrong uses in LibWeb which had to be fixed as
part of this change.
2022-12-14 15:21:15 +01:00
Andreas Kling
4abdb68655 LibJS: Remove Object(Object& prototype) footgun
This constructor was easily confused with a copy constructor, and it was
possible to accidentally copy-construct Objects in at least one way that
we dicovered (via generic ThrowCompletionOr construction).

This patch adds a mandatory ConstructWithPrototypeTag parameter to the
constructor to disambiguate it.
2022-12-14 15:11:57 +01:00
Andreas Kling
42b5c896e8 LibJS: Don't "copy construct" temporary value in ThrowCompletionOr ctor
It was possible for the generic ThrowCompletionOr constructor to
"copy-construct" a JS Object when instantiating a ThrowCompletionOr
via e.g `return *object;`.

This happened because it chose the Object(Object& prototype) constructor
which will be removed in a subsequent commit. It was not easy to debug.

As a first step towards avoiding this in the future, the generic
ThrowCompletionOr constructor now takes the value as a const reference.
2022-12-14 15:11:57 +01:00
Arda Cinar
3ea1584f2e Presenter: Provide default text styles to text objects
Having an uninitialized text alignment value caused a crash in
Gfx::Painter::draw_text.
2022-12-14 07:45:06 -05:00
Arda Cinar
9d9a6b6b64 Presenter: Fix a crash in loading untitled presentations
The Presentation::title() and Presentation::author() functions return a
StringView to the title/author defined in the json file or a default
value. Previously, this would return a StringView to already-freed
memory and crash the application when setting the window title. This
commit fixes that issue :^)
2022-12-14 07:45:06 -05:00
Timothy Flynn
e305b32d9a LibCore: Protect Core::Group against null group::gr_mem members
Serenity's implementation does not set this pointer to anything, so we
should not assume it was set.
2022-12-14 07:25:36 -05:00
Timothy Flynn
d09266237d LibCore: Define and use a fallible, OS-independent getgrent(_r) wrapper
Rather than maintaining a list of #ifdef guards to check systems that do
not provide the reentrant version of getgrent, we can use C++ concepts
to let the compiler perform this check for us.

While we're at it, we can also provide this wrapper as fallible to let
the caller TRY calling it.
2022-12-14 07:25:36 -05:00
Timothy Flynn
1ee808fae6 LibCore: Define and use a fallible, OS-independent getpwent(_r) wrapper
Rather than maintaining a list of #ifdef guards to check systems that do
not provide the reentrant version of getpwent, we can use C++ concepts
to let the compiler perform this check for us.

While we're at it, we can also provide this wrapper as fallible to let
the caller TRY calling it.
2022-12-14 07:25:36 -05:00
Ali Mohammad Pur
b367da592c AK: Bring back the AK_DONT_REPLACE_STD #define
This was removed in a910961f37d1da9dafb6385e348266746354cf98 in favour
of the more general USING_AK_GLOBALLY #define, but Ladybird (and
probably other projects) depend on the smaller hammer to include STL
headers and keep the USING_AK_GLOBALLY behaviour, so put it back and
preserve its behaviour.
2022-12-14 12:56:01 +01:00
Andrew Kaster
16d4791212 CMake: Pass NO_POLICY_SCOPE to options cmake helpers
Tell CMake to not create a new policy scope for the
(lagom|serenity|common)_options.cmake helpers, and lets us set common
policies for both projects in common_options.cmake that actually apply
to the rest of the project, instead of just common_options.cmake itself.
2022-12-14 12:43:12 +01:00
Ali Mohammad Pur
f96a3c002a Everywhere: Stop shoving things into ::std and mentioning them as such
Note that this still keeps the old behaviour of putting things in std by
default on serenity so the tools can be happy, but if USING_AK_GLOBALLY
is unset, AK behaves like a good citizen and doesn't try to put things
in the ::std namespace.

std::nothrow_t and its friends get to stay because I'm being told that
compilers assume things about them and I can't yeet them into a
different namespace...for now.
2022-12-14 11:44:32 +01:00
Ali Mohammad Pur
72514d6915 AK: Make Types.h not export its functions if !USING_AK_GLOBALLY 2022-12-14 11:44:32 +01:00
Linus Groh
b90f505409 LibJS: Convert WrappedFunction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
54ebf71da2 LibJS: Convert WeakSet::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
cac71a6847 LibJS: Convert WeakRef::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
3358ddfd0e LibJS: Convert WeakMap::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
37c85fa07e LibJS: Convert TypedArray::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
dd3d133968 LibJS: Convert SymbolObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
049e99b5f0 LibJS: Convert StringObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
337c55a893 LibJS: Convert StringIterator::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
c200c247e4 LibJS: Convert SetIterator::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
1c8b700248 LibJS: Convert Set::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
9946e9e874 LibJS: Convert RegExpStringIterator::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
cad40ec953 LibJS: Convert RegExpObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
bfb8d83535 LibJS: Convert Realm::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
e0818bf21e LibJS: Convert ProxyObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
6e386acb11 LibJS: Convert PromiseResolvingFunction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
d3cb7cd584 LibJS: Convert PromiseFooElementFunction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
716c8bdc9d LibJS: Convert PromiseReaction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
a4d85cd522 LibJS: Convert Promise::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
ddc6e139a6 LibJS: Convert Object::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
f990095728 LibJS: Convert NumberObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
b42e293ddd LibJS: Convert NativeFunction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
9846d23c79 LibJS: Convert MapIterator::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
d48cdc7fa6 LibJS: Convert Map::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
45f903da00 LibJS: Convert Intrinsics::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
237402aea9 LibJS: Convert Intl::Segments::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
df589bb05b LibJS: Convert Intl::SegmentIterator::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
658bd2f342 LibJS: Convert Intl::NumberFormatFunction::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00