Commit graph

34057 commits

Author SHA1 Message Date
Ali Mohammad Pur
6a4c8a66ae LibRegex: Only skip full instructions when optimizing alternations
It makes no sense to skip half of an instruction, so make sure to skip
only full instructions!
2022-02-09 21:02:24 +00:00
Lenny Maiorani
f0d2489254 Applications: Port Assistant to LibMain 2022-02-09 21:01:52 +00:00
electrikmilk
133a30c8b7 Base+Browser: Add browser icons
Add local storage and style sheet icons. I also noticed the name of the
DOM tree icon needed updated (tree => dom_tree).
2022-02-09 21:00:37 +00:00
Ali Mohammad Pur
3bfcd7b52d LibJS: Implement Sets using Maps
This implements ordered sets using Maps with a sentinel value, and
includes some extra set tests.
Fixes #11004.

Co-Authored-By: davidot <davidot@serenityos.org>
2022-02-09 20:57:41 +00:00
Ali Mohammad Pur
4a73ec07c5 LibJS: Make Map iterators independent of the underlying hashmap
This implements ordered maps as a pair of an RBTree for key order, and
an underlying unordered hash map for storage.
Fixes (part of) #11004.
2022-02-09 20:57:41 +00:00
Ali Mohammad Pur
e7dea10381 AK: Add RBTree::find_smallest_above_iterator(Key) 2022-02-09 20:57:41 +00:00
Ali Mohammad Pur
9ff22ac7e0 LibHTTP: Skip the body when response code is 204
...even if the headers claim that there's some data in the form of
Content-Length.
This finally fixes loading Discord with RequestServer ConnectionCache
on :^)
2022-02-09 21:23:25 +01:00
Ali Mohammad Pur
cb7becb067 LibTLS+RequestServer: Add an option to dump TLS keys to a log file
This file allows us to decrypt TLS messages in wireshark, which can help
immensely in debugging network stuff :^)
2022-02-09 21:23:25 +01:00
Sam Atkins
a796207b9f LibWeb: Paint box-shadows more efficiently
Our previous code roughly did this:

1. Generate a bitmap as large as the shadow would end up.
2. Paint a rectangle onto it.
3. Blur the whole bitmap.
4. Split it up and render each section.

This patch takes advantage of the fact that (aside from corners) each
horizontal or vertical strip of a box-shadow is identical to the
others, to generate and blur a much smaller bitmap - only large enough
for the four corners and 1px of central "side" in each direction. This
greatly reduces the memory footprint, and should also speed things up,
since there is much less to blur.
2022-02-09 19:36:26 +01:00
Andreas Kling
3ec71e1400 LibC: Remove debug spam in getaddrinfo() 2022-02-09 19:36:15 +01:00
Daste
a22323ecce Browser: Make underlined shortcuts in "Debug" menu unique 2022-02-09 19:33:51 +01:00
electrikmilk
1d8b213b5b Base+Browser: Add browser icons folder
Move browser specific icons to their own folder in /res/icons/
2022-02-09 19:33:28 +01:00
Lenny Maiorani
138d54e595 AK+Kernel: Alphabetize debug macros
This is not ASCII-betical because `_` comes after all the uppercase
characters. Treating `_` as a ` ` (space character), these lists are
now alphabetical.
2022-02-09 17:59:19 +00:00
Andrew Kaster
820e99f97d LibWeb: Add initial implementation for WorkerGlobalScope
This initial implementation stubs out the WorkerGlobalScope,
WorkerLocation and WorkerNavigator classes. It doesn't take into account
all the things that actually need passed into the constructors for these
objects, nor the extra abstract operations that need to be performed on
them by the rest of the Browser infrastructure. However, it does create
bindings that compile and link :^)
2022-02-09 17:21:05 +01:00
Daniel van Gerpen
8b38df72a3 LibSQL: Update list of expected statements
Add an entry for the DESCRIBE TABLE statement and add an Oxford comma.
2022-02-09 15:35:37 +00:00
Brian Gianforcaro
2e81990a3c LibWeb: Do not set Content-Length headers twice for POST requests
While trying to get http://lite.duckduckgo.com to work in the Browser I
noticed that we kept on getting 400 (Bad Request) errors when you click
the "Search" button for a request.

After turning on `JOB_DEBUG` to see what headers we were sending it
turned out that we were actually setting `Content-Length` twice once
in LibWeb, and again when the request is handled by LibHTTP.

Since LibHTTP transparently handles this now, we can avoid it in LibWeb.
2022-02-09 14:05:07 +00:00
electrikmilk
72e0d3d20b Base: Enlarge globe in CSS file icon
Make globe in CSS file icon more visible.
2022-02-09 13:54:14 +00:00
Andreas Kling
0ba2a3ff30 LibWeb: Don't fill or stroke SVG <path> with transparent color
Before this, we were filling and stroking every <path>, whether they had
a fill/stroke color or not. We can avoid a bunch of unnecessary work by
checking if the color is transparent (also the case if unset) before
doing the painting work.

