Commit graph

44421 commits

Author SHA1 Message Date
Lenny Maiorani
f2336d0144 AK+Everywhere: Move custom deleter capability to OwnPtr
`OwnPtrWithCustomDeleter` was a decorator which provided the ability
to add a custom deleter to `OwnPtr` by wrapping and taking the deleter
as a run-time argument to the constructor. This solution means that no
additional space is needed for the `OwnPtr` because it doesn't need to
store a pointer to the deleter, but comes at the cost of having an
extra type that stores a pointer for every instance.

This logic is moved directly into `OwnPtr` by adding a template
argument that is defaulted to the default deleter for the type. This
means that the type itself stores the pointer to the deleter instead
of every instance and adds some type safety by encoding the deleter in
the type itself instead of taking a run-time argument.
2022-12-17 16:00:08 -05:00
Tim Ledbetter
53133b4359 PixelPaint: Debounce ImageEditor on_modified_change event
This limits the frequency of updates performed by the histogram and
vectorscope widgets.
2022-12-17 19:52:11 +00:00
Tim Ledbetter
7e020154a5 PixelPaint: Improve guide tool performance for large images
This commit ensures that the vectorscope and histogram widgets are not
updated while moving a guide with the guide tool. This significantly
improves performance for large images.
2022-12-17 19:52:11 +00:00
Keir Davis
4a0af3dc77 SystemMonitor: Propagate errors when trying to load an icon 2022-12-17 19:20:21 +00:00
Rodrigo Tobar
d116b9a8c6 PDFViewer: Move to page when outline item is selected 2022-12-17 19:40:52 +01:00
Rodrigo Tobar
d739877807 PDFViewer: Inform about selections on Outline view
Selecting an Outline Item from the Outline view informs via callback the
corresponding Destination that has been selected. This will be used to
move the application to the corresponding page/section/etc.
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
aaa210e6db PDFViewer: Show page numbers in Outline TreeView
This is a nice addition to the outline view, which previously simply
displayed the titles of each section. Pages are shown in the first
column, but the tree is expanded via the second column, where the title
is.
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
c76564b533 PDFViewer: Fix parent_index() implementation in OutlineModel
The previous implementation had some repeated code, and wasn't really
working (because the OutlineItem.parent member was never populated). In
fact, when navigating with the up/down arrows in the associted TreeView
one could experience some funky behavior.

Now that we store OutlineItem's parents, we are fixing the
implementation for parent_index(), which was comparing the parent
siblings against the item's outline item instead of to its parent.
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
6df9aa8f2c LibPDF: Store page number, not Value, in OutlineItem
The Value previously stored corresponded to a Reference to a Page object
in the PDF document. This isn't useful information, since what we want
to display at the end of the day is the page an outline item refers to.

This commit changes the page member on OutlineItem to be a Optional<u32>
(some destinations don't necessarily refer to a Page), which we resolve
while building OutlineItems.
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
3db6af6360 LibPDF: Keep track of OutlineItem parents
While OutlineItem had a parent field, it was never populated nor used.
This commit populates it when possible (no parent means the OutlineItem
is a top-level item).
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
2ea8d2547e PDFViewer: Propagate errors from OutlineModel construction
This follows the same idea that Andreas was doing in this latest videos,
where construction-time TRY()s were not present but should have been.
Like Andreas did, moving the initialisation of such fields to the
factory function, which then returns ErrorOr solves the issue.
2022-12-17 19:40:52 +01:00
Rodrigo Tobar
cb2cf6de99 PDFViewer: Perform standard error handling when opening files
The previous implementation of open_file had a lambda that was used to
inspect the call of ErrorOr-returning calls. This was a non-standard way
of doing this though, as the more usual and clearer way is to have an
inner function that returns ErrorOr, then handle any incoming errors on
the top level function.

This commit adds a try_open_file function, where all the logic occurs,
and all the failure-producing steps are simplied TRY'ed. The top level
open_file function takes that result and does what the lambda previously
did: showing a message box with the actual error.
2022-12-17 19:40:52 +01:00
Karol Kosek
5049b103c0 PixelPaint: Encode layers in PixelPaint project files as PNG
Previously layers weren't compressed at all and the file size could go
up really fast in a project with multiple layers.  By switching to PNG,
the situation is slightly better now.

Interestingly enough, this change won't break compatibility with old
files, as PixelPaint loads layers using ImageDecoder which will try
every codec possible. :^)
2022-12-17 18:37:04 +01:00
Karol Kosek
11377bf0f8 PixelPaint: Propagate more errors when saving a project file 2022-12-17 18:37:04 +01:00
Quentin Ligier
588994bb00 LibWeb: Improve variable name in HTMLTableElement
The variables 'child_to_append_after' are used to specify the child
before which new elements will be inserted, its name is misleading.
These variables are always passed as 'child' to pre_insert.
2022-12-17 18:35:32 +01:00
Baitinq
0f2ca95b5e Kernel: Propagate errors in E1000NetworkAdapter
We now move the ErrorOr returning functions in the constructor to the
try_to_initialize() factory,  which allows us to handle the errors and
removes two FIXME's :))
2022-12-17 18:34:57 +01:00
Lenny Maiorani
5875e66531 Tests: ASCII-betical-ize CMakeLists AK tests 2022-12-17 18:32:26 +01:00
Alexander Narsudinov
45525d4f85 LibWeb: Add NamedNodeMap::setNamedItemNS() method
This patch adds implementation of the missing `setNamedItemNS()` method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
530d5adc62 LibWeb: Add NamedNodeMap::removeNamedItemNS() method
This patch adds implementation of the missing `removeNamedItemNS()`
method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
7679d38c5f LibWeb: Fix incorrect behaviour in NamedNodeMap::removeNamedItem()
According to the spec we should return removed attribute, but the old
implementation returned nullptr instead.

