Commit graph

17799 commits

Author SHA1 Message Date
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
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
Andreas Kling 64cb04996f AK: Make ByteBuffer::slice(0, size()) a freebie
If you want the whole buffer, we can just give you the buffer itself.
2021-03-15 18:01:11 +01:00
Elie Donadio 3a5a9a683f Apply suggestions from code review
Small adjustments, as suggested by linus.

Co-authored-by: Linus Groh <mail@linusgroh.de>
2021-03-15 16:08:31 +01:00
ElDonad f4f12982ff bt: add source file number integration 2021-03-15 16:08:31 +01:00
ElDonad a0c0d781e8 LaunchServer: added additional file parameters
This small commit should allow to specify additionnal parameters in the
form of URL queries, when opening a file via a "file://" url through the
LaunchServer.
2021-03-15 16:08:31 +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
Brendan Coles 7156b61d57 UserspaceEmulator: downgrade TODO to dbgln for invalid fcntl cmd arg 2021-03-15 16:07:31 +01:00
Luke 7276511833 Kernel/Storage: Add SATA error disambiguation 2021-03-15 09:57:27 +01:00
Andreas Kling a166a65eff Kernel: Don't return -EFOO when return type is KResultOr<...> 2021-03-15 09:09:04 +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
Cesar Torres 4f34a78337 TextEditor: Add charcount info about selected text to the statusbar 2021-03-15 09:08:15 +01:00
Tom Needham daf2e5d335 Ports: Do not call ./package.sh from a subshell in ./build_all.sh
This patch ensures that ./package.sh is run in the same shell
This solves compiling issues when building certain ports.

This fix was suggested by linusg in
https://github.com/SerenityOS/serenity/issues/5783#issuecomment-798906817
2021-03-15 09:07:17 +01:00
Tom Needham 26d72d3048 Ports: Allow verbose argument in build_all.sh
This patch allows for a verbose argument to be passed
so that the build output of the individual builds
is printed to stdout instead of /dev/null to help with diagnosing errors

If the verbose argument is not passed the old behaviour is preserved
and the build output is printed to /dev/null
2021-03-15 09:07:17 +01:00
Liav A 3c35ea30cc Kernel: Return 0 to indicate EOF when reading from end-of-file of device
If we happen to read with offset that is after the end of file of a
device, return 0 to indicate EOF. If we return a negative value,
userspace will think that something bad happened when it's really not
the case.
2021-03-15 09:06:41 +01:00
Tom 5ccc3637e3 Kernel: Fix race conditions processing async device requests 2021-03-15 09:06:41 +01:00
Tom 8177f2474b Kernel: Fix race condition completing IDEChannel async request 2021-03-15 09:06:41 +01:00