Commit graph

34025 commits

Author SHA1 Message Date
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
electrikmilk
4263dad838 Base: Change JSON file icon to add CSS file icon
Add CSS icon and add replacement JSON icon as the colors conflict.

Update HackStudioWidget.cpp
2022-02-08 22:42:47 +00:00
Jackson
d55978c254 Ports: Fix lua not building 2022-02-08 22:21:00 +00:00
Kenneth Myhra
bf7f6a9e98 LibWeb: Implement EventHandler::focus_previous_element()
This implements EventHandler::focus_previous_element() so we can cycle
backwards through focusable elements on a web page with Shift+Tab.
2022-02-08 22:15:10 +00:00
Andreas Kling
3f9fc0f690 Browser+LibWeb: Add "Dump Local Storage" item to Browser's Debug menu 2022-02-08 21:53:20 +01:00
Andreas Kling
47979996e8 LibWeb: Add Storage interface and window.localStorage
This is a naive-but-somewhat-functional initial implementation of
HTML Storage.

Note that there is no persistence yet, everything is in-process only,
and one local Storage object per origin.
2022-02-08 21:53:20 +01:00
Andreas Kling
a856cf8d4c LibWeb: Allow using Origin as a HashMap key 2022-02-08 21:53:20 +01:00
Ali Mohammad Pur
5dceba29a4 RequestServer: Avoid Vector OOB access in ConnectionCache
`it.is_end()` could be updated to return false for a previously-invalid
iterator after we append a new socket, copy its value out to a local
variable to not hit this behaviour.
2022-02-08 18:47:19 +00:00
Linus Groh
fd0f1d0c1a LibJS: Fix two typos in comments 2022-02-08 18:17:12 +00:00
Luke Wilde
17aeb99e9e LibWeb: Implement the JS host hooks for promises, job callbacks and more
This overrides the JS host hooks to follow the spec for queuing
promises, making/calling job callbacks, unhandled promise rejection
handling and FinalizationRegistry queuing.

This also allows us to drop the on_call_stack_emptied hook in
Document::interpreter().
2022-02-08 17:47:44 +00:00
Luke Wilde
4c1c6ef91c LibJS: Setup host hooks and have promise jobs work out the realm
This allows the host of LibJS (notably LibWeb in this case) to override
certain functions such as HostEnqueuePromiseJob, so it can do it's own
thing in certain situations. Notably, LibWeb will override
HostEnqueuePromiseJob to put promise jobs on the microtask queue.

This also makes promise jobs use AK::Function instead of
JS::NativeFunction. This removes the need to go through a JavaScript
function and it more closely matches the spec's idea of "abstract
closures"
2022-02-08 17:47:44 +00:00
Luke Wilde
5aacec65ab LibWeb: Rewrite EventTarget to more closely match the spec
This isn't perfect (especially the global object situation in
activate_event_handler), but I believe it's in a much more complete
state now :^)

This fixes the issue of crashing in prepare_for_ordinary_call with the
`i < m_size` crash, as it now uses the IDL callback functions which
requires the Environment Settings Object. The environment settings
object for the callback is fetched at the time the callback is created,
for example, WrapperGenerator gets the incumbent settings object for
the callback at the time of wrapping. This allows us to remove passing
in ScriptExecutionContext into EventTarget's constructor.

With this, we can now drop ScriptExecutionContext.
2022-02-08 17:47:44 +00:00
Luke Wilde
3bb5c6207f LibWeb: Make FormAssociatedElement inherit from HTMLElement
The new event target implementation requires us to downcast an
EventTarget to a FormAssociatedElement to check if the current Element
EventTarget has a form owner to setup a with scope for the form owner.

This also makes all form associated elements inherit from
FormAssociatedElement where it was previously missing.

https://html.spec.whatwg.org/#form-associated-element
2022-02-08 17:47:44 +00:00
Luke Wilde
f71f404e0c LibWeb: Introduce the Environment Settings Object
The environment settings object is effectively the context a piece of
script is running under, for example, it contains the origin,
responsible document, realm, global object and event loop for the
current context. This effectively replaces ScriptExecutionContext, but
it cannot be removed in this commit as EventTarget still depends on it.

https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
2022-02-08 17:47:44 +00:00
Andreas Kling
4db5406d62 LibWeb: Support passing more parameter types to HTML::report_exception()
We now allow any JS::ThrowCompletion<T>, as well as JS::Completion
directly (although we'll VERIFY() that it's a throw completion.)
2022-02-08 17:47:44 +00:00
Rafał Babiarz
3383ae1598 LibWeb: Fixed disabled checkbox input behaviour
Previously disabled checkbox could be checked by clicking on it's label
2022-02-08 17:51:33 +01:00
Sam Atkins
103613a3a9 LibWeb: Incorporate spread-distance into box-shadow rendering
We also pass whether the shadow goes inside or outside the element. Only
outer shadows are rendered currently, and inner ones may want to be
handled separately from them, as they will never interfere with each
other.
2022-02-08 17:45:51 +01:00
Sam Atkins
10c6c77b5c LibWeb: Render multiple box-shadows
Because why not? :^)
2022-02-08 17:45:51 +01:00
Sam Atkins
b51f428165 LibWeb: Parse multiple box-shadows :^)
Again, we don't yet render these (we render nothing) but this gets rid
of a decent amount of CSS spam on Discord.
2022-02-08 17:45:51 +01:00
Sam Atkins
e5b0369dfd LibWeb: Parse spread-distance and inset parts of box-shadow
We do not actually use these when rendering the shadow yet.
2022-02-08 17:45:51 +01:00
Sam Atkins
c547bed13b LibWeb: Reorganize box-shadow parsing code
The pattern we've adopted for other multi-value properties is to run in
a loop like this, since that makes it easier to cater for values
appearing in different orders.
2022-02-08 17:45:51 +01:00
thankyouverycool
1cd77fd1b4 WindowServer: Preserve cursor position when dragging between states
Previously windows would end up in awkward positions relative to
the move cursor when dragging between tile types or unmaximizing.
This feels a bit more ergonomic.
2022-02-08 16:37:46 +01:00
thankyouverycool
ee637b44fb WindowServer: Add Vertically/HorizontallyMaximized WindowTileTypes
VerticallyMaximized tiling replaces set_vertically_maximized() to
take advantage of tiling ergonomics.

