Commit graph

5849 commits

Author SHA1 Message Date
Andreas Kling
1c8eaf28cd LibGUI: Add GUI::Application::active_window()
Instead of each window having a bool flag that says whether that window
is currently active, have a pointer to the active window on the app
object instead.
2021-01-05 17:13:17 +01:00
Andreas Kling
8b90e8d08b LibGUI: Remove unused hook Window::on_activity_change 2021-01-05 17:13:16 +01:00
Andreas Kling
7d5a369ac9 LibGfx: Fail PGM decode if there isn't enough color data in image
If we have less pixel color data than we need to fill the image, just
fail the decode.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29127
2021-01-05 15:14:29 +01:00
Andreas Kling
5e95d62ffe LibTTF: Guard against unsigned overflow in TTF table parsing
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29170
2021-01-05 14:50:17 +01:00
Andreas Kling
51b880b038 LibJS: Disable ASAN during the conservative GC stack scan
This allows the JS fuzzer to survive garbage collection (so we can find
more interesting bugs!)

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29266
2021-01-05 12:27:45 +01:00
Andreas Kling
fdd974b7ef LibJS: Fix UB downcast during GlobalObject construction
When constructing a GlobalObject, it has to pass itself as the global
object to its own Shape. Since this is done in the Object constructor,
and Object is a base class of GlobalObject, it's not yet valid to cast
"this" to a GlobalObject*.

Fix this by having Shape store the global object as an Object& and move
Shape::global_object() to GlobalObject.h where we can at least perform a
valid static_cast in the getter.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29267
2021-01-05 12:02:59 +01:00
Rok Povsic
b4a783d923 TextEditor+EditingEngine: Add support for the basics of Vim emulation 2021-01-05 00:00:36 +01:00
Andreas Kling
da536c8d22 LibGUI: Add CommonActions::make_about_action()
This creates an "About" menu action given the app name and icon.
It takes care of showing the about dialog for you.
2021-01-04 23:31:42 +01:00
Andreas Kling
22325dd63e LibWeb: Don't careleslly insert inline-level boxes into inline-blocks
Just because an inline-block is inline doesn't mean it's ready to
accept random inline children. If it's a block, we may need to create
an anonymous wrapper first.

Fixes #4604.
2021-01-04 22:32:34 +01:00
Andreas Kling
d991658794 Kernel+LibC: Tidy up assertion failures with a dedicated syscall
This patch adds sys$abort() which immediately crashes the process with
SIGABRT. This makes assertion backtraces a lot nicer by removing all
the gunk that otherwise happens between __assertion_failed() and
actually crashing from the SIGABRT.
2021-01-04 21:57:30 +01:00
Andreas Kling
ce2894c95b LibWeb: Restart the cursor blink cycle whenever the user edits content
Having the text cursor disappear during rapid continuous editing is
quite jarring, so let's make sure we always restart the blink cycle
whenever the user performs some kind of editing action in a frame.
2021-01-04 20:48:27 +01:00
AnotherTest
1c4a425bff LibLine: Don't overwrite stuff when moving origin around
This fixes an issue (mainly) with multiline prompts, where a multiline
prompt would overwrite the lines before it when libline tries to display
it.
To reproduce, set `PROMPT="a\nb\nc> "` in the shell, then press return
a few times.
2021-01-04 19:13:18 +01:00
Andreas Kling
1e4b9a9cd9 LibGUI: Don't include invisible widgets in BoxLayout preferred size 2021-01-04 18:48:41 +01:00
Andreas Kling
21bacec13f LibGUI: Simplify ToolBarContainer by using shrink-to-fit
This class was implementing shrink-to-fit manually. No need for that
anymore now that we can use Widget's shrink-to-fit mode.
2021-01-04 18:21:05 +01:00
Andreas Kling
b03e1b08b5 LibGUI: Add Widget shrink-to-fit layout flag
If this flag is enabled for a widget, it will be automatically sized
based on its children. This only works for widgets using a layout.

This allows you to put widgets inside each other without having to
manually calculate how large the container should be. It's not the
perfect API but it's a decent progression in ergonomics. :^)
2021-01-04 18:17:14 +01:00
Andreas Kling
6041e48eaa LibCore: Make Core::Object::property() const 2021-01-04 13:41:13 +01:00
Emanuele Torre
370ce42430 Toolchain+LibTTF: Remove some blank line at the end of CMake files. 2021-01-03 23:58:54 +01:00
Linus Groh
0571a17f57 Kernel+LibELF: Store termination signal in coredump ProcessInfo 2021-01-03 22:12:42 +01:00
Tom
bc3c0fa936 LibCore: Allow caching and reusing the ProcFS file descriptors
Because ProcFS will refresh the data upon seek to 0, we can re-use
the same file descriptor. This saves us from having to open it every
time, but it also reduces the odds that we are unable to open a new
file descriptor due to low memory conditions.
2021-01-03 22:12:19 +01:00
Tom
cf89180c35 LibCore: Report error condition when reading process statistics failed 2021-01-03 22:12:19 +01:00
Linus Groh
e608723031 LibGUI: Add GMLFormatter
This will be useful for both the Playground app as well as for a
standalone CLI tool (à la clang-format). It cannot handle comments yet
(and will drop them from the formatted output), but other than that it
produces valid GML that matches the formatting we have so far! :^)
2021-01-03 22:12:08 +01:00
Linus Groh
acdbf66b54 LibGUI: Allow comment(s) before first class marker in GML parser
This wasn't considered valid GML but now is:

    // This is a comment
    // This as well
    @Foo::Bar {}
