Commit graph

13719 commits

Author SHA1 Message Date
Luke
e8a9e8aed5 LibWeb: Add namespace to Element 2020-10-22 15:24:42 +02:00
Luke
efaf03e986 LibWeb: Use modern namespaces and fix clang-format comments in tag names 2020-10-22 15:24:42 +02:00
Tom
52a847a0eb LibGUI: Implement searching/jumping as you type in views
This allows the user to start typing and highlighting and jumping
to a match in ColumnsView, IconView, TableView and TreeView if
the model supports it.
2020-10-22 15:23:45 +02:00
Tom
307f0bc778 LibGUI: Fix scroll_into_view flipping between left/top and right/bottom
This fixes flipping between left/top and right/bottom when the rectangle
to make visible doesn't fit into the visible portion each time the
function is called.
2020-10-22 15:23:45 +02:00
Tom
a823d2a962 LibGfx: Add colors for highlight-searching to palette and themes 2020-10-22 15:23:45 +02:00
Tom
f239fbaa58 LibGfx: Reduce code duplication in Painter::draw_text
Use the same logic for all variants for Painter::draw_text. Also,
add an overload that allows taking a callback function for custom
gylph drawing. This allows drawing some glyphs differently in the
correct location when drawing more complex strings (e.g. multi-line,
elisions, etc).
2020-10-22 15:23:45 +02:00
Tom
25e7225782 AK: Enhance String::contains to allow case-insensitive searches 2020-10-22 15:23:45 +02:00
Tom
6413acd78c AK: Make Utf8View and Utf32View more consistent
This enables use of these classes in templated code.
2020-10-22 15:23:45 +02:00
Linus Groh
15642874f3 LibJS: Support all line terminators (LF, CR, LS, PS)
https://tc39.es/ecma262/#sec-line-terminators
2020-10-22 10:06:30 +02:00
Andreas Kling
5043c4a3e5 LibCore+WebServer+LibWeb: Make MIME type guesser take a StringView
This reverts my previous commit in WebServer and fixes the whole issue
in a much better way. Instead of having the MIME type guesser take a
URL (which we don't actually have in the WebServer at that point),
just take a path as a StringView.

Also, make use of the case-insensitive StringView::ends_with() :^)
2020-10-21 21:16:20 +02:00
Andreas Kling
9c14e2ea5d WebServer: Force "text/html" mimetype for directories with index.html
When you GET a directory with an index.html file, we were using the
mime type guessing logic from LibCore on the "/" filename, which gave
us "text/plain". Force the mime type to "text/html" in these cases
so browsers actually interpret it as HTML. :^)
2020-10-21 20:55:16 +02:00
Andreas Kling
a6aee0c097 IPv4: Take the socket lock more (fixes TCP connection to localhost)
This fixes an issue where making a TCP connection to localhost didn't
work correctly since the loopback interface is currently synchronous.
(Sending something to localhost would enqueue a packet on the same
interface and then immediately wake the network task to process that
packet.)

This was preventing the TCP handshake from working correctly with
localhost since we'd send out the SYN packet before moving to the
SynSent state. The lock is now held long enough for this operation
to be atomic.
2020-10-21 20:51:02 +02:00
Lenny Maiorani
91ea6057d6 TestArray: constexpr_sum using span
Problem:
- `constexpr_sum` is implemented using `Array` which means the
  function needs to be a function template so that the size can be
  deduced.

Solution:
- Change the `Array` function argument to a `Span` since `Span` now is
  `constexpr`.
2020-10-21 19:42:46 +02:00
Lenny Maiorani
18a40587ea HashFunctions: constexpr capability
Problem:
- Hash functions can be `constexpr`, but are not.

Solution:
- Change `inline` keyword to `constexpr`.
- Add `static_assert` tests to ensure the hash functions work in a
  `constexpr` context.
2020-10-21 19:42:12 +02:00
Lenny Maiorani
070fc69562 TestHashFunctions: Tests to bind hash functionality
Problem:
- The hash functions have no associated tests, so there is nothing
  binding their behavior.

Solution:
- Bind the hash function behavior by adding tests.
- Use the existing behavior as "correct".
2020-10-21 19:42:12 +02:00
Linus Groh
1e86379327 LibJS: Rest parameter in setter functions is a syntax error 2020-10-20 20:27:58 +02:00
Linus Groh
6331d45a6f LibJS: Move checks for invalid getter/setter params to parse_function_node
This allows us to provide better error messages as we can point the
syntax error location to the exact first invalid parameter instead of
always the end of the function within a object literal or class
definition.

Before this change:

    const Foo = { set bar() {} }
                               ^
    Uncaught exception: [SyntaxError]: Object setter property must have one argument (line: 1, column: 28)

    class Foo { set bar() {} }
                             ^
    Uncaught exception: [SyntaxError]: Class setter method must have one argument (line: 1, column: 26)

