Commit graph

9332 commits

Author SHA1 Message Date
Andreas Kling
8fae4ee931 LibGUI: Add ScrollableWidget::viewport_rect_in_content_coordinates() 2020-05-04 22:33:20 +02:00
Sergey Bugaev
718271c9df Base: Document unveil(2)
Also, escape underscores in chroot_with_mount_flags.
2020-05-04 21:44:50 +02:00
Sergey Bugaev
183fa98214 LibMarkdown: Support multi-line list items
You can now continue one list item across several lines, as long as you indent
it the same as the first line of the item. For example:

* This is the first item,
  which spans multiple lines.
* This is the second item, which also has some
  *emphasis* in it.
2020-05-04 21:44:50 +02:00
Linus Groh
d4bfcea570 LibJS: Add indentation to sections in SwitchCase::dump()
This now matches the output of

Program
  (Variables)
    ...
  (Children)
    ...

or

FunctionDeclaration 'foo'
  (Parameters)
    ...
  (Body)
    ...

etc.

Also don't print each consequent statement index, it doesn't add any
value.
2020-05-04 21:42:47 +02:00
mattco98
adb4accab3 LibJS: Add template literals
Adds fully functioning template literals. Because template literals
contain expressions, most of the work has to be done in the Lexer rather
than the Parser. And because of the complexity of template literals
(expressions, nesting, escapes, etc), the Lexer needs to have some
template-related state.

