Commit graph

428 commits

Author SHA1 Message Date
Lucas CHOLLET a5edc9cdfc Userland: Prefer _short_string over String::from_utf8_short_string
This user-defined literal is a strictly equivalent but shorter alias to
`String::from_utf8_short_string`.
2023-08-08 07:37:21 +02:00
Andreas Kling 34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Hediadyoin1 50bf303edd LibJS: Capture UnrealizedSourceRanges in ExecutionContext, not ASTNodes
This loosens the connection to the AST interpreter and will allow us to
generate SourceRanges for the Bytecode interpreter in the future as well

Moves UnrealizedSourceRanges from TracebackFrame to the JS namespace for
this
2023-08-05 06:39:06 +02:00
0GreenClover0 259228d8d2 Spreadsheet: Set Help window mode to Modeless in the constructor
And don't try to do it every time the Help button is clicked.
This fixes a crash when clicking the Help button twice (setting window
mode on an already visible window is not supported).

This also fixes a situation where when opening the Help window with an
action, we didn't set its mode to "Modeless".
2023-08-05 02:14:51 +03:30
Karol Kosek eb41f0144b AK: Decode data URLs to separate class (and parse like every other URL)
Parsing 'data:' URLs took it's own route. It never set standard URL
fields like path, query or fragment (except for scheme) and instead
gave us separate methods called `data_payload()`, `data_mime_type()`,
and `data_payload_is_base64()`.

Because parsing 'data:' didn't use standard fields, running the
following JS code:

    new URL('#a', 'data:text/plain,hello').toString()

not only cleared the path as URLParser doesn't check for data from
data_payload() function (making the result be 'data:#a'), but it also
crashes the program because we forbid having an empty MIME type when we
serialize to string.

With this change, 'data:' URLs will be parsed like every other URLs.
To decode the 'data:' URL contents, one needs to call process_data_url()
on a URL, which will return a struct containing MIME type with already
decoded data! :^)
2023-08-01 14:19:05 +02:00
Shannon Booth 8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Valtteri Koskivuori 8ed3cc5f7b Spreadsheet: Update cell colors interactively while picking
Spreadsheet cells now show a real-time preview of the currently selected
color while the user is picking in `GUI::ColorPicker`
2023-07-24 11:30:54 +03:30
Andreas Kling 52cd671163 LibJS: Make Object::internal_get() reveal the used property offset
This function now takes an optional out parameter for callers who would
like to what kind of property we ended up getting.

This will be used to implement inline caching for property lookups.

Also, to prepare for adding more forms of caching, the out parameter
is a struct CacheablePropertyMetadata rather than just an offset. :^)
2023-07-09 12:54:06 +02:00
Timothy Flynn c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Sam Atkins f33824d2e9 LibGUI+Userland: Propagate errors in Model::column_name() 2023-06-14 17:53:59 +02:00
Karol Kosek 8bd68198d6 Userland: Filter out unsupported file types in open dialogs in more apps 2023-06-11 09:40:17 +01:00
thankyouverycool caa8f43dbe Applications+Demos+LibGUI: Migrate to fallible WizardDialogs and Pages
And port page text to String. Also removes WizardDialog::show() helper
as all current implementations prefer to derive their own Dialog.
2023-06-09 17:21:43 +02:00
Andreas Kling 87ac906ee6 LibJS: Make Error stack traces lazier
Instead of eagerly populating the stack trace with a textual
representation of every call frame, just store the raw source code range
(code, start offset, end offset). From that, we can generate the full
rich backtrace when requested, and save ourselves the trouble otherwise.

This makes test-wasm take ~7 seconds on my machine instead of ~60. :^)
2023-05-28 10:03:11 +02:00
thankyouverycool 02d94a303c Base+Userland: Apply Human Interface Guidelines to Object text
Corrects a slew of titles, buttons, labels, menu items and status bars
for capitalization, ellipses and punctuation.

Rewords a few actions and dialogs to use uniform language and
punctuation.
2023-05-23 05:59:49 +02:00
Karol Kosek bde96640ac Spreadsheet: Don't release the file buffer when importing CSV files
CSVImportDialogPage takes and holds a StringView meaning that the data
was dropped instantly and displayed garbage instead.
2023-05-15 06:55:41 +02:00
Karol Kosek 945f05ed76 Userland: Port Model::column_name() to String 2023-05-15 06:42:10 +02:00
Lucas CHOLLET 1a97382305 LibGUI: Make Application's construction fallible
The pattern to construct `Application` was to use the `try_create`
method from the `C_OBJECT` macro. While being safe from an OOM
perspective, this method doesn't propagate errors from the constructor.
This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually
define a `create` method that can bubble up errors from the
construction stage.

