Commit graph

1454 commits

Author SHA1 Message Date
Linus Groh
0cf04d07aa LibJS: Temporarily clear exception in Object::get_without_side_effects()
This would return an empty value once it hits an exception check
otherwise. Considering that this mostly is used in situations where we
already *do* have an exception (traceback printing, for example), let's
make this easier for ourselves to use.
2021-04-24 20:11:04 +02:00
Linus Groh
5caab0148c LibJS: Add TemporaryClearException helper class
This is very similar to AK::TemporaryChange (and in fact replaces one
use of it), but since we can't directly set VM's m_exception from
outside of the VM, we need something more sophisticated.
Sometimes we need to temporarily remove the stored exception for some
other operation to succeed (e.g. anything that uses call(), as well as
get_without_side_effects()) and later restore it - the boilerplate code
required for this is annoying enough to justify a helper.
2021-04-24 20:11:04 +02:00
Andreas Kling
3a4d42bbbb LibJS: Remove stray '%' from MemberExpression AST dump 2021-04-24 18:50:12 +02:00
Andreas Kling
8ebb9d350c LibGUI: Remove some unused cruft from GUI::IconView 2021-04-24 18:50:12 +02:00
Mart G
157cd7c819 LibGUI: Prevent a Painter's clip_rect from being outside of its target
Previously a Painter's m_clip_origin field was initialized to a
widget's window_relative_rect, which is not ensured to be within
the target rect.
m_clip_origin is normally not used for clipping, but after calling
clear_clip_rect the clip rect that IS used for clipping gets reset
to m_clip_origin (so an invalid state is entered).
Now the window_relative_rect will be clipped by the target rect
first, and will only then be used to initialize both the active
clip_rect and m_clip_origin.
2021-04-24 15:57:20 +02:00
Timothy Flynn
1500479a1d LibSQL: Parse ALTER TABLE statement
There are 4 forms an ALTER TABLE statement can take, and each are very
distinct, so they each get their own AST node class.
2021-04-24 14:22:08 +02:00
Timothy Flynn
0764a68616 LibSQL: Parse UPDATE statement
This also migrates parsing of conflict resolution to a helper method,
since both INSERT and UPDATE need it.
2021-04-24 14:22:08 +02:00
Timothy Flynn
8d79b4a3e1 LibSQL: Parse INSERT statement
This also adds missing '&' on a couple AST getter methods.
2021-04-24 14:22:08 +02:00
Timothy Flynn
35f0450dd8 LibSQL: Add missing forward declarations 2021-04-24 14:22:08 +02:00
Brendan Coles
e0188d27de Utilities: Add pathchk 2021-04-24 11:48:57 +02:00
Gunnar Beutner
f74b8a2d1f LibELF: Avoid calculating symbol hashes when we don't need them 2021-04-23 23:35:36 +02:00
Hendiadyoin1
f1957bb86b UE+LibX86: Support bigger reads and writes 2021-04-23 22:50:53 +02:00
Hendiadyoin1
a99812633b LibX86: Add basic u128 and u256 constainers
These support all bitwise operations
2021-04-23 22:50:53 +02:00
Timothy Flynn
fa59d02692 LibSQL: Parse IN / NOT IN expressions with a nested SELECT statement 2021-04-23 22:36:07 +02:00
Timothy Flynn
004025c3c4 LibSQL: Parse common-table-expressions with a nested SELECT statement
This also moves testing of common-table-expression to its own test case.
2021-04-23 22:36:07 +02:00
Timothy Flynn
cb943a2179 LibSQL: Parse CREATE TABLE statements with a nested SELECT statement 2021-04-23 22:36:07 +02:00
Timothy Flynn
99b38aa3fa LibSQL: Parse EXISTS expressions
The EXISTS expression is a bit of an odd-man-out because it can appear
as any of the following forms:

    EXISTS (select-stmt)
    NOT EXISTS (select-stmt)
    (select-stmt)

Which makes it the only keyword expression that doesn't require its
keyword to actually be used. The consequence is that we might come
across an EXISTS expression while parsing another expression type;
NOT would have triggered a unary operator expression, and an opening
parentheses would have triggered an expression chain.
2021-04-23 22:36:07 +02:00
Timothy Flynn
e62e76ca1a LibSQL: Parse terminating semi-colon in top-level statement parser
Currently, every parse_*_statement method ends by parsing a semi-colon.
This will prevent nested statements, e.g. a SELECT statement may be
nested in a CREATE TABLE statement. Move the semi-colon expectation up
and out of the individual statement parsers.
2021-04-23 22:36:07 +02:00
Timothy Flynn
27685bc799 LibSQL: Add Parser::parse_schema_and_table_name helper
Another common semantic is parsing an identifier of the form
"schema_name.table_name" / "table_name". Add a helper to do this work.