When entering a new template literal, a TemplateLiteralStart token is
emitted. When inside a literal, all text will be parsed up until a '${'
or '`' (or EOF, but that's a syntax error) is seen, and then a
TemplateLiteralExprStart token is emitted. At this point, the Lexer
proceeds as normal, however it keeps track of the number of opening
and closing curly braces it has seen in order to determine the close
of the expression. Once it finds a matching curly brace for the '${',
a TemplateLiteralExprEnd token is emitted and the state is updated
accordingly.

When the Lexer is inside of a template literal, but not an expression,
and sees a '`', this must be the closing grave: a TemplateLiteralEnd
token is emitted.

The state required to correctly parse template strings consists of a
vector (for nesting) of two pieces of information: whether or not we
are in a template expression (as opposed to a template string); and
the count of the number of unmatched open curly braces we have seen
(only applicable if the Lexer is currently in a template expression).

TODO: Add support for template literal newlines in the JS REPL (this will
cause a syntax error currently):

    > `foo
    > bar`
    'foo
    bar'
2020-05-04 16:46:31 +02:00
Andreas Kling
2fdeb464f7 Meta: Add a basic "issue policy" to CONTRIBUTING.md 2020-05-04 13:49:15 +02:00
Andreas Kling
a75af443d4 LibX86: Simplify "register index to string" functions a bit 2020-05-04 13:49:15 +02:00
Andreas Kling
57b2b96a67 LibX86: Remove accidental camelCase in some names 2020-05-04 13:49:15 +02:00
Ben Wiederhake
b80ad2d791 MouseDemo: Add menu, using the new icon :^) 2020-05-04 09:58:14 +02:00
Ben Wiederhake
fe178b6234 SystemMenu+MouseDemo: Add menu entry and nice icons 2020-05-04 09:58:14 +02:00
Nathan Lanza
f4e6c4c6f0
Kernel: Use Multiboot macros instead of magic constants (#2090)
MUTLIBOOT_FRAMEBUFFER_TYPE_{RGB,EGA_TEXT} are defined in the Multiboot.h
header. Use those definitions instead of hard-coding 1 and 2.
2020-05-04 09:52:04 +02:00
Devashish
f22c973ba3 Meta: Add configuration for setting up project in CLion
This commit adds a CMakeLists.txt file that will be used by CLion to
configure the project and documentation explaining the steps to follow.
Configuring CLion this way enables important features like code
completion and file search. The configuration isn't perfect. There are
source files for which CLion cannot pick up the headers and asks to
manually include them from certain directories. But for the most part,
it works all right.
2020-05-04 09:50:45 +02:00
Ben Wiederhake
f09a8f8a6e sysctl: Permit 'sysctl -a' invocation
The point of '-a' is to list all keys.
It is counter-intuitive to require the user to then
supply a specific key additionally.
2020-05-04 09:41:43 +02:00
Ben Wiederhake
e6547a7e95 sysctl: Fix newlines in error messages 2020-05-04 09:41:43 +02:00
Emanuele Torre
de0ed0e2dc
AK: Rename variables with camelCase names in PrintfImplementation.h (#2095)
zeroPad => zero_pad
leftPad => left_pad
fieldWidth => field_width

These were the only variables with names in camelCase.
We were not consistent with the naming of these variables: some times we
called them zeroPad, leftPad, fieldWidth; other times we called them
zero_pad, left_pad, field_width.

These inconsistencies made the code hard to read, so I changed their
names to snake_case.

Also rename width => field_width in AK::print_hex()
2020-05-04 09:40:17 +02:00
Andrew Kaster
3cae4cee81 Shell: Check for invalid #! in commands 2020-05-04 09:39:05 +02:00
Andrew Kaster
3eb3c2477f AK: Add StringView::find_first/last_of
These methods search from the beginning or end of a string for the
first character in the input StringView and returns the position in
the string of the first match. Note that this is not a substring match.
Each comes with single char overloads for efficiency.
2020-05-04 09:39:05 +02:00
Linus Groh
94c28552c6 LibWeb: Add basic support for redirects 2020-05-04 00:01:31 +02:00
Andreas Kling
e09b83c60c LibTextCodec: Start fleshing out a simple text codec library
We're starting with a very basic decoding API and only ISO-8859-1 and
UTF-8 decoding (and UTF-8 decoding is really a no-op since String is
expected to be UTF-8.)
2020-05-03 23:01:58 +02:00
Andreas Kling
f3676ebef5 LibWeb: Handle iso-8859-1 web content a little bit better
We now look at the HTTP response headers for a Content-Type header and
try to parse it if present to find the text encoding.

If the text encoding is iso-8859-1, we turn all non-ASCII characters
into question marks. This makes Swedish Google load on my machine! :^)
2020-05-03 23:01:58 +02:00
Andreas Kling
eb6e35a1be ProtocolServer: Pass HTTP response headers to the client
We now store the response headers in a download object on the protocol
server side and pass it to the client when finishing up a download.

Response headers are passed as an IPC::Dictionary. :^)
2020-05-03 23:01:58 +02:00
Andreas Kling
a83d74b38c Base: Add browser bookmark for Google :^) 2020-05-03 23:01:58 +02:00
Andreas Kling
78943f031e LibIPC: Add a simple IPC::Dictionary type (String key -> String value) 2020-05-03 23:01:58 +02:00
Ben Wiederhake
dce3faff08 Kernel: Don't crash on invalid fcntl 2020-05-03 22:46:28 +02:00
Ben Wiederhake
b24cfd36ae Kernel: Demonstrate kernel crash on invalid fcntl 2020-05-03 22:46:28 +02:00
Andreas Kling
e6922c0d40 LibCrypto: Manage vector sizing manually in performance-critical places
Use Vector::resize_and_keep_capacity() to resize BigInt vectors to just
the right size without risking deallocation. Then do direct indexed
accesses to the underlying words (or use memset/memcpy.)

This gives a ~40% speed-up on the RSA tests in "test-crypto -t pk" :^)
2020-05-03 19:14:50 +02:00
Andreas Kling
baadde122b AK: Add Vector::resize_and_keep_capacity()
This function is just like resize() except it does not deallocate the
vector buffer when shrinking.
2020-05-03 19:14:50 +02:00
Andreas Kling
e7abbc6655 LibTLS: Put some debug spam behind an #ifdef 2020-05-03 19:14:50 +02:00
Andreas Kling
7f41a1adda LibHTTP: Put some debug spam behind an #ifdef 2020-05-03 19:14:50 +02:00
AnotherTest
b028a123b8 LibTLS: "Properly" handle the server dropping the connection
Contrary to popular belief, not every implementation of TLS follows the
specs.
Some of them just drop the connection without sending a proper
close_notify, and we should handle that gracefully.
2020-05-03 19:08:40 +02:00
DexesTTP
8aeccf4f02 LibCrypto: Added BigInteger 'division by u16' operator 2020-05-03 14:31:26 +02:00
DexesTTP
0efd58bf6d LibCrypto: Changed ModularFunctions to use non-allocating operations
This change leads to between 10% and 35% performance improvement when executing
the RSA decryption method.