This commit also removes the ability to use `argc` and `argv` to
create an `Application`, only `Main`'s `Arguments` can be used.

From a user point of view, the patch renames `try_create` => `create`,
hence the huge number of modified files.
2023-05-05 16:41:21 +01:00
thankyouverycool f7e034d4b2 LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle
Previously, Frames could set both these properties along with a
thickness to confusing effect: Most shapes of the same shadowing only
differentiated at a thickness >= 2, and some not at all. This led
to a lot of creative but ultimately superfluous choices in the code.

Instead let's streamline our options, automate thickness, and get
the right look without so much guesswork.

Plain shadowing has been consolidated into a single Plain style,
and 0 thickness can be had by setting style to NoFrame.
2023-04-30 05:49:46 +02:00
thankyouverycool 91bafc2653 LibGUI+Userland: Port Labels to String 2023-04-30 05:48:14 +02:00
Abuneri a04316403e Spreadsheet: Add blank sheet when import dialog is cancelled
If you launch the Spreadsheet app by clicking on a CSV
(or other supported formats) the import dialog is immediately
launched. If you cancel out of the import the application ends
up in an empty state where there are no sheets added. When you
launch the app normally it defaults to having a blank sheet, so
we should have the same behaviour in this scenario to prevent users
from having to manually add the new/blank sheet before being able to
use the app
2023-04-29 12:14:21 +01:00
huttongrabiel 8bc232e6be Spreadsheet: Enable the ability to undo/redo changes in cell color
Cells can be updated with new background/foreground colors and then this
action can be undone/redone.
2023-04-29 12:09:08 +01:00
huttongrabiel 7c204745ee Spreadsheet: Add CellUndoMetadataCommand class
Enables the ability to undo changes in metadata without undoing chages
in data. Previously there was only CellUndoData which cannot undo things
such as changes in cell background color.
2023-04-29 12:09:08 +01:00
huttongrabiel 40725c7c8c Spreadsheet: Add CellChange constructor for changes in type metadata
Allows the creation of CellChanges where the change is in the type
metadata instead of in data.
2023-04-29 12:09:08 +01:00
Cameron Youell 8134dccdc7 AK: Add new failable JsonArray::{append/set} functions
Move all old usages to the more explicit `JsonArray:must_{append/set}`
2023-04-24 09:21:51 +02:00
Karol Kosek 969543a847 LibGUI+Userland: Make Window::*add_menu take name using new string 2023-04-19 07:59:54 +02:00
thankyouverycool 5872fe6536 SpreadSheet: Use new InputBox features
Rename now uses a compact box and populates the editor with the
old name, and "Add new" now has a comfy icon. Both prevent empty
names.
2023-04-18 10:05:21 +02:00
thankyouverycool 02a9e5d3f6 LibGUI+Userland: Improve error and font handling for InputBox
Adds fallible factories, ports DeprecatedString, and rebuilds the
layout to accomodate system font changes.
2023-04-18 10:05:21 +02:00
MacDue 35612c6a7f AK+Everywhere: Change URL::path() to serialize_path()
This now defaults to serializing the path with percent decoded segments
(which is what all callers expect), but has an option not to. This fixes
`file://` URLs with spaces in their paths.

The name has been changed to serialize_path() path to make it more clear
that this method will generate a new string each call (except for the
cannot_be_a_base_url() case). A few callers have then been updated to
avoid repeatedly calling this function.
2023-04-15 06:37:04 +02:00
Matteo Benetti 3e1626acdc Spreadsheet+LibSyntax: Never insert spans directly
Function `CellSyntaxHighlighter::rehighlight()` direct inserted spans
to TextDocument `m_span` vector missing out important reordering and
merging operation carried out by `TextDocument::set_spans()`.

