Commit graph

5823 commits

Author SHA1 Message Date
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
Andreas Kling
f1b1558c7b Everywhere: Tweak "2020-2020" => "2020" in copyright headers 2020-12-25 12:24:05 +01:00
Tyler Lanphear
aed5ec9314 LibC: Further stub out tcflow()
POSIX says we can set errno EINVAL and return -1 if the action is not
supported. This is better than crashing, and fixes bash crashing
whenever you press ^C.
2020-12-25 12:20:37 +01:00
Andreas Kling
1e4c010643 LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous
purpose was actually to load executables for the kernel, and that is
now handled by the kernel itself.

This patch includes some drive-by cleanup in LibDebug and CrashDaemon
enabled by the fact that we no longer need to keep the ref-counted
ELF::Loader around.
2020-12-25 02:14:56 +01:00
Andreas Kling
7551a66f73 Kernel+LibELF: Move sys$execve()'s loading logic from LibELF to Kernel
It was really weird that ELF loading was performed by the ELF::Loader
class instead of just being done by the kernel itself. This patch moves
all the layout logic from ELF::Loader over to sys$execve().

The kernel no longer cares about ELF::Loader and instead only uses an
ELF::Image as an interpreting wrapper around executables.
2020-12-25 01:22:55 +01:00
Andreas Kling
d7ad082afa Kernel+LibELF: Stop doing ELF symbolication in the kernel
Now that the CrashDaemon symbolicates crashes in userspace, let's take
this one step further and stop trying to symbolicate userspace programs
in the kernel at all.
2020-12-25 01:03:46 +01:00
Andreas Kling
edf01803cd LibGfx: Make all image decoders reject image sizes above 16384 pixels
Let's just say no to shenanigans by capping images at 16384 pixels both
wide and tall. If a day comes in the future where we need to handle
images larger than this, we can deal with it then.
2020-12-25 00:19:06 +01:00
Alex McGrath
9014d300ed LibGUI: Add a Link widget
This is a widget that can represent a link, its underlined and has an
onclick action
2020-12-24 21:52:02 +01:00
Itamar
bbedd320b5 Toolchain+LibC: Fix usage of crt files
We now configure the gcc spec files to use a different crt files for
static & PIE binaries.

This relieves us from the need to explicitly specify the desired crt0
file in cmake scripts.
2020-12-24 21:46:35 +01:00
Itamar
a83a9f3a55 Loader: Support loading non-position independent executables 2020-12-24 21:46:35 +01:00
Itamar
0cb636078a Kernel+LibELF: Allow Non ET_DYN executables to have an interpreter 2020-12-24 21:34:51 +01:00
Andreas Kling
79818bbf8e LibC: Unbreak assert.h when compiled with a C compiler :^) 2020-12-24 21:06:13 +01:00
Luke
200c7572b7 LibJS: Implement Object.prototype.propertyIsEnumerable
Spec: https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable

This is used by core-js, which is used by frameworks such as Vue.
2020-12-24 21:00:28 +01:00
Linus Groh
b53011a198 Terminal+LibVT: Use GUI::FileIconProvider for app icons 2020-12-24 20:50:30 +01:00
Andreas Kling
80ae407d73 LibGfx: Always compute the DIB mask shifts and sizes if needed
The pixel decoding logic later on assumes that if we have DIB masks,
we also have shifts and sizes, so we should make sure they are
always computed.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28237
2020-12-23 20:16:53 +01:00
Andreas Kling
cd046fae44 LibGfx: Fail JPEG decode instead of asserting on bogus start-of-scan
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28628
2020-12-23 19:22:15 +01:00
Andreas Kling
0fc8561029 LibGfx: Catch integer overflows in PNG decoder and fail the decode
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28134&sort=reported&q=serenity
2020-12-23 19:04:12 +01:00
Andreas Kling
491a5f5e34 LibGfx: Avoid a ByteBuffer heap allocation in PNG filtering 2020-12-23 18:06:25 +01:00
Andreas Kling
068615fe5e LibGfx: Reject PNG files with invalid filter/interlace methods
Might as well reject these when parsing the IHDR chunk instead of
continuing to load something invalid.
2020-12-23 15:45:59 +01:00
Andreas Kling
5f182746b6 LibCore: Stop logging that a Core::Socket has disconnected in receive()
This is perfectly normal and nothing we need to inform about.
2020-12-23 15:45:59 +01:00
Andreas Kling
75da835ffb LibDebug: Allow DWARF compilation unit header version <= 4
I think this is okay, the main thing to protect against is new versions
of the format that we don't know about yet.