Now we return the element's removed attribute.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
f2d7690702 LibWeb: Add NamedNodeMap::getNamedItemNS()
This patch allows us to use method getNamedItemNS() of NamedNodeMap API.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
ce6cf5bab8 LibWeb: Make method NamedNodeMap::set_attribute() closer to the spec
This patch eliminates 1 FIXME that I've got during fixme roulette! :^)
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
1a0fbe1e85 LibWeb: Add internal get_attribute_ns() methods of NamedNodeMap
This patch adds methods for querying element by namespace and
local name.

These methods are defined by the spec for internal
usage, but weren't implemented in LibWeb yet.
2022-12-17 18:27:57 +01:00
Freakness109
1f1e58ed75 Kernel/Plan9FS: Propagate errors in Plan9FSMessage::append_data 2022-12-17 09:37:04 +00:00
Eli Youngs
0dd8066a79 tsort: Suppress warnings with -q 2022-12-16 10:41:56 -07:00
Eli Youngs
9caa3d2b55 Userland: Add a tsort utility 2022-12-16 10:41:56 -07:00
Eli Youngs
950b36f95d AK: Add a try_ensure() method to HashMap 2022-12-16 10:41:56 -07:00
Eli Youngs
a2024cfb69 AK: Support popping an arbitrary element from a HashTable 2022-12-16 10:41:56 -07:00
Andre Eisenbach
e80f0b23e3 CatDog: Simplify animation frame logic and fix minor bugs
Moved all images into a Vector instead of storing every animation frame
in its own member variable. This greatly simplifies the bitmap selection
logic and removes redundant if() checks.

Also fixes minor state bugs. For example, CatDog woudld go to sleep
immediately after actively moving for > 5 seconds. Also fixes arbitrary
hardcoded values for mouse offset movement tresholds as well as
inconsistent movement increments. This allows clicking anywhere on the
CatDog window without moving CatDog.

In addition to removing many member variables, the API interface is
also cleaned up a bit to expose less CatDog internals. Nobody likes
exposed CatDog internals ;).

Variables and function are also renamed where necessary to (hopefully)
improve readability.
2022-12-16 08:50:35 -07:00
Tim Ledbetter
213d82f39b PixelPaint: Fix move tool scaling function when zoomed
The move tool enters scaling mode when the user mouses within 10
pixels either side of the the bottom right of the active layer
boundary.

Previously, the bounding box used to determine whether the mouse was
at the bottom right of the layer used coordinates that were scaled to
the size of the image. This made the size of the area
you need to enter proportional the current zoom level.

