Commit Graph

28644 Commits

Author SHA1 Message Date
Junior Rantila
1552873275 Tests: Add LibThreading to CMakeLists.txt 2021-10-06 19:05:39 +02:00
Marco Cutecchia
3c5e07fa1c HackStudio: Save editor's font in configs 2021-10-06 17:14:40 +02:00
Marco Cutecchia
423c2e44c9 HackStudio: Add option to change the editor's font 2021-10-06 17:14:40 +02:00
Andreas Kling
f2b626daba LibWeb: Add a handful of missing CSS "display" value identifiers 2021-10-06 17:14:22 +02:00
Andreas Kling
0264ae23bc LibWeb: Make CSS layout lazier
Instead of doing layout synchronously whenever something changes,
we now use a basic event loop timer to defer and coalesce relayouts.

If you did something that requires a relayout of the page, make sure
to call Document::set_needs_layout() and it will get coalesced with all
the other layout updates.

There's lots of room for improvement here, but this already makes many
web pages significantly snappier. :^)

Also, note that this exposes a number of layout bugs where we have been
relying on multiple relayouts to calculate the correct dimensions for
things. Now that we only do a single layout in many cases, these kind of
problems are much more noticeable. That should also make them easier to
figure out and fix. :^)
2021-10-06 17:14:22 +02:00
Tim Schumacher
228a32effc Kernel: Don't retrieve possibly nonexistent APIC table 2021-10-06 17:11:02 +02:00
Rodrigo Tobar
c3a6d96988 Ports: Patch Python to deal with Serenity's strftime
The xmlrpc.client module has some trial-and-error logic at module import
time to figure out how to properly format years using strftime. There
have already been problems in the past with this code in Python (see
https://bugs.python.org/issue13305, which is still open), and Serenity
only adds to that.

This problem has been reported at https://bugs.python.org/issue45386, so
hopefully in time we won't need this patch anymore.
2021-10-06 13:57:52 +01:00
Rodrigo Tobar
c38c93bff1 Ports: Patch Python's http.client due to unimplemented socket option
This problem has been reported on https://bugs.python.org/issue45328 and
a fix has been provided, potential review and merge are pending.
2021-10-06 13:57:52 +01:00
Peter Elliott
e02c843af4 LibMarkdown: Add blockquotes 2021-10-06 12:35:46 +02:00
Peter Elliott
2227a80f34 LibMarkdown: Add blockquote support to LineIterator
This patch adds contexts to line iterator for nesting list items and
blockquotes. It also incidentally makes the api for LineIterator
simpler, and will make it easier to add other containers in the future.
2021-10-06 12:35:46 +02:00
Rodrigo Tobar
4b091a7cc2 LibELF: Fix dynamic linking of dlopen()-ed libs
Consider the situation where two shared libraries libA and libB, both
depending (as in having a NEEDED dtag) on libC. libA is first
dlopen()-ed, which produces libC to be mapped and linked. When libB is
dlopen()-ed the DynamicLinker would re-map and re-link libC though,
causing any previous references to its old location to be invalid. And
if libA's PLT has been patched to point to libC's symbols, then any
further invocations to libA will cause the code to jump to a virtual
address that isn't mapped anymore, therefore causing a crash. This
situation was reported in #10014, although the setup was more convolved
in the ticket.

This commit fixes the issue by distinguishing between a main program
loading being performed by Loader.so, and a dlopen() call. The main
difference between these two cases is that in the former the
s_globals_objects maps is always empty, while in the latter it might
already contain dependencies for the library being dlopen()-ed. Hence,
when collecting dependencies to map and link, dlopen() should skip those
that are present in the global map to avoid the issue described above.

With this patch the original issue seen in #10014 is gone, with all
python3 modules (so far) loading correctly.

A unit test reproducing a simplified issue is also included in this
commit. The unit test includes the building of two dynamic libraries A
and B with both depending on libline.so (and B also depending on A); the
test then dlopen()s libA, invokes one its function, then does the same
with libB.
2021-10-06 12:33:21 +02:00
Peter Elliott
669b23ac0a Kernel: Handle backspace for tab character in TTY cooked mode
Before, serenity would only backspace one character for a tab.
This is the only feature that my OS has and serenity doesn't.
2021-10-06 12:31:13 +02:00
Peter Elliott
c515121844 AK: Calculate CircularQueue::end() correctly
Previously end() was only correct when m_head == 0.
2021-10-06 12:31:13 +02:00
Brian Gianforcaro
3b7d8ed6a5 Meta: Add actions work flow to run pvs-studio static analysis
Much like the sonar cloud workflow, this workflow runs pvs-studio
static analysis, and uploads the SARIF results to github. This
is the most "convenient" way to publish results, but unfortunately
users need write access to the repository to reach static analysis
results rendered in github.

As a work around folks can just look at the logs where issues are
printed during analysis, this works reasonably well.

In the future it might make sense to also render the results as HTML
and publish them using github page, much like we do with man pages.
I believe the pvs-studio plog-converter tool supports that as well.
https://pvs-studio.com/en/docs/manual/0036/
2021-10-05 20:07:04 +00:00
Linus Groh
fe802f5ff5 js: Fix pretty-printing of RegExp objects
Regressed in b7e5f08.

Use the newly available RegExpObject::escape_regexp_pattern() instead of
attempting to call the RegExp.prototype.source accessor getter directly.
2021-10-05 18:35:49 +01:00
Linus Groh
78fd8c1ca2 LibJS: Make escape_regexp_pattern() a RegExpObject member function
Similarly to regexp_initialize() this can be a member function instead
of taking a RegExpObject argument.
Having it available outside RegExpPrototype is also useful for other
things that need RegExp.prototype.source behavior - e.g. the REPL for
pretty-printing.
2021-10-05 18:35:49 +01:00
Andreas Kling
83bd675477 LibJS: Make WeakContainer pruning do less work
Instead of iterating *all* swept cells when pruning weak containers,
only iterate the cells actually *in* the container.

Also, instead of compiling a list of all swept cells, we can simply
check the Cell::state() flag to know if something should be pruned.
2021-10-05 18:52:00 +02:00
Sam Atkins
19fc225b45 Base: Add window.matchMedia() test to media-queries.html 2021-10-05 18:51:39 +02:00
Sam Atkins
050823bea7 LibWeb: Fire MediaQueryListEvents when an MQL's match-state changes
The HTML event loop does a check for MQL match-state changes and
dispatches the events. This requires us to keep a list of MQLs on the
Document.
2021-10-05 18:51:39 +02:00
Sam Atkins
1c829e0417 LibWeb: Implement MediaQuery matching :^)
Currently, `evaluate()` recalculates whether the MediaQuery matches or
not, and stores it in `m_matches`, which users can query using
`matches()`. This allows us to know when the match-state changes, which
is required to fire MediaQueryList's change event.
2021-10-05 18:51:39 +02:00
Sam Atkins
f354fd72f1 LibWeb: Split Length::absolute_length_to_px() out from to_px()
In cases where we know the Length is absolute, we know we don't need to
pass in a Layout::Node or FontMetrics etc, and yet we were required to
before. Splitting it means jumping through less hoops that we don't have
to. :^)
2021-10-05 18:51:39 +02:00
Sam Atkins
fd51b02f9d LibWeb: Implement Window::query_media_feature()
This method provides the needed information to evaluate media queries.

