Commit graph

44525 commits

Author SHA1 Message Date
Agustin Gianni 9a2ee5a9dd AK: Add DeprecatedString::find_last(StringView)
This adds the the method DeprecatedString::find_last() as wrapper for
StringUtils::find_last for the StringView type.
2022-12-20 11:24:05 +01:00
Alexander Narsudinov 03107d4028 FileManager: Handle possible ByteBuffer allocation failure
Before this patch we created ByteBuffer with the help of the
VERIFY macro that could cause a crash of FileManager
in case of memory allocation failures.

Now we propagate the error to a caller instead of using the
`release_value_but_fixme_should_propagate_errors()` method.
2022-12-20 11:04:44 +01:00
Andrew Kaster c0542ed40b Meta+test262-runner: Check for signature of __assert_fail in CMake
Rather than trying to assume the only two C libraries on Linux are musl
and glibc, this solution fixes musl builds by explicitly checking for
the one C library function we are overwriting.

That being said, we should find another solution to retrieving this
error information from crashing tests. Possibly just overriding the
SIGABRT handler would work. The full solution might require checking
stderr as well as stdout in the test driver though.
2022-12-20 11:04:05 +01:00
Andrew Kaster 4ed5520e3e ntpquery: Explicitly zero initialize msghdr and fill in fields
Rather than trying to use designated initializers, zero init the
msghdr variable and fill in its fields. This makes sure to zero-init any
padding bytes, and fixes a compilation error on musl-libc based systems.
2022-12-20 11:04:05 +01:00
Andrew Kaster 0d813ee519 LibThreading: Remove unused include of <sys/cdefs.h>
This file is not needed here, and causes a compile issue on musl-libc
based distributions. We should only be including this file in LibC, for
the most part anyway.
2022-12-20 11:04:05 +01:00
Andrew Kaster 61573caf53 LibELF: Include <pthread.h> to ensure PTHREAD_STACK_MAX is available
Android's bionic C library puts this definition in pthread.h rather than
limits.h
2022-12-20 11:04:05 +01:00
MacDue a9ea0ee9af LibWeb: Fix passing size/position to paint_radial_gradient()
This was wrong twice making it right... But let's fix that.

The center was being passed as a DevicePixelPoint, but was in fact in
CSS pixels, the size was passed as a Gfx::FloatSize but was in
CSS pixels again. Then we were scaling from device pixels to CSS pixels
when painting which does not need to be done if everything is passed
which the correct scale factors already applied.
2022-12-20 11:03:18 +01:00
MacDue 6c27f2c071 LibGfx: Don't blend opaque pixels 2022-12-20 11:03:18 +01:00
MacDue e3c64a0858 LibGfx: Remove unnecessary divides in Color::mixed_with()
This is mathematically the same thing, but the compiler can't optimize
these out without -Ofast, so let's give it a hand.
2022-12-20 11:03:18 +01:00
Karol Kosek 4784ad66b2 HackStudio: Port to Core::Stream::File :^) 2022-12-20 10:58:54 +01:00
Karol Kosek 697d6ffb1d LibDiff: Make Diff::generate_only_additions take text as StringView 2022-12-20 10:58:54 +01:00
Alexander Narsudinov ce2ed7615a LookupServer: Propagate the errors from MulticastDNS::handle_packet()
This is a bit awkward, but I think it is better to make the caller
deal with possible errors.
2022-12-20 10:45:20 +01:00
Alexander Narsudinov e279a1723b LookupServer: Propagate the errors from MulticastDNS::lookup()
This patch slightly change the signature of lookup() method
and propagates all the errors to the caller with help of ErrorOr.
2022-12-20 10:45:20 +01:00
Alexander Narsudinov 767529ebf5 LibCore: Make UDPServer::receive() return ErrorOr<ByteBuffer>
This is a first step towards handling OOM errors instead of just
crashing the program.

Now UDPServer's method `receive()` return memory allocation
errors explicitly with help of ErrorOr.

