Commit graph

5936 commits

Author SHA1 Message Date
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
Andreas Kling
2c9147154c Terminal+LibVT: Add settings window to the terminal context menu 2020-12-30 13:42:16 +01:00
Andreas Kling
04e3bcfa75 LibGUI: Add Window::center_within(Window)
This allows you to easily center one window within another window.
2020-12-30 13:41:53 +01:00
AnotherTest
4a2da10e38 ProtocolServer: Stream the downloaded data if possible
This patchset makes ProtocolServer stream the downloads to its client
(LibProtocol), and as such changes the download API; a possible
download lifecycle could be as such:
notation = client->server:'>', server->client:'<', pipe activity:'*'
```
> StartDownload(GET, url, headers, {})
< Response(0, fd 8)
* {data, 1024b}
< HeadersBecameAvailable(0, response_headers, 200)
< DownloadProgress(0, 4K, 1024)
* {data, 1024b}
* {data, 1024b}
< DownloadProgress(0, 4K, 2048)
* {data, 1024b}
< DownloadProgress(0, 4K, 1024)
< DownloadFinished(0, true, 4K)
```

Since managing the received file descriptor is a pain, LibProtocol
implements `Download::stream_into(OutputStream)`, which can be used to
stream the download into any given output stream (be it a file, or
memory, or writing stuff with a delay, etc.).
Also, as some of the users of this API require all the downloaded data
upfront, LibProtocol also implements `set_should_buffer_all_input()`,
which causes the download instance to buffer all the data until the
download is complete, and to call the `on_buffered_download_finish`
hook.
2020-12-30 13:31:55 +01:00
AnotherTest
90aeacbb58 LibGUI: Register a whole bunch of properties in various widgets 2020-12-30 12:53:39 +01:00
AnotherTest
20b74e4ede LibGUI+HackStudio: Add an opt-in autocompletion interface to TextEditor
...and use that to implement autocomplete in HackStudio.

Now everyone can have autocomplete :^)
2020-12-30 12:53:39 +01:00
Idan Horowitz
7e457b98c3 Terminal: Remove redundant scroll length settings option
This is no longer needed as a global one is now available
under mouse settings.
2020-12-30 11:58:52 +01:00
Andreas Kling
5b1a6d7c66 LibGUI: Move GUI::SeparatorWidget from ToolBar.cpp to its own file
This makes this nice line separator widget usable outside toolbars.
Also support both horizontal and vertical orientation. :^)
2020-12-30 03:52:27 +01:00
Andreas Kling
bc5635422b LibGUI: Give a default min-width to a bunch of widgets 2020-12-30 02:57:45 +01:00
Andreas Kling
01ccbdb017 LibGUI: Register GUI::ComboBox :^) 2020-12-30 02:45:20 +01:00
Andreas Kling
e07a66d011 LibGUI: Remove unused Widget backcolor/forecolor properties
These were some leftovers from the VisualBuilder times.
2020-12-30 02:45:20 +01:00
asynts
50d24e4f98 AK: Make binary_search signature more generic. 2020-12-30 02:13:30 +01:00
Gal Horowitz
fea498e9ac LibKeyboard: get_char now handles e0 prefix for control keys
Control keys which have numpad counter-parts have the same scancode
except for an e0 prefix. We now return a 0 code_point for those keys.
2020-12-30 02:12:04 +01:00
Andreas Kling
675bfb934b LibGUI: Unbreak GUI::ScrollBar default size
Oops, got my width/height mixed up here. :^)
2020-12-30 01:55:25 +01:00
Andreas Kling
1cca2405fc LibGUI: Give some widgets a reasonable default fixed height
Instead of hard-coding 22 in random places, just make the following
widgets have a fixed height of 22 by default: Button, CheckBox,
ColorInput, ComboBox, RadioButton, SpinBox, TextBox.

In the future we can make this relative to the current font size,
but for now at least this centralizes the setting a bit better.
2020-12-30 01:54:53 +01:00
Andreas Kling
0f3b0b65ae LibGUI+LibCore: Remove the GUI::SizePolicy enum 2020-12-30 01:38:29 +01:00
Andreas Kling
7dc5a3ead8 LibGUI: Rewrite layout system in terms of min and max sizes
This patch removes size policies and preferred sizes, and replaces them
with min-size and max-size for each widget.

