Commit Graph

755 Commits

Author SHA1 Message Date
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
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
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
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
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
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
8cafdf8985 LibWeb: Make sure <script> elements get prepared when connected
There's a bit more nuance to how this should really work, but let's at
least make sure we execute <script> elements if you insert them into
the document.
2021-03-15 21:20:33 +01:00
Andreas Kling
d434ae71b3 LibWeb: Add CanvasRenderingContext2D.clearRect()
Similar to fillRect, except this API fills with transparent black.
2021-03-15 21:20:33 +01:00
Andreas Kling
4559faf8d8 LibWeb: Support named CSS properties on CSSStyleDeclaration wrapper
Use the new CustomGet/CustomPut wrapper mechansim to intercept gets and
puts on CSSStyleDeclaration objects. This allows content to get and set
individual CSS properties from JavaScript. :^)
2021-03-15 21:20:33 +01:00
Andreas Kling
ab23ef92b6 LibWeb: Allow JS wrappers to customize get() and put()
You can now set the CustomGet and/or CustomPut extended attributes on
an interface. This allows you to override JS::Object::get/put in the
wrapper class.
2021-03-15 21:20:33 +01:00
Andreas Kling
c7d1f73990 LibWeb: Make <option> elements display:none in the default CSS for now 2021-03-15 21:20:33 +01:00
Andreas Kling
8062fc711c LibJS: Add arguments.callee to our hack arguments object
arguments.callee refers to the currently executing function.
2021-03-15 21:20:33 +01:00
Andreas Kling
093331df06 LibJS: Add Date.prototype.toGMTString() 2021-03-15 21:20:33 +01:00
Andreas Kling
36ea9fbd9e LibWeb: Stub out Document.cookie
We don't get/set anything, but at least scripts that access document
cookies can now progress further. :^)
2021-03-15 21:20:33 +01:00
Andreas Kling
3596c42deb LibJS: Partial support for Date.prototype.setFullYear() 2021-03-15 21:20:33 +01:00
Andreas Kling
4da3e5d91f LibJS: Add naive implementation of eval() :^)
This parses and executes a code string in the caller's lexical scope.
2021-03-15 21:20:33 +01:00
Idan Horowitz
c9f25bca04 LibTextCodec: Make UTF16BEDecoder read only up to an even offset
Reading up to the end of the input string of odd length results in
an out-of-bounds read
2021-03-15 16:08:12 +01:00
Cesar Torres
2b269b27e7 LibGUI: Fix crash when text_in_range() was called on an empty document 2021-03-15 09:08:15 +01:00
Linus Groh
f59d58cb76 LibELF+LibTest: Fix serenity_install_sources() paths
Currently we end up with the following:

    serenity/
        AK/
            ...
        Kernel/
            ...
        Libraries/
            LibELF/
            LibTest/
        Userland/
            Libraries/
                <all other libs>
            ...
2021-03-15 09:06:10 +01:00
Mițca Dumitru
32b9437c13 LibM: Add remainder{f, l}
These just forward their arguments to fmod, but I think that should be
fine.
2021-03-14 21:43:08 +01:00
Mițca Dumitru
e4197b7854 LibM: Define HUGE_VAL{F,L} in terms of compiler builtins 2021-03-14 21:43:08 +01:00
Mițca Dumitru
e9533da0e7 LibM: Define MAXFLOAT
Looks like a POSIX extension
2021-03-14 21:43:08 +01:00
Mițca Dumitru
86ee9211be LibM: Define FLT_EVAL_METHOD, float_t and double_t 2021-03-14 21:43:08 +01:00
Mițca Dumitru
1f1a4f488f LibM: Declare ldexpl in math.h
It was already defined, but it wasn't declared in the header
2021-03-14 21:43:08 +01:00
Mițca Dumitru
93c554f6bd LibM: Add the gamma family of functions 2021-03-14 21:43:08 +01:00
Mițca Dumitru
7aac174bc8 LibM: Organise math.h so it is less of a wall of functions
The categories are the same categories used by cppreference on its page
for numeric functions.
2021-03-14 21:43:08 +01:00