2021-01-03 22:12:08 +01:00
Andreas Kling
5cbcb35d34 LibELF: Add missing newlines at end of files 2021-01-03 17:26:03 +01:00
Andreas Kling
7e0226dd02 LibVT: Show terminal hyperlink targets as tooltips
This lets you see the target of a hyperlink before deciding to drag or
double click it.
2021-01-03 17:25:06 +01:00
Andreas Kling
347e5aa7b5 LibGUI: Hide the tooltip if widget with open tooltip unsets it
If you call set_tooltip({}) on a widget currently showing a tooltip,
we will now remove the tooltip window from screen.
2021-01-03 17:25:06 +01:00
Andreas Kling
a0f2135f47 LibVT: Make terminal hyperlinks double-click-to-activate
This patch makes hyperlinked terminal cells require a double click
to activate. The appearance of a hovered link is changed to not look
like a classic underlined link, but instead like some kind of typical
double-clickable GUI widget.

Also the hover cursor for links is changed from Hand to Arrow.
2021-01-03 17:25:06 +01:00
William Marlow
05345fc07d LibELF: Support relocating weak symbols against global libraries
A strong symbol anywhere in an executable must override any
weak symbol used in any library. This means that the weak symbol
must be overridden by a strong symbol even if the strong symbol
is in a dependent library. This means we need to perform relocations
twice, and resolve weak symbols globally before attempting to resolve
them locally. Consequentially we need to defer performing any
initialisations until after we have performed the second round of
relocations.
2021-01-03 17:15:55 +01:00
William Marlow
3e815ad5b1 Loader.so+LibELF: Move most of Loader.so's logic into ELF::DynamicLinker
Loader.so now just performs the initial self relocations and static
LibC initialisation before handing over to ELF::DynamicLinker::linker_main
to handle the rest of the process.

As a trade-off, ELF::DynamicLinker needs to be explicitly excluded from
Lagom unless we really want to try writing a cross platform dynamic loader
2021-01-03 17:15:55 +01:00
Emanuele Torre
ec8577ac3c LibGfx+Ports: Add missing newlines at the end of file. 2021-01-03 17:12:50 +01:00
Andreas Kling
7bb18215cb LibGUI: Use String::formatted() and String::number() more 2021-01-03 15:26:47 +01:00
Andreas Kling
f181ddb56a LibGUI: Use String::formatted() and String::number() more 2021-01-03 14:52:50 +01:00
Andreas Kling
5e157eaf37 LibWeb: Convert a bunch of String::format() => String::formatted() 2021-01-03 14:35:09 +01:00
Andreas Kling
70c59dcbf8 LaunchServer+LibDesktop: Add ability to allow URL without handler
This lets clients say they want to be able to open a specific URL
without specifying which handler to use.
2021-01-03 12:10:01 +01:00
Andreas Kling
1f1763c37a LaunchServer+LibDesktop: Add unveil-like mechanism for LaunchServer
Clients of LaunchServer can now provide a list of allowed handlers,
optionally with a specific set of URLs. The list can be sealed to
prevent future additions to it.

If LaunchServer receives a request to open something not on the allowed
handlers list, it will disconnect the client immediately.