The main impact is to drastically reduce the number of allocations done in this
method from around 50% of the profile hits to less than 2%.
2020-05-03 14:31:26 +02:00
DexesTTP
28ea347e55 LibCrypto: Added static non-allocating UnsignedBigInteger operators
This changes the plus, minus, etc... operators from UnsignedBigInteger to use a
static helper method. The static methods do not allocate any variables, instead
all the required BigInteger output and temporary variables are required on call
as parameters.

This change already optimizes the number of allocations in complex operations
such as multiply or divide, by having a single allocation per call (instead of
one per loop).

This new API also provides a way to limit the number of allocations for complex
computations in other parts of the code. This is done by using these helpers in
any place that currently makes use of the standard operators.
2020-05-03 14:31:26 +02:00
DexesTTP
d008a38f93 LibCrypto: Small fixes in BigInteger & test-crypto 2020-05-03 14:31:26 +02:00
DexesTTP
8ad48cca29 test-crypto: Display execution time for passing tests 2020-05-03 14:31:26 +02:00
Andreas Kling
3c0ca04ad3 LookupServer: Only pass A record responses to clients
This works around an issue where we'd try responding to a LookupServer
client with an empty CNAME record.
2020-05-03 14:24:54 +02:00
Andreas Kling
82d83f0fe1 WindowServer: Remove debug spam when creating new windows 2020-05-03 14:24:54 +02:00
Ben Wiederhake
da837fe46e Meta: Fix Makefile permissions (not executable) 2020-05-03 14:24:08 +02:00
AnotherTest
06cf9d3fb7 ProtocolServer: Implement and handle download progress
Also updates `pro` to display download progress and speed on stderr
2020-05-03 12:59:26 +02:00
AnotherTest
c6825a96c7 AK+FileManager: Move out human_readable_size to AK::NumberFormat 2020-05-03 12:59:26 +02:00
AnotherTest
6fcb6baa69 IPCCompiler: Add support for Optional<T> (so long as T is trivial) 2020-05-03 12:59:26 +02:00
Linus Groh
32742709dc LibJS: Support empty statements
We already skipped random semicolons in Parser::parse_program(), but now
they are properly matched and parsed as empty statements - and thus
recognized as a valid body of an if / else / while / ... statement.
2020-05-03 12:57:48 +02:00
AnotherTest
3b432eed98 LibCrypto: Correct RFC5246 un-padding behaviour
The decrypted data is legally allowed to have any amount of padding, so
long as it is block-aligned, we should not assume that padding bytes
fall inside the same block, or that an entire block cannot be padding.

Fixes #2072
2020-05-03 11:46:40 +02:00
Shannon Booth
637ecdb415 Userland: Fix leak in keymap
Pretty harmless here, but eh
2020-05-03 11:42:32 +02:00
Linus Groh
25cf0da2fb LibJS: Set name of anonymous functions during assignment 2020-05-03 11:41:56 +02:00
Matthew Olsson
5e66f1900b LibJS: Add function default arguments
Adds the ability for function arguments to have default values. This
works for standard functions as well as arrow functions. Default values
are not printed in a <function>.toString() call, as nodes cannot print
their source string representation.
2020-05-03 00:44:57 +02:00
Linus Groh
751f813f6a WindowServer: Update desktop window rect on resolution change
Fixes #2073.
2020-05-03 00:41:35 +02:00
Michael Lelli
58a34fbe09
Kernel: Fix pledge syscall applying new pledges when it fails (#2076)
If the exec promises fail to apply, then the normal promises should
not apply either. Add a test for this fixed functionality.
2020-05-03 00:41:18 +02:00
Andreas Kling
37d1b0c875 WindowServer: Reset double-click timers for back/forward buttons
Thanks for movAX13H for pointing this out!
2020-05-03 00:29:57 +02:00
Andreas Kling
b8f778a430 Demos: Add a little "Mouse" demo for showing mouse button states
This was very helpful when adding support for 5-button mice! :^)
2020-05-02 22:13:54 +02:00