Commit graph

23955 commits

Author SHA1 Message Date
Tim Schumacher
ad31265e60 LibCompress: Implement block size validation for XZ streams 2023-04-01 13:57:54 +02:00
Tim Schumacher
20f1a29202 LibCompress: Factor out the list of XZ check sizes 2023-04-01 13:57:54 +02:00
Nico Weber
bc70d7bb77 LibCompress: Reduce indentation in CompressedBlock::try_read_more()
...by removing `else` after `return`.

No behavior change.
2023-04-01 13:57:39 +02:00
Andreas Kling
bc6e61adec LibWeb: Don't churn HTML::EventLoop while in microtask checkpoint
At the end of HTML::EventLoop::process(), the loop reschedules itself if
there are more runnable tasks available.

However, the condition was flawed: we would reschedule if there were any
microtasks queued, but those tasks will not be processed if we're
currently within the scope of a microtask checkpoint.

To fix this, we now only reschedule the HTML event loop for microtask
processing *if* we're not already in a microtask checkpoint.

This fixes the 100% CPU churn seen when looking at PRs on GitHub. :^)
2023-04-01 12:45:47 +01:00
Tim Ledbetter
37bbd20cee LibCore: Remove colons from markdown header names in ArgsParser
This makes formatting more consistent across man pages.
2023-04-01 11:49:57 +01:00
Timothy Flynn
da6f32e5d8 gzip: Use utilities from LibCompress to (de)compress files 2023-04-01 08:15:49 +02:00
Timothy Flynn
7ec91dfde7 LibCompress: Add a utility to GZIP compress an entire file
This is copy-pasted from the gzip utility, along with its existing TODO.
This is currently only needed by that utility, but this gives us API
symmetry with GzipDecompressor, and helps ensure we won't end up in a
situation where only one utility receives optimizations that should be
received by all interested parties.
2023-04-01 08:15:49 +02:00
Timothy Flynn
857f559a06 gunzip+LibCompress: Move utility to decompress files to GzipDecompressor
This is to allow re-using this method (and any optimization it receives)
by other utilities, like gzip.
2023-04-01 08:15:49 +02:00
MacDue
df577b457a Browser: Add tooltip to reset zoom level button 2023-03-31 21:46:56 +01:00
sbcohen2000
9e21b3f216 KeyboardSettings: Add checkbox to enable Caps Lock mapping to Ctrl
This patch adds an additional control to KeyboardSettings allowing
the user to map Caps Lock to Ctrl. Previously, this was only possible
by writing to /sys/kernel/variables/caps_lock_to_ctrl.

Writing to /sys/kernel/variables/caps_lock_to_ctrl requires root
privileges, but KeyboardSettings will not attempt to elevate
the privilege of the user if they are not root. Instead, the
checkbox is rendered as un-editable.
2023-03-31 12:45:21 -04:00
Nico Weber
c3b8b3124c LibCompress: Remove two needless heap allocations 2023-03-31 08:44:30 -06:00
Sam Atkins
88d64fcb55 LibWeb: Add HTMLAnchorElement.referrerPolicy property 2023-03-31 11:36:41 +01:00
Sam Atkins
0c19d3aa58 LibWeb: Add HTMLAnchorElement.text getter and setter
And a FIXME for the missing `referrerPolicy` property.
2023-03-31 11:36:41 +01:00
Sam Atkins
888efe367e LibWeb: Add "CEReactions" to HTMLAnchorElement IDL as in spec 2023-03-31 11:36:41 +01:00
Sam Atkins
0761926127 HackStudio: Migrate git-diff indicators to TextEditor API
As part of this, the CodeDocument now keeps track of the kind of
difference for each line. Previously, we iterated every hunk every time
the editor was painted, but now we do that once whenever the diff
changes, and then save the type of difference for each line.
2023-03-31 12:09:40 +02:00
Sam Atkins
620bf45f43 HackStudio: Migrate execution-position indicator to TextEditor API 2023-03-31 12:09:40 +02:00
Sam Atkins
99221a436e HackStudio: Migrate breakpoint indicators to TextEditor API 2023-03-31 12:09:40 +02:00
Sam Atkins
4b29702fee LibGUI: Add gutter indicators to TextEditor :^)
HackStudio's Editor has displayed indicators in its gutter for a long
time, but each required manual code to paint them in the right place
and respond to click events. All indicators on a line would be painted
in the same location. If any other applications wanted to have gutter
indicators, they would also need to manually implement the same code.

