Commit graph

47522 commits

Author SHA1 Message Date
Timothy Flynn
fd1fbad1d2 LibGfx+LibUnicode: Support specifying the path to search for emoji
Similar to the FontDatabase, this will be needed for Ladybird to find
emoji images. We now generate just the file name of emoji image in
LibUnicode, and look for that file in the specified path (defaulting to
/res/emoji) at runtime.
2023-03-01 14:54:16 +00:00
Timothy Flynn
fb6ca386cc LibWeb: Delete entire grapheme clusters on backspace/delete key presses 2023-03-01 14:24:01 +00:00
Timothy Flynn
4734214ac1 LibWeb: Skip over grapheme clusters on left/right arrow key presses
Currently, if you use the left/right arrow keys to move over a multi-
code point glyph, we will move through that glyph one code point at a
time. This means you can "pause" your movement in the middle of a glyph
and delete a subsection of a grapheme cluster. This now moves the cursor
across the entire cluster.
2023-03-01 14:24:01 +00:00
Timothy Flynn
2c4acba883 LibWeb: Convert Web::DOM::Position::to_deprecated_string to String 2023-03-01 14:24:01 +00:00
Tim Schumacher
cd5868a0f1 Toolchain: Don't abuse crt{begin,end}.o for shared or PIE binaries
aarch64 required this to successfully build, but the actual fix to that
is to just make sure that crtbeginS and crtendS get built as a part of
the toolchain.

This partially reverts commit c18c84dbfd.
2023-03-01 12:41:56 +00:00
Sam Atkins
64eb326f26 LibGUI: Give SeparatorWidget a minimum size
Without this, it can be squished down into nothing, which looks really
odd.
2023-03-01 10:55:20 +01:00
Luke Wilde
ddc7bedca6 LibJS: Make int_part a double in StringPrototype::to_string
u64 is not big enough to hold extremely large numbers, such as
4.192938423e+54. This would cause an integer underflow on the radix
index when performing something like `toString(36)` and thus cause an
OOB Array read.
2023-03-01 10:53:31 +01:00
Luke Wilde
52a6f1ff8c LibWeb: Bail FrameLoader's load callbacks if associated BC is discarded
This prevents us setting up the document of a removed browsing context
container (BCC, e.g. <iframe>), which will cause a crash if the
document contains a script that inserts another BCC as this will use
the stale browsing context it previously set up, even if it's
reinserted.

Required by Prebid.js, which does this by inserting an `<iframe>` into
a `<div>` in the active document via innerHTML, then transfers it to
the `<html>` element:
7b7389c5ab/src/utils.js (L597)

This is done in the spec by removing all tasks and aborting all fetches
when a document is destroyed:
https://html.spec.whatwg.org/multipage/document-lifecycle.html#destroy-a-document

See the code comments for a simplified example.
2023-03-01 10:51:04 +01:00
Ali Mohammad Pur
23c514cda3 LibCore+Userland: Remove ArgsParser::add*(Vector<char const*>&)
This finally makes ArgsParser's value API free of silly char*'s!
2023-03-01 10:47:19 +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
Andreas Oppebøen
60908adcbe SoundPlayer: Add action with icon for toggling mute
This adds a button on the menubar next to the volume slider to
indicate mute state and allow toggling the mute. Pressing the M key
will still toggle the mute, as before. When muted, the volume scroll
bar now gets disabled.
2023-03-01 09:04:48 +00:00
Tim Ledbetter
e33791502f PixelPaint: Do not change layers when scaling with the move tool
The move tool will no longer change the foreground layer if the cursor
is currently hovering over a resize anchor.
2023-03-01 08:15:46 +00:00
Linus Groh
51c3967516 Everywhere: Use '_{short_,}string' literals more
This mostly updates code what was written before but merged after these
were added.
2023-02-28 15:15:36 +00:00
Andreas Kling
d0ba5f2ed7 ImageViewer: Add list of recently open files to the File menu :^) 2023-02-28 14:39:32 +01:00
Andreas Kling
5f23515796 TextEditor: Add list of recently open files to the File menu :^) 2023-02-28 14:39:32 +01:00
Andreas Kling
544366ff2a LibGUI: Add a simple "recently open files" feature
This feature allows any application to easily install an automatically
updating list of recently open files in a GUI::Menu.

There are three main pieces to this mechanism:

- GUI::Application::set_config_domain(domain): This must be called
  before using the recent files feature. It informs the Application
  object about which config domain to find the relevant RecentFiles
  list under.

