Commit graph

17824 commits

Author SHA1 Message Date
Andreas Kling ea81dc13cf AK: Move move() into the "std" namespace
This makes GCC emit warnings about redundant and pessimizing moves.
It also allows static analyzers like clang-tidy to detect common bugs
like use-after-move.
2021-03-17 16:31:17 +01:00
Andreas Kling f59ad2dc57 Everywhere: Remove pessimizing and redundant move() 2021-03-17 16:30:15 +01:00
Brendan Coles fa28cc85e6 AK: Tests: TestURL: Add port_int_overflow_wrap test 2021-03-17 12:39:03 +01:00
Linus Groh 10843a2c8c QuickShow: Animate animated images :^)
With a little help (read: copy & paste) from ImageWidget, QuickShow will
now cycle through the frames of animated images - enjoy the cat GIFs!

Future improvement: cache decoded images like LibWeb's ImageResource to
waste less CPU - the same applies to LibGUI though, maybe we can put
something shared in LibGfx.

Closes #5837.
2021-03-17 12:37:48 +01:00
Linus Groh 41e5155467 LibGUI: Animate any image in ImageWidget, not just *.gif
The image decoder already tells us whether the image is animated and it
can provide more than one frame, let's not put this behind an artificial
"file path must end with lowercase .gif" barrier.
2021-03-17 12:37:48 +01:00
Oleg Sikorskiy 961137ea4c LibGfx: Don't truncate macroblock indices in JPG decoder. 2021-03-16 22:17:15 +01:00
Linus Groh 47645fc976 LibJS: Ensure SequenceExpression has two or more expressions
Just a sanity check, as we should be able to make this assumption
elsewhere - this way we can catch silly mistakes early.
2021-03-16 22:12:56 +01:00
Linus Groh 88a3267e46 LibJS: Replace global_object.global_object() with just global_object
That's just silly...
2021-03-16 22:12:56 +01:00
Linus Groh 4f36b6bfbd LibJS: Only set receiver value fallback once in Object::get() 2021-03-16 22:12:56 +01:00
Idan Horowitz 8533cceed5 LibCompress: Fail gracefuly on missing huffman codes in DeflateDecompressor 2021-03-16 21:57:44 +01:00
Idan Horowitz be5a8d9c7f LibCompress: Check and fail for input stream errors in DeflateDecompressor
Since we were not checking for error flags set by read_bits we would
just always read 0 as the bits' value, which in some edge cases could
lead to an infinite loop.
2021-03-16 21:57:44 +01:00
Brendan Coles 46c7f52896 UserspaceEmulator: Add symlink, rename, set_coredump_metadata syscalls 2021-03-16 21:57:13 +01:00
thatdutchguy 569d6d47fe Kernel: sysconf(_SC_CLK_TCK): Use TimeManagement::ticks_per_second() 2021-03-16 21:56:47 +01:00
thatdutchguy 10e3e8f6d4 Kernel: Add _SC_CLK_TCK to sysconf.
Unbreaks the hatari port.
2021-03-16 21:56:47 +01:00
Linus Groh fa6bce5087 LibJS: Throw RangeError on BigInt exponentiation with negative exponent
https://tc39.es/ecma262/#sec-numeric-types-bigint-exponentiate
2021-03-16 21:54:51 +01:00
Linus Groh 11138f5c1f LibJS: Throw RangeError on BigInt division/modulo by zero
https://tc39.es/ecma262/#sec-numeric-types-bigint-divide
https://tc39.es/ecma262/#sec-numeric-types-bigint-remainder
2021-03-16 21:54:51 +01:00
Idan Horowitz 1d8ab74cbf LibCompress: Allow partial header reads in GzipDecompressor
We now read the header into a temporary header byte array that is used
as the header once its filled up by the input stream, instead of just
ending the stream if we are out of bytes mid header.
2021-03-16 21:53:34 +01:00
Dan MacDonald 3dfa3d2d9d
Ports: Add Hatari Atari ST/STE/TT/Falcon emulator (#5812) 2021-03-16 21:53:13 +01:00
Idan Horowitz 211031e4f4 LibGfx: Fail gracefuly on invalid interlace method in PNGLoader
This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29791
2021-03-16 21:52:05 +01:00
AnotherTest 80d21f120f LibLine: Make the DSR response parser a bit more robust
At the cost of using more read() syscalls, process the DSR response
character-by-character.
This avoids blocking forever waiting for an 'R' that will never come :P
2021-03-16 21:51:49 +01:00
Brendan Coles fe97aec8c3 UserspaceEmulator: Print PID in mmap nullptr with MAP_FIXED reportln() 2021-03-16 21:48:29 +01:00
Andreas Kling cad4cc9a2a LibWeb: Invalidate element style after setting Element.style.foo
This makes us recompute style for the element so the change actually
takes effect. :^)
2021-03-16 19:00:42 +01:00
Linus Groh 6c8185151e LibCpp: Return empty TranslationUnit from Parser::parse() if no tokens exist
Fixes #5704.
Fixes #5825.
Fixes #5827.
2021-03-16 18:59:19 +01:00
Linus Groh 8e84ca6b16 LibJS: Don't apply arguments object hack to global execution context
Checking for the existence of a call frame is not enough to check if
we're in a function call, as the global execution context is a regular
call frame as well.