Middle-clicking a window's maximize button now tiles vertically;
secondary-clicking tiles horizontally.

Adds Super+Alt+Arrow shortcuts for both. Super+Left/Right tiling
shortcuts now let windows shift between tile types directly.
2022-02-08 16:37:46 +01:00
thankyouverycool
32be05957a WindowServer: Fix comments in WindowManager 2022-02-08 16:37:46 +01:00
thankyouverycool
1607fd511f WindowServer: Unify Window restore rects
Previously, different rects were used to restore tiled and maximized
windows, creating edge cases for inconsistent restoration. All states
now restore m_floating_rect, which saves the last valid size and
location of a window while free-floating.
2022-02-08 16:37:46 +01:00
thankyouverycool
3d7e701451 WindowServer: Rename Window::tiled() => tile_type() and add is_tiled()
This seems more consistent with naming conventions across the system
and makes conditionals easier to read.
2022-02-08 16:37:46 +01:00
Ali Mohammad Pur
d3c25b8ea2 LibCore: Make BufferedHelper::read() block at most once per read
The previous method could block multiple times, leading to a completely
stuck/deadlocked read() call, and it could also consume data without
telling the user about it, which is Not A Good Thing ™️.
This patch makes it block at most once, and fixes loading HTTP pages
with LibHTTP :^)
2022-02-08 15:43:20 +01:00
Lady Gegga
17a3dd23f4 Base: Add Sinhala character to font Katica Regular 10
0D9E https://www.unicode.org/charts/PDF/U0D80.pdf
2022-02-08 10:48:30 +00:00
Lady Gegga
2768f6cfbc Base: Add Transport and Map Symbols to font Katica Regular 10
1F6E0 https://www.unicode.org/charts/PDF/U1F680.pdf
2022-02-08 10:48:30 +00:00
Lady Gegga
c8ae84fd5c Base: Add Miscellaneous Symbols and Pictographs to Katica Regular 10
1F519, 1F51A, 1F51B, 1F51C, 1F51D, 1F52C, 1F52D, 1F53E, 1F53F, 1F5A5
https://www.unicode.org/charts/PDF/U1F300.pdf
2022-02-08 10:48:30 +00:00
Lady Gegga
5aa1f55150 Base: Add Enclosed Alphanumeric Supplement to font Katica Regular 10
1F12A, 1F12F, 1F130, 1F131, 1F132, 1F133, 1F134, 1F135, 1F136, 1F137,
1F138, 1F139, 1F13A, 1F13B, 1F13C, 1F13D, 1F13E, 1F13F, 1F140, 1F141,
1F142, 1F143, 1F144, 1F145, 1F146, 1F147, 1F148, 1F149, 1F150, 1F151,
1F152, 1F153, 1F154, 1F155, 1F156, 1F157, 1F158, 1F159, 1F15A, 1F15B,
1F15C, 1F15D, 1F15E, 1F15F, 1F160, 1F161, 1F162, 1F163, 1F164, 1F165,
1F166, 1F167, 1F168, 1F169, 1F16A, 1F16B, 1F16C, 1F16D, 1F16E, 1F16F,
1F170, 1F171, 1F172, 1F173, 1F174, 1F175, 1F176, 1F177, 1F178, 1F179,
1F17A, 1F17B, 1F17C, 1F17D, 1F17E, 1F17F, 1F180, 1F181, 1F182, 1F183,
1F184, 1F185, 1F186, 1F187, 1F188, 1F189, 1F1E6, 1F1E7, 1F1E8, 1F1E9,
1F1EA, 1F1EB, 1F1EC, 1F1ED, 1F1EE, 1F1EF, 1F1F0, 1F1F1, 1F1F2, 1F1F3,
1F1F4, 1F1F5, 1F1F6, 1F1F7, 1F1F8, 1F1F9, 1F1FA, 1F1FB, 1F1FC, 1F1FD,
1F1FE, 1F1FF
https://www.unicode.org/charts/PDF/U1F100.pdf
2022-02-08 10:48:30 +00:00
Lady Gegga
6ad0e0a99f Base: Add Miscellaneous Symbols and Arrows to font Katica Regular 10
2B05, 2B08, 2B09, 2B0A, 2B0B, 2B12, 2B13, 2B14, 2B15, 2B16,
2B17, 2B18, 2B19, 2B1A, 2B24, 2B25, 2B26, 2B45, 2B46, 2BD0,
2BD1, 2BD2
https://www.unicode.org/charts/PDF/U2B00.pdf
2022-02-08 10:48:30 +00:00
Lady Gegga
d32c519da6 Base: Add Dingbats to Katica Regular 10
2754, 2776, 2777, 2778, 2779, 277A, 277B, 277C, 277D, 277E,
277F, 27A0, 27A1, 27A5, 27A6, 27A7, 27AF, 27B0, 27B1, 27B2,
27B3, 27BE, 27BF
https://www.unicode.org/charts/PDF/U2700.pdf
2022-02-08 10:48:30 +00:00