After this change:

    const Foo = { set bar() {} }
                          ^
    Uncaught exception: [SyntaxError]: Setter function must have one argument (line: 1, column: 23)

    class Foo { set bar() {} }
                        ^
    Uncaught exception: [SyntaxError]: Setter function must have one argument (line: 1, column: 21)

The only possible downside of this change is that class getters/setters
and functions in objects are not distinguished in the message anymore -
I don't think that's important though, and classes are (mostly) just
syntactic sugar anyway.
2020-10-20 20:27:58 +02:00
Linus Groh
db75be1119 LibJS: Refactor parse_function_node() bool parameters into bit flags
I'm about to add even more options and a bunch of unnamed true/false
arguments is really not helpful. Let's make this a single parse options
parameter using bit flags.
2020-10-20 20:27:58 +02:00
Andreas Kling
50f8f27ac6 Userland: Run clang-format on tree.cpp 2020-10-20 19:19:30 +02:00
Andreas Kling
f5f99ccd6a WindowServer: Return some event members by const reference 2020-10-20 18:10:22 +02:00
Andreas Kling
c8c7db8c33 LibC: Fix a warning when building LibC with -O2 2020-10-20 18:10:22 +02:00
Andreas Kling
ce6ef54337 ICMP: Check that incoming ICMP echo requests are large enough
Otherwise, just ignore them.
2020-10-20 18:10:10 +02:00
Andreas Kling
0af2795662 LibWeb: Tear down layout trees properly
Instead of just ripping out the root of the layout tree from its RefPtr
in Document, actually go through the DOM and gather up all the layout
nodes. Then destroy them all in one swoop.

Also, make sure to do this when detaching Document from Frame,
to enforce the invariant that layout only occurs in framed documents.
2020-10-20 18:08:37 +02:00
Andreas Kling
633b6fbc48 Userland: Use new format functions in some programs 2020-10-20 18:08:37 +02:00
Lenny Maiorani
d1fe6a0b53
Everywhere: Redundant inline specifier on constexpr functions (#3807)
Problem:
- `constexpr` functions are decorated with the `inline` specifier
  keyword. This is redundant because `constexpr` functions are
  implicitly `inline`.
- [dcl.constexpr], §7.1.5/2 in the C++11 standard): "constexpr
  functions and constexpr constructors are implicitly inline (7.1.2)".

Solution:
- Remove the redundant `inline` keyword.
2020-10-20 18:08:13 +02:00
Lenny Maiorani
a40abd6ce3 Checked: constexpr support
Problem:
- `Checked` is not `constexpr`-aware.

Solution:
- Decorate member functions with `constexpr` keyword.
- Add tests to ensure the functionality where possible.
2020-10-20 16:31:24 +02:00
Lenny Maiorani
bd99083436 Checked: Use default compiler-generated functions
Problem:
- Compiler-generated functions are being defined which results in
  extra code to maintain.

Solution:
- Switch to compiler-generated default functions for default
  construction, copy assignment, move assignment, copy construction
  and move construction.
2020-10-20 16:31:24 +02:00
Laurent Cimon
b4790010a8 Build: Modify various parts to allow the build to succeed on FreeBSD 2020-10-20 14:40:47 +02:00
Linus Groh
a82c56f9f7 LibJS: Speed up IndexedPropertyIterator by computing non-empty indices
This provides a huge speed-up for objects with large numbers as property
keys in some situation. Previously we would simply iterate from 0-<max>
and check if there's a non-empty value at each index - now we're being
smarter and compute a list of non-empty indices upfront, by checking
each value in the packed elements vector and appending the sparse
elements hashmap keys (for GenericIndexedPropertyStorage).

Consider this example, an object with a single own property, which is a
number increasing by a factor of 10 each iteration:

    for (let i = 0; i < 10; ++i) {
        const o = {[10 ** i]: "foo"};
        const start = Date.now();
        Object.getOwnPropertyNames(o);  // <-- IndexedPropertyIterator
        const end = Date.now();
        console.log(`${10 ** i} -> ${(end - start) / 1000}s`);
    }

Before this change:

    1 -> 0.0000s
    10 -> 0.0000s
    100 -> 0.0000s
    1000 -> 0.0000s
    10000 -> 0.0005s
    100000 -> 0.0039s
    1000000 -> 0.0295s
    10000000 -> 0.2489s
    100000000 -> 2.4758s
    1000000000 -> 25.5669s

After this change:

    1 -> 0.0000s
    10 -> 0.0000s
    100 -> 0.0000s
    1000 -> 0.0000s
    10000 -> 0.0000s
    100000 -> 0.0000s
    1000000 -> 0.0000s
    10000000 -> 0.0000s
    100000000 -> 0.0000s
    1000000000 -> 0.0000s

Fixes #3805.
2020-10-20 08:51:41 +02:00
Andreas Kling
0e900ca5df LibX86: clang-format 2020-10-20 08:41:59 +02:00
Nico Weber
2c82b69bd7 LibX86: malloc a bit less
This reduces malloc()/free() calls in `disasm /bin/id` by 30%
according to LIBC_DUMP_MALLOC_STATS.