Every feature in Media Queries Level 4 is present, either as code or as
a FIXME: https://www.w3.org/TR/mediaqueries-4/#media-descriptor-table
There's a draft Level 5 which I have ignored for now.

Some are unimplemented for now since we do not have access to the
requested information. Some require StyleValue types that we do not yet
support. Many are hard-coded for now since we do not (and may never)
support monochrome or text-only displays for Browser.
2021-10-05 18:51:39 +02:00
Sam Atkins
de82764f2f LibWeb: Add identifiers used by MEDIAQUERIES-4
To avoid duplicating a lot of functionality, we're using StyleValues for
the values of media-features. So, we need their identifiers added here.
2021-10-05 18:51:39 +02:00
Sam Atkins
68c246368b LibWeb: Predeclare MediaList and CSSRuleList 2021-10-05 18:51:39 +02:00
Sam Atkins
341c67453c LibWeb: Add resolved style lookup for border properties
The only one I didn't implement is `border` itself, because there isn't
an obvious sensible value for it if the borders are different.
2021-10-05 18:49:47 +02:00
Sam Atkins
a521c02db2 LibWeb: Add resolved style lookup for margin/padding shorthands 2021-10-05 18:49:47 +02:00
Sam Atkins
fc7af21c7c LibWeb: Make things aware of box-sizing
Of course, we don't actually *use* the box-sizing property yet, but the
value is applied and shows up in the computed style.
2021-10-05 18:49:47 +02:00
Rodrigo Tobar
3c192f492a Ports: Compile Python against OpenSSL to gain ssl module
Compiling against an OpenSSL thread-enabled shared library (see #10207)
lets Python compile its _ssl module, which yields an importable ssl
module.

The ssl module suffers from the same problem described in #10014 though,
namely that python crashes when importing different modules results in
multiple libcrypto.so loads, and its functions are later invoked by one
of the modules. Once #10277 is merged though the module becomes quite
usable.
2021-10-05 15:45:08 +01:00
Rodrigo Tobar
dc03c559df Ports: Compile OpenSSL with threads and as a shared library
By defining our own target platform in the OpenSSL compilation
configuration we can now compile an OpenSSL shared library. We need to
avoid symbol versioning though, as serenity's LibELF doesn't support
this yet.

We are now also compiling with threading support to allow using this
from Python.
2021-10-05 15:35:48 +01:00
Marco Cutecchia
80e70f95ab PixelPaint: Fix first undo action not working 2021-10-05 15:41:21 +02:00
Marco Cutecchia
c7431da3f2 PixelPaint: Ensure a layer is selected when restoring a snapshot
Previously when restoring the starting snapshot in the UndoStack we
would end up with no layer selected, which was kinda annoying
2021-10-05 15:41:21 +02:00
Andreas Kling
6108bac606 LibJS: Only do a single property lookup in internal_get_own_property()
Instead of checking storage_has(), followed by storage_get(), we can do
storage_get() directly and avoid a redundant property lookup.

This exposed a bug in SimpleIndexedPropertyStorage::get() which would
previously succeed for array holes.
2021-10-05 15:15:29 +02:00
Linus Groh
8074bdc049 LibJS: Skip declarative env in block statement without lexical decls
The idea here is simple: If the block statement doesn't contain any
lexical declarations, we don't need to allocate, initialize and
eventually garbage collect a new declarative environment.
This even makes lookups across nested blocks slightly faster as we don't
have to traverse a chain of empty environments anymore - instead, the
execution context just stores the outermost non-empty one.

This doesn't speed up test-js considerably, but has a noticeable effect
on test262 and real-world web content :^)
2021-10-05 14:52:53 +02:00
Mohsan Ali
d609dde7b0 2048: Let user decide if he wants to continue the game
Before game finish when a player has reached target tile,
Now player will be able to decide if he wants to continue or not
2021-10-05 13:27:57 +03:30
Peter Elliott
accf4b338d AK: Expand to_int<i64> to to_int<long> and to_int<long long>
This change also applys to to_uint