This commit adds an API to GUI::TextEditor so it deals with these
indicators. It makes sure that multiple indicators on the same line
each have their own area to paint in, and provides a callback for when
one is clicked.

- `register_gutter_indicator()` should be called early on. It returns a
  `GutterIndicatorID` that is then used by the other methods.
  Indicators on a line are painted from right to left, in the order
  they were registered.
- `add_gutter_indicator()` and `remove_gutter_indicator()` add the
  indicator to the given line.
- `clear_gutter_indicators()` removes a given indicator from every line.
- The `on_gutter_click` callback is called whenever the user clicks on
  the gutter, but *not* on an indicator.
2023-03-31 12:09:40 +02:00
Sam Atkins
ce9b9a4f20 LibGUI: Rename TextEditor::LineVisualData -> LineData
This is going to hold other per-line data too.
2023-03-31 12:09:40 +02:00
Sam Atkins
03571b1fa9 LibGUI: Extract repeated code for populating TextEditor per-line data 2023-03-31 12:09:40 +02:00
Liav A
ba43ee4046 CrashReporter: Warn about malloc and free patterns in fault address
Warn the user about seemingly known malloc() and free() patterns in the
fault address.
This brings back the functionality that was removed recently in the
5416a37fde commit, but this time we detect
these patterns in userspace code and not in kernel code.
2023-03-31 12:09:06 +02:00
Pankaj Raghav
14e75ed721 disk_benchmark: Remove the call to umask
Calling umask and open with same permission value will result in a file
with no permissions bits if the program is stopped while it is doing an
IO. This will result in an error with EACCES when we try to run the
benchmark with the same file name. The file needs to be manually
removed before continuing the benchmark.

There is no use in calling umask here, so just remove it so that
interrupting the program while it is doing an IO will not result int the
file with no permissions the next time we run the program.
2023-03-31 09:43:00 +02:00
Timothy Flynn
8b56d82865 AK+LibCompress: Remove the Deflate back-reference intermediate buffer
Instead of reading bytes from the output stream into a buffer, just to
immediately write them back out, we can skip the middle-man and copy the
bytes directly into the output buffer.
2023-03-31 06:56:11 +02:00
Timothy Flynn
9f238793e0 gunzip+LibCompress: Increase buffer sizes used by Deflate and gunzip
Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-03-31 06:56:11 +02:00
Timothy Flynn
62b575ad7c LibCrypto: Implement little endian CRC using the slicing-by-8 algorithm
This implements Intel's slicing-by-8 algorithm for CRC checksums (only
little endian CPUs for now, as I don't have a way to test big endian).

The original paper for this algorithm seems to have disappeared, but
Intel's source code is still available as a reference:

    https://sourceforge.net/projects/slicing-by-8/

As well as other implementations for reference:

    https://docs.rs/slice-by-8/latest/src/slice_by_8/algorithm.rs.html

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), decompression
time decreases from:

    4.89s to 3.52s on Serenity (cold)
    1.72s to 1.32s on Serenity (warm)
    1.06s to 0.92s on Linux
2023-03-31 06:56:05 +02:00
Ali Mohammad Pur
83cb73a045 LibCore: Don't assume ArgsParser arguments are non-empty
This was fine before as the last entry was a null string (which could be
printed), but we no longer use C-style sentinel-terminated arrays for
arguments.
2023-03-31 06:55:46 +02:00
Ali Mohammad Pur
1173adb90a Shell: Don't require ArgsParser values to be null-terminated 2023-03-31 06:55:46 +02:00
Sam Atkins
1280d70d74 LibWeb: Split CalculatedStyleValue out of StyleValue.{h,cpp} 2023-03-30 21:29:50 +02:00
Sam Atkins
0c14103025 LibWeb: Move PercentageOr and subclasses into PercentageOr.{h,cpp}
This solves an awkward dependency cycle, where CalculatedStyleValue
needs the definition of Percentage, but including that would also pull
in PercentageOr, which in turn needs CalculatedStyleValue.

