Commit graph

10055 commits

Author SHA1 Message Date
Andreas Kling 643464c455 AK: Make {String,FlyString}::is_one_of() const
Also, make the zero-argument variant private since it's not meant to be
called by clients directly.
2020-05-30 11:31:49 +02:00
Andreas Kling 2b1517f215 LibWeb: Add all branches from the parsing spec to "in body"
This makes us crash in TODO() more often, but it's better that we know
what's missing instead of incorrectly ending up on the fallback path.
2020-05-30 11:31:49 +02:00
Jack Karamanian d4e97b17ab LibJS: Use a non-arrow function to check the |this| value in the
callback for Array.prototype.{reduce,reduceRight}

Arrow functions always retain the |this| binding.

Running this code in Node:

[1, 2].reduce(() => { "use strict"; console.log(this === undefined) }

Output: false
2020-05-30 10:33:24 +02:00
Jack Karamanian 4a49c8412c LibJS: Add tests ensuring the |this| value can't be set for arrow
functions in Function.prototype.{call,apply}
2020-05-30 10:33:24 +02:00
Jack Karamanian f4129ac422 LibJS: Use the function's bound |this| and bound arguments in
Interpreter::call()
2020-05-30 10:33:24 +02:00
Jack Karamanian 3ffb0a4e87 LibJS: Throw a TypeError when an arrow function is used as a constructor 2020-05-30 10:33:24 +02:00
Jack Karamanian 1110b1b444 LibJS: Don't define the "prototype" property for arrow functions 2020-05-30 10:33:24 +02:00
Jack Karamanian 45ccd9f8d9 LibJS: Set the bound |this| value to the |this| value of the current
scope for arrow functions
2020-05-30 10:33:24 +02:00
Jack Karamanian c12125fa81 LibJS: Track whether ScriptFunctions and FunctionExpressions are arrow
functions
2020-05-30 10:33:24 +02:00
Jack Karamanian 5243e9974d LibJS: Remove unnecessary explicit from the 3 argument Function
constructor
2020-05-30 10:33:24 +02:00
Matthew Olsson 4e331a1fcf LibJS: Object.getOwnPropertyDescriptor works properly with accessors 2020-05-30 10:32:52 +02:00
FalseHonesty 12fe546be9 LibGUI+HackStudio: Fix cursor appearance and crash while debugging
HackStudio uses a TreeView to display the list of current variables
while debugging, and when the program completes, it sets that view's
model to a null model. This would trip an assertion if the TreeView
had something selected at the time, so this patch lessens the
assertion into a simple null check.

Additionally, the cursor would look laggy when moving about the
editor because the code was waiting for a window repaint to update
the cursor's look when it makes more sense to update the cursor
when it actually moves. This change also requires the base
GUI::TextEditor to expose a getter to tell if its currently in a drag
selection.

Finally, requesting a context menu in the line ruler on the side of
the editor would also place/remove breakpoints, which was counter
intuitive, so this requires a left click to modify breakpoint placement.
2020-05-30 10:18:14 +02:00
AnotherTest 77039e5354 Shell: Correctly complete paths in redirections
This commit allows the Shell to complete paths in redirections.
A closing quote is added if the path is an unclosed quote.
```
$ foo > "foob<tab>
$ foo > "foobar"
```
2020-05-30 00:36:51 +02:00
Marcin Gasperowicz 9a4ee9aa1a Lagom: Adjust AK, LibCore and LibTLS to build on MacOS 2020-05-30 00:36:13 +02:00
Marcin Gasperowicz 4e8de753c9 LibJS: Parse arrow function expression with correct precedence
The parser was chomping on commas present after the arrow function expression. eg. [x=>x,2] would parse as [x=>(x,2)] instead of [(x=>x),2].

This is not the case anymore. I've added a small test to prove this.
2020-05-30 00:33:18 +02:00
FalseHonesty 20faa93cb0 LibMarkdown: Change internal MD API to return OwnPtrs
Previously, all Markdown blocks had a virtual parse method which has
been swapped out for a static parse method returning an OwnPtr of
that block's type.

The Text class also now has a static parse method that will return an
Optional<Text>.
2020-05-30 00:32:12 +02:00
FalseHonesty 7ca562b200 LibMarkdown: Change MD Document parse API to return a RefPtr
Markdown documents are now obtained via the static Document::parse
method, which returns a RefPtr<Document>, or nullptr on failure.
2020-05-30 00:32:12 +02:00
FalseHonesty 9a2177437b Browser: Add clear output button to the console 2020-05-29 22:14:45 +02:00
FalseHonesty 2619d72eeb LibJS: Add all remaining tokens to MarkupGenerator's style converter 2020-05-29 22:14:45 +02:00
FalseHonesty 061938206a LibGUI: Fix cursor being out of view after typing
Previously, if the cursor moved out of the visible area while text
was being inserted, the text editor would never scroll the cursor
back into view until the arrow keys were pressed to move the cursor.
This was caused by the TextEditor's reflow deferral system stopping
visual line recomputation until the end of text insertion, so now
when reflow deferral is completed, the TextEditor will make sure
the cursor is visible.
2020-05-29 22:14:45 +02:00
Paul Redmond 4d4e578edf Ports: Fix CMake-based ports
The SDL port failed to build because the CMake toolchain filed pointed
to the old root. Now the toolchain file assumes that the Root is in
Build/Root.

Additionally, the AK/ and Kernel/ headers need to be installed in the
root too.
2020-05-29 20:21:10 +02:00
FalseHonesty b0b03c52af LibGUI: Fix TextEditor crashing when selecting a blank line
Previously, the TextEditor would crash when selecting a line with
no codepoints due to a null dereference, so this patch makes sure
there is actually any text to render before giving it to the painter.
2020-05-29 20:17:53 +02:00
AnotherTest 2a241a11bb LibCrypto: Fix some issues preventing compilation w/ clang 10 2020-05-29 20:17:12 +02:00
AnotherTest d497521d2b LibCrypto: Format all files with clang-format 10 2020-05-29 20:17:12 +02:00
Matthew Olsson d52ea37717 LibJS: Integrate labels into the Interpreter
The interpreter now considers a statement or block's label when
considering whether or not to break. All statements can be labelled.
2020-05-29 16:20:32 +02:00
Matthew Olsson 03615a7872 LibJS: Parse labels in continue and break statements 2020-05-29 16:20:32 +02:00
Matthew Olsson 10bf4ba3dc LibJS: Parse labelled statements
All statements now have an optional label string that can be null.
2020-05-29 16:20:32 +02:00
Matthew Olsson 5cd01ed79e LibJS: New expressions look for expressions with correct precedence 2020-05-29 15:56:39 +02:00
Linus Groh 688ca7b196 LibJS: Make Object::invoke() non-const
As suggested in #2431's code review.
2020-05-29 15:55:40 +02:00
Linus Groh 1dd44210b7 LibJS: Add Array.prototype.toLocaleString() 2020-05-29 08:00:02 +02:00
Linus Groh 70d2add22f LibJS: Add Object.prototype.toLocaleString() 2020-05-29 08:00:02 +02:00
Linus Groh 9755f8d297 LibJS: Add Object::invoke() 2020-05-29 08:00:02 +02:00
Emanuele Torre 5c6323c130 LibLine: Remove unused header in Span.h 2020-05-29 07:59:45 +02:00
Emanuele Torre 83c11434e4 CMake: Add convenience targets to run lint-shell-scripts and check-style 2020-05-29 07:59:45 +02:00
Emanuele Torre d963be795d Meta: update lint-shell-scripts.sh so that it does not search in Build/
We now use git-ls-files(1) instead of find(1).
2020-05-29 07:59:45 +02:00
Emanuele Torre 937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Gabriel Mihalache 8e151ff33e
PixelPaint: Set active layer to nullptr after its removal (#2433)
This prevents a crash if removal was called twice, without setting a
new active layer in the meanwhile.
2020-05-29 07:58:22 +02:00
Matthew Olsson 664085b719 LibJS: Fix conditional expression precedence
This fixes the following from parsing incorrectly due to the comma
that occurs after the conditional:

  let o = {
    foo: true ? 1 : 2,
    bar: 'baz',
  };
2020-05-29 07:57:14 +02:00
Sergey Bugaev 3847d00727 Kernel+Userland: Support remounting filesystems :^)
This makes it possible to change flags of a mount after the fact, with the
caveats outlined in the man page.
2020-05-29 07:53:30 +02:00
Sergey Bugaev d395b93b15 Kernel: Misc tweaks 2020-05-29 07:53:30 +02:00
Sergey Bugaev ec4902d1dd LibCore+Inspector: Move RPC sockets to /tmp/rpc
We have a hierarchical filesystem, let's make use of it :^)
2020-05-29 07:53:30 +02:00
Sergey Bugaev 8afcf0d87a LibCore: Do not assert that we can start the RPC server
Now that the Shell uses Core::EventLoop, we can't afford to just crash if /tmp
is unwritable.
2020-05-29 07:53:30 +02:00
Sergey Bugaev 53647e347f Kernel+Base: Mount root filesystem read-only :^)
We remount /home and /root as read-write, to keep the ability to modify files
there. /tmp remains read-write, as it is mounted from a TmpFS.
2020-05-29 07:53:30 +02:00
Sergey Bugaev 39cde80545 Base: Document MS_RDONLY
Also fix a couple of issues with the man pages.
2020-05-29 07:53:30 +02:00
Sergey Bugaev 4b300e085d Userland+SystemMonitor: Recognize the MS_RDONLY mount flag 2020-05-29 07:53:30 +02:00
Sergey Bugaev fdb71cdf8f Kernel: Support read-only filesystem mounts
This adds support for MS_RDONLY, a mount flag that tells the kernel to disallow
any attempts to write to the newly mounted filesystem. As this flag is
per-mount, and different mounts of the same filesystems (such as in case of bind
mounts) can have different mutability settings, you have to go though a custody
to find out if the filesystem is mounted read-only, instead of just asking the
filesystem itself whether it's inherently read-only.