This happens because an .S file compiled into libc.so has version 2
instead of version 4 like everything else.

Fixes #4491.
2020-12-23 00:53:27 +01:00
Érico Nogueira Rolim
a8f0e489a4
LibCore: Rename identifiers that can clash with libc macros (#4127)
POSIX allows the default streams (stdin, stdout and stderr) to be
macros, which means that on such systems (musl libc is one) building
Lagom will fail due to the File::std*() names.

Also fix any files that use these identifiers.
2020-12-22 23:37:11 +01:00
AnotherTest
7c8d35600c Spreadsheet: Override visit_edges() and visit stored JS objects
...and don't let them leak out of their evaluation contexts.
Also keep the exceptions separate from the actual values.
This greatly reduces the number of assertions hit while entering random
data into a sheet.
2020-12-22 23:35:29 +01:00
Brendan Coles
e8e8d3caf5 LibC: __generate_unique_filename(): Replace rand() with arc4random()
LibC stdlib `arc4random()` uses the `getrandom` system call which
uses `KernelRng::get_good_random_bytes`.

This ensures that filenames generated using functions such as
`mkstemp()` are suitably randomised and are no longer predictable.
2020-12-22 23:25:26 +01:00
Andreas Kling
531c3fe72e LibGfx: Fix OOB access in GIF deinterlacing
It was possible to go outside the interlacing row strid/offset arrays.
Just fail the decode if this is about to happen. I've added a FIXME
about rejecting such images earlier, since it's a bit sad to only do
this once we realize the pass index is about to overflow.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28239
2020-12-22 10:09:41 +01:00
Lenny Maiorani
a95d230a3e LibGfx: Commonize functions in P*MLoader class implementations
Problem:
- Functions are duplicated in [PBM,PGM,PPM]Loader class
  implementations. They are functionally equivalent. This does not
  follow the DRY (Don't Repeat Yourself) principle.

Solution:
- Factor out the common functions into a separate file.
- Refactor common code to generic functions.
- Change `PPM_DEBUG` macro to be `PORTABLE_IMAGE_LOADER_DEBUG` to work
  with all the supported types. This requires adding the image type to
  the debug log messages for easier debugging.
2020-12-22 09:24:12 +01:00
Andreas Kling
780c64e1f0 LibELF: Fix ELF::Image::symbol_count() asserting on section-less ELF
If we have no sections, we also have no symbols, so just return 0.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28683
2020-12-21 18:37:53 +01:00
Andreas Kling
ab549cf942 LibGUI+TextEditor+HackStudio: Add GML syntax highlighter :^) 2020-12-21 18:26:18 +01:00
Andreas Kling
3d3084f088 LibGUi: Rework GML parser into a lexer+parser
This will make it easier to add GML syntax highlighting. :^)
2020-12-21 18:26:18 +01:00
Tom
5f51d85184 Kernel: Improve time keeping and dramatically reduce interrupt load
This implements a number of changes related to time:
* If a HPET is present, it is now used only as a system timer, unless
  the Local APIC timer is used (in which case the HPET timer will not
  trigger any interrupts at all).
* If a HPET is present, the current time can now be as accurate as the
  chip can be, independently from the system timer. We now query the
  HPET main counter for the current time in CPU #0's system timer
  interrupt, and use that as a base line. If a high precision time is
  queried, that base line is used in combination with quering the HPET
  timer directly, which should give a much more accurate time stamp at
  the expense of more overhead. For faster time stamps, the more coarse
  value based on the last interrupt will be returned. This also means
  that any missed interrupts should not cause the time to drift.
* The default system interrupt rate is reduced to about 250 per second.
* Fix calculation of Thread CPU usage by using the amount of ticks they
  used rather than the number of times a context switch happened.
* Implement CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE and use it
  for most cases where precise timestamps are not needed.
2020-12-21 18:26:12 +01:00
Lenny Maiorani
58c52b155a LibGfx: Extraction of Streamer from P*MLoader
Problem:
- `Streamer` is the same in [PBM,PGM,PPM]Loader class implementations.