The main idea here is to allow otherwise restricted programs to launch
specific things, e.g "Help" to open their manual, or "Browser" to load
the SerenityOS home page. :^)
2021-01-03 11:39:33 +01:00
Andreas Kling
8b2e7628fa LibGUI: Also specialize PgUp/PgDn/Home/End in line-wrapped TextEditors
This exposes some bugs in TextEditor's widget/document coordinate
conversions which we'll need to track down separately.
2021-01-03 10:49:20 +01:00
Andreas Kling
906e310411 LibGUI: Improve up/down arrow behavior in TextEditor with wrapping
Instead of moving between physical lines, the up/down arrow keys now
move between visual lines.
2021-01-03 10:49:20 +01:00
AnotherTest
7f7656fe4e LibGUI: Make the autocomplete box window a child of its editor's window
Fixes #4761.
2021-01-03 10:47:29 +01:00
AnotherTest
432c37cafc LibGUI: Stop the automatic autocomplete timer when typing whitespace
There's no reason to bring up autocomplete when the user is just
inserting indentation and spaces and such.
2021-01-03 10:47:29 +01:00
AnotherTest
3b2668e996 LibGUI: Register the various BoxLayouts
They're not exactly "widgets", but the widget registration registers
Core::Objects anyway.
2021-01-03 10:47:29 +01:00
AnotherTest
2b38b2f83b LibCore: Add a way to check if a property is readonly 2021-01-03 10:47:29 +01:00
Glenford Williams
b795f582cf LibGUI: Add missing properties to Widget gml
Add a few properties to Widget class for usage when in a gml environment
2021-01-03 10:34:55 +01:00
Andrew Kaster
39908fd569 LibGUI: Move widget registrations to the corresponding cpp file
This gets a lot of unecessary includes out of Widget.cpp. Doing this
didn't work before, but improvements in the C library and using dynamic
libraries have likely un-broken it :^).

Also, move the registration global object to an anonymous namespace. No
reason it has to be an extern symbol.
2021-01-03 10:31:42 +01:00
Luke
0bf44ac9d8 LibWeb: Fully implement end tag parsing in foreign content
Required to view the Spotify home page
2021-01-03 00:29:28 +01:00
Linus Groh
306aff80d0 LibGUI: Remove Widget's unused m_{foreground,background}_color
...as well as the few remaining references to set_foreground_color().

These properties are not being used for rendering anymore, presumably
because they completely mess up theming - assigning random white and
gray backgrounds just doesn't work with dark themes.
I've chosen to not replace most of the few remaining uses of this
broken functionality with custom palette colors (the closest
replacement is background_role) for now (except for Minesweeper where
squares with mines are painted red again now), as no one has actually
complained about them being broken, so it must look somewhat decent
(some just look right anyway). :^)

Examples of this are the taskbar buttons, which apparently had a
DarkGray foreground color for minimized windows once - this has since
been replaced with bold/regular font. Another one is the Profiler's
ProfileTimelineWidget, which is supposed to have a white background -
which it didn't have for quite some time, it's grey now (with the
default theme, that is). Doesn't look bad either.
2021-01-02 23:31:22 +01:00
Andreas Kling
05f5d0dda3 LibGfx: Add Gfx::TextAttributes (and use it in GUI::TextDocumentSpan) 2021-01-02 20:57:43 +01:00
Andreas Kling
1898aa8cd4 LibWeb: Use Gfx::Bitmap::create_shareable() in OOPWV
We were jumping through some pretty wasteful hoops in the resize event
handler of OOPWV by first creating a bitmap and then immediately
creating a new (shareable) clone of that bitmap. Now we go straight
to the shareable bitmap instead.
2021-01-02 16:57:31 +01:00
Andreas Kling
0bc8d58c3b LibGfx: Add Gfx::Bitmap::create_shareable(format, size)
This helper allocates a shbuf and returns it wrapped in a Bitmap.
2021-01-02 16:57:31 +01:00
Brian Gianforcaro
fd08c93ef5 LibC: Randomize the stack check cookie value on initialization
Previously we had a static stack check cookie value for LibC.
Now we randomize the cookie value on LibC initialization, this should
help make the stack check more difficult to attack (still possible just
a bigger pain). This should also help to catch more bugs.
2021-01-02 13:55:48 +01:00
Brendan Coles
69e3879b7a LibGUI: CommonActions: Add make_help_action common action 2021-01-02 11:43:25 +01:00
AnotherTest
a4a238ddc8 LibGUI: Add an optional "automatic" autocomplete feature to TextEditor
This aims to be a "smart" autocomplete that tries to present the user
with useful suggestions without being in the way (too much).
Here is its current configuration:
- Show suggestions 800ms after something is inserted in the editor
- if something else is inserted in that period, reset it back to 800ms
  to allow the user to type uninterrupted
- cancel any shown autocomplete (and the timer) on external changes
  (paste, cut, etc)
2021-01-02 11:37:01 +01:00
Brian Gianforcaro
06da50afc7 Build + LibC: Enable -fstack-protector-strong in user space
Modify the user mode runtime to insert stack canaries to find stack corruptions.

The `-fstack-protector-strong` variant was chosen because it catches more
issues than vanilla `-fstack-protector`, but doesn't have substantial
performance impact like `-fstack-protector-all`.

Details:

    -fstack-protector enables stack protection for vulnerable functions that contain:

    * A character array larger than 8 bytes.
    * An 8-bit integer array larger than 8 bytes.
    * A call to alloca() with either a variable size or a constant size bigger than 8 bytes.

    -fstack-protector-strong enables stack protection for vulnerable functions that contain:

    * An array of any size and type.
    * A call to alloca().
    * A local variable that has its address taken.

