Commit graph

29072 commits

Author SHA1 Message Date
Ben Wiederhake e6ea13af61 LibSyntax: Add missing headers to HighlighterClient.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake 9d89b64d59 LibSQL: Resolve cyclic dependency
Previously, class SQL::Key
depends on def class SQL::IndexDef (because inline def index())
depends on def class SQL::KeyPartDef (inline def key_definition())
depends on def class SQL::ColumnDef (because base class)
depends on def class SQL::Relation (because base class)
depends on def class SQL::Key (because inline def hash()).

This hasn't caused any problems so far because Meta.h happened to be
always included after Key.h (in part due to alphabetical ordering).

However, a compilation that for example only contains
    #include <Userland/Libraries/LibSQL/Key.h>
would fail to compile.

This patch resolves this issue by pushing the inline definition of
SQL::Relation::hash() into a different file. Yes, this might reduce
performance marginally, but this gets it to compile again.
2021-10-06 23:52:40 +01:00
Ben Wiederhake a95b321bf1 LibJS: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake 9d2e06b039 LibGUI: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake 5f25182cd5 LibCrypto: Add missing header to EMSA_PSS.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake ce1313fbdc LibCompress: Add missing header to DeflateTables.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake f9a4f4f7e6 LibC: Fix redeclaration in x86_64/regs.h
In QtCreator (and under weird configurations with gcc), this used to
fail with the error messages like: "error: member of anonymous union
redeclares '___'".

This patch gives each member a unique name.
2021-10-06 23:52:40 +01:00
Ben Wiederhake 8ba572d650 LibC: Make sure ARCH macro is available before use 2021-10-06 23:52:40 +01:00
Ben Wiederhake 7cd0440571 Base: Fix idempotency in 'little' example 2021-10-06 23:52:40 +01:00
Ben Wiederhake f8d7b4daea AK: Add missing headers
Example failure:

IDAllocator.h only pulls in AK/Hashtable.h, so any compilation unit that
includes AK/IDAllocator.h without including AK/Traits.h before it used
to be doomed to fail with the cryptic error message "In instantiation of
'AK::HashTable<T, TraitsForT, IsOrdered>::Iterator AK::HashTable<T,
TraitsForT, IsOrdered>::find(const T&) [with T = int; TraitsForT =
AK::Traits: incomplete type 'AK::Traits<int>' used in nested name
specifier".
2021-10-06 23:52:40 +01:00
sin-ack c330ad27b6 SystemMonitor: Use u64 for all GraphWidget values
Turns out size_t is not guaranteed to be 64-bit on i686 and trying to
set the max value using a u64 caused a narrowing conversion.
2021-10-07 00:42:24 +02:00
Andreas Kling 4444bcabde LibJS: Make Reference aware of DeclarativeEnvironment indices
VM::resolve_binding() can now return a Reference that knows the exact
binding index if it's pointing into a DeclarativeEnvironment.

Reading/writing through the Reference will now use direct environment
access when possible.
2021-10-07 00:23:36 +02:00
Andreas Kling 540ce075b6 LibJS: Add direct (indexed) binding accessors to DeclarativeEnvironment
This patch adds two DeclarativeEnvironment APIs:

- get_binding_value_direct()
- set_mutable_binding_direct()

These work identically to their non-direct-suffixed counterparts, but
take an index instead of a bound name. This will allow someone who has
a binding index to get/set that binding directly without any additional
hash lookups.
2021-10-07 00:23:36 +02:00
Andreas Kling cb696eff08 LibJS: Make Environment::has_binding() optionally return binding index
If the caller wants to use the binding index for anything, if there is
such a thing, it can now be obtained via an optional out-parameter.
2021-10-07 00:23:36 +02:00
Andreas Kling 6ef5464015 LibJS: Make DeclarativeEnvironment store bindings in a Vector
The previous storage for DeclarativeEnvironment looked like this:

    HashMap<FlyString, Binding> m_bindings;

This patch changes that to:

    HashMap<FlyString, size_t> m_names;
    Vector<Binding> m_bindings;

The main goal here is to give each binding an index that can ultimately
be cached and used for optimized environment accesses.
2021-10-07 00:23:36 +02:00
sin-ack 7aa3cfda09 SystemMonitor: Use size_t for graph values
The memory and CPU graphs fail to display anything when the memory size
is larger than 2**31 bytes, because of the small range of int. This
commit makes replaces the type with size_t. Hopefully nobody will have
18 quintillion bytes of memory before this gets replaced. :^)
2021-10-07 00:04:05 +02:00
Andreas Kling f73aa8e2bd LibWeb: Move line boxes from Layout::Box to BlockContainer
Per the spec, only a BlockContainer" can have line boxes, so let's not
clutter up every Layout::Box with line boxes.

