Commit graph

14528 commits

Author SHA1 Message Date
Andreas Kling
d6c2a61fa1 LibWeb: Add type casting helpers for Layout::InlineNode 2020-12-03 21:45:38 +01:00
Andreas Kling
17e9a5e0c5 LibWeb: Hoist an early return in Layout::BlockBox::paint() 2020-12-03 17:17:11 +01:00
Andreas Kling
194d7d3471 LibWeb: Hack the CSS parser to handle integer values (like z-index)
We were rejecting perfectly valid z-index values like '1000' since we
were passing all CSS values through the length parser and unit-less
lengths are not valid in this context.

It's yet another hack for the ad-hoc CSS parser (its days are numbered)
but this makes the top header links on google.com actually work. :^)
2020-12-03 11:46:10 +01:00
AnotherTest
62bd1adb06 Shell: Replace one more user-controlled assert with a syntax error
test-case: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28114&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
AnotherTest
9d9347cd5a Shell: Fix bad cast to BarewordLiteral
As found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28109&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
AnotherTest
c1c5225b72 LibRegex: Fix assertion when parsing '(?'
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28186&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
Andreas Kling
4fe987ba00 LibWeb: Don't layout twice for every InProcessWebView resize event
Calling Frame::set_size() already triggered a relayout, so calling
layout() again right after meant we did all the work one more time.

Not being dumb like this makes resizing significantly smoother. :^)
2020-12-02 23:50:19 +01:00
Andreas Kling
15e35b0d71 LibWeb: Layout viewport rect was lagging behind when resizing
Layout was using an outdated viewport rect that we set *after* doing
a layout due to resize. That meant that layout-in-response-to-resize
was always lagging behind the current size of the view.

The root of this problem was how Frame kept both a viewport rect
(with both scroll offset and size) and a frame size. To fix this,
only store the viewport scroll offset, and always use the frame size.
This way they can't get out of sync and the problem goes away. :^)