Solution:
- Extract it to its own header file to reduce maintenance burden.
- Implement `read` in terms of `read_bytes` to make the class "DRY".
- Decorate all functions with `constexpr`.
2020-12-21 09:58:27 +01:00
Andreas Kling
09e069bc0b LibGUI: Soft tab expansion should be based on insertion column
We were using the line length as the column, which worked as long as
you were at the end of the line, but not so well otherwise. :^)
2020-12-21 09:26:31 +01:00
Brian Gianforcaro
4f86893927 LibC: Add SCNu64 and SCNd64 macros for stress-g port 2020-12-21 00:19:45 +01:00
Alex McGrath
f1d7d864ae LibVT+Terminal: Add the option to disable the bell 2020-12-21 00:17:12 +01:00
William Marlow
d16eabed06 LibGUI: Get executable file icons from PNGs stored in ELF sections.
If an ELF application contains sections called "serenity_icon_s"
or "serenity_icon_m" then parse these as PNG images and use them
for the 16x16 and 32x32 executable file icons respectively.

If the application is not an ELF binary, the sections do not
exist, the sections are not valid PNGs, or the file cannot be read
then the default application icon will be used.
2020-12-21 00:12:59 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
c7d0c2ee7a LibGfx: Teach all image decoders to fail on bitmap allocation failure
We don't need to wait for oss-fuzz to find this for us. :^)
2020-12-20 16:04:29 +01:00
Andreas Kling
3e0b913e44 LibGfx: Fail PNG decode if output bitmap can't be allocated
Otherwise we'll assert soon afterwards.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28838
2020-12-20 15:24:50 +01:00
Andreas Kling
6e0976d858 LibGUI: Make the GML parser a bit more fault-tolerant
It will now fail and whine in the debug log instead of asserting.
2020-12-20 14:30:40 +01:00
Andreas Kling
64ba41ea13 LibGUI: Make GUI::Label auto-sizing declarative
You can now set the "autosize" property on a GUI::Label and it will
automatically update its width preference to fit the text.
2020-12-20 12:36:32 +01:00
Andreas Kling
de08e7b8c9 LibGUI: Rename ProgressBar property caption => text and expose to GML 2020-12-20 12:29:40 +01:00
Andreas Kling
48b0f4844b LibGUI: Add a couple more Widget registrations
Make it possible to instantiate BreadcrumbBar, ProgressBar and TreeView
from GML. :^)
2020-12-20 12:15:49 +01:00
Andreas Kling
822dc56ef3 LibGUI: Introduce GML - a simple GUI Markup Language :^)
This patch replaces the UI-from-JSON mechanism with a more
human-friendly DSL.

The current implementation simply converts the GML into a JSON object
that can be consumed by GUI::Widget::load_from_json(). The parser is
not very helpful if you make a mistake.

The language offers a very simple way to instantiate any registered
Core::Object class by simply saying @ClassName

@GUI::Label {
    text: "Hello friends!"
    tooltip: ":^)"
}

Layouts are Core::Objects and can be assigned to the "layout" property:

@GUI::Widget {
    layout: @GUI::VerticalBoxLayout {
        spacing: 2
        margins: [8, 8, 8, 8]
    }
}

And finally, child objects are simply nested within their parent:

@GUI::Widget {
    layout: @GUI::HorizontalBoxLayout {
    }
    @GUI::Button {
        text: "OK"
    }
    @GUI::Button {
        text: "Cancel"
    }
}

