Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
Adds fallible factories, ports DeprecatedString, and rebuilds the
layout to accomodate system font changes.
|
|
|
|
This fixes a bug where we would construct a ModelIndex with a pointer to
NonnullRefPtr<OutlineItem>, instead of a pointer to the underlying
OutlineItem, which caused a crash later on when we would try to
dereference that pointer.
|
|
|
|
|
|
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>>.
|
|
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 :^)
|
|
|
|
|
|
|
|
As usual, this removes many unused includes and moves used includes
further down the chain.
|
|
|
|
|
|
Because usage of the input_type parameter is now higher than of the
placeholder parameter, this makes for a cleaner API.
|
|
Those don't have any non-try counterpart, so we might as well just omit
it.
|
|
These are not needed anymore since the introduction of the new
get_root_session_id syscall.
|
|
|
|
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. :^)
|
|
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.
|
|
While this is not super useful to end users, it's still better than the
simpler, generic "failed to load" error message.
|
|
In 7c5e30daaa615ad3a2ef55222423a747ac0a1227, the focus was "only" on
Userland/Libraries/, whereas this commit cleans up the remaining
headers in the repo, and any new badly-formatted include.
|
|
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.
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
A new checkbox in the toolbar now allows users toggle image rendering. A
corresponding Config option makes this setting non-volatile. To void
clashing with the previous "show_clipping_paths" option when caching a
Page, we now use the RenderingPreferences.hash() and the pair_int_hash
funcitons to compute a unique key into the page cache map for a given
RenderingPreferences and zoom level.
|
|
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.
|
|
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 :^)
|
|
These actions were being constructed, and they work, but were not shown
in the toolbar. Adding them will allow users to actually use them, as
well as pick up any bugs they might have.
|
|
These actions were not updated accordingly when one scrolled through the
document, and thus one could accidentally, for example, move to the next
page when standing on the last, which caused a crash.
This commit fixes that behavior, toggling the actions' enabled status
depending on the new page being displayed.
|
|
When removing all contents from the NumericInput box in PDFViewer the
callback set the (empty) text again back in the box, triggering another
callback in a recursive, non-stopping fashion. Not setting the text back
in the box avoids the problem.
|
|
Now that the Renderer accepts preferences, PDFViewer can offer ways for
changing these preferences. The first step in this direction is to add a
checkbox that allows toggling whether clipping paths are visible or not.
A Config item has also been added to remember this setting.
|
|
We now respect the system-wide setting for scroll speed, where we would
previously use a fixed step.
|
|
We now show a simple, if less helpful, message to the user and print
the verbose error message to serial instead.
|
|
This fixes an issue where we would show an error message on every
subsequent paint event, making it impossible to close or use the
application further.
Some more architectural work is needed if we want to invalidate the
sidebar entries as well.
|
|
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.
|