Many places that previously included StyleValue.h no longer need to. :^)
2023-03-30 21:29:50 +02:00
Sam Atkins
16e3a86393 LibWeb: Make absolutized_length() helper a Length method
There were a mix of users between those who want to know if the Length
changed, and those that just want an absolute Length. So, we now have
two methods: Length::absolutize() returns an empty Optional if nothing
changed, and Length::absolutized() always returns a value.
2023-03-30 21:29:50 +02:00
Sam Atkins
7d29262b8b LibWeb: Move to_gfx_scaling_mode() helper
There's no longer any reason to have this in StyleValue.h
2023-03-30 21:29:50 +02:00
Sam Atkins
d64ddeaec4 LibWeb: Move PositionValue into its own files
It's in Position.{h,cpp} because it represents a <position> in CSS, even
though it's currently named PositionValue to avoid collisions.
2023-03-30 21:29:50 +02:00
Sam Atkins
bcebca62d3 LibWeb: Move CSS::EdgeRect into its own files
Also remove the unused StyleValue::to_rect() because an EdgeRect is only
ever held by a RectStyleValue.
2023-03-30 21:29:50 +02:00
Sam Atkins
b3a7a00ccf LibWeb: Move BackgroundSize enum to ComputedValues.h
Again, this doesn't belong in StyleValue.h, though this may not be the
ideal place for it either.
2023-03-30 21:29:50 +02:00
Sam Atkins
c4afa79fed LibWeb: Move FlexBasis enum to ComputedValues.h
This may not be the ideal place for this, but it definitely doesn't
belong in StyleValue.h
2023-03-30 21:29:50 +02:00
Sam Atkins
53a4a31af2 LibWeb: Remove CalculatedStyleValue from Length 2023-03-30 21:29:50 +02:00
Sam Atkins
62a8cf2bb8 LibWeb: Let CSS::Size contain a CalculatedStyleValue
Technically this was already true, but now we explicitly allow it
instead of that calc value being hidden inside a Length or Percentage.
2023-03-30 21:29:50 +02:00
Sam Atkins
ac4350748e LibWeb: Remove CalculatedStyleValue from Time
Time also isn't used anywhere yet, hooray!
2023-03-30 21:29:50 +02:00
Sam Atkins
bf915fdfd7 LibWeb: Remove CalculatedStyleValue from Frequency
Conveniently, we don't actually use Frequency for any properties.
2023-03-30 21:29:50 +02:00
Sam Atkins
7a1a97f153 LibWeb: Remove CalculatedStyleValue from Angle
...and replace it with AngleOrCalculated.

This has the nice bonus effect of actually handling `calc()` for angles
in a transform function. :^) (Previously we just would have asserted.)
2023-03-30 21:29:50 +02:00
Sam Atkins
fa90a3bb4f LibWeb: Introduce CalculatedOr type
This is intended as a replacement for Length and friends each holding a
`RefPtr<CalculatedStyleValue>`. Instead, let's make the types explicit
about whether they are calculated or not. This then means a Length is
always a Length, and won't require including `StyleValue.h`.

As noted, it's probably nicer for LengthOrCalculated to live in
`Length.h`, but we can't do that until Length stops including
`StyleValue.h`.
2023-03-30 21:29:50 +02:00
Andreas Kling
b727f8113f LibJS: Add fast path to Value::to_u32() if Value is a positive i32
6.6% speed-up on Kraken's stanford-crypto-aes subtest. :^)
2023-03-30 19:13:35 +01:00
Andreas Kling
45f8542965 LibWeb: Actually visit rules and media queries in imported style sheets
Due to CSSImportRule::has_import_result() being backwards, we never
actually entered imported style sheets when traversing style rules or
media queries.

With this fixed, we no longer need the "collect style sheets" step in
StyleComputer, as normal for_each_effective_style_rule() will now
actually find all the rules. :^)
2023-03-30 16:54:15 +02:00
Tim Schumacher
fe761a4e9b LibCompress: Use LZMA context from preexisting dictionary 2023-03-30 14:39:31 +02:00
Tim Schumacher
c020ee8bfa LibCompress: Avoid overflowing the size of uncompressed LZMA2 chunks 2023-03-30 14:39:31 +02:00
Tim Schumacher
023c64011c LibCompress: Use the correct LZMA repetition offset in all cases 2023-03-30 14:39:31 +02:00
Tim Schumacher
9ccb0fc1d8 LibCompress: Only require new LZMA2 properties after dictionary reset 2023-03-30 14:39:31 +02:00
Tim Schumacher
d9627503a9 LibCompress: Reduce repeated code in the LZMA decompressor 2023-03-30 14:39:31 +02:00
Tim Schumacher
726963edc7 LibCompress: Implement support for multiple concatenated XZ streams 2023-03-30 14:38:47 +02:00
Tim Schumacher
00332c9b7d LibCompress: Move XZ header validation into the read function
The constructor is now only concerned with creating the required
streams, which means that it no longer fails for XZ streams with
invalid headers. Instead, everything is parsed and validated during the
first read, preparing us for files with multiple streams.
2023-03-30 14:38:47 +02:00