This feels a *lot* more pleasant to write than the JSON we had. The fact
that no new code was being written with the JSON mechanism was pretty
telling, so let's approach this with developer convenience in mind. :^)
2020-12-20 11:59:40 +01:00
Andreas Kling
18f1c49804 LibWeb: Don't leave "border" CSS property around after expansion
The "border" property is a shorthand that expands into multiple
longhand properties. We shouldn't leave it set in a StyleProperties
after expanding it.
2020-12-20 11:59:40 +01:00
Andreas Kling
b30acdb4b7 LibTLS+Userland: Remove all uses of ByteBuffer::slice_view()
This was another way to get a non-owning ByteBuffer wrapper.
2020-12-19 18:29:13 +01:00
Andreas Kling
d5600e966a LibTLS+LibCrypto: Remove all remaining uses of ByteBuffer::wrap() 2020-12-19 18:29:13 +01:00
Andreas Kling
a8dbfc3398 LibCrypto: Yet more ByteBuffer::wrap() removal. Not much left now! 2020-12-19 18:29:13 +01:00
Andreas Kling
497f1fd472 LibWeb: Don't use ByteBuffer::wrap() when loading about: URLs
Let's just copy an empty string here to make ourselves a ByteBuffer.
2020-12-19 18:29:13 +01:00
Andreas Kling
48d74c5356 LibHTTP: Make HTTPRequest::from_raw_request() take a ReadonlyBytes
This allows us to get rid of some ByteBuffer::wrap() usage.
2020-12-19 18:29:13 +01:00
Andreas Kling
e517505e35 LibTLS: Even more ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling
f82b0a78ef LibTLS+LibCrypto: More ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling
8e20208dd6 LibTLS+LibCrypto: Replace a whole bunch of ByteBuffers with Spans 2020-12-19 18:29:13 +01:00
Andreas Kling
7c94856c12 LibELF+LibDebug: Remove use of ByteBuffer::wrap() 2020-12-19 13:14:00 +01:00
Andreas Kling
685d5f4e25 LibProtocol: Remove use of ByteBuffer::wrap() in protocol API 2020-12-19 13:09:02 +01:00
Andreas Kling
77515fead2 LibGfx: Remove use of ByteBuffer::wrap() in BMP decoder 2020-12-19 13:05:48 +01:00
Andreas Kling
8cf6b75dd9 LibGfx: Remove use of ByteBuffer::wrap() in PNG decoder 2020-12-19 12:00:35 +01:00
Andreas Kling
0e4ecca336 LibIPC: Remove use of ByteBuffer::wrap()
ByteBuffer::wrap() was useful before we had Span. Let's see if we can't
get rid of some more ByteBuffer wrapping.
2020-12-19 11:30:02 +01:00
AnotherTest
5d1425718e LibLine: Treat leftover data in buffer as a read event
Fixes #4328.
2020-12-18 19:20:37 +01:00
AnotherTest
5e6b9cbc91 LibLine: Be less lazy when moving prompt origin row
Fixes the issue where adding multiple lines in one refresh cycle would
break cursor positioning.
2020-12-18 19:20:37 +01:00
Brendan Coles
27a5c51f3f LibCore: UDPServer::bind: Replace bind failure assert() with perror() 2020-12-18 19:20:30 +01:00
Linus Groh
fe88f46bc9 LibGUI: Don't assume main widget exists in Window::handle_resize_event()
Just like the other event handler functions, handle_resize_event()
shouldn't assume that the window has a main widget (which is being
resized in this case).

Fixes #4450.
2020-12-18 19:20:15 +01:00
Nico Weber
573d5b7ff2 LibGfx: Give Size and Rect * and *= operators 2020-12-18 17:35:30 +01:00
Nico Weber
b67eed5b80 LibGfx: Fix type of scale factor in Point scale operators 2020-12-18 17:35:30 +01:00
Sahan Fernando
8dc0d9b7b7 LibGUI: Make autoformatting performed on InsertTextCommand visible to on_edit_action 2020-12-18 16:25:42 +01:00
Andreas Kling
18f1f4e1a2 LibWeb: Only preserve full whitspace for white-space: pre{,-wrap} 2020-12-18 11:04:29 +01:00
Andreas Kling
b322452ef4 LibWeb: Silence BFC spam about not knowing how to place boxes
This gets way too noisy on some pages, and isn't even interesting.
2020-12-18 10:25:50 +01:00
Andreas Kling
6d7892cfc4 LibWeb: Whitespace that causes a line to wrap should be hidden
We were only pruning trailing whitespace on lines. This patch makes it
so we also don't add whitespace as the leading line box fragment on new
lines.