Example of it catching corrupting in the `stack-smash` test:
```
courage ~ $ ./user/Tests/LibC/stack-smash
[+] Starting the stack smash ...
Error: Stack protector failure, stack smashing detected!
Shell: Job 1 (/usr/Tests/LibC/stack-smash) Aborted
```
2021-01-02 11:34:55 +01:00
Andreas Kling
bf3772362a LibWeb: When collapsing margins, consider border box heights
Empty boxes should be fully collapsed, but a box with border and/or
padding is not empty.

This fixes an issue where <hr> elements were getting weirdly collapsed
since they have zero content height (but some border height.)
2021-01-02 03:48:35 +01:00
Andreas Kling
5116b94114 LibWeb: Fix unnecessary wrapping of block boxes in anonymous blocks
Outside of tables, we don't need to wrap block-level boxes in anymous
blocks. Only inline-level boxes need this treatment.
2021-01-02 03:48:35 +01:00
Andreas Kling
042890d319 LibMarkdown: Parse horizontal rules
A horizontal rule is generated by a line with three or more of these
characters: '*', '-', '_'.
2021-01-02 02:41:15 +01:00
Andreas Kling
b4af4a4085 LibGUI: Allow widget sibling navigation with arrow keys
There's no spatial navigation here, Left/Up moves to the previous
sibling in the tab order, while Right/Down moves to the next.

The arrow keys keep focus within the same parent widget, unlike the tab
key which cycles through all focusable widgets in the window.