Found by OSS-Fuzz, where simply accessing "arguments" in the global
scope would crash due to call_frame().callee being an empty value
(https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32115).
2021-03-16 18:48:25 +01:00
Idan Horowitz 00f1cb924b LibAudio: decrease WavLoader's size limit to a more reasonable size
A 4 GiB wav (current size limit) is very unreasonable, and larger
than oss-fuzz's 2.5 GiB per-process memory limit.
2021-03-16 18:40:42 +01:00
Andreas Kling efc6060df0 LibWeb: Dispatch "resize" events on the Window object
It's a little awkward that we do this in two places, but IPWV and OOPWV
currently implement resizing a little differently from each other so we
need to cover both paths.
2021-03-16 18:10:21 +01:00
thankyouverycool d2d69f3efb LibGUI: Remove has_visible_list members from TextEditor
This was a kludge to paint ComboBox editors before the advent of
accessory windows, isn't being used anymore, and was inadvertently
letting two ComboBoxes paint as if both had focus.
2021-03-16 17:58:24 +01:00
Andreas Kling 906cccbf7f LibWeb: Add Window.innerWidth and Window.innerHeight 2021-03-16 17:22:59 +01:00
Roi 72501775a7
Base: Change path to both modload and modunload (#5804) 2021-03-16 16:05:42 +01:00
Idan Horowitz eb343296ce LibCompress: Handle and propagate stream errors in GzipDecompressor
This commit makes read short-circuit if its input stream errored,
as well as propagate error handling to wrapped sub streams, similarly
to DeflateDecompressor.
2021-03-16 14:56:50 +01:00
Idan Horowitz ea5f83616e LibCompress+AK: Dont short-circuit error handling propagation
In the case that both the stream and the wrapped substream had errors
to be handled only one of the two would be resolved due to boolean
short circuiting. this commit ensures both are handled irregardless
of one another.
2021-03-16 14:56:50 +01:00
Andreas Kling c684af1f83 LibWeb: Use Gfx::Bitmap::RGBA8888 for ImageData bitmaps
This makes the colors show up correctly when using putImageData() to
draw an ImageData onto a CanvasRenderingContext2D. :^)
2021-03-16 12:10:31 +01:00
Andreas Kling fe861512c8 LibGfx: Add BitmapFormat::RGBA8888
This will be used by ImageData objects in LibWeb since the web spec
says these store colors in RGBA8888 order.

The only thing you can do with this format right now is blitting it
onto a BGRA8888 bitmap.
2021-03-16 12:09:15 +01:00
Andreas Kling 5023331726 LibGfx: Rename 32-bit bitmap StorageFormats to BGRA8888 and BGRx8888 2021-03-16 12:00:43 +01:00
Andreas Kling e0f32626bc LibGfx: Rename 32-bit BitmapFormats to BGRA8888 and BGRx888x
The previous names (RGBA32 and RGB32) were misleading since that's not
the actual byte order in memory. The new names reflect exactly how the
color values get laid out in bitmap data.
2021-03-16 11:50:03 +01:00
Andreas Kling 0bfdf95af6 LibJS: Make an RAII helper for entering/exiting AST nodes 2021-03-16 10:51:55 +01:00
Linus Groh c499239137 LibJS: Implement non-value-producing statements properly
For various statements the spec states:

    Return NormalCompletion(empty).