No measurable performance change (the number of empty block hits
remains unchanged, and that's what's slow), but maybe a nice
change regardless?
2020-10-19 22:44:24 +02:00
Linus Groh
8fe89cf441 Toolchain: Set CACHED_TOOLCHAIN_ARCHIVE after computing hash 2020-10-19 21:11:39 +02:00
Andreas Kling
be4005cb9e Profiler: Implement "Top functions" feature like Instruments.app has
This view mode takes every stack frame and turns it into a root in the
profile graph. This allows functions that are called from many places
to bubble up to the top. It's a very handy way to discover heavy things
in a profile that are otherwise obscured by having many callers.
2020-10-19 20:08:57 +02:00
Linus Groh
46cc1f718e LibJS: Unprefixed octal numbers are a syntax error in strict mode 2020-10-19 20:08:22 +02:00
Linus Groh
602eb98479 Toolchain: Remove cached archive and rebuild if extracting fails
This is currently the case on Travis CI: the file exists but fails to
extract, breaking all the CI builds.
2020-10-19 20:06:59 +02:00
Linus Groh
e898c98873 LibJS: Don't parse arrow function with newline between ) and =>
If there's a newline between the closing paren and arrow it's not a
valid arrow function, ASI should kick in instead (it'll then fail with
"Unexpected token Arrow")
2020-10-19 11:31:55 +02:00
Linus Groh
965d952ff3 LibJS: Share parameter parsing between regular and arrow functions
This simplifies try_parse_arrow_function_expression() and fixes a few
cases that should not produce an arrow function AST but did:

    (a,,) => {}
    (a b) => {}
    (a ...b) => {}
    (...b a) => {}

The new parsing logic checks whether parens are expected and uses
parse_function_parameters() if so, rolling back if a new syntax error
occurs during that. Otherwise it's just an identifier in which case we
parse the single parameter ourselves.
2020-10-19 11:31:55 +02:00
Linus Groh
aa68de3530 LibJS: Fix dump() indentation of UpdateExpression with suffix operator 2020-10-19 11:31:55 +02:00
Linus Groh
2dbea60fe2 LibJS: Multiple 'default' clauses in switch statement are a syntax error 2020-10-19 11:30:14 +02:00
Linus Groh
57e7b2f8e4 Base: Update test-js(1) man page 2020-10-19 11:29:55 +02:00
Linus Groh
ed116636ce test-js: Support test262 parser tests
test-js now has a --test262-parser-tests option. Modules are skipped for
now, current results:

    Test Suites: 1309 failed, 4314 passed, 5623 total
    Tests:       1309 failed, 262 skipped, 4052 passed, 5623 total
    Files:       5361 total
    Time:        ~100ms (Lagom) / 600-800ms (Serenity)

For more info, see: https://github.com/tc39/test262-parser-tests
2020-10-19 11:29:55 +02:00
Linus Groh
3a72a93b9d test-js: Exit with 1 if any test failed 2020-10-19 11:29:55 +02:00
Linus Groh
03b817b130 test-js: Include skipped tests in total test count
The current output is a bit strange:

    Tests:       3 skipped, 979 passed, 979 total

This makes more sense to me:

    Tests:       3 skipped, 979 passed, 982 total
2020-10-19 11:29:55 +02:00
Linus Groh
cce673e7b0 test-js: Add argument for explicit test root directory
Right now test-js has a hardcoded test root directory when running on
Serenity or will get it based on SERENITY_ROOT otherwise. Now it is
also possible to pass a path to the command which will take precedence
over these mechanisms.

This will also be useful for adding test262 support as those files will
not have a default location.
2020-10-19 11:29:55 +02:00
Andreas Kling
69a015cd9a Documentation: Remove outdated comment about global git identity
This was used by the toolchain build script at one point but is now
only used when running BuildIt.sh with --dev.
2020-10-18 20:33:02 +02:00
Andreas Kling
57c2da1f86 Documentation: Remove "flock" from dependencies
The build system no longer uses "flock", so stop telling people they
need to install it.
2020-10-18 20:33:02 +02:00
Linus Groh
f8886ef5ba LibJS: Handle continue in switch statement unwinding 2020-10-18 19:08:52 +02:00
Linus Groh
8f54edb7a0 LibJS: Handle return value in switch statement unwinding
Fixes #3790.
2020-10-18 19:08:52 +02:00
Stephan Unverwerth
2c888b3c6e LibJS: Fix parsing of invalid numeric literals
i.e. "1e" "0x" "0b" "0o" used to be parsed as valid literals.
They now produce invalid tokens. Fixes #3716
2020-10-18 15:38:57 +02:00
Dano Perniš
3efd4c105f AK: Reduce memory writes in HashTable destructor 2020-10-18 14:44:23 +02:00