This makes GUI::MessageBox feel a bit nicer since you can now arrow
between the Yes/No/Cancel buttons. :^)
2021-01-02 01:56:59 +01:00
Luke
5dfcecd244 Lagom/Fuzzers: Add TTF fuzzer 2021-01-02 01:39:34 +01:00
Luke
ad243ef3aa LibTTF: Add option to load font from a byte buffer 2021-01-02 01:39:34 +01:00
Brian Gianforcaro
84c2be604a
Kernel+LibELF: Use hex instead of decimal for stack offsets in back traces (#4728)
Hex is the de facto format for representing memory addresses, make backtraces
conform to that convention.
2021-01-02 01:38:43 +01:00
Andreas Kling
4cfef0cd95 LibGUI: Tweak MessageBox layout slightly 2021-01-02 01:36:24 +01:00
Andreas Kling
f5384d7c70 LibGUI: Correct selection width when using fonts with glyph spacing
We were not adding the glyph spacing after the last character in the
selection, causing it to be slightly too small in some cases.
2021-01-02 00:39:52 +01:00
Andreas Kling
c1339baba8 LibGUI: Fix cursor height in single-line text boxes
We should use the TextEditor::line_height() for the cursor height,
same as we do in multi-line mode.
2021-01-02 00:35:34 +01:00
Andreas Kling
c381e7f5a0 LibGUI: Add Window::on_close hook
This will be invoked when the window is closed, which is helpful if you
want to remove the window from some kind of owner after it's closed.
2021-01-02 00:35:34 +01:00
Tom
e21cc4cff6 Kernel: Remove MAP_PURGEABLE from mmap
This brings mmap more in line with other operating systems. Prior to
this, it was impossible to request memory that was definitely committed,
instead MAP_PURGEABLE would provide a region that was not actually
purgeable, but also not fully committed, which meant that using such memory
still could cause crashes when the underlying pages could no longer be
allocated.

This fixes some random crashes in low-memory situations where non-volatile
memory is mapped (e.g. malloc, tls, Gfx::Bitmap, etc) but when a page in
these regions is first accessed, there is insufficient physical memory
available to commit a new page.
2021-01-01 23:43:44 +01:00
Andreas Kling
849e2ded24 LibGfx: Tweak color of checkmark in disabled+checked GUI::CheckBox 2021-01-01 23:08:59 +01:00
Andrew Kaster
8d0b4657e7 LibThread: Improve semantics of Thread::join, and remove Thread::quit.
Thread::quit was created before the pthread_create_helper in pthread.cpp
that automagically calls pthread_exit from all pthreads after the user's
thread function exits. It is unused, and unecessary now.

Cleanup some logging, and make join return a Result<T, ThreadError>.
This also adds a new type, LibThread::ThreadError as an
AK::DistinctNumeric. Hopefully, this will make it possible to have a
Result<int, ThreadError> and have it compile? It also makes it clear
that the int there is an error at the call site.

By default, the T on join is void, meaning the caller doesn't care about
the return value from the thread.

As Result is a [[nodiscard]] type, also change the current caller of
join to explicitly ignore it.

Move the logging out of join as well, as it's the user's
responsibility whether to log or not.
2021-01-01 23:01:48 +01:00
Andrew Kaster
7b94ca21b3 LibPthread: Implement destruction of pthread_keys
Add a function to destroy any keys that were set on the current thread
using the algorithm from Dr. POSIX's pthread_key_create. Add some
defines to pthread.h for pthread key use, and implement
pthread_key_delete. It has a prototype in pthread.h, but any program
trying to actually use it would be in for a link-time surprise.

Currently, keys are destroyed either via global destructors, with the
s_key_destroyer object, or in exit_thread. exit_thread is invoked by
pthread_exit, and transitively by pthread_create, via the
pthread_create_helper that ensures all threads created with the pthread
API properly clean up for themselves when they exit gracefully.

A future patch might make s_key_destroyer a C++11 thread_local instead,
assuming we get thread_local and thread_local destructors working.
2021-01-01 23:01:48 +01:00
Andreas Kling
19ffa676f2 LibWeb: Use is<T> in XMLHttpRequestPrototype 2021-01-01 22:41:50 +01:00
asynts
e77031ce67 AK: Deal with unsigned integers in binary search. 2021-01-01 22:23:13 +01:00
Andreas Kling
db790dda62 LibJS: Remove hand-rolled type information in JS AST in favor of RTTI 2021-01-01 19:34:07 +01:00
Andreas Kling
07dd73c351 LibWeb: Remove hand-rolled is_foo() helpers in Layout::Node classes 2021-01-01 18:56:49 +01:00
Andreas Kling
3bb0cb2202 LibWeb: Remove more hand-rolled type information :^)
Hoo boy, we've really accumulated a lot of this stuff.
2021-01-01 18:14:00 +01:00
Andreas Kling
d2613403e0 LibJS+LibWeb: Stop generating is_foo_wrapper() for JS DOM wrappers 2021-01-01 18:06:38 +01:00
Andreas Kling
f48751a739 LibJS: Remove hand-rolled Object is_foo() helpers in favor of RTTI 2021-01-01 17:46:39 +01:00
Andreas Kling
8333055c3d LibJS: Use RTTI for inheritance checks
This replaces the hand-rolled string-based inheritance check tech.
2021-01-01 17:00:20 +01:00
Andreas Kling
fc86717f43 LibWeb: Demangle the names returned by Layout::Node::class_name()
Note that these are only used in debugging/test output so it's not
performance sensitive.
2021-01-01 16:42:44 +01:00
Andreas Kling
730af2c524 LibWeb: Simplify Layout::Node::class_name() with RTTI 2021-01-01 16:08:49 +01:00
Andreas Kling
7841528cd4 LibCore: Remove Core::Object::is_widget() in favor of RTTI 2021-01-01 16:08:49 +01:00
Andreas Kling
42179715c3 LibCore: Remove some hand-rolled type information from Core::Object
Both is_action() and is_window() can be answered by RTTI.
2021-01-01 16:08:49 +01:00
Andreas Kling
32fd59b471 LibGUI: Remove some hand-rolled type information from Widget 2021-01-01 16:08:49 +01:00
Andreas Kling
865f524d5b AK+LibGUI+LibWeb: Remove AK::TypeTraits in favor of RTTI-based helpers
Now that we have RTTI in userspace, we can do away with all this manual
hackery and use dynamic_cast.

We keep the is<T> and downcast<T> helpers since they still provide good
readability improvements. Note that unlike dynamic_cast<T>, downcast<T>
does not fail in a recoverable way, but will assert if the object being
casted is not a T.
2021-01-01 15:33:30 +01:00
Linus Groh
aa92adeedf LibJS: Fix email in TypedArray{Constructor,Prototype} copyright headers 2021-01-01 15:02:58 +01:00
Andrew Kaster
347bf6459d Applications+LibGUI: Convert all GML consumers to use the LibCore finder
Remove Widget::find_child_by_name and Widget::find_descendant_by_name,
and convert all users to using the type-safer version in Core::Object.
2021-01-01 14:45:09 +01:00
Andrew Kaster
5b03a0867f LibCore: Add typed find_child and find_descendant helpers to Object
These look a lot like the parallel functionality in GUI::Widget :).
These use dynamic_cast now, to make use of that RTTI we just added.
2021-01-01 14:45:09 +01:00
Brendan Coles
74a65cffbd LibELF: validate_program_headers: Validate p_memsz and p_align 2021-01-01 14:34:25 +01:00
AnotherTest
887a62582d ProtocolServer: Use an empty Optional<IPC::File> to pass along "no fd"
Passing `-1` wouldn't work, as these are passed to `sendfd()'.
Fixes #4706.
2021-01-01 14:26:43 +01:00
Andreas Kling
39efb3df18 LibGUI: Hide unnecessary scrollbars in MultiView
This removes pointless scrollbars in FilePicker which looks nice.
2021-01-01 02:12:39 +01:00
Andreas Kling
3eba01a02d LibGUI: Simplify setup code in GUI::MultiView
Use for_each_view_implementation() to avoid duplicating the setup code
for each subview.
2021-01-01 02:12:39 +01:00
Andreas Kling
78fbfd7795 Meta: Update project copyright dates (2018-2021) :^) 2021-01-01 01:14:16 +01:00
Andreas Kling
2e8db6560f LibGUI: Transfer focus when checking exclusive button programmatically
When calling set_checked(true) on an exclusive button, we will now
transfer focus to the newly checked button if one of its now-unchecked
siblings had focus before.