On i686 u64 == long long but on x86_64 u64 == long. Therefor on either
arch, one of the instantiations is missed. This change makes sure that
all integer types have an instantiation.
2021-10-05 13:27:25 +03:30
Peter Elliott
285038ebcf LibMarkdown: Add start numbers for ordered lists
5. hey -> <ol start="5"><li>hey</li></ol>
2021-10-05 13:27:25 +03:30
Peter Elliott
a76a23e33b LibMarkdown: Allow spaces before list items
also allow '+' as an unordered list marker
2021-10-05 13:27:25 +03:30
Peter Elliott
0a21c2bace LibMarkdown: Implement "tightness" for lists
From the commonmark spec:
A list is loose if any of its constituent list items are separated by
blank lines, or if any of its constituent list items directly contain
two block-level elements with a blank line between them. Otherwise a
list is tight. (The difference in HTML output is that paragraphs in a
loose list are wrapped in <p> tags, while paragraphs in a tight list are
not.)
2021-10-05 13:27:25 +03:30
Peter Elliott
5bb87c630c LibMarkdown: Allow non-text items in Lists 2021-10-05 13:27:25 +03:30
Peter Elliott
10f6f6a723 LibMarkdown: Add LineIterator
LineIterator wraps a vector's ConstIterator, to provide an iterator that
can work on indented container blocks (like lists and blockquotes).
2021-10-05 13:27:25 +03:30
Peter Elliott
cd560d3ae3 LibMarkdown: Refactor Document's parser into ContainerBlock
This will better allow us too do things like have Lists and blockquotes
support multiple blocks.
2021-10-05 13:27:25 +03:30
Linus Groh
4fa5748093 LibJS: Add an optimization to avoid needless arguments object creation
This gives FunctionNode a "might need arguments object" boolean flag and
sets it based on the simplest possible heuristic for this: if we
encounter an identifier called "arguments" or "eval" up to the next
(nested) function declaration or expression, we won't need an arguments
object. Otherwise, we *might* need one - the final decision is made in
the FunctionDeclarationInstantiation AO.