This also adds a lot of checks we were previously missing; and moves some of
them to happen after more specific checks (such as regular permission checks).

One outstanding hole in this system is sys$mprotect(PROT_WRITE), as there's no
way we can know if the original file description this region has been mounted
from had been opened through a readonly mount point. Currently, we always allow
such sys$mprotect() calls to succeed, which effectively allows anyone to
circumvent the effect of MS_RDONLY. We should solve this one way or another.
2020-05-29 07:53:30 +02:00
Sergey Bugaev b905126365 Kernel+LibC: Move O_* and MS_* flags to UnixTypes.h
That's where the other similar definitions reside. Also, use bit shift
operations for MS_* values.
2020-05-29 07:53:30 +02:00
Sergey Bugaev b6845de3f6 Kernel: Fix error case in Process::create_user_process()
If we fail to exec() the target executable, don't leak the thread (this actually
triggers an assertion when destructing the process), and print an error message.
2020-05-29 07:53:30 +02:00
Sergey Bugaev 6627c3ea3a Kernel: Fix some failing assertions
When mounting Ext2FS, we don't care if the file has a custody (it doesn't if
it's a device, which is a common case). When doing a bind-mount, we do need a
custody; if none is provided, let's return an error instead of crashing.
2020-05-29 07:53:30 +02:00
Sergey Bugaev f945d7c358 Kernel: Always require read access when mmaping a file
POSIX says, "The file descriptor fildes shall have been opened with read
permission, regardless of the protection options specified."
2020-05-29 07:53:30 +02:00