This caused overlapping spans for a cell with only a `=` symbol
(one for the actual token and one for the highlighting) to
miscalculate `start` and `end` value and a `length` value (of
`size_t` type) with a `0-1` substraction (result: 18446744073709551615)
causing `Utf32View::substring_view()` to fail the
`!Checked<size_t>::addition_would_overflow(offset, length)` assertion

This remove the possibility to directly alter `TextDocument`'s spans
thus forcing the utilization of `HighlighterClient::do_set_spans()`
interface function.

Proper refactor have been applied to
`CellSyntaxHighlighter::rehighlight()` function
2023-04-14 10:00:52 +02:00
Linus Groh f345f72b55 LibJS: Port Value::to_object() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh b84f8fb55b LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and
some lazily, but in neither case the getters actually return a nullptr.

This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has
an `operator T&()`), and also has the interesting side effect of forcing
us to explicitly use the FunctionObject& overload of call(), as passing
a NonnullGCPtr is ambigous - it could implicitly be turned into a Value
_or_ a FunctionObject& (so we have to dereference manually).
2023-04-13 14:29:42 +02:00
Sam Atkins b746d324cf Spreadsheet: Propagate errors from SpreadsheetWidget::initialize_menubar 2023-04-03 21:16:26 +02:00
Sam Atkins 1e275dd942 Spreadsheet: Add list of recently-opened files 2023-04-03 21:16:26 +02:00
Lucas CHOLLET fd0b809d54 Spreadsheet: Port to Core::File 2023-03-22 23:21:20 +01:00
Cameron Youell 1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
Timothy Flynn 13dfadba79 LibJS: Propagate errors from VM creation 2023-03-17 16:39:08 +00:00
Karol Kosek 66402b0666 LibGUI+Userland: Port TabWidget set_tab_title to new string 2023-03-16 09:58:42 +01:00
Karol Kosek 797968c310 LibGUI+Userland: Make TabWidget::*add_tab() take title using new string 2023-03-16 09:58:42 +01:00
Sam Atkins 6d8f046fd0 LibGfx+Userland: Make TextAttributes::underline_style optional
Rather than having a style AND a field saying whether to use the style,
just make the style Optional.
2023-03-15 14:55:49 +01:00
Matthew Olsson b5f01bd212 Spreadsheet: Wrap raw JS::Cell*/& fields in GCPtr/NonnullGCPtr 2023-03-15 08:48:49 +01:00
Tim Schumacher ecd1862859 AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
No functional changes.
2023-03-13 15:16:20 +00:00
Andreas Kling 21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling 689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling 8a48246ed1 Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-06 23:46:35 +01:00
Ali Mohammad Pur 500044906d LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in
StringViews and might have a non-properly-null-terminated string as a
value. As a bonus, using StringView (and DeprecatedString where
necessary) leads to nicer looking code too :^)
2023-03-01 10:47:19 +01:00
Tim Ledbetter ec5d2a5144 Spreadsheet: Fix column index to number conversion
The output of Spreadsheet::convert_from_string() is now correct for
numbers larger than 26^2.
2023-02-26 21:06:21 +03:30
Linus Groh 09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
Sam Atkins 77ad0fdb07 Userland: Specify margins and spacing in the GUI::Layout constructor 2023-02-18 16:56:56 +00:00
Sam Atkins 9561ec15f4 Userland: Use Widget::add_spacer() everywhere 2023-02-18 16:56:56 +00:00
Timothy Flynn 88814acbd3 LibJS+Everywhere: Convert JS::Error to String
This includes an Error::create overload to create an Error from a UTF-8
StringView. If creating a String from that view fails, the factory will
return an OOM InternalError instead. VM::throw_completion can also make
use of this overload via its perfect forwarding.
2023-02-17 09:14:23 -05:00
Lucas CHOLLET e8249d735d LibFileSystemAccessClient: Remove the deprecated API
Concerned functions are:
 - try_request_file_read_only_approved_deprecated
 - try_request_file_deprecated
 - try_open_file_deprecated
 - try_save_file_deprecated