This logic is pretty crufty and I think we can do better, but for now
I've just made it handle this extra case so we can stop having lines
that start with a space character. :^)
2020-12-17 21:10:57 +01:00
Brendan Coles
853664bd3c LibC: stdlib: Add clearenv() function 2020-12-17 19:39:56 +01:00
Linus Groh
3436317c08 LibWeb: Escape text nodes in innerHTML getter 2020-12-17 19:39:48 +01:00
Linus Groh
4833f0066e LibWeb: Include element attributes in innerHTML getter 2020-12-17 19:39:48 +01:00
Andreas Kling
4c8dbc908c LibWeb: Notify the PageClient when the children of <title> change 2020-12-17 02:02:00 +01:00
Andreas Kling
2a5877b02c LibWeb: Fix shrink-to-fit layout for position:absolute
We were following the spec incorrectly. The comment was right, but the
code was wrong.
2020-12-17 01:47:42 +01:00
Andreas Kling
a5422a210f LibWeb: Use the correct containing block for position:absolute width 2020-12-17 01:46:51 +01:00
Andreas Kling
f0a4a6bb11 LibWeb: Always break around inline-blocks in AllPossibleLineBreaks mode 2020-12-17 01:42:03 +01:00
Andreas Kling
f35f605a24 LibWeb: Make sure the ICB is at least as tall as the viewport
This is a hack until we implement a proper overflow mechanism. For now,
this allows us to right-click below the lowest content on the page.
2020-12-17 00:58:23 +01:00
Andreas Kling
598efa60a3 LibGUI: Table views with SelectRows should scroll entire rows into view 2020-12-17 00:54:58 +01:00
Andreas Kling
f0138fcb25 LibGUI: Move selection behavior from TableView up to AbstractView
Let's make SelectionBehavior a view concept where views can either
select individual items (row, index) or whole rows. Maybe some day
we'll do whole columns, but I don't think we need that now.
2020-12-17 00:54:58 +01:00
Andreas Kling
226ac8a47b LibGUI: Don't fill IconView item text background unless actually wanted
We were always filling the rect behind item texts, even when the widget
had fill_with_background_color() == false.
2020-12-16 19:39:26 +01:00
Andreas Kling
4236127fb9 LibGUI: Make the IconView cursor rect show up on the desktop
It was getting lost in some bogus coordinate conversion math while
trying to constrain unusually long item texts.
2020-12-16 19:39:26 +01:00
Andreas Kling
50aab509ce LibGUI: Add ScrollableWidget helpers for rect conversion
to_content_rect() and to_widget_rect() help you convert rects from one
coordinate space to the other.
2020-12-16 19:39:26 +01:00
Conrad Pankoff
bb4e4921c0 LibCore: Expose some Socket properties to make then inspectable 2020-12-16 17:12:13 +01:00
Andreas Kling
525509cfe6 LibWeb: The fallback 'color' value should be black, not transparent
Fixes #4425.
2020-12-16 15:46:43 +01:00
Andreas Kling
2759d518b7 FileManager+LibGUI: Draw the item text for desktop icons with shadow
This makes it look nice regardless of wallpaper or background color.
2020-12-16 12:16:14 +01:00
Andreas Kling
0fef901513 LibGUI: Show app icons for executables with associated .af files
This is a rather ugly hack just to get app icons to show up in the
FileManager. It would be a lot nicer to embed icons in executables
instead but it's not obvious to me how to do that.
2020-12-16 12:08:55 +01:00
Andreas Kling
c44dbabda1 LibGUI: Generate nicer icons for symlinked files
Instead of symlinks showing up with the "filetype-symlink" icon, we now
generate a new icon by taking the target file's icon and slapping a
small arrow emblem on top of it.

This looks rather nice. :^)
2020-12-16 12:08:48 +01:00
Andreas Kling
3d5e30a1e6 LibGUI: Add GUI::Icon::sizes()
This gives you a Vector<int> with all the sizes contained in the Icon.
2020-12-16 11:53:23 +01:00
Andreas Kling
72bd672da0 LibWeb: Remove use of specified_style() in Layout::ImageBox 2020-12-15 20:50:58 +01:00
Andreas Kling
613764b83c LibWeb: Actually apply recomputed style to element's layout node
Otherwise fetching stuff via LayoutNode::style() will have stale values
since we were only updating the specified_style() here.