In those cases we have been returning undefined so far, which is
incorrect.

In other cases it states:

    Return Completion(UpdateEmpty(stmtCompletion, undefined)).

Which essentially means a statement is evaluated and its completion
value returned if non-empty, and undefined otherwise.

While not actually noticeable in normal scripts as the VM's "last value"
can't be accessed from JS code directly (with the exception of eval(),
see below), it provided an inconsistent experience in the REPL:

    > if (true) 42;
    42
    > if (true) { 42; }
    undefined

This also fixes the case where eval() would return undefined if the last
executed statement is not a value-producing one:

    eval("1;;;;;")
    eval("1;{}")
    eval("1;var a;")

As a consequence of the changes outlined above, these now all correctly
return 1.

See https://tc39.es/ecma262/#sec-block-runtime-semantics-evaluation,
"NOTE 2".

Fixes #3609.
2021-03-16 10:08:07 +01:00
Linus Groh dadf2e8251 LibJS: Make Interpreter::run() a void function
With one small exception, this is how we've been using this API already,
and it makes sense: a Program is just a ScopeNode with any number of
statements, which are executed one by one. There's no explicit return
value at the end, only a completion value of the last value-producing
statement, which we then access using VM::last_value() if needed (e.g.
in the REPL).
2021-03-16 10:08:07 +01:00
AnotherTest ef3679f9c3 Shell: Avoid unnecessarily taking control of the standard streams
As of a0506cb39e, this is no longer
needed to write to stdout.
Fixes #5776.
2021-03-16 09:41:37 +01:00
Linus Groh 18a5ddfadd LibGfx: Draw window frame icon scaled to title_bar_icon_rect()
Partially fixes #5806.
2021-03-15 22:47:05 +01:00
Oleg Sikorskiy 33bd18f308 QuickShow: Do not reset the panning on 100% zoom. 2021-03-15 22:46:53 +01:00
Oleg Sikorskiy ee64c814c6 QuickShow: Use a better formula for zooming.
Now the pixel under the cursor doesn't move, which is more consistent
with other image viewers (e.g. GwenView and IrfanView). Also switch
m_pan_origin to use window space to have less space transformations.
2021-03-15 22:46:53 +01:00
Linus Groh d6239b691f LibJS: Throw SyntaxError in eval() when parser has error(s) 2021-03-15 22:43:27 +01:00
Mițca Dumitru 01a49dda85 LibM: Implement fmin/fmax 2021-03-15 22:02:38 +01:00
Mițca Dumitru 987cc904c2 LibM: Make the gamma family of functions more accurate and conformant
This patch makes tgamma use an approximation that is more accurate with
regards to floating point arithmetic, and fixes some issues when tgamma
was called with positive integer values.

It also makes lgamma set signgam to the correct value, and makes its
return value be more inline with what the C standard defines.
2021-03-15 22:02:38 +01:00
Mițca Dumitru 2d0f334e5d LibM: Declare rintl in math.h 2021-03-15 22:02:38 +01:00
Andreas Kling 45e6b5e601 LibJS: Make eval() return the last value from the executed statement
This is kinda awkward but since the statement we're executing is
actually a JS::Program, we have to get the result via VM::last_value().
2021-03-15 21:43:40 +01:00
Idan Horowitz a955fd4156 LibCompress+AK: Propagate error handling to wrapped streams
This ensures that when a DeflateCompressor stream is cleared of any
errors its underlying wrapped streams (InputBitStream/InputMemoryStream)
will be cleared as well and wont fail a VERIFY on destruction.
2021-03-15 21:35:48 +01:00
Idan Horowitz f532421c9c LibCompress: Make the Zlib decompressor fail gracefuly
This commit adds a verify-less try_create method to the Zlib
decompressor to allow for graceful failures of parsing the
Zlib headers.
2021-03-15 21:35:48 +01:00
Andreas Kling a7b5a58509 Kernel: Fix sys$select() not marking fd's after blocking was avoided
In case multiple file descriptors in the `fd_set` were already readable
and/or writable when calling Thread::block<SelectBlocker>(), we would
only mark the first fd in the output sets instead of all relevant fd's.

The short-circuit code path when blocking isn't necessary must ensure
that unblock flags are collected for all file descriptors, not just the
first one encountered.

Fixes #5795.
2021-03-15 21:21:52 +01:00