- GUI::Menu::add_recently_open_files(callback): This inserts the list
  in a menu. A callback must be provided to handle actually opening
  the recent file in some application-specific way.

- GUI::Application::set_most_recently_open_file(path): This updates
  the list of recently open files, both in the configuration files,
  and in the GUI menu.
2023-02-28 14:39:32 +01:00
CanadaHonk
3e2ceef8c3 LibWeb: Add size to URLSearchParams
Added new size parameter to URLSearchParams.

Spec: https://url.spec.whatwg.org/#dom-urlsearchparams-size
Co-Authored-By: Linus Groh <mail@linusgroh.de>
2023-02-28 13:24:27 +00:00
Timothy Flynn
e231f72f61 LibGfx: Render text presentation emoji as text if we have its glyph 2023-02-28 13:22:58 +00:00
Timothy Flynn
42c272c059 LibUnicode: Allow ignoring text presentation emoji in sequence detection
This adds an option to only detect emoji that should always present as
emoji. For example, the copyright symbol (unless followed by an emoji
presentation selector) should render as text.
2023-02-28 13:22:58 +00:00
Sam Atkins
c06f4ac6f5 AK+Everywhere: Make GenericLexer::ignore_until() stop before the value
`consume_until(foo)` stops before foo, and so does
`ignore_until(Predicate)`, so let's make the other `ignore_until()`
overloads consistent with that so they're less confusing.
2023-02-28 12:55:10 +00:00
Sam Atkins
0511059d60 LibJS: Assign folding regions for JS files
Each {} block is now treated as a folding region, so that they can be
collapsed and expanded in TextEditor, HackStudio, and anywhere else
that uses the syntax highlighter. :^)
2023-02-28 13:23:55 +01:00
Sam Atkins
cac14a3f0a LibGUI: Assign folding regions for GML files
Each {} block is now treated as a folding region, so that they can be
collapsed and expanded in TextEditor, GML Playground, HackStudio, and
anywhere else that uses the syntax highlighter. :^)
2023-02-28 13:23:55 +01:00
Sam Atkins
d169af117d LibSyntax+LibGUI: Let syntax highlighters assign folding regions 2023-02-28 13:23:55 +01:00
Sam Atkins
92b128e20a LibGUI: Support folding regions in TextEditor 2023-02-28 13:23:55 +01:00
Sam Atkins
3d25b4eb34 LibGUI: Add folding regions to TextDocument
A `TextDocumentFoldingRegion` represents a region of the document which
the user can collapse/expand to make code easier to navigate.
2023-02-28 13:23:55 +01:00
Sam Atkins
96cf9355b2 LibGUI: Add TextRange::line_count() 2023-02-28 13:23:55 +01:00
Sam Atkins
640f6f476c LibGUI: Store Utf32Views in TextEditor::LineVisualData
Previously this stored the position of each visual line break, meaning
that all the text would always be painted. By storing each visual
line's Utf32View, we can skip over parts of the text, such as for code
folding.
2023-02-28 13:23:55 +01:00
Sam Atkins
b5e1babc26 LibGUI: Create TextAttributes for unspanned text once, not repeatedly
Also, stop unnecessarily creating a RefPtr for the unspanned font - just
use `font()`, which returns a reference.
2023-02-28 13:23:55 +01:00
Sam Atkins
e8b7bdbd57 LibGUI: Skip painting TextEditor spans that end on previous lines
This only becomes a problem with folding, since arbitrary lines may be
invisible, meaning we try to apply a span for an invisible line N, on
line N+X instead, causing occasional crashes.

This check means we can remove the loop that skips spans occurring at
the end of the line.
2023-02-28 13:23:55 +01:00
Ali Mohammad Pur
db886fe18b Userland+AK: Stop using getopt() for ArgsParser
This commit moves the implementation of getopt into AK, and converts its
API to understand and use StringView instead of char*.
Everything else is caught in the crossfire of making
Option::accept_value() take a StringView instead of a char const*.