This helper does not parse any optional alias after the table name.
some syntaxes specify an alias using the AS keyword, some let the AS
keyword be optional, and others just parse it as an identifier. So
callers to this helper will just continue parsing the alias however
they require.
2021-04-23 22:36:07 +02:00
Timothy Flynn
418884ab64 LibSQL: Add Parser::parse_comma_separated_list helper
A quite common semantic emerged for parsing comma-separated expressions:

    consume(TokenType::ParenOpen);

    do {
        // do something

        if (!match(TokenType::Comma))
            break;

        consume(TokenType::Comma);
    } while (!match(TokenType::Eof));

    consume(TokenType::ParenClose);

Add a helper to do the bulk of the while loop.
2021-04-23 22:36:07 +02:00
Timothy Flynn
6a69b8efa7 LibSQL: Fix handling of optional AS keywords
In some syntaxes, using the 'AS' keyword to define an alias is optional.
But if it does appear, an identifier better appear afterwards.
2021-04-23 22:36:07 +02:00
Linus Groh
a4c1860bfc LibRegex: Put to dbgln()s behind REGEX_DEBUG 2021-04-23 20:52:12 +02:00
Linus Groh
0053816e9d LibJS: Correctly handle mixing +0 and -0 in Math.{min,max}()
The native C++ < and > operators won't handle this correctly, so the
result was different depending on the order of arguments. This is now
fixed by explicitly checking for positive and negative zero values.

Fixes #6589.
2021-04-23 20:51:48 +02:00
Linus Groh
883e8683b2 LibJS/Tests: Remove fileName and lineNumber args from ExpectationError
This is nono-standard, not supported by our Error implementation and not
even used anywhere, so let's just remove it.
2021-04-23 20:30:52 +02:00
Linus Groh
d400be05ec LibJS/Tests: Improve expectation error details 2021-04-23 20:30:52 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Andreas Kling
f7a33043e0 LibWeb: Don't assume name is string in HTMLCollectionWrapper::get()
If the property name is not a string (symbol or integer), we should
just defer to the base class instead of trying to handle it.

Fixes #6575.
2021-04-23 15:45:54 +02:00
Ali Mohammad Pur
cb134cd702 LibTLS: Call the read hooks after processing messages too
Otherwise the notification would be deferred until the next read event,
which means the client will not get any events if the server initiates
the appdata transfers.
2021-04-23 13:14:35 +02:00
thankyouverycool
cc7744f6ca LibGfx+FontEditor: Account for raw width when painting glyphs
Fixes hidden glyphs being painted in editor and map, and '?'
subsitute glyphs being overdrawn in the system.
2021-04-23 11:08:11 +02:00
thankyouverycool
99e7ad4b76 LibGUI: Allow bypassing hook when setting SpinBox range
Pass false to set_range to avoid on_change side-effects.
2021-04-23 11:08:11 +02:00
Ali Mohammad Pur
bf9c04a3da LibRegex: Implement multiline stateful matches 2021-04-23 10:05:04 +02:00
Ali Mohammad Pur
bb40d4d5ff LibRegex: Do not attempt to find more matches when one match is needed 2021-04-23 10:05:04 +02:00
Ali Mohammad Pur
2ef5b138ee LibJS: Use the match's global offset for 'index' in RegExp.exec()
This was not noticed before because all the previous matches were
single-line.
2021-04-23 10:05:04 +02:00
Matthew Olsson
6c02ea39d1 LibM: Add more macros; increase precision of existing macros 2021-04-23 09:11:07 +02:00
Matthew Olsson
fcd3b9a0df Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
Luke
31364da590 LibWeb+HackStudio: Use lukew@serenityos.org for my copyright headers 2021-04-22 23:15:33 +02:00
Linus Groh
ebdeed087c Everywhere: Use linusg@serenityos.org for my copyright headers 2021-04-22 22:51:19 +02:00
Idan Horowitz
1c512a702a AK+Userland: Use idan.horowitz@serenityos.org for my copyright headers 2021-04-22 22:42:38 +02:00
Ali Mohammad Pur
38418fdfdf AK+Userland: Use mpfard@serenityos.org for my copyright headers 2021-04-22 22:19:09 +02:00
Andreas Kling
b74bf31a53 LibWeb: Implement document.anchors
This returns an HTMLCollection of all <a> elements in the document that
have a "name" attribute.
2021-04-22 22:14:55 +02:00
Andreas Kling
43d16fa5b6 LibWeb: Implement document.applets
This is a legacy interface that returns an always-empty HTMLCollection.
2021-04-22 22:11:42 +02:00
Andreas Kling
e4df1b223f LibWeb: Implement a slow but functional HTMLCollection :^)
HTMLCollection is an awkward legacy interface from the DOM spec.