This also allows us to establish an invariant that BFC and IFC always
operate on a Layout::BlockContainer.

Note that if BlockContainer has all block-level children, its line boxes
are not used for anything. They are only used in the all inline-level
children scenario.
2021-10-06 21:53:25 +02:00
Andreas Kling a0bea52a5f LibWeb: Mark Layout::ListItemMarkerBox as never having children
List item markers will never have children, so let's mark them as such,
which now allows our layout system to skip over their "insides" and
going straight to positioning instead.
2021-10-06 21:49:09 +02:00
Andreas Kling dfeb4550d5 LibWeb: Don't attempt to layout the inside of childless boxes
Some boxes cannot have children (most commonly replaced elements),
and so there is nothing meaningful inside them to layout.

We now use the can_have_children() flag to quickly skip over such boxes
instead of creating a formatting context and other pointless busywork.
2021-10-06 21:47:57 +02:00
Andreas Kling d9e0fd8823 LibWeb: Rename Layout::Node::is_block_box() => is_block_container() 2021-10-06 20:10:36 +02:00
Andreas Kling fa45b905bf LibWeb: Remove unused local in FormattingContext::layout_inside() 2021-10-06 20:10:36 +02:00
Andreas Kling c4826eae4f LibWeb: Rename Layout::BlockBox => BlockContainer
There's a subtle difference here. A "block box" in the spec is a
block-level box, while a "block container" is a box whose children are
either all inline-level boxes in an IFC, or all block-level boxes
participating in a BFC.

Notably, an "inline-block" box is a "block container" but not a "block
box" since it is itself inline-level.
2021-10-06 20:10:36 +02:00
Andreas Kling 5408913b22 LibWeb: Add BlockFormattingContext::root()
The CSS spec uses the name "block formatting context root" when talking
about a box that establishes a BFC. So let's call it BFC::root() in our
code as well, instead of the less specific BFC::context_box().
2021-10-06 20:10:36 +02:00
Hediadyoin1 bce3bf9f1e UserspaceEmulator: Handle PerfEvent syscalls
We only froward String setting and FlagPost creation for now, due to the
other performance events being nonsensical to forward.
We also record these signposts in the optionally generated profile.
2021-10-06 17:35:29 +00:00
Hendiadyoin1 045461b7cb UserspaceEmulator: Use only the base name for the profile name 2021-10-06 17:35:29 +00:00
Andreas Kling 2494ce2bab LibWeb: Add CSS/Display.h 2021-10-06 19:30:14 +02:00
Andreas Kling fc36f830ae Tests: Disable LibThreading detach tests for now
These tests don't pass (at least not without KVM) at the moment,
so let's not run them on CI.
2021-10-06 19:21:35 +02:00
Andreas Kling 85a0772147 LibWeb: Start work towards modern CSS "display" values
Until now, we've internally thought of the CSS "display" property as a
single-value property. In practice, "display" is a much more complex
property that comes in a number of configurations.

The most interesting one is the two-part format that describes the
outside and inside behavior of a box. Switching our own internal
representation towards this model will allow for much cleaner
abstractions around layout and the various formatting contexts.

Note that we don't *parse* two-part "display" yet, this is only about
changing the internal representation of the property.

Spec: https://drafts.csswg.org/css-display
2021-10-06 19:12:52 +02:00
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