This removes one FIXME and make a bunch of new ones. :(
2022-12-20 10:45:20 +01:00
implicitfield 9ae9d82a03 unzip: Use StringView instead of DeprecatedString 2022-12-20 10:44:02 +01:00
implicitfield a520894522 unzip: Verify extracted files against CRC32 checksums
This removes one TODO.
2022-12-20 10:44:02 +01:00
Jelle Raaijmakers 2da1c1c10e LibGL: Generate the API wrappers
We now generate all LibGL API wrappers from a single API method
definition list stored in `GLAPI.json`. Since a significant portion of
the OpenGL API methods are relatively consistent variants, we take
advantage of this to generate a lot of these variants at once.

The autogenerated methods check for the non-nullness of the current
`GLContext`, and only perform an action if a `GLContext` is present.
This prevents a crash in ports like GLTron, who assume you can still
call the OpenGL API without an active context.

This increases our API wrapper method count from 211 to 356.

Fixes #15814.
2022-12-20 10:42:31 +01:00
Jelle Raaijmakers 8c094699db LibGL: Implement glLightModel integer normalization
For the ambient light model, integers need to be remapped to a range of
`-1.` through `1.`. Add the `+` and `-` operators to `VectorN` to make
it a bit easier to normalize 4 values at once.
2022-12-20 10:42:31 +01:00
Jelle Raaijmakers a074b7e871 LibGL: Support glLightModel inside lists
We now dereference the pointer given to us before adding the arguments
to an active list. This also factors out the switching logic from the
API wrappers, which helps us with a future commit where we autogenerate
all API wrapper functions.
2022-12-20 10:42:31 +01:00
Jelle Raaijmakers 403c560a7a LibGL: Correct GL_LIGHT_MODEL_LOCAL_VIEWER comparison
We were comparing the `x` parameter to `1.f` instead of `0.f`.
2022-12-20 10:42:31 +01:00
Jelle Raaijmakers 6d68f47495 LibGL: Dereference pointer in a consistent way for glMaterial* 2022-12-20 10:42:31 +01:00
Jelle Raaijmakers 7c4bbdc398 LibGL: Simplify transposing input matrices
We do not need to templatize the output type - it's always `float`.
Also, the input type can be inferred. Finally, use template
specialization instead of a conditional to deal with same type input and
output matrices.
2022-12-20 10:42:31 +01:00
Cnidarias 0ca1247a7f PixelPaint: Propagate errors when creating images or layers
This fixes a dozen release_value_but_fixme_should_propage_errors
2022-12-20 10:42:11 +01:00
Jelle Raaijmakers 25f2e4981c AK: Stop using DeprecatedString in Base64 encoding 2022-12-20 10:34:19 +01:00
Jelle Raaijmakers 99c1b634fc AK: Stop using DeprecatedString in UUID 2022-12-20 10:34:19 +01:00
EWouters f050a426f5 Ports: Add grepcidr port 2022-12-20 10:33:00 +01:00
Baitinq 75ea339ee9 LibGUI: Fix bug in the ColorPicker's spinbox not changing colors
Before this patch, when having the initial spinbox color value
(Color::White), if you changed the color value in the vertical color
picker it didn't update the spinbox's colors.

This is fixed by manually calling update() in the color picker's
onchange() handler if the new color is equal to the previous color,
which is the case in the initial spinbox's case as it will always be
white unless it is changed (and won't be affected by the vertical
color picker).

I added a NOTE in the source to explain this "opaque" update() call :))
2022-12-20 10:30:06 +01:00
Rodrigo Tobar 89061883f2 PDFViewer: Prompt password for encrypted documents
This tackles a FIXME, but also makes sense to implement only now that
the SecurityHandler logic has been fixed. When a Document is created an
automatic attempt is made to provide the empty string as the password;
even if this attempt failed the SecurityHandler still reported it had a
user password, hence we never arrived to the VERIFY_NOT_REQUIRED line
this commit is changing.
2022-12-20 10:28:58 +01:00
Rodrigo Tobar bb48a67f84 LibPDF: Reset encryption key on failed user password attempt
When an attempt is made to provide the user password to a
SecurityHandler a user gets back a boolean result indicating success or
failure on the attempt. However, the SecurityHandler is left in a state
where it thinks it has a user password, regardless of the outcome of the
attempt. This confuses the rest of the system, which continues as if the
provided password is correct, resulting in garbled content.