Box layout now works in 3 passes:

    1) Set all items (widgets/spacers) to their min-size
    2) Distribute remaining space evenly, respecting max-size
    3) Place widgets one after the other, adding spacing in between

I've also added convenience helpers for setting a fixed size (which is
the same as setting min-size and max-size to the same value.)

This significantly reduces the verbosity of widget layout and makes GML
a bit more pleasant to write, too. :^)
2020-12-30 01:36:41 +01:00
Andreas Kling
b2bba5ce5c LibGUI: Make Layout::margins() return a const reference 2020-12-30 01:28:28 +01:00
Andreas Kling
ee85713e52 LibGUI: Add fixed_size/fixed_width/fixed_height helpers to Widget
Fixed sizes are really just shorthands for setting min and max size to
the same value.

This makes it much nicer to express fixed sizes in GML:

Before:

    @GUI::Widget {
        horizontal_size_policy: "Fixed"
        preferred_width: 20
    }

After:

    @GUI::Widget {
        fixed_width: 20
    }
2020-12-30 01:28:28 +01:00
Andreas Kling
60e3f685db LibGUI: Add min/max sizes to GUI::Widget
This patch adds min_size and max_size properties to GUI::Widget. These
can also be accessed as min_width/min_height and max_width/max_height.

Layouts will respect these constraints and size widgets accordingly.
2020-12-30 01:28:28 +01:00
Luke
18d99919be LibWeb: Expose three more attribute methods on Element
Exposes removeAttribute, hasAttribute and hasAttributes.
2020-12-29 23:38:14 +01:00
Idan Horowitz
b05f048c05 LibGUI: offset value by minimum to ensure proper rendering of sliders
This subtracts the minimum from the value when rendering so that the
knob doesnt go off screen for a non-zero minimum.
2020-12-29 23:37:38 +01:00
AnotherTest
8ca0e8325a LibJS: Don't save rule start positions along with the parser state
This fixes #4617.
Also fixes the small problem where some save states would be leaked.
2020-12-29 17:39:42 +01:00
Luke
6ffcd53479 LibWeb: Fix character references losing characters in certain situations
This fixes 4 issues:
- RECONSUME_IN_RETURN_STATE was functionally equivalent to
  SWITCH_TO_RETURN_STATE, which caused us to lose characters.
  For example, &test= would lose the =

- & characters by themselves would be lost. For example, 1 & 2
  would become 1 2. This is because we forgot to flush
  characters in the the ANYTHING_ELSE path in CharacterReference

- Named character references didn't work at all in attributes.
  This is because there was a path that was checking the entity
  code points instead of the entity itself. Plus, the path that
  was checking the entity itself wasn't quite spec compliant.

- If we fail to match a named character reference, the first
  character is lost. For example &test would become &est.
  However, this relies on a little hack since I can't wrap my
  head around on how to change the code to do as the spec says.
  The hack is to reconsume in AmbigiousAmpersand instead of
  just switching to it.

Fixes #3957
2020-12-29 17:39:08 +01:00
AnotherTest
5e5eb615ec Shell: Add runtime errors and implement break/continue
Such errors are raised when SyntaxError nodes are executed, and are also
used for internal control flow.
The 'break' and 'continue' commands are currently only allowed inside
for loops, and outside function bodies.