If there is no fill color, we also avoid making a copy of the path to
ensure that it's closed.
2022-02-09 13:44:00 +01:00
Linus Groh
7676b1b925 LibJS: Remove MarkedValueList in favor of MarkedVector<Value> :^) 2022-02-09 12:25:27 +00:00
Linus Groh
6508ff5bbd LibWeb: Stop using MVL for sequence storage in WrapperGenerator
Use MarkedVector<Value> instead.
2022-02-09 12:25:27 +00:00
Linus Groh
bc183dbbcb LibJS: Replace uses of MarkedValueList with MarkedVector<Value>
This is effectively a drop-in replacement.
2022-02-09 12:25:27 +00:00
Linus Groh
1d32ac7b8b LibJS: Convert get_iana_time_zone_epoch_value() to MarkedVector<BigInt*> 2022-02-09 12:25:27 +00:00
Linus Groh
af7003ebd2 LibJS: Convert 'possible instants' AOs to MarkedVector<Instant*>
Resolve TODOs suggesting the use of a strongly typed MarkedValueList
(a.k.a. MarkedVector<T>) in the following AOs:

- get_possible_instants_for()
- disambiguate_possible_instants()
2022-02-09 12:25:27 +00:00
Linus Groh
a863363b06 LibJS: Let MarkedVector<T> inherit from Vector and handle Cell* + Value
Note: MarkedVector is still relatively new and has zero users right now,
so these changes don't affect any code other than the class itself.

Reasons for this are the rather limited API:

- Despite the name and unlike MarkedValueList, MarkedVector isn't
  actually a Vector, it *wraps* a Vector. This means that plenty of
  convenient APIs are unavailable and have to be exported on the class
  separately and forwarded to the internal Vector, or need to go through
  the exposed Span - both not great options.
- Exposing append(Cell*) and prepend(Cell*) on the base class means that
  it was possible to append any Cell type, not just T! All the strong
  typing guarantees are basically gone, and MarkedVector doesn't do much
  more than casting Cells to the appropriate type through the exposed
  Span.

All of this combined means that MarkedVector - in its current form -
doesn't provide much value over MarkedValueList, and that we have to
maintain two separate, yet almost identical classes.

Let's fix this!

The updated MarkedVector steals various concepts from the existing
MarkedValueList, especially the ability to copy. On the other hand, it
remains generic enough to handle both Cell* and Value for T, making
MarkedValueList effectively redundant :^)

Additionally, by inheriting from Vector we get all the current and
future APIs without having to select and expose them separately.

MarkedVectorBase remains and takes care of communicating creation and
destruction of the class to the heap. Visiting the contained values is
handled via a pure virtual method gather_roots(), which is being called
by the Heap's function of the same name; much like the VM has one.
From there, values are added to the roots HashTable if they are cells
for T = Value, and unconditionally for any other T.

As a small additional improvement the template now also takes an
inline_capacity parameter, defaulting to 32, and forwards it to the
Vector template; allowing for possible future optimizations of current
uses of MarkedValueList, which hard-codes it to 32.
2022-02-09 12:25:27 +00:00
Timothy Flynn
3c88749800 CI: Bundle and upload a js(1) release package
To include Serenity's LibJS on test262.report, we will need to integrate
with esvu. Create a .tar.gz with js(1) binary and the Lagom libraries it
it needs to run, and upload that package as a build artifact.
2022-02-09 12:19:56 +03:30
Timothy Flynn
636a6a2fb8 Meta: Add a CPack installation target for js(1)
This adds a CPack configuration to generate a release package for js(1).
Our current CMake requirement is 3.16, which doesn't have a great story
for automatically installing a binary target's library dependencies. If
we eventually require CMake 3.21 or above, we can remove the helper
.cmake file added here in lieu of RUNTIME_DEPENDENCIES.
2022-02-09 12:19:56 +03:30
Rodolfo Olivieri
a05d25d4e5 CI: Add statement to ensure workflow runs only on serenity
Ensure that the `cmake.yml` workflow runs only on SerenityOS repository.
2022-02-09 11:27:06 +03:30
Andrew Kaster
353e72ac9b LibC+Kernel: Remove global variable use from snprintf and fprintf
The global variable use in these functions is super thread-unsafe and
means that any concurrent calls to sprintf or fprintf in a process
could race with each other and end up writing unexpected results.
We can just replace the function + global variable with a lambda that
captures the relevant argument when calling printf_internal instead.
2022-02-09 06:22:33 +00:00
Itamar
8ec4328fcb HackStudio: Allow toggling between simple and semantic highlighting
Until it becomes enough stable and performant, semantic highlighting is
disabled by default.

It can be toggled on via the "Project" menu in HackStudio.
2022-02-09 00:51:31 +01:00
Itamar
81dcf6c58b Base: Add more syntax highlighting color roles to the Default theme 2022-02-09 00:51:31 +01:00
Itamar
aba2e03b71 HackStudio: Use the C++ semantic syntax highlighter
HackStudio::Editor will now send a request to get semantic token
information to the language server whenever there's a short pause in
editing.