This commit fixes the issue by using non-scaled coordinates to
calculate the bounding box, meaning its size is unaffected by the
current zoom level.
2022-12-16 10:24:34 +00:00
Tim Ledbetter
5ba0b551f4 PixelPaint: Display a preview image when scaling with the move tool
A preview of the scaled image and an outline of the updated layer
boundary are now shown when scaling with the move tool.
2022-12-16 10:24:34 +00:00
Timothy Slater
7b4e5d6ac0 PixelPaint: Add Text Tool 2022-12-16 10:14:20 +00:00
Timothy Slater
7b62e02bc3 LibGUI: Prevent key_down event from bubbling for Key_Up and Key_Down
This just corrects an oversight in EditingEngine where we do not
properly signal "we handled this event" for Key_Up and Key_Down like we
do for the other keys
2022-12-16 10:14:20 +00:00
Timothy Slater
296b76095f PixelPaint: Change tool keydown handle to non-const
This was changed to const in PR #15788 but presents problems for tools
that may need to forward this event to non-const event handlers.
2022-12-16 10:14:20 +00:00
Timothy Slater
159f6cf0ac PixelPaint: Account for rulers on Tool second paint events
This change makes ImageEditor provide an altered PaintEvent to the
active tool when rulers are visible. This PaintEvent has a rect that has
been adjust to account for the thickness of the rulers. Tools use this
rect for Painter clipping and this prevents a Tool's on_second_paint
from drawing over top of the rulers
2022-12-16 10:14:20 +00:00
Timothy Slater
a321df12e1 PixelPaint: Allow tools to know when the user has left them 2022-12-16 10:14:20 +00:00
Timothy Flynn
d28c9ba054 AK: Synchronize explicit instantiations of to_int and to_uint
1. Ensure long and long long are instantiated for to_int.
2. Ensure long and long long are not instantiated for to_uint.
2022-12-16 10:06:26 +01:00
Timothy Flynn
a67ad665b1 LibLine: Convert strings to time_t using signed conversion methods
The time_t type itself is signed, and the result of this conversion is
always stored as time_t, so let's not use to_uint<>.
2022-12-16 10:06:26 +01:00
Rodrigo Tobar
d4ecdf3ced PDFViewer: Avoid errors due to copying of ErrorOr
The handle_error took PDFErrorOr<T> objects by value, meaning that their
inner values (the error or value stored in the underlying Variant) were
somehow copied over. In the first instance where this lambda is called
with T = NonnullRefPtr, resulting in funky behavior (invalid
NonnullRefPtr state with a VALIDATE fail): if there is no error then the
PDFErrorOr<T> copy is destroyed, which might be causing the underlying
NonnullRefPtr to be destroyed, but somehow the original in the caller
context gets affected and fails verification.

The solution seems simple anyway: just pass the value by reference
(lvalue or rvalue) so the original object can be used directly, avoiding
destruction.
2022-12-16 10:04:23 +01:00
Rodrigo Tobar
124ab5bec6 PDFViewer: Remove unnecessary ternary operation 2022-12-16 10:04:23 +01:00
Rodrigo Tobar
6d0869c14a PDFViewer: Add TreeView to communicate rendering errors
Now that the rendering process communicates all errors upstream, and
PDFViewer has a way to tap into those errors as they occur, we can
visualise them more neatly.

This commit adds a TreeView that we populate with the errors stemming
from the rendering process. The TreeView has two levels: at the top sit
pages where errors can be found, and under each page we can see the
errors that have been found on that page. The TreeView sits below the
main PDF rendering.
2022-12-16 10:04:23 +01:00
Rodrigo Tobar
c4bc27f274 LibPDF: Don't abort on unsupported drawing operations
Instead of calling TODO(), which will abort the program, we now return
an Error specifying that we haven't implemented the drawing operation
yet. This will now nicely trickle up all the way through to the
PDFViewer, which will then notify its clients about the problem.
2022-12-16 10:04:23 +01:00
Rodrigo Tobar
e87fecf710 LibPDF: Switch to best-effort PDF rendering
The current rendering routine aborts as soon as an error is found during
rendering, which potentially severely limits the contents we show on
screen. Moreover, whenever an error happens the PDFViewer widget shows
an error dialog, and doesn't display the bitmap that has been painted so
far.

This commit improves the situation in both fronts, implementing
rendering now with a best-effort approach. Firstly, execution of
operations isn't halted after an operand results in an error, but
instead execution of all operations is always attempted, and all
collected errors are returned in bulk. Secondly, PDFViewer now always
displays the resulting bitmap, regardless of error being produced or
not. To communicate errors, an on_render_errors callback has been added
so clients can subscribe to these events and handle them as appropriate.
2022-12-16 10:04:23 +01:00
Rodrigo Tobar
96fb4b20f1 LibPDF: Add Errors class that accumulate multiple errors
This will be used to perform a best-effort rendering, where an error in
rendering won't abort the whole rendering operation, but instead will be
stored for later reference while rendering continues.
2022-12-16 10:04:23 +01:00
Rodrigo Tobar
d9718064d1 LibPDF: Add support for multi-line comments
The code parsing comments parsed only a single line of comments, but
callers assumed they parsed all comments that appeared contiguously in a
block. The latter is an easier to understand API, so this commit changes
the parse_comment function to parse entire blocks of comments instead of
single lines.
2022-12-16 10:04:23 +01:00
Liav A
d94f3b902c Kernel: Propagate properly errors from ISAIDEController initialization 2022-12-16 10:00:31 +01:00
Linus Groh
e785c66f91 LibJS: Convert get_this_environment() to NonnullGCPtr 2022-12-16 09:59:56 +01:00
Linus Groh
c132064ee9 LibJS: Convert new_private_environment() to NonnullGCPtr 2022-12-16 09:59:56 +01:00
Linus Groh
208be8b86d LibJS: Convert new_function_environment() to NonnullGCPtr 2022-12-16 09:59:56 +01:00
Linus Groh
111a38c464 LibJS: Convert new_object_environment() to NonnullGCPtr 2022-12-16 09:59:56 +01:00