This also adds a 'loop' keyword for infinite loops.
2020-12-29 16:55:43 +01:00
Linus Groh
2939ad0110 LibCoreDump+CrashDaemon: Add and use CoreDump::Backtrace
Creating a backtrace from a crashdump already existed as a few
standalone functions in CrashDaemon. This patch refactors the code
required for this to make it generally usable and moves it to
CoreDump::Backtrace, which provides both raw data as well as
stringification.
2020-12-29 15:42:30 +01:00
Linus Groh
e2e2b2c08e LibELF: Add MemoryRegionInfo::object_name()
We had multiple implementations of this function, and it's a small
helper related to MemoryRegionInfo's region_name, so let's move it
there.
2020-12-29 15:42:30 +01:00
Linus Groh
c39323401c LibGUI: Consider comment tokens in GMLParser
It was just ignoring them, so any GML containing a comment would fail
to parse with "Expected child, property, or }"!
2020-12-29 15:42:30 +01:00
Linus Groh
d161007e9e LibGUI: Register Label "text_alignment" property 2020-12-29 15:42:30 +01:00
Linus Groh
750a608441 LibGUI: Register TextEditor "mode" property
This makes it possible to construct a read-only (or display-only)
TextEditor in GML:

    @GUI::TextEditor {
        mode: "ReadOnly"
        text: "Well hello friends! :^)"
    }
2020-12-29 15:42:30 +01:00
Linus Groh
1e70986d19 LibCore: Add REGISTER_TEXT_ALIGNMENT_PROPERTY macro 2020-12-29 15:42:30 +01:00
Linus Groh
6c0fa6ad93 LibCore: Add REGISTER_ENUM_PROPERTY macro
This can be used to register a property that maps enum values to certain
strings, e.g.

    REGISTER_ENUM_PROPERTY(
        property_name, getter, setter, Enum,
        { Enum::Foo, "Foo" },
        { Enum::Bar, "Bar" });