This makes windows that place initial focus somewhere in a group of
radio buttons look nicer when they show up, since focus will be on
whichever radio button was pre-checked, which may not be the first one
in the group.
2021-01-01 00:40:12 +01:00
Andreas Kling
5e19e72a6a LibGUI: Simplify RadioButton by using AbstractButton exclusive mode
Making an AbstractButton exclusive means that we enforce that only one
of the exclusive buttons within the same parent widget can be checked
at a time.

RadioButton was doing exactly the same thing, except in a custom way.
So just remove the custom code and make it exclusive. :^)
2021-01-01 00:33:44 +01:00
Stephan Unverwerth
bb27b212de LibGfx: Introduce provisional font interface
Old font functionality has been moved into BitmapFont
and an abstract Font interface has been introduced to
faciliate further development of TTF font integration.
2020-12-31 23:40:27 +01:00
Andreas Kling
f330dc3886 LibGUI: Add a bunch of missing widget registrations 2020-12-31 23:32:13 +01:00
Tom
a4b3eb6b2d LibWeb: Clear circular download reference when download finished 2020-12-31 22:15:00 +01:00
Andrew Kaster
06865c78c7 LibAudio: Make it so that an unused WavWriter is destructible
WavWriter::finalize didn't check that m_file was actually valid before
trying to seek and close it. The file is only set by set_file, so it's
not an invariant. Just add a null guard to finalize().
2020-12-31 21:59:20 +01:00
Andrew Kaster
644f5ec160 LibThread: Give Thread std::jthread semantics
Because pthread_create will always call pthread_exit internally before
exiting the thread function, we can remove the odd requirement that the
user's thread function must call Thread::quit internally.

Make Thread::join clear m_tid on success, and print to stderr on
failure. Call join from ~Thread(). Now if you write an infinite loop in
your thread in an application and don't have an exit condition, you will
block in the thread's destructor forever. Time for stop_token? :)
2020-12-31 21:59:20 +01:00
Andrew Kaster
2b3993b008 LibThread: Hide Thread's constructor, as it is a Core::Object
Just constructing one of these guys on the stack willy nilly will leak
the first reference to them. There might be other C_OBJECTs that have
public constructors, seems like a good place for some static analysis
checks :).

Force users to call the construct() method for it.
2020-12-31 21:59:20 +01:00
Linus Groh
bbe787a0af Everywhere: Re-format with clang-format-11
Compared to version 10 this fixes a bunch of formatting issues, mostly
around structs/classes with attributes like [[gnu::packed]], and
incorrect insertion of spaces in parameter types ("T &"/"T &&").
I also removed a bunch of // clang-format off/on and FIXME comments that
are no longer relevant - on the other hand it tried to destroy a couple of
neatly formatted comments, so I had to add some as well.
2020-12-31 21:51:00 +01:00
AnotherTest
2568a93b5d ProtocolServer: Avoid blocking all downloads when client stops reading
Fixes #4668.
2020-12-31 16:57:09 +01:00
AnotherTest
83fed3fd5d LibWeb: Don't hold on to the Download instance after it's finished
Fixes* 4668
2020-12-31 16:57:09 +01:00
AnotherTest
a6b04cf8ef LibProtocol: Ensure download is finished before invoking on_finished 2020-12-31 16:57:09 +01:00
Andreas Kling
e6e4fe4f51 LibGUI: Add 1px of margin to EmojiPickerDialog
The left and top highlight edges were cut off by the dialog frame.
Add a small margin to make sure all buttons can be painted fully.
2020-12-31 14:39:23 +01:00
Andreas Kling
d441dec5d8 LibGUI: Make the emojis in the emoji input dialog fit in the window
GUI::Button has a default min-width of 32, so we have to override that
here in order to squeeze all the emojis into the window.

