Commit graph

44070 commits

Author SHA1 Message Date
MacDue
27fae78335 Meta+Userland: Pass Gfx::IntSize by value
Just two ints like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
e011eafd37 Meta+Userland: Pass Gfx::FloatPoint by value
Just a small 8-byte value like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
MacDue
bbc149ebb9 Meta+Userland: Pass Gfx::Color by value
Gfx::Color is always 4 bytes (it's just a wrapper over u32) it's less
work just to pass the color directly.

This also updates IPCCompiler to prevent from generating
Gfx::Color const &, which makes replacement easier.
2022-12-07 11:48:27 +01:00
Marcus Nilsson
f76c7f3788 LibGL: Generate GL_OUT_OF_MEMORY error in glBufferData when OOM 2022-12-07 11:46:37 +01:00
Linus Groh
54abfcf835 LibJS: Remove redundant AK_MAKE_NON{COPYABLE,MOVABLE} from Symbol class
These are already applied to the Cell base class.
2022-12-07 09:58:59 +00:00
Linus Groh
f490ba13ff LibJS: Move creation of global symbols into Symbol.for()
This is now according to the spec. Having a non-standard lookup API
that creates symbols on the fly doesn't seem ideal.
2022-12-07 09:58:59 +00:00
Linus Groh
b821356ba6 LibJS: Add const/non-const VM::global_symbol_registry() getters
This will allow us to replace the strange get_global_symbol() API that
creates symbols on the fly when not found.
2022-12-07 09:58:59 +00:00
Linus Groh
d5457375e6 LibJS: Store NonnullGCPtr<Symbol> values in m_global_symbol_registry 2022-12-07 09:58:59 +00:00
Linus Groh
2c579ed0df LibJS: Rename m_global_symbol_map to m_global_symbol_registry
The spec calls it "GlobalSymbolRegistry".
2022-12-07 09:58:59 +00:00
Linus Groh
112b3f7342 LibJS: Convert MarkupGenerator to the new String 2022-12-07 09:58:38 +00:00
Linus Groh
f23b55ae86 AK: Add StringView(String const&) constructor
This allows us to pass the new String type to functions that take a
StringView directly, having to call bytes_as_string_view() every time
gets old quickly.
2022-12-07 09:58:38 +00:00
Linus Groh
daec065fde LibJS: Move initialize_instance_elements() from VM to Object
This makes more sense as an Object method rather than living within the
VM class for no good reason. Most of the other 7.3.xx AOs already work
the same way.
Also add spec comments while we're here.
2022-12-07 00:23:51 +00:00
Linus Groh
cdeaced54e LibJS: Add spec link and comment to VM::execution_context_stack() 2022-12-07 00:14:10 +00:00
Linus Groh
91a9f41155 LibJS: Add spec link and comment to VM::running_execution_context() 2022-12-07 00:14:01 +00:00
Linus Groh
1832474a37 LibJS: Remove forgotten VM::construct() declaration
This has been a standalone AO function for a long time now.
2022-12-06 23:46:47 +00:00
Linus Groh
1f4437ff2b LibJS: Remove unused VM::join_arguments() function
The last uses of this were removed in ff5e07d.
2022-12-06 23:45:24 +00:00
Linus Groh
c756585deb LibWeb: Ignore -Wshadow in TRY_OR_RETURN_OOM() 2022-12-06 21:31:00 +00:00
Linus Groh
5103e08b77 AK: Ignore -Wshadow in TRY() and MUST()
This makes the warning in CLion disappear when nesting them.
2022-12-06 21:31:00 +00:00
Linus Groh
d2e143eec7 AK: Add a helper macro to temporarily ignore diagnostics with _Pragma() 2022-12-06 21:31:00 +00:00
Maciej
6e4f886999 3DFileViewer: Properly propagate errors from WavefrontOBJLoader
Fixes 3 FIXMEs.
2022-12-06 17:24:45 +00:00
Andreas Kling
a3e82eaad3 AK: Introduce the new String, replacement for DeprecatedString
DeprecatedString (formerly String) has been with us since the start,
and it has served us well. However, it has a number of shortcomings
that I'd like to address.

Some of these issues are hard if not impossible to solve incrementally
inside of DeprecatedString, so instead of doing that, let's build a new
String class and then incrementally move over to it instead.

Problems in DeprecatedString:

- It assumes string allocation never fails. This makes it impossible
  to use in allocation-sensitive contexts, and is the reason we had to
  ban DeprecatedString from the kernel entirely.

- The awkward null state. DeprecatedString can be null. It's different
  from the empty state, although null strings are considered empty.
  All code is immediately nicer when using Optional<DeprecatedString>
  but DeprecatedString came before Optional, which is how we ended up
  like this.

- The encoding of the underlying data is ambiguous. For the most part,
  we use it as if it's always UTF-8, but there have been cases where
  we pass around strings in other encodings (e.g ISO8859-1)

- operator[] and length() are used to iterate over DeprecatedString one
  byte at a time. This is done all over the codebase, and will *not*
  give the right results unless the string is all ASCII.

How we solve these issues in the new String:

- Functions that may allocate now return ErrorOr<String> so that ENOMEM
  errors can be passed to the caller.

- String has no null state. Use Optional<String> when needed.

- String is always UTF-8. This is validated when constructing a String.
  We may need to add a bypass for this in the future, for cases where
  you have a known-good string, but for now: validate all the things!

- There is no operator[] or length(). You can get the underlying data
  with bytes(), but for iterating over code points, you should be using
  an UTF-8 iterator.

Furthermore, it has two nifty new features:

- String implements a small string optimization (SSO) for strings that
  can fit entirely within a pointer. This means up to 3 bytes on 32-bit
  platforms, and 7 bytes on 64-bit platforms. Such small strings will
  not be heap-allocated.

- String can create substrings without making a deep copy of the
  substring. Instead, the superstring gets +1 refcount from the
  substring, and it acts like a view into the superstring. To make
  substrings like this, use the substring_with_shared_superstring() API.

One caveat:

- String does not guarantee that the underlying data is null-terminated
  like DeprecatedString does today. While this was nifty in a handful of
  places where we were calling C functions, it did stand in the way of
  shared-superstring substrings.
2022-12-06 15:21:26 +01:00
Timothy Flynn
d50b9165cd Meta: Manually compute the length of the WASM JS REPL source string
The REPL does not have a reliable way to tell us the UTF-8 byte count of
the source string, so we must use strlen() ourselves.
2022-12-06 13:53:24 +00:00
Hendiadyoin1
fcc3348bc8 LibJS: Intercept returns through finally blocks in Bytecode
This is still not perfect, as we now actually crash in the
`try-finally-continue` tests, while we now succeed all
`try-catch-finally-*` tests.

Note that we do not yet go through the finally block when exiting the
unwind context through a break or continue.
2022-12-06 16:09:24 +03:30
Hendiadyoin1
c2108489a5 LibJS: Don't try to manage unwind contexts in the execution loop in BC
We are already doing this in a good manner via the generated code,
doing so in the execution loop as well will cause us to pop contexts
multiple times, which is not very good.
2022-12-06 16:09:24 +03:30
Hendiadyoin1
133faa0acc LibJS: Remove FinishUnwind instruction
This is essentially a LeaveUnwind+Jump, so lets just do that, that will
make it easier to optimize it, or see unwind state transitions
2022-12-06 16:09:24 +03:30
Hendiadyoin1
fc332be2e5 LibJS: Leave unwind contexts on enter of finally blocks in Bytecode
Before we were doing so while exiting the catch-block, but not when
exiting the try-block.
This now centralizes the responsibility to exit the unwind context to
the finalizer, ignoring return/break/continue.
This makes it easier to handle the return case in a future commit.
2022-12-06 16:09:24 +03:30
Ali Mohammad Pur
c500647eee AK: Take the bump-allocated chunk header into account in destroy_all()
Previously we allowed the end_offset to be larger than the chunk itself,
which made it so that certain input sizes would make the logic attempt
to delete a nonexistent object.
Fixes #16308.
2022-12-06 11:19:50 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Aliaksandr Kalenik
f74251606d LibWeb: Do not try to place out-of-flow blocks in anonymous nodes
Currently placing floating blocks in anonymous nodes makes
https://stackoverflow.com/ hang so let's leave it to try
to place only absolute blocks in anonymous nodes for now.

Also it breaks flex formatting when element with floating is
flex child.
2022-12-06 08:53:10 +01:00
Timothy Flynn
91b3a3bb58 Meta: Initialize the WASM JS REPL with a known time zone
The runtime environment of the WASM REPL does not have time zone
information; the file system is virtual (does not have /etc/localtime),
and the TZ environment variable is not set. This causes LibTimeZone to
always fall back to UTC.

Instead, we can get the time zone from the user's browser before we
enter this limited environment. The REPL website will pass the time zone
into the WASM REPL.
2022-12-05 22:24:50 +00:00
Timothy Flynn
14524ad019 Meta: Explicitly link generated compile-time data into the WASM JS REPL
Without this, we were in a weird state where LibTimeZone believed it had
TZDB data, but that data wasn't actually available to it. This caused
functions like JS::get_named_time_zone_offset_nanoseconds() to trip an
assertion when entering "new Date();" into the REPL.
2022-12-05 22:24:50 +00:00
Tim Schumacher
312a41fddf LibAudio: Use NonnullOwnPtr to keep track of LoaderPlugin streams
This doesn't have any immediate uses, but this adapts the code a bit
more to `Core::Stream` conventions (as most functions there use
NonnullOwnPtr to handle streams) and it makes it a bit clearer that this
pointer isn't actually supposed to be null. In fact, MP3LoaderPlugin
and FlacLoaderPlugin apparently forgot to check for that completely
before starting to decode data.
2022-12-05 17:49:47 +01:00
Tim Schumacher
c57be0f474 LibAudio: Switch LoaderPlugin to a more traditional constructor pattern
This now prepares all the needed (fallible) components before actually
constructing a LoaderPlugin object, so we are no longer filling them in
at an arbitrary later point in time.
2022-12-05 17:49:47 +01:00
Tim Schumacher
3cf93d0dd2 LibAudio: Stop passing Bytes by reference
`Bytes` is very slim, so the memory and/or performance gains from
passing it by reference isn't that big, and it passing it by value is
more compatible with xvalues, which is handy for things like
`::try_create(buffer.bytes())`.
2022-12-05 17:49:47 +01:00
MacDue
385ba1280b LibWeb: Fix box-shadows where the border-radius is < the blur-radius
This fixes a rendering issue where box-shadows would not appear or
render completely broken if the blur radius was larger than the
border radius (border-radius < 2 * blur-radius to be exact).
2022-12-05 17:48:51 +01:00
Aliaksandr Kalenik
ca123350cc LibWeb: Inherit TableFormattingContext from FC instead of BFC 2022-12-05 17:47:48 +01:00
Aliaksandr Kalenik
fae0b96fe4 LibWeb: Add vertical-align support for table cells 2022-12-05 17:47:48 +01:00
Aliaksandr Kalenik
ba64d0462c LibWeb: Move box_baseline from LineBuilder.cpp to LayoutState.cpp 2022-12-05 17:47:48 +01:00
Aliaksandr Kalenik
2f38f8c84a LibWeb: Implement intrinsic width calculation for TFC 2022-12-05 17:47:48 +01:00
Aliaksandr Kalenik
dbf76e8ae1 LibWeb: Take rowspan into account while table formatting 2022-12-05 17:47:48 +01:00
Aliaksandr Kalenik
1c6783cd7e LibWeb: Start implementation of CSS Table 3 spec
Here I try to address bug where content of table overflows
it's width (hacker news is an example of such site) by
reimplementing some parts of table formatting context.

Now TFC implements first steps of:
https://www.w3.org/TR/css-tables-3/#table-layout-algorithm
but column width and row height distribution steps are
still very incomplete.
2022-12-05 17:47:48 +01:00
Cameron Youell
4e3b965d7f LibGUI: Fix a typo 2022-12-05 13:59:00 +00:00
Agustin Gianni
bf522d3bb3 Documentation: Fix typo in AdvancedBuildInstructions.md
Fixes a small typo where the word `are` was missing.
2022-12-05 11:08:19 +00:00
Andreas Kling
d8a3e2fc4e Kernel: Don't memset() allocated memory twice in kcalloc()
This patch adds a way to ask the allocator to skip its internal
scrubbing memset operation. Before this change, kcalloc() would scrub
twice: once internally in kmalloc() and then again in kcalloc().

The same mechanism already existed in LibC malloc, and this patch
brings it over to the kernel heap allocator as well.

This solves one FIXME in kcalloc(). :^)
2022-12-05 10:29:18 +01:00
djwisdom
3f38f61043 Ports: Update serenity-theming app use latest commit
Add fonts Hantschrift and Schwedische Schreibschrift
2022-12-04 14:02:18 -08:00
Filiph Sandström
2e3efd34c3 MouseSettings: Add "Natural scrolling" toggle 2022-12-04 19:32:43 +00:00
Filiph Sandström
5a083c03a6 WindowServer: Add "Natural scrolling" support
Also commonly referred to as "reverse scrolling" or "inverted
scrolling".
2022-12-04 19:32:43 +00:00
Liav A
bef9ad4e44 Meta: Update all references of clang-format-14 to clang-format-15
Also, we add a section that describes how to get an updated clang-format
with multiple possible options to do that.
2022-12-04 09:13:24 -07:00