It provides a live view of a DOM subtree, with some kind of filtering
that determines which elements are part of the collection.

We now return HTMLCollection objects from these APIs:

- getElementsByClassName()
- getElementsByName()
- getElementsByTagName()

This initial implementation does not do any kind of caching, since that
is quite a tricky problem, and there will be plenty of time for tricky
problems later on when the engine is more mature.
2021-04-22 21:21:46 +02:00
Andreas Kling
49f3d88baf LibWeb: Allow IDL interfaces to override get_by_index()
You can now specify the "CustomGetByIndex" extended interface attribute
which will cause the generator to emit an override declaration for
JS::Object::get_by_index().

It's up to you to implement that function somewhere. Just like the
CustomGet mechanism already works. :^)
2021-04-22 21:21:46 +02:00
Brian Gianforcaro
dc0fc16981 Everywhere: Use bgianf@serenityos.org for my copyright attribution 2021-04-22 21:15:54 +02:00
Simon Danner
c8d56ee4f4
LibWeb: Improve fallback font selection
Try to find a font that has at least some of the requested properties.
This makes e.g. rfcs on tools.ietf.org easier to read since their
headers are now bold.
2021-04-22 20:47:47 +02:00
Simon Danner
7ab8be9e0b
LibWeb: Encode URL in ResourceLoader::load()
Encode URLs before requesting them - this fixes loading of resources
that have spaces in their URL, for example.
2021-04-22 20:45:59 +02:00
Egor Ananyin
c2280a907d LibWeb: Parse line-height inside font property 2021-04-22 19:17:10 +02:00
Egor Ananyin
174c940479 LibWeb: Fix height computation (again) :^)
Height computation algorithm is actually
different for absolutely positioned boxes
and block formatting contexts (where it doesn't include floats)
Fixes #6408
2021-04-22 19:17:10 +02:00
Timothy Flynn
ac0e387beb LibSQL: Parse (most of) SELECT statement
This doesn't yet parse join clauses, windowing functions, or compound
SELECT statements.
2021-04-22 18:08:15 +02:00
Timothy Flynn
9331293e44 LibSQL: Separate parsing of common-table-expression list
Statements like SELECT, INSERT, and UPDATE also optionally include this
list, so move its parsing out of parse_delete_statement(). Since it will
appear before the actual statement, parse it first in next_statement();
then only parse for statements that are allowed to include the list.
2021-04-22 18:08:15 +02:00
Timothy Flynn
6a7d7624a7 LibSQL: Fix parsing of lists of common-table-expression
Misread the graph: In the "WITH [RECURSIVE] common-table-expression"
section, common-table-expression is actually a repeating list. This
changes the parser to correctly parse this section as a list. Create a
new AST node, CommonTableExpressionList, to store both this list and the
boolean RECURSIVE attribute (because every statement that uses this list
also includes the RECURSIVE attribute beforehand).
2021-04-22 18:08:15 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Linus Groh
024fd9b957 LibWeb: Fix HTML injection on FrameLoader error page
Small regression introduced by 3857148, we still have to escape HTML
entities.
2021-04-22 10:17:00 +02:00
Andreas Kling
de7062af9c LibRegex: Unbreak the ALL_DEBUG build 2021-04-22 09:23:28 +02:00
Andreas Kling
3857148028 LibWeb+Base: Use AK::SourceGenerator for error pages
Instead of storing a format string in a file, let's be reasonable
and use SourceGenerator's template functionality. :^)
2021-04-22 00:00:59 +02:00
Andreas Kling
0005fa0e2b LibELF: Convert String::format() => String::formatted() 2021-04-21 23:49:03 +02:00
Andreas Kling
7254d4c4b8 LibCoreDump: Convert String::format() => String::formatted() 2021-04-21 23:49:03 +02:00
Andreas Kling
f4a15c8d42 LibCore: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
9db2036437 LibGUI: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
9a8dd38493 LibWeb+Base: Convert String::format() to String::formatted()
This error page template is slightly hilarious and should probably
be replaced with AK::SourceGenerator or some such, but for now let's
just get rid of the call to String::format().
2021-04-21 23:49:02 +02:00
Andreas Kling
83d3003208 LibDebug: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
c68dcf45b6 LibRegex: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
90ee84621f LibLine: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
4e6d2374b6 LibVT: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
2a6a54dea5 Userland: Use Core::DirIterator::next_full_path()
Simplify some code by using this instead of concatenating the full path
ourselves at the call site.
2021-04-21 23:49:01 +02:00
Andreas Kling
dba58ad9ec LibX86: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
e875d4e044 LibGfx: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
d996e43df6 LibGfx: Minor clean-ups in Gfx::FontDatabase
Use Core::DirIterator::next_full_path() instead of manually building
each path.

Also convert a fprintf(stderr, ...) to warnln()
2021-04-21 23:49:01 +02:00
Andreas Kling
e5318d51e6 LibCore: Remove the barely-used Core::safe_syscall()
This was a helper that would call a syscall repeatedly until it either
succeeded or failed with a non-EINTR error.

It was only used in two places, so I don't think we need this helper.
2021-04-21 23:49:01 +02:00
Rafał
c41c41cc0f
LibGUI: Prevent selecting empty line in TextEditor on double click (#6537) 2021-04-21 23:48:26 +02:00
Timothy Flynn
6cbf88ad4c LibSQL: Rename TestSqlParser -> TestSqlStatementParser
A little bit clearer what is being tested now, since the expression
parser also lives in its own file.
2021-04-21 21:37:55 +02:00
Timothy Flynn
733806b6a1 LibSQL: Parse DELETE statement 2021-04-21 21:37:55 +02:00
Timothy Flynn
ce6c7ae18a LibSQL: Parse most language expressions
https://sqlite.org/lang_expr.html

The entry point to using expressions, parse_expression(), is not used
by SQL::Parser in this commit. But there's so much here that it's easier
to grok as its own commit.
2021-04-21 21:37:55 +02:00
Timothy Flynn
8c8d611fb3 LibSQL: Add forwarding header
SQL AST nodes will need to have other node types forward declared before
using them.
2021-04-21 21:37:55 +02:00
Timothy Flynn
a11f49f627 LibSQL: Add Parser::consume_if helper
The following is a common (and soon to be *very* common) expression:

    if (match(token_type))
        consume();

Using consume_if() makes this a bit simpler and makes it less likely to
forget to invoke consume() after the match().
2021-04-21 21:37:55 +02:00
Timothy Flynn
570aa57df3 LibSQL: Lex string and blob literals
Blob literals are the same as string literals except prefixed with an
'x' or 'X'.
2021-04-21 21:37:55 +02:00
Lenny Maiorani
ece8aeaaf4 Everywhere: Remove redundant inline keyword with constexpr
Problem:
- `constexpr` functions are additionally decorated with `inline`
  keyword. This is redundant since `constexpr` implies `inline`.

Solution:
- Remove redundancies.
2021-04-21 20:49:49 +02:00
Idan Horowitz
ec67b1ac32 LibWeb: Implement scientific notation parsing in PathDataParser
This was required by webkit.org and is based on the following spec:
https://svgwg.org/svg2-draft/paths.html#PathDataBNF
2021-04-21 18:57:50 +02:00
iCristalrope
8bb4409a5d
LibGUI: Track selection starting index in AbstractView (#6515)
Modifying the selection while holding the shift button and selecting
with the mouse or the arrow keys no longer results in broken selections.

Fixes #6279.
2021-04-21 17:09:04 +02:00
jakewestrip
b9fc7780ae LibGUI: Remove premature return in Window::handle_key_event 2021-04-21 15:24:57 +02:00
Ali Mohammad Pur
f90a1f83ed LibJS: Precompile Heap.h and GlobalObject.h
This is somewhat noticable difference (~10s), as these two headers are
basically included in every single JS file anyway.
2021-04-21 14:29:46 +02:00
FalseHonesty
58d6781cbb HackStudio+LibDebug: Support stopping a debugged process
In LibDebug this required implementing the Kill debug action, and
in HackStudio this required making the toolbar's stop action stop
the debugger if active.
2021-04-21 13:42:09 +02:00
Brian Gianforcaro
5a31ca06db LibPthread: Add non functional pthread_attr_[set|get]scope stubs
Standard: https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getscope.html

Needed for https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
14f6425b8f LibC: Add pwrite(..) implementation to match the existing pread(..)
Add a basic non-thread safe implementation of pwrite, following the
existing pread(..) design.

This is needed for https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
56ba3e1cbd LibC: Add LOG_NOWAIT stub to syslog.h
Needed for porting https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
2ebb3f3c0d LibC: Add a definition for INET6_ADDRSTRLEN
Although serenity doesn't implement IPv6 yet, applications
will often declare buffers to be of size `INET6_ADDRSTRLEN`
so it's guaranteed to work in both IPv4 / IPv6 environments.

This is needed specifically for a port of Flexible IO Tester
https://fio.readthedocs.io

This is standardized here:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/netinet/in.h.html
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
a1720eed2a LibC: Setup a unit test harness for LibC, add ctime_r / asctime_r tests.
LibC is no different than any other code, it should be unit tested where
appropriate / possible.
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
df808f0ed3 LibC: Fix missing '\n' at the end of ctime/ctime_r/asctime/asctime_r
@linusg noticed this bug in the original implementation during code review.
This makes all of these API's more spec conforming.
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
440b81deba LibC: Add ctime_r() and asctime_r() implementations
Need this for a port of FIO (Flexible IO Tester)
https://fio.readthedocs.io/
2021-04-21 08:04:52 +02:00
Marco Biscaro
8124719c3d Tests: Reorganize LibCompress unit tests
Move LibCompress unit tests to LibCompress/Tests directory and register
them with CMake's add_test. This allows us to run these tests with
ninja test instead of running a separate executable.

Also split the existing tests in 3 test files that better follow the
source code structure (inspired by AK tests).
2021-04-21 08:00:32 +02:00
Andreas Kling
78733417a4 LibWeb: Register FormAssociatedElement with their owner form
This will eventually allow us to implement HTMLFormControlsCollection.
2021-04-20 23:38:27 +02:00
Andreas Kling
e454e1a45d LibWeb: Make HTMLSelectElement a FormAssociatedElement 2021-04-20 23:38:27 +02:00
Gunnar Beutner
2520ccfca4 LibPthread: Add stubs for pthread_spin_* functions
The stress-ng port depends on these now that it detects we have
thread support.
2021-04-20 21:08:17 +02:00
Gunnar Beutner
88cebb05ad LibC+LibPthread: Implement function forwarding for libpthread
GCC will insert various calls to pthread functions when compiling
C++ code with static initializers, even when the user doesn't link
their program against libpthread explicitly.

This is used to make static initializers thread-safe, e.g. when
building a library that does not itself use thread functionality
and thus does not link against libpthread - but is intended to
be used with other code that does use libpthread explicitly.

This makes these symbols available in libc.
2021-04-20 21:08:17 +02:00
Linus Groh
7400e3d8fc LibWeb: Don't call ResourceLoader error callback on 4xx status code
A website with a 4xx status code is still a valid website, we should not
artificially hide it. In fact, many websites implement custom 404 error
pages for example, often containing search functionality or links back
to the homepage.
This might have implications regarding the loading of stylesheets where
the request 404s, but since we were not handling 5xx status codes as
errors either, I think that's fine for now (but might need additional
work later). Worst case, the parser rejects to load some error page HTML
as CSS :^)
2021-04-20 19:47:23 +02:00
Linus Groh
7af1d2c170 LibJS: Make Object.getOwnPropertyDescriptor() work with string indexed property
E.g. for "0" we have to contruct a PropertyName with Type::Number so it
looks in the indexed properties as expected.
2021-04-20 18:53:07 +02:00
Linus Groh
614bad86bc LibJS: Fix Object.getOwnPropertyDescriptor() attributes for numeric property
We were getting the attributes of the existing value and then
immediately assigned the default attributes instead.
2021-04-20 18:42:10 +02:00
Tobias Christiansen
5338708091 LibWeb: Display <ol> and respect list-style-type in <ul>
In the ListItemMarkerBox render the correct thing when painting.
This covers decimal counting for ordered lists as well as square,
disc, and circle for unordered lists. Thus all currently supported
list-style-types are displayed correctly.

This closes #2059
2021-04-20 18:29:19 +02:00
Tobias Christiansen
bfcfe84240 LibWeb: Make the ListItemMarkerBox index-aware.
In the ListItemBox we get the index of the current <li> element in the
parent and pass it to the ListItemMarkerBox.

This patch is work towards #2059
2021-04-20 18:29:19 +02:00
Tobias Christiansen
c09ac536c5 LibWeb: Add capabilities to find the index of a child in its parent.
For Elements depending on the index they are inside their parent. Most
notably the <ol> element.
Also added a typed version to only count children of a certain type.

This patch is work towards #2059
2021-04-20 18:29:19 +02:00