Now, this is obviously not perfect. Even if you avoid eval, something
like `foo.arguments` will still trigger a false positive - but it's a
start and already massively cuts down on needlessly allocated objects,
especially in real-world code that is often minified, and so a full
"arguments" identifier will be an actual arguments object more often
than not.

To illustrate the actual impact of this change, here's the number of
allocated arguments objects during a full test-js run:

Before:
- Unmapped arguments objects: 78765
- Mapped arguments objects: 2455

After:
- Unmapped arguments objects: 18
- Mapped arguments objects: 37

This results in a ~5% speedup of test-js on my Linux host machine, and
about 3.5% on i686 Serenity in QEMU (warm runs, average of 5).

The following microbenchmark (calling an empty function 1M times) runs
25% faster on Linux and 45% on Serenity:

    function foo() {}
    for (var i = 0; i < 1_000_000; ++i)
        foo();

test262 reports no changes in either direction, apart from a speedup :^)
2021-10-05 10:15:14 +01:00
Linus Groh
fcb355f193 LibJS: Set arguments_object_needed = false if scope_body == nullptr
For obvious reasons.
2021-10-05 10:15:14 +01:00
Linus Groh
b2bded390a LibJS: Stop iterating lexically declared names once 'arguments' is found
In ECMAScriptFunctionObject::function_declaration_instantiation() we
iterate over all lexically declared names of the function scope body to
determine whether any of them is named 'arguments', because we don't
need to create an arguments object in that case. We can also stop at
that point, because the decision won't change anymore.
2021-10-05 10:15:14 +01:00
Linus Groh
3ab22c8012 LibJS: Rename needs_argument_object to arguments_object_needed
- It's an "arguments object", not "argument object"
- This is what the spec calls it (argumentsObjectNeeded)
2021-10-05 10:15:14 +01:00
fleximus
3115a5306d LookupServer: Fix to handle whitespaces and tabs in /etc/hosts 2021-10-05 02:23:45 +02:00
Jan de Visser
fe50598a03 LibSQL: Allow expressions and column names in SELECT ... FROM
Up to now the only ``SELECT`` statement that worked was ``SELECT *
FROM <table>``. This commit allows a column list consisting of
column names and expressions in addition to ``*``. ``WHERE``
still doesn't work though.
2021-10-05 02:22:19 +02:00
Jan de Visser
f33a288ca4 SQL Utility: Implement reading sql files
Add a number of command line switches:
- '-r/--read': Read a SQL file and quit the REPL when done
- '-s/--source': Read a SQL file and return to a SQL prompt when done
- '--no-sqlrc': Do not read ~/.sqlrc on startup (see below)

Add a dot-command:
.read <filename>: Read a SQL file and return to a SQL prompt when done

In addition, the sql REPL will source the ~/.sqlrc file on startup if
it exists, unless the --no-sqlrc flag is set on startup.

Note the slight asymmetry between the --read command line flag (which
results in the program quitting when the file is read) and the .read
command (which doesn't cause a quit).

Also fix merge conflict with #10091
2021-10-05 02:22:19 +02:00
Jan de Visser
89835ec83c SQL Utility: Redesigned the input loop
The existing input loop called the `read_sql` method recursively. This
lead to strange behaviour in the event loop. This is solved by
encapsulating the REPL in an object and ensuring the `read_sql` method
is not called recursively. The method now returns after the first
recognized SQL statement or command.
2021-10-05 02:22:19 +02:00
Jan de Visser
9d9f082221 SQL Utility: Implement connection switching
You can now connect to a different database using the .connect meta
command.
2021-10-05 02:22:19 +02:00