This commit fixes the situation by resetting the internal fields holding
the encryption key (which is used to determine whether a user password
has been successfully provided) in case of a failed attempt.
2022-12-20 10:28:58 +01:00
Rodrigo Tobar dc6a11cf6b LibPDF: Treat Encyption's Length item as optional
With the StandardSecurityHandler the Length item in the Encryption
dictionary is optional, and needs to be given only if the encryption
algorithm (V) is other than 1; otherwise we can assume a length of 40
bits for the encryption key.
2022-12-20 10:28:58 +01:00
Rodrigo Tobar b8dc05a08e PDFViewer: Fix indexing error in ErrorsView
I confused myself when implementing this, plus I tested using pages that
had errors in pages 1 and 2, so the index and the number of the page
(internally represented as 0-indexed) was always the same. When opening
files with errors on higher pages it became evident that there was an
issue with how I was reading the errors per page from the corresponding
ModelIndex object.
2022-12-20 10:28:58 +01:00
Bruno Conde 7e9019a9c3 LibGfx: Support BMP favicons with less than 32 bpp
Adapt BMPImageDecoderPlugin to support BMP images included in ICOns.
ICOImageDecoderPlugin now uses BMPImageDecoderPlugin to decode all
BMP images instead of it's own ad-hoc decoder which only supported
32 bpp BMPs.
2022-12-20 10:26:55 +01:00
thankyouverycool 91609f9327 FontEditor: Update preview window after pasting and deleting glyphs 2022-12-20 10:22:27 +01:00
thankyouverycool 96d7964913 FontEditor: Add Unicode block/glyph selection Statusbar Segment
Displays the current active Unicode block range, or, if multiple
glyphs are selected, their count. Clicking toggles the Unicode
block ListView.
2022-12-20 10:22:27 +01:00
thankyouverycool 40e94a315a LibGUI+FontEditor: Restore normalized selections on Undo/Redo
Selections are always normalized when saving undo commands.
The restore_selection() function reverses this process so
negatively sized selections (created right-to-left) continue
to resize correctly with the keyboard when restored.
2022-12-20 10:22:27 +01:00
thankyouverycool 02212f373b LibGUI: Reset GlyphMapWidget scroll value when changing active range
Fixes being teleported to the old location when scrolling on a
previously browsed range.
2022-12-20 10:22:27 +01:00
thankyouverycool d973d43b13 LibGUI: Focus the actively resizing end of GlyphMapWidget selections 2022-12-20 10:22:27 +01:00
thankyouverycool 673afffd5a LibGUI: Only reset GlyphMapWidget selection on Escape
and when using unmodified arrows.
2022-12-20 10:22:27 +01:00
thankyouverycool 4c81fbc8c4 LibGUI: Add Page{Up,Down} support for GlyphMapWidget 2022-12-20 10:22:27 +01:00
thankyouverycool a98d5c52f8 LibGUI: Improve visible glyph estimate in GlyphMapWidget
Previously the widget used a very rough estimate for visible glyphs
based on viewport and glyph areas. Now it simply figures rows times
columns with a two row overdraw to accommodate fractional glyphs
on either end of visible content. For KaticaRegular10, this ends up
reducing unnecessary glyph iterations during painting by about 30%.
2022-12-20 10:22:27 +01:00
thankyouverycool e34503800c LibGUI: Adjust GlyphMapWidget content sizing and glyph padding
Fixes a slightly oversized content rect and erroneous glyph outer
rect values. Increases glyph rect padding to guarantee at least 1px
between the focus rect and glyph.
2022-12-20 10:22:27 +01:00
thankyouverycool 0f5ce017c5 LibGUI: Implement calculated_min_size() for GlyphMapWidget 2022-12-20 10:22:27 +01:00
thankyouverycool c4ac73d073 LibGUI: Check bounds when moving GlyphMapWidget selections
Fixes crashing on invalid code points when creating selections
with the keyboard and applying actions to them.

Also adds Home/End key support for selections. Ctrl+Shift+{Home,End}
now extends the selection to the beginning or end of the active range,
respectively. Shift+{Home,End} extends the selection to the start or
end of the row. Alt+{Home,End} resets the selection and moves the
active glyph to the beginning or end of the active range.
2022-12-20 10:22:27 +01:00
thankyouverycool 12cd30f1ac LibGUI: Ensure GlyphMapWidget selection resets when requested
Previously selection reset was ignored on active glyph change if the
old glyph equaled the new one. This was an intentional behavior that
allowed selections to resize by dragging the focused glyph, but has
proved more counterintuitive than useful.

Now the widget behaves like other text selection controls: selections
can be reset by clicking anywhere in them or shift can be held to
grow the selection.
2022-12-20 10:22:27 +01:00
thankyouverycool 360e58a276 LibGUI: Disallow GlyphMapWidget selection sizes equal to zero
This is a bogus size as the map must always have at least 1 glyph
selected, and it was causing occasional desync between selection
contents and the focused glyph when manipulating selections with
the keyboard.
2022-12-20 10:22:27 +01:00
thankyouverycool 8d3f60c7ef LibGUI: Forward GlyphMapWidget Key_Tab events
Allows focus to be passed using the keyboard.
2022-12-20 10:22:27 +01:00
thankyouverycool 61d214eab1 FontEditor: Set Unicode ListView's focus proxy to its search box
Provides a visual cue that arrow key input is shared between these
widgets.
2022-12-20 10:22:27 +01:00
thankyouverycool b8969ffe97 FontEditor: Remove unused includes 2022-12-20 10:22:27 +01:00
Karol Kosek 9b3335723f TextEditor: Suggest saving new files with an extension from highlighter 2022-12-19 14:13:50 -05:00
Karol Kosek c75bfa9cda LibSyntax: Add common_language_extension() function
The main motivation for this is to prefill an extension for user when
saving a new file.
2022-12-19 14:13:50 -05:00