Fixes #4689.
2020-12-31 14:32:09 +01:00
Andreas Kling
ddaa13577e LibGUI: Add a new GUI::OpacitySlider widget :^)
This widgets offers a more visually intuitive way to adjust the opacity
of something.
2020-12-31 12:10:01 +01:00
Andreas Kling
acb87cd164 LibGfx: Remove unnecessary assertion in Painter::draw_pixel() 2020-12-31 12:10:01 +01:00
Tom
eabbe03b97 LibGUI: Constrain relative cursor delta to valid range 2020-12-31 10:54:02 +01:00
Tom
0c57e16ce4 LibGUI: Don't change the actual combobox value while hovering it
We don't want to trigger an actual selection change until either
confirming the new selection by keyboard or clicking on it.
Dismissing the dropdown should have no effect on the current
selection.

Fixes #4657
2020-12-31 10:54:02 +01:00
Andreas Kling
412a91d58f LibGfx: Add Gfx::Font::bold_variant() that does a proper font lookup
We previously had a cached bold variant font in Gfx::Font that was very
haphazardly located by filename pattern. This patches replaces that
mechanism with a proper Gfx::FontDatabase lookup for the same font but
with bold weight (700).
2020-12-31 01:51:18 +01:00
Luke
0f66589007 Everywhere: Fix more typos 2020-12-31 01:47:41 +01:00
Andreas Kling
4f1db41a6c LibGUI: Show font weight names instead of numeric weights in FontPicker
Map font weights to their names from the OpenType specification.
2020-12-31 01:13:52 +01:00
Andreas Kling
c770b0bbec LibGUI: Don't keep creating new models in FontPicker
We can reuse the same model, as long as we call update() on them when
the list of weights/sizes change.
2020-12-31 00:46:00 +01:00
Andreas Kling
91493be4f3 LibGUI: Simplify FontPicker::set_font()
Use Vector::find_first_index() instead of iterating manually. :^)
2020-12-31 00:45:43 +01:00
Tom
54eeb8ee9a AK: Fix a race condition with WeakPtr<T>::strong_ref and destruction
Since RefPtr<T> decrements the ref counter to 0 and after that starts
destructing the object, there is a window where the ref count is 0
and the weak references have not been revoked.

Also change WeakLink to be able to obtain a strong reference
concurrently and block revoking instead, which should happen a lot
less often.

Fixes a problem observed in #4621
2020-12-31 00:39:43 +01:00
Andreas Kling
3e00e3da72 LibGUI: Sort all the lists in the FontPicker
Fixes #4671.
2020-12-31 00:33:50 +01:00
Andreas Kling
a68275914e LibGUI: Tweak FontPicker layout
Make everything a bit smaller and hide the horizontal scrollbars in the
list views since we don't really need them.
2020-12-30 21:01:28 +01:00
Stephan Unverwerth
b4d1390714 LibGFX: Move default_xxx_font() methods from Font to FontDatabase
When we have an abstract font class it makes no sense to keep
these methods in the Font class.
2020-12-30 20:40:30 +01:00
Stephan Unverwerth
1a072a61fb LibTTF: Cache rasterized glyphs within TTF::ScaledFont 2020-12-30 20:40:30 +01:00
Stephan Unverwerth
0f6cf9caa1 LibTTF: Use ReadonlyBytes where possible to avoid copies 2020-12-30 20:40:30 +01:00
Stephan Unverwerth
187acd8f21 LibTTF: Do not assert on glyphs with broken line coordinates
Until we figure out what causes this problem or we can
fixup the coordinates we should simply not render this line.
2020-12-30 20:40:30 +01:00
Stephan Unverwerth
9689d914b4 LibTTF: Use ByteBuffer::copy() since wrap() was removed 2020-12-30 20:40:30 +01:00
Stephan Unverwerth
222b7f6c87 LibTTF: Use AffineTransform::multiply() instead of * operator 2020-12-30 20:40:30 +01:00
Stephan Unverwerth
a060b6cefd LibTTF: Fix code after rebase 2020-12-30 20:40:30 +01:00
Srimanta Barua
3b31f069f0 LibTTF: Address code-style comments, gracefully handle load failures. 2020-12-30 20:40:30 +01:00
Srimanta Barua
ec08e9e780 LibTTF: Split up Font.h into smaller internal header files. 2020-12-30 20:40:30 +01:00
Srimanta Barua
1e1d2cdedf LibTTF: Initial work on parsing and rasterizing composite glyphs.
This doesn't handle every case yet.
2020-12-30 20:40:30 +01:00
Srimanta Barua
bd354bc2ae LibTTF: Reorganized TTF parsing code into LibTTF 2020-12-30 20:40:30 +01:00
Srimanta Barua
22fbe59126 LibGfx: Address awesomekling's comments on API and codestyle 2020-12-30 20:40:30 +01:00
Srimanta Barua
1931535218 LibGfx: Cut down on magic constants in the TTF parser. 2020-12-30 20:40:30 +01:00
Srimanta Barua
186499cc25 LibGfx: Update Painter's bezier curve drawing algorithm.
The new algorithm is an iterative one with an arbitrary threshold for splitting
curves. It splits curves evenly. This should theoretically be less accurate
than the existing recursive approach, but seems to give subjectively better
results in practice.
2020-12-30 20:40:30 +01:00
Srimanta Barua
0e9fb803c8 LibGfx: Finally render simple TTF outlines. 2020-12-30 20:40:30 +01:00
Srimanta Barua
b70c1fe181 LibGfx: Rasterize simple TTF glyphs. 2020-12-30 20:40:30 +01:00
Srimanta Barua
e3b5d2afeb LibGfx: Load glyph definition from "glyf" table for TTF fonts.
CFF fonts don't have "glyf" or "loca", so this code will need to be
extended to handle them.
2020-12-30 20:40:30 +01:00
Srimanta Barua
675237180f LibGfx: Get glyph ID for codepoint, from the CMAP table. 2020-12-30 20:40:30 +01:00
Srimanta Barua
be1586850d LibGfx: Started working on TTF font parser.
I'm planning to make this a minimal-allocation TTF parser. This will
speed up start-up time for applications, but have some overhead for
rasterizing glyphs. Which should be okay, since rasterized glyph bitmaps
should be cached anyway.