It also allows some simplifications in the implementation of the client.
2023-02-16 20:11:52 +01:00
Timothy Flynn a2f1b80c36 Assistant+Spreadsheet: Convert usages of Value::TDSWOSE to Value::TSWOSE 2023-02-16 14:32:22 +01:00
Timothy Flynn b245300ba1 LibJS+Everywhere: Deprecate Value::to_string_without_side_effects 2023-02-16 14:32:22 +01:00
Tim Schumacher 43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher 874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher 606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Karol Kosek e39adc4772 Userland: Set Button text using the new String class 2023-02-13 00:45:09 +00:00
Karol Kosek f802920a3a Userland: Use default initializer instead of an empty string for Buttons 2023-02-13 00:45:09 +00:00
Tim Ledbetter d32961777b Spreadsheet: Don't recalculate column sizes when no data has changed
Use the Model::UpdateFlag::DontResizeColumns option when performing a
model update where no data has been changed. This improves navigation
performance on large spreadsheets.
2023-02-10 05:12:06 +03:30
Tim Schumacher 093cf428a3 AK: Move memory streams from LibCore 2023-01-29 19:16:44 -07:00
Tim Schumacher 8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Timothy Flynn b75b7f0c0d LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
2023-01-29 00:02:45 +00:00
Timothy Flynn 2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +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 4b17cba074 Spreadsheet: Replace uses of JsonObject::get_deprecated()/get_ptr() 2023-01-27 08:07:24 -05: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
Sam Atkins 1dd6b7f5b7 AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()
This is a preparatory step to making `get()` return `ErrorOr`.
2023-01-17 19:52:52 -05:00
Lucas CHOLLET c6aeb9811c Spreadsheet: Port to Core::Stream
It also takes advantage of the new, `Core::Stream`-friendly, interface
in `LibFileSystemAccessClient`.
2023-01-16 17:28:32 +03:30
Lucas CHOLLET 81008062a7 Spreadsheet: Port from Result to ErrorOr 2023-01-16 17:28:32 +03:30
Lucas CHOLLET 4952cdfe2b Spreadsheet: Move to a non-owning model for Stream in Writer::XSV 2023-01-16 17:28:32 +03:30
Timothy Flynn afeb7273cc LibJS+Everywhere: Rename Value::to_string to to_deprecated_string 2023-01-15 01:00:20 +00:00
Timothy Flynn a59ebdac2d LibJS+Everywhere: Return strings by value from PrimitiveString
It turns out return a ThrowCompletionOr<T const&> is flawed, as the GCC
expansion trick used with TRY will always make a copy. PrimitiveString
is luckily the only such use case.
2023-01-13 18:50:47 -05:00
Liav A e241b47fee Userland: Remove a bunch of unveil calls on /sys/kernel/processes
These are not needed anymore since the introduction of the new
get_root_session_id syscall.
2023-01-13 13:41:30 +01:00
Sam Atkins 652f87821b Userland: Replace remaining Core::Timer::construct()s with try_create() 2023-01-12 11:25:51 +01:00
Timothy Flynn 115baa7e32 LibJS+Everywhere: Make PrimitiveString and Utf16String fallible
This makes construction of Utf16String fallible in OOM conditions. The
immediate impact is that PrimitiveString must then be fallible as well,
as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string
from ropes.

There are a couple of places where it is very non-trivial to propagate
the error further. A FIXME has been added to those locations.
2023-01-08 12:13:15 +01:00
Sam Atkins f0395a2042 LibGUI+Userland: Rename try_load_from_gml() -> load_from_gml() :^)
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07 14:39:30 +01:00
Sam Atkins 54b1326165 Userland: Replace all uses of load_from_gml with try_load_from_gml
MOAR FIXMES! ;^)
2023-01-07 14:39:30 +01:00
Karol Kosek 247db3fdd0 LibFileSystemAccessClient: Rename try_* functions to try_*_deprecated
These functions return the deprecated `Core::File` class, so let's mark
it as such to avoid possible confusion between future non try_*
functions which will use Core::Stream family classes and to possibly
grab someone's attention. :^)
2023-01-07 10:53:43 +00:00
Karol Kosek e9d73a6256 Spreadsheet: Port ExportDialog to Core::Stream 2023-01-07 04:03:01 +03:30
Karol Kosek 3a8450ae11 Spreadsheet: Port XSV writer to Core::Stream 2023-01-07 04:03:01 +03:30
Karol Kosek 5793f7749c Spreadsheet: Make file export functions return ErrorOr<> 2023-01-07 04:03:01 +03:30
Karol Kosek 29a3cdcfb7 Spreadsheet: Generate file previews in memory and save directly to file
When we were asked to make a new preview text, we first generated the
whole file in the /tmp directory and then read the first 8 lines to put
them in a text box. This was doing a bit of unnecessary work at first,
but more importantly, didn't work on a given file descriptor from
FileSystemAccessServer as we were copying a file to a filename instead,
meaning that we also had to unveil the whole home directory.