The result is used by the semantic c++ syntax highlighter to provide
better highlighting information.
2022-02-09 00:51:31 +01:00
Itamar
10d75d7f21 LibGUI: Add TextEditor::force_rehighlight() method 2022-02-09 00:51:31 +01:00
Itamar
22f835332a LibGfx: Add more syntax-related ColorRoles 2022-02-09 00:51:31 +01:00
Itamar
4646bf4b92 LibCpp: Add SemanticSyntaxHighlighter
The SemanticSyntaxHighlighter uses TokenInfo results from the
language server to provide 'semantic' syntax highlighting, which
provides more fin-grained text spans results.

For example, the SemanticSyntaxHighlighter can color function calls,
member fields references and user-defined types in different colors.

With the simple lexer-only syntax highlighter, all of these tokens were
given the same text highlighting span type.

Since we have to provide immediate highlighting feedback to the user
after each edit and before we get the result for the language server,
we use a heuristic which computes the diff between the current tokens
and the last known tokens with compete semantic information
(We use LibDiff for this).

This heuristic is not very performant, and starts feeling sluggish with
bigger (~200 LOC) files.
A possible future improvement would be only computing the diff for
tokens in text ranges that have changes since the last commit.
2022-02-09 00:51:31 +01:00
Itamar
4737fc2485 LibDiff: Flush leftover hunks at the end
This change makes sure that we arrive at the end of the "DP-matrix" and
flush any leftover hunks to get a complete diff result.
2022-02-09 00:51:31 +01:00
Itamar
33043f269d HackStudio: Add tokens_info_result() and tokens_info_result() IPC calls
These IPC calls are used in the communication with the language server
to fetch semantic information about the tokens in a code document.
2022-02-09 00:51:31 +01:00
Itamar
76000e9137 LanguageServers/Cpp: Make find_declaration_of() more flexible
Previously, find_declaration_of() only worked for AST nodes of type
Identifier. It now also works for declaration node, member variables
and function parameters.
2022-02-09 00:51:31 +01:00
Itamar
a54d0cc805 LibGUI+HackStudio: Add TokenInfo struct for language-server IPC
The TokenInfo struct contains the token's position and a
"semantic type". The semantic type is a more fine-grained token type
than what's in Cpp::Token::Type.
For example, the semantic token type differentiates between a reference
to a variable and to a function parameter. In the normal Token::Type,
both would be Token::Type::Identifier.
2022-02-09 00:51:31 +01:00
Itamar
605becb28b LibCpp: Update regressions tests results
The LibCpp regression tests results have to be updated after tweaking
the token end position calculation logic of some token types.
2022-02-09 00:51:31 +01:00
Itamar
b67a090b79 LibCpp: Fix lexing of IncludePath token
Previously, there was a duplicate IncludePath token in the lexing
result.
2022-02-09 00:51:31 +01:00
Itamar
bed60b2d49 LibCpp: Add Preprocessor:unprocessed_token() 2022-02-09 00:51:31 +01:00
Itamar
4a8afd6b4e LibCpp: Add public Parser::tokens() method 2022-02-09 00:51:31 +01:00
Itamar
4f1c77a059 LibCpp: Fix end position calculation for various AST node types
Previously, the end position of the Type and Name nodes was incorrect.
It was incorrectly set to the start position of the next unconsumed
token.

This commit adds a previous_token_end() method and uses it to correctly
get the end position for these node types.
2022-02-09 00:51:31 +01:00
Itamar
ae68355a56 LibCpp: Fix parent of parameter type node
Previously, the parent of a parameter's Type node was incorrectly set
to the parent of the Parameter node.

We now set the parent of the parameter's Type node to the Parameter
node itself.
2022-02-09 00:51:31 +01:00
Itamar
36aac14798 LibCpp: Fix Declaration::is_member()
Previously, Declaration::is_member() was just a stub that always
returned false.

It now works by checking whether the parent ASTNode is a declaration
of a struct or a class type.
2022-02-09 00:51:31 +01:00
Idan Horowitz
13aee1b780 LibJS: Compare types instead of sizes in %TypedArray%.prototype.set
Just checking for a matching size is not enough, since floats and ints
have the same size, but are represented completely differently.
2022-02-08 23:08:43 +00:00
Idan Horowitz
c7a8902746 LibJS: Make TypedArray::element_name return FlyString instead of String
This ensures that comparison between TypedArray names will be
essentially free (just a pointer comparison), which will allow us to
efficiently implement specification steps like:
"24. If srcType is the same as targetType, then"
efficiently.
2022-02-08 23:08:43 +00:00
Idan Horowitz
9839e2eeb6 LibJS: Implement the missing step 20 in %TypedArray%.prototype.set 2022-02-08 23:08:43 +00:00
Idan Horowitz
20d3869182 LibJS: Implement the CloneArrayBuffer AO 2022-02-08 23:08:43 +00:00
Idan Horowitz
d225b5e94c LibJS: Add spec comments to %TypedArray%.prototype.set 2022-02-08 23:08:43 +00:00