This commit just adds the loading of the HEAD table.
2020-12-30 20:40:30 +01:00
Andreas Kling
8fe1643c4b LibGUI: Make FontPicker correctly select the current font when opened 2020-12-30 20:37:51 +01:00
Andreas Kling
7e40c7cf99 LibGUI: Allow GUI::FilePicker to show only fixed-width fonts
This is useful when you really only want something monospaced. :^)
2020-12-30 20:37:51 +01:00
Andreas Kling
ddaa526769 LibGUI: Add a GUI::FontPicker dialog class :^)
This allows you to pick & choose a font by selecting the family, weight
and size you want. It shows you a nice preview sentence and everything.
2020-12-30 20:37:51 +01:00
Andreas Kling
aacab897e8 LibGUI: Add widget registration for GUI::ListView 2020-12-30 20:37:51 +01:00
AnotherTest
bdd4b99d72 LibIPC: Add an on_destruction hook to IPC::Message
Any cleanup of resources needed (up until the message is sent) can be
done here.
Currently, the only such resource is an IPC::File.
2020-12-30 20:37:41 +01:00
AnotherTest
b03e8a6d06 LibWeb: Re-enable favicons after forgotten if-0 2020-12-30 20:37:41 +01:00
asynts
7e62ffbc6e AK+Format: Remove TypeErasedFormatParams& from format function. 2020-12-30 20:33:53 +01:00
Linus Groh
efdbd778c2 LibC: Set "assertion" coredump metadata in __assertion_failed() 2020-12-30 16:28:27 +01:00
Linus Groh
7413a7c509 LibELF+LibCoreDump: Add a Metadata notes entry
This is a new NotesEntry type which will allow applications to embed
arbitrary metadata in crashdumps (stored as a JSON string). It will be
used to store an assertion message, for example.
2020-12-30 16:28:27 +01:00
Andreas Kling
aa941a31ed LibGUI: Make SpinBox up/down buttons look right when disabled 2020-12-30 16:13:38 +01:00
Andreas Kling
26abb691d8 LibGUI: Make disabled scrollbars have more disabled looking icons
Draw a threed drop highlight under the arrows on disabled scrollbars.
This makes it more visible that they are disabled.
2020-12-30 16:13:38 +01:00
Andreas Kling
1215d2a642 LibGUI: Make GUI::ScrollBar inherit from AbstractSlider 2020-12-30 15:20:47 +01:00
Andreas Kling
cb67264f61 LibGUI: Rename AbstractSlider::on_value_changed => on_change
This matches other similar hook names.
2020-12-30 15:20:47 +01:00
Andreas Kling
3b445bc66a LibGUI: Add page_step setting to AbstractSlider and use it in Slider
This makes clicking on the track of a GUI::Slider actually move the
knob more than 1 value unit (assuming page_step > 1)
2020-12-30 15:20:47 +01:00
Andreas Kling
fa836a4dda LibGUI: Add GUI::AbstractSlider and move generic parts of Slider there
This will allow us to share some code between Slider and ScrollBar.
2020-12-30 15:20:47 +01:00
Linus Groh
a28954a882 LibELF+LibCoreDump: Add a ProcessInfo notes entry
This is a new NotesEntry type which contains information related to the
coredump's process:

- PID
- executable path

Having these in the coredump explicitly avoids having to parse them from
the coredump filename and backtrace, respectively.
2020-12-30 15:00:17 +01:00
Andreas Kling
9227e66bb4 LibGUI: Use Window::center_within() in GUI::Dialog 2020-12-30 13:44:58 +01:00