Anyway, previews will be written now to a MemoryStream by the generator,
which will limit to 8 lines. File saves will omit /tmp entirely,
allowing us to tighten program unveil list a little. :^)
2023-01-07 04:03:01 +03:30
Karol Kosek c74441395b Spreadsheet: Use has_flag helper functions for XSV WriterBehaviors 2023-01-07 04:03:01 +03:30
Cody Hein e0aae9e60a Spreadsheet: Remove cursor keys from is_navigation
This change allows for cursor navigation of a forumula while editing
rather than having to use the mouse to edit the cursor position within
a cell. Tab and Enter still allow you to navigate out of the cell to
next row or columns. :)
2023-01-07 03:46:52 +03:30
Sam Atkins 0c24522635 LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06 13:36:02 -07:00
Ben Wiederhake b83cb09db1 Everywhere: Fix badly-formatted includes
In 7c5e30daaa, the focus was "only" on
Userland/Libraries/, whereas this commit cleans up the remaining
headers in the repo, and any new badly-formatted include.
2023-01-02 11:06:15 -05:00
Optimoos d856dae07c Spreadsheet: Allow Functions Help HorizontalSplitter to resize
Using set_fixed_width prevents the splitter from resizing, so it has
been changed to set_preferred_width. Added a FIXME that I'm not
familiar enough with the codebase to tackle yet.

This addresses issue #16589
2022-12-23 07:53:26 +00:00
Lucas CHOLLET 9ae97c8cb1 LibFileSystemAccessClient: Rename try_save_file =>
`try_save_file_deprecated`

This precedes the addition of a new api using `Core::Stream`
2022-12-14 18:26:25 +00: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
Tim Schumacher 2fc2025f49 LibCore: Move Core::Stream::File::exists() to Core::File
`Core::Stream::File` shouldn't hold any utility methods that are
unrelated to constructing a `Core::Stream`, so let's just replace the
existing `Core::File::exists` with the nicer looking implementation.
2022-12-08 12:52:14 +00:00
Linus Groh 525f22d018 LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was
misleading - it would not always create a rope string, only if both
sides are not empty strings. Use a three-argument create() overload
instead.
2022-12-07 16:43:06 +00: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
Linus Groh d26aabff04 Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
Andreas Kling b0b022507b LibJS: Reduce AST memory usage by shrink-wrapping source range info
Before this change, each AST node had a 64-byte SourceRange member.
This SourceRange had the following layout:

    filename:       StringView (16 bytes)
    start:          Position (24 bytes)
    end:            Position (24 bytes)

The Position structs have { line, column, offset }, all members size_t.

To reduce memory consumption, AST nodes now only store the following:

    source_code:    NonnullRefPtr<SourceCode> (8 bytes)
    start_offset:   u32 (4 bytes)
    end_offset:     u32 (4 bytes)

SourceCode is a new ref-counted data structure that keeps the filename
and original parsed source code in a single location, and all AST nodes
have a pointer to it.

The start_offset and end_offset can be turned into (line, column) when
necessary by calling SourceCode::range_from_offsets(). This will walk
the source code string and compute line/column numbers on the fly, so
it's not necessarily fast, but it should be rare since this information
is primarily used for diagnostics and exception stack traces.

With this, ASTNode shrinks from 80 bytes to 32 bytes. This gives us a
~23% reduction in memory usage when loading twitter.com/awesomekling
(330 MiB before, 253 MiB after!) :^)
2022-11-22 21:13:35 +01:00
Daniel Bertalan 4296425bd8 Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so
there is no point in writing such functions by hand if all they do is
call through to `operator==`.

This fixes a compile error with compilers that implement P2468 (Clang
16 currently). This paper restores the C++17 behavior that if both
`T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be
rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators
makes the rewriting possible again.
See https://reviews.llvm.org/D134529#3853062
2022-11-06 10:25:08 -07:00
Nico Weber daeaefad17 Everywhere: Clean up "the the" comment typos 2022-11-03 17:38:32 +00:00
Tim Schumacher ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00