LayoutNode::specified_style() should eventually go away since there's
no need to carry those uncooked values around with the layout tree.
2020-12-15 20:49:11 +01:00
Andreas Kling
ef61430738 LibWeb: Update text-decoration hack to use text-decoration-line
We have a hack that propagates text-decoration-line through inheritance
even though it's not an inherited property. Once we implement the CSS
cascade properly we can stop doing this.
2020-12-15 20:48:16 +01:00
Andreas Kling
17c529e6c5 LibWeb: Generate the CSS::ValueID enum and its helper functions 2020-12-15 20:40:10 +01:00
Andreas Kling
92d8e559ba LibWeb: Oops, not all length boxes should default to 'auto' values
Only the offset box (left/top/right/bottom) box defaults to 'auto'.
Both the padding and margin boxes default to '0' for all values.
2020-12-15 20:01:00 +01:00
Andreas Kling
30685a7714 LibWeb: Add equals() for LengthStyleValue and ColorStyleValue
The default equals() does to_string() on both sides which is pretty
silly when they are of the same type.
2020-12-15 19:40:06 +01:00
Andreas Kling
58bade25dd LibWeb: Add hack to disable StyleInvalidator while parsing document
Running a StyleInvalidator for every attribute set in a new document
was making it impossible to load larger sites. :^)
2020-12-15 19:33:53 +01:00
Andreas Kling
23f70535e2 LibWeb: Dimension inline-block and replaced boxes during splitting
Don't wait until fragment layout to compute width/height of boxes on
the line, just do it while we're splitting into lines.
2020-12-15 19:33:53 +01:00
Andreas Kling
4a9dcd974a LibWeb: Remove unused Element::set_attributes() 2020-12-15 19:33:53 +01:00
Andreas Kling
9c76c4f0cf LibWeb: Use IdentifierStyleValue for CSS 'list-style-type' 2020-12-15 19:33:53 +01:00
Andreas Kling
c630ae517e LibWeb: Put final foreground/background colors in LayoutStyle
This way we don't have to look them up in the CSS::StyleProperties
every time we want to paint with them.
2020-12-15 19:33:53 +01:00
Andreas Kling
78a51933ad LibWeb: Use IdentifierStyleValue for CSS 'text-transform' 2020-12-15 19:33:53 +01:00
Andreas Kling
4d7ce81835 LibWeb: Use IdentifierStyleValue for CSS 'text-decoration-line'
Also 'text-decoration' is actually a shorthand, so treat it that way.
2020-12-15 19:33:53 +01:00
Andreas Kling
7e78e4b232 LibWeb: Make CSS "background: none" work again
This broke since "none" is now always going to be an identifier value.
2020-12-15 19:33:53 +01:00
Linus Groh
5e7945e26f LibWeb: Add a simple StyleInvalidator class
This patch adds a simple, naive & inefficient class for document-wide
style invalidation, e.g. after element attribute updates. During
construction it collects a HashMap of a document's elements and their
matching rules, during destruction it does the same and then compares
the results; dirtying all elements that have a different number or order
of matching rules afterwards.

Much room for improvement, but it solves the problem of stale element
styling after attribute updates for now :^)

Fixes #4404.
2020-12-14 23:38:08 +01:00
Itamar
9a9d655abe Chess: Add LibCore as a dependency
This fixes Dynamic Loader crash because of an unresolved LibCore symbol
2020-12-14 23:05:53 +01:00
Itamar
93b68f5566 LibELF: Move the implementation of find_demangled_function to ELF::Image 2020-12-14 23:05:53 +01:00
Itamar
0220b5361e LibC: Also build a static version of libc 2020-12-14 23:05:53 +01:00
Itamar
dfdd977a82 LibC: Link statically with libstdc++
This allows us to have the implementation of __cxa_demangle in libc.so.
2020-12-14 23:05:53 +01:00
Itamar
a74dad14a8 LibCoreDump: Add library for parsing coredump files 2020-12-14 23:05:53 +01:00
Itamar
50219429fd LibELF: Allow using ELF::Loader for ET_CORE objects 2020-12-14 23:05:53 +01:00
Itamar
5a2e68d699 LibELF: Temporarily disable name demangling
Demangling is currently not supported with shared libraries, but we will fix this soon :)
2020-12-14 23:05:53 +01:00
Itamar
349c6780ce LibELF: Refactor coredump notes section structures 2020-12-14 23:05:53 +01:00
Itamar
0b0c09e647 LibCore: Add DirectoryWatcher
DirectoryWatcher is a wrapper around watch_file, and can be used to
watch for changes in directories.
2020-12-14 23:05:53 +01:00
Itamar
b4842d33bb Kernel: Generate a coredump file when a process crashes
When a process crashes, we generate a coredump file and write it in
/tmp/coredumps/.

The coredump file is an ELF file of type ET_CORE.
It contains a segment for every userspace memory region of the process,
and an additional PT_NOTE segment that contains the registers state for
each thread, and a additional data about memory regions
(e.g their name).
2020-12-14 23:05:53 +01:00
Itamar
efe4da57df Loader: Stabilize loader & Use shared libraries everywhere :^)
The dynamic loader is now stable enough to be used everywhere in the
system - so this commit does just that.
No More .a Files, Long Live .so's!
2020-12-14 23:05:53 +01:00
Itamar
58c583f584 LibC: Add libc.so
We now compile everything with -static flag so libc.a would be use
2020-12-14 23:05:53 +01:00
Itamar
09ccdc697b Demos: Add "DynamicObjectDemo" to demo the dynamic loader 2020-12-14 23:05:53 +01:00