Fixes #4250.
2020-12-02 23:50:19 +01:00
Tom
766db673c1 Kernel: Flush TLBs concurrently
Instead of flushing the TLB on the current processor first and then
notifying the other processors to do the same, notify the others
first, and while waiting on the others flush our own.
2020-12-02 23:49:52 +01:00
John Brehm
6914cf830d
Games: Added level select and aditional level to Breakout (#4302)
Added a level select menu which is shown when the game start where
either of the 2 available levels may be selected.
2020-12-02 23:49:42 +01:00
Linus Groh
cc5be96724 LibJS: Use ArrayBuffer for typed array data
This is how the spec describes it, and it allows sharing data between
multiple typed arrays.
Typed arrays now support constructing from an existing ArrayBuffer,
and has been prepared for constructing from another typed array or
iterator as well.
2020-12-02 23:49:00 +01:00
Linus Groh
32571dfa53 LibJS: Add ArrayBuffer 2020-12-02 23:49:00 +01:00
Linus Groh
cf9da66b3e LibJS: Use Value::to_index() in typed array constructors 2020-12-02 23:49:00 +01:00
Linus Groh
eaa85969c4 LibJS: Add Value::to_{index,length,integer_or_infinity} abstract operations
We should pay more attention to using the well-defined abstract
operations from the spec rather than making up our own, often slightly
different rules. This is another step in that direction.
2020-12-02 23:49:00 +01:00
Linus Groh
6de4f1fcb3 LibJS: Add generic InvalidLength error type
We have multiple array types now, so ArrayInvalidLength has been
replaced with a generic InvalidLength.

Also fixes a small issue in the Array constructor, it should throw
RangeError for invalid lengths, not TypeError.
2020-12-02 23:49:00 +01:00
Tom
5e08ae4e14 Kernel: Fix counting interrupts
Move counting interrupts out of the handle_interrupt method so that
it is done in all cases without the interrupt handler having to
implement it explicitly.

Also make the counter an atomic value as e.g. the LocalAPIC interrupts
may be triggered on multiple processors simultaneously.

Fixes #4297
2020-12-02 23:19:59 +01:00
Ben Wiederhake
aec8983819 LibGfx: Accept BMP RLE of 255 repeated bytes
Previously, in the case of RLE4, parsing took suspiciously long.
What happened was that 'pixel_count' was 255, and 'i' was incremented
by *two* in each iteration, so the for-loop continued until the
entire output buffer was full, and then rejected the RLE data
as bogus.

This little diff allows pixel_count to reach 256, be greater than
pixel_count, and thus terminate the loop in the intended way.
2020-12-02 22:51:05 +01:00
Julian Offenhäuser
21977a2188 LibAudio: Allow loading sounds from memory
The Loader and WavLoaderPlugin classes now have methods for loading
from a ByteBuffer, in addition to streaming from disk.
2020-12-02 16:31:30 +01:00
Julian Offenhäuser
dff5983706 LibAudio: Move Audio::Buffer implementation into its own file 2020-12-02 16:31:30 +01:00
Julian Offenhäuser
bad8cd3d8f Applications+Userland: Switch to new Audio::Loader API 2020-12-02 16:31:30 +01:00
Julian Offenhäuser
1f47b01e3b LibAudio: Add generic Audio::Loader class
The Audio::Loader class is able to load different types of audio files
by using a generic plugin interface for all file formats. Every new
loader will have to derive from Audio::LoaderPlugin to provide a common
API.

This makes it easy to add support for more audio file formats in the future.
2020-12-02 16:31:30 +01:00
Linus Groh
0b086c759a LibJS: Move TypedArray length getter to prototype 2020-12-02 14:39:53 +01:00
Tom
12cf6f8650 Kernel: Add CLOCK_REALTIME support to the TimerQueue
This allows us to use blocking timeouts with either monotonic or
real time for all blockers. Which means that clock_nanosleep()
now also supports CLOCK_REALTIME.

Also, switch alarm() to use CLOCK_REALTIME as per specification.
2020-12-02 13:02:04 +01:00
Tom
4c1e27ec65 Kernel: Use TimerQueue for SIGALRM 2020-12-02 13:02:04 +01:00
Tom
601a688b6f Kernel: TimerQueue::cancel_timer needs to wait if timer is executing
We need to be able to guarantee that a timer won't be executing after
TimerQueue::cancel_timer returns. In the case of multiple processors
this means that we may need to wait while the timer handler finishes
execution on another core.

This also fixes a problem in Thread::block and Thread::wait_on where
theoretically the timer could execute after the function returned
and the Thread disappeared.
2020-12-02 13:02:04 +01:00
Tom
c6230b746d AK: Add insert_before/insert_after to InlineLinkedList 2020-12-02 13:02:04 +01:00
Luke
9a2a673e51 SystemMonitor: Add Interrupts tab
I was looking through the proc folder, noticed this and thought
"why not?"

It's setup as an updating model because of the call count, however,
the call count doesn't appear to be working right now.
2020-12-02 12:57:38 +01:00
Tom
f68115aba3 Taskbar: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:25 +01:00
Tom
d6174f9c79 SystemServer: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

This fixes random zombie processes sticking around after e.g. closing
Browser.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:15 +01:00
Linus Groh
ddaab598a7 LibJS: Add TypedArray.BYTES_PER_ELEMENT 2020-12-02 12:52:31 +01:00
Linus Groh
bb6bc70c5b LibJS: Add more tests for TypedArray 2020-12-02 12:52:31 +01:00
Linus Groh
3d05836a3e LibJS: Make TypedArray constructor (somewhat) spec-compliant
- Calling without 'new' is an error
- If the first argument is an object, we need a separate code path to
  initialize from TypedArray, ArrayBuffer, Iterable or Array-like
  object (marked TODO for now)
- Don't insert values into array if more than one argument is present
  (that's not part of the spec)
2020-12-02 12:52:31 +01:00
Linus Groh
1bff65c591 LibJS: Add ErrorType::ConstructorWithoutNew
...and use it in Proxy::call(), rather than having a specific error
type just for that.
2020-12-02 12:52:31 +01:00
Linus Groh
7fb299fe46 LibJS: Clean up TypedArray constructors and prototypes
The current implementation is not entirely correct yet. Two classes have
been added:
- TypedArrayConstructor, which the various typed array constructors now
  inherit from. Calling or constructing this class (from JS, that is)
  directly is not possible, we might want to move this abstract class
  functionality to NativeFunction at a later point.
- TypedArrayPrototype, which the various typed array prototypes now have
  as their own prototype. This will be the place where most of the
  functionality is being shared.

Relevant parts from the spec:

22.2.1 The %TypedArray% Intrinsic Object
The %TypedArray% intrinsic object:
- is a constructor function object that all of the TypedArray
  constructor objects inherit from.
- along with its corresponding prototype object, provides common
  properties that are inherited by all TypedArray constructors and their
  instances.

22.2.2 Properties of the %TypedArray% Intrinsic Object
The %TypedArray% intrinsic object:
- has a [[Prototype]] internal slot whose value is %Function.prototype%.

22.2.2.3 %TypedArray%.prototype
The initial value of %TypedArray%.prototype is the %TypedArray%
prototype object.

22.2.6 Properties of the TypedArray Constructors
Each TypedArray constructor:
- has a [[Prototype]] internal slot whose value is %TypedArray%.

22.2.6.2 TypedArray.prototype
The initial value of TypedArray.prototype is the corresponding
TypedArray prototype intrinsic object (22.2.7).

22.2.7 Properties of the TypedArray Prototype Objects
Each TypedArray prototype object:
- has a [[Prototype]] internal slot whose value is %TypedArray.prototype%.

22.2.7.2 TypedArray.prototype.constructor
The initial value of a TypedArray.prototype.constructor is the
corresponding %TypedArray% intrinsic object.
2020-12-02 12:52:31 +01:00
Ben Wiederhake
453c63fd04 LibGfx+BMP: Remove set_remaining, fix size check
The set_remaining method is inherently dangerous. It can be avoided easily here,
so let's do that.
2020-12-02 10:46:40 +01:00
Ben Wiederhake
36daeee34f LibGfx: Fix BMP mask detection off-by-one
Also, since the loops can be replaced by a little bit-twiddling,
call ctz() directly. This might be a bit faster, or it might not.
2020-12-02 10:46:40 +01:00
Ben Wiederhake
6be9b6349d LibGfx: Prevent potential heap-overflow in BMP non-RLE 2020-12-02 10:46:40 +01:00
Ben Wiederhake
461bdeda2b LibGfx: Fix heap-overflow in BMP RLE
The field previously named 'data_size' apparently was misunderstood.
2020-12-02 10:46:40 +01:00
Ben Wiederhake
d66b0683eb LibGfx: Distinguish between RGB data and file data
This was confusing and has hidden a bug, so let's change it.
2020-12-02 10:46:40 +01:00
Ben Wiederhake
9ff001c4d3 LibGfx: Avoid ByteBuffer assertions for huge bitmaps 2020-12-02 10:46:40 +01:00
Ben Wiederhake
d6c0776b45 LibGfx: Reject OS/2 BMP files with invalid bpp values 2020-12-02 10:46:40 +01:00
Ben Wiederhake
bd6d365166 LibGfx: Disallow RLE8 compression for 16bpp BMPs
Also, disallow similar silly combinations. Technically, we support *more* than
the definition seems to require.

For future reference:
https://archive.org/details/mac_Graphics_File_Formats_Second_Edition_1996/page/n607/mode/2up
Book page 580 (pdf page 608)
2020-12-02 10:46:40 +01:00
Ben Wiederhake
e3e2eecc33 LibGfx: Fix BMP compression checks
- OSv2 DIBs were not checked at all
- Regular Info DIBs had the compression checked after applying a 0xFF mask,
  which let many invalid compression values pass.
- There may still be a separate latent bug that causes mask_sizes and mask_shifts to be empty.
2020-12-02 10:46:40 +01:00
Ben Wiederhake
031814796e LibGfx: Recognize incomplete BMP colormaps 2020-12-02 10:46:40 +01:00
Ben Wiederhake
a4b207e04f LibGfx: Mark static method as static 2020-12-02 10:46:40 +01:00
Ben Wiederhake
4b4f23165f Meta+LibHTTP: Fuzz HTTP request parsing 2020-12-02 10:46:40 +01:00
xspager
57c9f77921 LibC: Add flag SO_BROADCAST so we can at least build programs that use it 2020-12-02 10:45:38 +01:00
Nico Weber
a1d3f9e81e
CI: Use Ninja for building (#4293)
Makes watching build output on Actions on PRs slightly more pleasant.
2020-12-02 10:45:16 +01:00
AnotherTest
d1a5b4d906 LibWeb: Complete the URL in href_setter() before trying to load it
Also note that setting an invalid URL here should raise a JS exception
(and not navigate away).
Fixes #4301.
2020-12-02 10:08:29 +01:00
Andreas Kling
3565d3c60c LibJS: Add six typed arrays (signed and unsigned 8/16/32-bit)
This patch adds six of the standard type arrays and tries to share as
much code as possible:

- Uint8Array
- Uint16Array
- Uint32Array
- Int8Array
- Int16Array
- Int32Array
2020-12-01 21:05:25 +01:00