Also use it for REGISTER_SIZE_POLICY_PROPERTY :^)
2020-12-29 15:42:30 +01:00
Linus Groh
c4991d969c LibGUI: Register the ImageWidget and LinkLabel widgets 2020-12-29 15:42:30 +01:00
Linus Groh
b8eb1baac8 LibGUI: Move REGISTER_WIDGET(GUI, TabWidget) to Widget.cpp
All the other (GUI) registrations happen here, so it's confusing to have
just one elsewhere ("wait... is TabWidget not registered?!").
2020-12-29 15:42:30 +01:00
Linus Groh
a514f2cbfd LibGUI: Set default value of LinkLabel text argument to a null string
The regular Label also does this, being able to call the constructor
with no arguments is required for REGISTER_WIDGET(GUI, LinkLabel).
2020-12-29 15:42:30 +01:00
Linus Groh
21bc8cfe8f LibCoreDump: Make for_each_thread_info() callback arg a reference
It's never nullptr, so it should be a reference.
2020-12-29 15:42:30 +01:00
Linus Groh
87f1f69dd2 LibCoreDump: Make for_each_memory_region_info() callback arg a reference
It's never nullptr, so it should be a reference.
2020-12-29 15:42:30 +01:00
Linus Groh
8ec1da2fca LibCoreDump: CoreDumpReader => CoreDump::Reader
As mentioned in 2d39da5 the usual pattern is that LibFoo provides a Foo
namespace - LibCoreDump doesn't, so this renames CoreDumpReader to
Reader and puts it in the CoreDump namespace. :^)
2020-12-29 15:42:30 +01:00
Egor Ananyin
1dbd264239 LibJS: Uncomment the tests that pass now 2020-12-29 13:43:16 +01:00
Egor Ananyin
92c6ae57fc LibM: Reimplement some functions using FPU 2020-12-29 13:43:16 +01:00
Andreas Kling
5c99296b92 LibELF: Don't try to call mremap() on macOS
There is no mremap() on macOS. I'm just #ifdef'ing out the call here
since I don't think the dynamic loader code matters on macOS anyway.
2020-12-29 10:56:43 +01:00
AnotherTest
d0363bca01 LibJS: `save_state()' before creating a RulePosition
Fixes #4617.
2020-12-29 10:51:33 +01:00
Andreas Kling
572d3bb0b8 DynamicLoader: Only remap text segments private if there are textrels
We now map most shared library text segments shared, read+exec only.
This reduces our memory footprint at system startup by 16 MB which is
pretty neat! :^)
2020-12-29 02:28:36 +01:00
Andreas Kling
30dbe9c78a Kernel+LibC: Add a very limited sys$mremap() implementation
This syscall can currently only remap a shared file-backed mapping into
a private file-backed mapping.
2020-12-29 02:20:43 +01:00
AnotherTest
b34b681811 LibJS: Track source positions all the way down to exceptions
This makes exceptions have a trace of source positions too, which could
probably be helpful in making fancier error tracebacks.
2020-12-29 00:58:43 +01:00
Andreas Kling
cdf87d2204 LibWeb: Fill OOPWV with the palette base color until we have pixels
We were painting unfinished pixels while waiting for the WebContent
process to render the page. This caused OOPWV to flicker black
sometimes, which looked pretty bad.

This way we still flicker, but at least we flicker with the correct
palette color. :^)
2020-12-29 00:47:30 +01:00
Andreas Kling
f06b240ce0 LibGUI: Enforce the SelectionMode in AbstractView::set_cursor() 2020-12-29 00:43:50 +01:00
Andreas Kling
66c0374fd7 LibGUI: Make FilePicker a little smaller by default 2020-12-29 00:30:25 +01:00
Andreas Kling
461c0afc25 LibGUI: Tweak FilePicker's default titles 2020-12-29 00:27:57 +01:00
Andreas Kling
13594b7146 LibGfx+AK: Make text elision work with multi-byte characters
This was causing WindowServer and Taskbar to crash sometimes when the
stars aligned and we tried cutting off a string ending with "..." right
on top of an emoji. :^)
2020-12-28 23:54:10 +01:00
Andreas Kling
9af33e2e4b LibGfx: Make Painter::draw_text() interpret StringView as UTF-8 2020-12-28 23:54:10 +01:00
Lukasz Maciejewski
7e5199a394 LibTextCodec: Fix minor errors in Latin2 decoder 2020-12-28 23:31:12 +01:00
Andreas Kling
7e79563bb9 LibGUI: Show tooltip after a small delay
It always felt a bit jarring that tooltips would pop in right away when
you hover over a toolbar button. This patch adds a 700ms delay before
they appear, and a 50ms delay before they disappear.

Once a tooltip is up, moving the cursor between two widgets that both
have tooltips will leave the tooltip on screen without delays.
2020-12-28 21:28:40 +01:00
Andreas Kling
add01b304b LibCore: Make Core::Timer::create_single_shot() create a stopped timer
None of the code using this actually expected the timer to fire right
away, but they would instead call start() on it once they were ready to
accept a timer fire.

Let's make the API behave the way its clients believed it did. :^)
2020-12-28 21:28:40 +01:00
Andreas Kling
f7116bba43 LibGUI: Refactor AbstractView "multi select" mode into "selection mode"
There are three possible selection modes for a GUI::AbstractView.

- NoSelection
- SingleSelection
- MultiSelection

We don't enforce these modes fully yet, this patch mostly adds them in
place of the old "multi select" flag.
2020-12-28 21:28:40 +01:00
Egor Ananyin
f30d4f22ef LibJS: Add tests for new Math functions 2020-12-28 19:03:11 +01:00
Egor Ananyin
7c9c3a10d3 LibJS: Add almost all Math functions 2020-12-28 19:03:11 +01:00
Andreas Kling
a35693915e LibGUI: Make syntax highlighter communicate boldness instead of font
Now that fonts know their own weight, we no longer need highlighters to
tell us which font to use. Instead, they can just say "this should be
bold" and we'll find the right font ourselves.
2020-12-28 15:53:10 +01:00
Andreas Kling
105eb8e1bc LibGfx: Add FontDatabase::get(family, size, weight)
This function allows you to look up a font by its exact parameters.
2020-12-28 15:53:10 +01:00
Andreas Kling
cd9ad6a05e LibGUI: Tweak AbstractButton and subclass constructors
Taking a "const StringView&" for the initial text does not achieve
anything useful. Just take a "String" and move it into storage.
2020-12-28 15:53:10 +01:00
Peter Nelson
476911e1f9 LibGfx: fix OOB access in LZW decoder on bad input
This fixes an issue where a corrupted LZW code can result in the first
element of an empty buffer being accessed.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27863
2020-12-28 15:12:29 +01:00
Luke
be30dc2b18 LibJS: Implement Object.prototype.isPrototypeOf
Spec: https://tc39.es/ecma262/#sec-object.prototype.isprototypeof
2020-12-28 13:10:07 +01:00
AnotherTest
ee1d9217aa LibRegex: Fail early if eof seen after '(?'
Fixes #4583.
2020-12-28 13:09:22 +01:00
Andreas Kling
92c073a9d1 LIbGUI+LibGfx: Paint focused push buttons with a heavier look
Draw a heavy shadow frame around focused push buttons for emphasis.
For now I've used the ThreedShadow2 color role as it feels dark enough.
2020-12-28 12:41:26 +01:00
Andreas Kling
2bbf3b5d0b LibGUI: Always focus the file name textbox in GUI::FilePicker
Previously we would only auto-focus it when choosing a save location.
It seems nice to have the same behavior when opening a file.
2020-12-28 11:44:29 +01:00
Andreas Kling
ffa241250b LibGUI: Make GUI::FileIconProvider::icon_for_executable() a public API
This way we can use it instead of icon_for_path() in a bunch of places
and avoid loading the full FileIconProvider configuration.
2020-12-28 11:41:09 +01:00
Idan Horowitz
0ddde46c19 LibVT: Implement find and scroll helper methods in TerminalWidget
This is mostly based on TextDocument's similar methods, these will
help implement searching within the terminal application.

The support for unicode code points is shaky at best, and should
probably be improved further.
2020-12-28 11:40:35 +01:00
Idan Horowitz
6446135681 LibVT: Create VT::Range and use it to replace selection start / end
Based on GUI::TextRange, This is both a bit more expressive and will
eventually be used for searching within the terminal
2020-12-28 11:40:35 +01:00
Linus Groh
58890e03b6 Everywhere: Move AppFile from LibGUI to LibDesktop
This was mentioned in #4574, and the more I think about it the more it
feels just right - let's move it there! :^)
Having to link LaunchServer against LibGUI explicitly should've been
telling enough...
2020-12-28 01:28:07 +01:00
Andreas Kling
97c42694db LibGUI: Make selected item tint color based on focused state
Use the inactive selection color for item icon tinting when the item
view is not focused.
2020-12-28 01:14:01 +01:00
Andreas Kling
0f1235be25 LibGUI: Show a hand cursor when hovering over a GUI::LinkLabel 2020-12-28 01:02:57 +01:00
Andreas Kling
644d5c5404 LibGUI: Switch focus if the currently focused widget is disabled 2020-12-28 01:02:57 +01:00
Brendan Coles
bceee87f61 LibELF: Reject ELF with program header p_filesz larger than p_memsz 2020-12-27 23:27:07 +01:00
Xavier Cooney
ca0f3db004 LibJS: Implement Array.prototype.sort() 2020-12-27 23:24:33 +01:00
Andreas Kling
a103eae0d4 LibJS: Run "prettier" on the tests :^) 2020-12-27 23:13:52 +01:00
dantje
d1366b660e
LibGUI: Use Object::remove_all_children() in BreadcrumbBar (#4580) 2020-12-27 23:07:10 +01:00
Nathan Lanza
d1891f67ac
AK: Use direct-list-initialization for Vector::empend() (#4564)
clang trunk with -std=c++20 doesn't seem to properly look for an
aggregate initializer here when the type being constructed is a simple
aggregate (e.g. `struct Thing { int a; int b; };`). This template fails
to compile in a usage added 12/16/2020 in `AK/Trie.h`.

Both forms of initialization are supposed to call the
aggregate-initializers but direct-list-initialization delegating to
aggregate initializers is a new addition in c++20 that might not be
implemented yet.
2020-12-27 23:06:37 +01:00
Stephen Gregoratto
1867c928a9 LibC: Add fseeko/ftello
This changes the signatures for FILE::seek and FILE::tell, to use
`off_t` as they use lseek internally. `fpos_t` is also redefined to use
`off_t`.

Dr. POSIX says that fpos_t is:

> A non-array type containing all information needed to specify uniquely
> every position within a file.

In practice, most *NIX typedef it to `off_t`, or a struct containing an
`off_t` and some internal state.
2020-12-27 23:05:14 +01:00
Stephan Unverwerth
f603128e55 LibJS: Fix old object numeric key test now that toString() is correct 2020-12-27 23:04:09 +01:00
Stephan Unverwerth
d3524f47a0 LibJS: Implement (mostly) spec compliant version of Number.toString() 2020-12-27 23:04:09 +01:00
Stephan Unverwerth
be9c2feff0 LibJS: Fix parsing of numeric object keys
Numeric keys were interpreted as their source text, leading to
something like {0x10:true} to end up as {"0x10":true}
instead of {16:true}
2020-12-27 23:04:09 +01:00
Idan Horowitz
fdacfefd09 LibVT: Use the 'U+FFFD replacement character' to indicate a parsing error
Based on this recommendation in the Unicode standard:
https://www.unicode.org/versions/Unicode13.0.0/ch23.pdf (Page 32)
2020-12-27 22:49:08 +01:00
Linus Groh
ddeb261bc2 Terminal+LibVT: Use GUI::AppFile 2020-12-27 22:46:52 +01:00
Linus Groh
616c217a09 LibGUI: Add GUI::AppFile, a simple wrapper around .af files 2020-12-27 22:46:52 +01:00
Łukasz Maciejewski
518ba73dcb
LibTextCodec: Add Latin2 text decoder (#4579) 2020-12-27 22:44:38 +01:00
Linus Groh
5122f98198 Base+LibJS+LibWeb: Make prettier clean
Also use "// prettier-ignore" comments where necessary rather than
excluding whole files (via .prettierignore).
2020-12-27 21:25:27 +01:00
Andreas Kling
76239f89c2 LibGUI: Select the edited text by default in StringModelEditingDelegate
This way, if you press F2 to edit the name of an item, the name will be
selected in the editor that pops up, and you can start typing a new
name for it immediately.
2020-12-27 19:08:19 +01:00
Andreas Kling
f294bdedcc LibGUI: Make IconView return a larger content rect for editing
This fixes a visual glitch where editing the name of an item in an
IconView would cut off the edited text.
2020-12-27 19:05:43 +01:00
Andreas Kling
04f1f74b85 LibGUI+WindowServer: Tweak hover shadows slightly
Move the shadow 1 more pixel away from the unhovered icon location,
making a total 2 pixel distance between the icon and the shadow.
Also tweak the shadow color to be a darkened variant of the base color
underneath the icon.
2020-12-27 18:43:34 +01:00
Linus Groh
2e7395d6da LibGUI: Include LibGfx/Bitmap.h in Icon.h
It doesn't compile with just the forwarding headers when nothing else
(e.g. Button.h) pulls in Bitmap.h.
2020-12-27 18:36:43 +01:00
Linus Groh
e955c024b2 LibCore: Add Object::remove_all_children() 2020-12-27 18:36:43 +01:00
Andreas Kling
8b31833650 LibGUI: Support top-to-bottom flow in IconView
Sometimes you might want your icons to flow from top-to-bottom instead
of from left-to-right. :^)
2020-12-27 14:48:12 +01:00
Andreas Kling
0117c57418 LibGUI: Move some large IconView internal helpers to the .cpp file
Stuff that's only used internally by the class is nice to keep out of
the header when possible.
2020-12-27 14:48:12 +01:00
Andreas Kling
0e2b7f9c9a Kernel: Remove the per-process icon_id and sys$set_process_icon()
This was a goofy kernel API where you could assign an icon_id (int) to
a process which referred to a global shbuf with a 16x16 icon bitmap
inside it.

Instead of this, programs that want to display a process icon now
retrieve it from the process executable instead.
2020-12-27 01:16:56 +01:00
Andreas Kling
cb68b8ff8b LibGUI: Use FileIconProvider in RunningProcessesModel
This was the last remaining client of the per-process icon_id.
2020-12-27 01:16:56 +01:00
Andreas Kling
21ccbc2167 Kernel: Expose process executable paths in /proc/all 2020-12-27 01:16:56 +01:00
Andreas Kling
3be9a9ac76 LibTLS: Fix TLS breakage after ByteBuffer => Span conversion
Oops, I accidentally shadowed the outer scope's "decrypted" ByteBuffer
which caused us to throw away the buffer too early.

Fixes #4533.
2020-12-26 16:09:02 +01:00
Andreas Kling
bdff88d8d5 LibGUI: Make the LinkLabel widget keyboard-friendly
Make it tab-focusable and activate it with the return key. :^)
2020-12-26 16:09:02 +01:00
Andreas Kling
7babe5ade6 LibGUI: Set LinkLabel tooltip if text can't fit the widget
We were setting a tooltip when the text overflowed the *window* width,
make this more general by basing it on the *widget* width.
2020-12-26 13:17:57 +01:00
Andreas Kling
4e084793df LibGUI: Tweak GUI::Label API a bit and add did_change_text() virtual 2020-12-26 13:11:43 +01:00
Andreas Kling
9fe310c470 LibGUI: Minor tweaks to the GUI::LinkLabel
Remove some unnecessary includes and make the constructor private.
2020-12-26 13:07:53 +01:00
Andreas Kling
5452c8a566 LibGUI: Rename Link => LinkLabel 2020-12-26 13:03:38 +01:00
Lenny Maiorani
b2316701a8 Everywhere: void arguments to C functions
Problem:
- C functions with no arguments require a single `void` in the argument list.

Solution:
- Put the `void` in the argument list of functions in C header files.
2020-12-26 10:10:27 +01:00
Sahan Fernando
b990fc5d3a LibC: Enable compiler warnings for scanf and strftime format strings 2020-12-26 10:05:50 +01:00
Sahan Fernando
d780e2265d LibC: Fix some incorrect printf usages 2020-12-26 10:05:50 +01:00
Sahan Fernando
6b01d1cf14 LibC: Enable compiler warnings for printf format strings 2020-12-26 10:05:50 +01:00
Linus Groh
d4a60583a9 LibDesktop: Remove icons from Desktop::Launcher::Details 2020-12-26 01:09:13 +01:00
Xavier Cooney
1cf92d39eb LibJS: Implement String.prototype.endsWith() 2020-12-26 01:09:04 +01:00
Xavier Cooney
43f948b357 LibJS: Implement IsRegExp abstract operation
This is needed by various String.prototype operations, as well as
the RegExp constructor.
2020-12-26 01:09:04 +01:00
Linus Groh
d8899ea65b WindowServer: Validate cursor type in SetWindowCursor message handler
Fixes #4536.
2020-12-25 23:07:06 +01:00
Andreas Kling
82f86e35d6 Kernel+LibC: Introduce a "dumpable" flag for processes
This new flag controls two things:
- Whether the kernel will generate core dumps for the process
- Whether the EUID:EGID should own the process's files in /proc

Processes are automatically made non-dumpable when their EUID or EGID is
changed, either via syscalls that specifically modify those ID's, or via
sys$execve(), when a set-uid or set-gid program is executed.

A process can change its own dumpable flag at any time by calling the
new sys$prctl(PR_SET_DUMPABLE) syscall.

Fixes #4504.
2020-12-25 19:35:55 +01:00
Andreas Kling
cb2c8f71f4 AK: Remove custom %b format string specifier
This was a non-standard specifier alias for %02x. This patch replaces
all uses of it with new-style formatting functions instead.
2020-12-25 17:04:28 +01:00
Andreas Kling
40e9edd798 LibELF: Move AuxiliaryValue into the ELF namespace 2020-12-25 14:48:30 +01:00
Andreas Kling
6c9a6bea1e Kernel+LibELF: Abort ELF executable load sooner when something fails
Make it possible to bail out of ELF::Image::for_each_program_header()
and then do exactly that if something goes wrong during executable
loading in the kernel.

Also make the errors we return slightly more nuanced than just ENOEXEC.
2020-12-25 14:42:42 +01:00