With this, we must now pass a Span<StringView> to ArgsParser::parse(),
applications using LibMain are unaffected, but anything not using that
or taking its own argc/argv has to construct a Vector<StringView> for
this method.
2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
b2b851b361 Shell: Convert the POSIX parser/lexer to ErrorOr 2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
0c28fd41ed Shell: Convert all immediately convertible fallible functions to ErrorOr 2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
e403dbabfa Shell: Convert the remaining fallible AST functions to ErrorOr 2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
5f950df3d4 Shell: Make Immediate expression invocation fallible
This removes a whole bunch of FIXMEs in the immediate expr
implementations as well :^)
2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
007767fc14 Shell: Convert builtins to use the modern main() style
That is, return ErrorOr<int>, handle fallible ops with TRY() and accept
a Main::Arguments.
Note that we do not populate the argc/argv members of Main::Arguments,
so all accesses have to go through .strings.
2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
6e5ba82929 LibCore: Make ArgsParser tolerate Main::Arguments with only .strings
This currently allocates in .parse(), but that's better than making the
caller do the exact same before passing us the values.

Note that this is only temporary to aid in conversion, a future commit
will remove this and switch to requiring the users to allocate the
vector instead.
2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
d575c50f3e Shell: Make AST::dump() ErrorOr-aware 2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
beeb58bd93 Shell+LibCodeComprehension: Start replacing {Deprecated => }String
This starts by switching all AST members to Strings, and dealing with
the fallout.
2023-02-28 15:52:24 +03:30
Ali Mohammad Pur
79e4027480 AK: Add two starts_with{bytes,}() APIs to String 2023-02-28 15:52:24 +03:30
Andreas Kling
3a5802540e LibWeb: Follow-up fixes for Linus's comments in #17658 2023-02-28 13:16:39 +01:00
Luke Wilde
4d0277cd9a LibWeb: Implement navigator.{plugins,mimeTypes} 2023-02-28 12:36:14 +01:00
Luke Wilde
5e422bdae0 LibWeb: Move pdfViewerSupported's answer to Page
This will also be accessed by navigator.{plugins,mimeTypes} to
determine if they should expose any information.
2023-02-28 12:36:14 +01:00
Luke Wilde
57d28c57f7 LibWeb: Restore Storage as a legacy platform object 2023-02-28 12:36:14 +01:00
Luke Wilde
54f58e2662 LibWeb: Restore proper functionality of legacy platform objects
With the GC heap conversion, the functionality of legacy platform
objects was broken. This is because the generated implementation of one
of them was used for all of them, removing functionality such as
deletion.

This re-adds all functionality, where questions such as "does the
object support indexed properties?" is instead answered by virtual
functions instead of by the IDL generator checking the presence of
certain keywords/attributes.
2023-02-28 12:36:14 +01:00
Andreas Kling
7e76a51cb0 LibWeb: Rename Layout::InitialContainingBlock to Layout::Viewport
The name "initial containing block" was wrong for this, as it doesn't
correspond to the HTML element, and that's specifically what it's
supposed to do! :^)
2023-02-28 12:21:56 +01:00
Cubic Love
60f699338d Base: Improve Presenter Icons
Before, the shading of the Presenter icons was the wrong way round and
the external contrast was not as good as it could be. This has been
rectified and the icons are now light on the left- and dark on the
right-side. Also, they now use the same gray colors as other system
icons, making them sit much more nicely together, and have been
generally improved.
2023-02-28 10:17:40 +01:00
Cubic Love
80d1fc39a4 Base: Update Presenter man page with correct icon + Add a link to open
Use the correct icon in the Presenter application man page and add a
link to open the executable.
2023-02-28 10:17:40 +01:00
Luke Wilde
e864444fe3 LibTextCodec/Latin1: Iterate over input string with u8 instead of char
Using char causes bytes equal to or over 0x80 to be treated as a
negative value and produce incorrect results when implicitly casting to
u32.

For example, `atob` in LibWeb uses this decoder to convert non-ASCII
values to UTF-8, but non-ASCII values are >= 0x80 and thus produces
incorrect results in such cases:
```js
Uint8Array.from(atob("u660"), c => c.charCodeAt(0));
```
This used to produce [253, 253, 253] instead of [187, 174, 180].

Required by Cloudflare's IUAM challenges.
2023-02-28 08:46:06 +00:00
Luke Wilde
1c918e826c LibWeb: Define navigator/clientInformation with define_native_accessor
Defining it as a direct property causes it to have no getter/setter
function, which causes an empty Optional crash when attempting to
access such getter on a cross-origin iframe.

Fixes amazon.com crashing on this particular crash.
2023-02-28 08:45:23 +00:00
Tim Ledbetter
f3d1be933a PixelPaint: Remove shrink_to_fit property from LevelsDialog GML
This was causing the levels dialog to be displayed incorrectly.
2023-02-28 08:44:05 +00:00