Commit Graph

5952 Commits

Author SHA1 Message Date
Andreas Kling
ce2747692d LibJS: Remove unused DeclarativeEnvironmentRecord::type()
Nothing was using this, and we now have separate classes for the
different types of environment records instead.
2021-06-24 13:28:15 +02:00
Andreas Kling
0cd65b55bd LibJS: Add ObjectEnvironmentRecord.[[IsWithEnvironment]] field
This is true for environments created by `with` statements, and false
for other (global) object environments.

Also add the WithBaseObject abstract operation while we're here.
2021-06-24 13:26:00 +02:00
Jamie Mansfield
3f8857cd21 Games: Add Spider
Scoring is designed to mimic Microsoft's implementation - starting at
500, decreasing by 1 every move, and increasing by 100 for every full
stack.

Fixes GH-5319.
2021-06-24 10:32:53 +02:00
Jamie Mansfield
b7e806e15e LibCards: Support non-alternating colour patience games
This introduces a new MovementType concept to LibCards, starting the
process to allow other patience games to be implemented using it - that
differ more substantially from Klondike in logic.

This is currently used for two purposes: 1. to verify that the
'grabbed' stack of cards is valid* (sequential and correct colours) and
2. to allow 'grabbed' stacks to be pushed onto same-colour,
either-colour, or alternating-colour stacks

* Klondike doesn't need this logic, as per how the game works any
  'grabbed' selection is guaranteed to be valid.
2021-06-24 10:32:53 +02:00
Gunnar Beutner
1ae7d68885 LibSymbolication: Fix incorrect argument type for symbolicate() 2021-06-24 09:27:13 +02:00
Gunnar Beutner
f2eb759901 Profiler: Use u32 when constructing InstructionData
When constructing values of the InstructionData type we assume that
the event_count field is a size_t while it actually is a u32. On x86_64
this fails because those are different types.
2021-06-24 09:27:13 +02:00
Gunnar Beutner
c9a8dfa1bf Userland: Add more TODO()s for arch-specific code
This enables building more of the userspace applications for x86_64.
2021-06-24 09:27:13 +02:00
Sam Atkins
f2d6cac692
Solitaire: Maybe fix rare crash from completing a game with TAB (#8217)
The crash happens very rarely and is hard to reproduce so it is
hard to know for certain, but I am confident this fixes it.

I previously delayed the start of the game-over animation by one
frame, but neglected to check m_start_game_over_animation_next_frame
wasn't set. This means multiple calls to start_game_over_animation()
on the same frame (or rather, before the first timer_event) would
each call Object::start_timer(). Now that we do check the flag,
that should no longer be possible.

Fixes #8122.
2021-06-24 09:25:01 +02:00
Gunnar Beutner
ac650d2362 Userland: Remove dummy IPC methods
They're not used anywhere and are unnecessary boilerplate code. So let's
remove them and update IPCCompiler to allow for empty endpoint
declarations.
2021-06-24 00:38:58 +02:00
Hendiadyoin1
37253ebcae LibELF: Fix missing include
A few files are expecting that someone brings PAGE_SIZE from possibly
the Kernel with them
2021-06-24 00:38:23 +02:00
Jan de Visser
5c4890411b LibSQL: Make lexer and parser more standard SQL compliant
SQL was standardized before there was consensus on sane language syntax
constructs had evolved. The language is mostly case-insensitive, with
unquoted text converted to upper case. Identifiers can include lower
case characters and other 'special' characters by enclosing the
identifier with double quotes. A double quote is escaped by doubling it.
Likewise, a single quote in a literal string is escaped by doubling it.

All this means that the strategy used in the lexer, where a token's
value is a StringView 'window' on the source string, does not work,
because the value needs to be massaged before being handed to the
parser. Therefore a token now has a String containing its value. Given
the limited lifetime of a token, this is acceptable overhead.

Not doing this means that for example quote removal and double quote
escaping would need to be done in the parser or in AST node
construction, which would spread lexing basically all over the place.
Which would be suboptimal.

There was some impact on the sql utility and SyntaxHighlighter component
which was addressed by storing the token's end position together with
the start position in order to properly highlight it.

Finally, reviewing the tests for parsing numeric literals revealed an
inconsistency in which tokens we accept or reject: `1a` is accepted but
`1e` is rejected. Related to this is the fate of `0x`. Added a FIXME
reminding us to address this.
2021-06-24 00:36:53 +02:00
Jan de Visser
4198f7e1af LibSQL: Move Lexer and Parser machinery to AST directory
The SQL engine is expected to be a fairly sizeable piece of software.
Therefore we're starting to restructure the codebase for growth.
2021-06-24 00:36:53 +02:00
Federico Guerinoni
e0f1c237d2 HackStudio: Make TODO entries clickable
Now you can click a TODO entry to set focus on that position of that
file.
2021-06-23 19:00:11 +01:00
Federico Guerinoni
935c7b2f4b HackStudio: Add TODO entries widget 2021-06-23 19:00:11 +01:00
Federico Guerinoni
26a7356e90 LanguageServers: Add function to collect TODO entries in a document 2021-06-23 19:00:11 +01:00
Federico Guerinoni
c397e030f4 LibCpp: Add function for retrieving TODO comments from the parser
Now `get_todo_entries` collects all TODO found within a comment
statement.
2021-06-23 19:00:11 +01:00
Ali Mohammad Pur
fcef84c461 LibVT: Rewrap the terminal history along with the normal buffer 2021-06-23 19:04:08 +02:00
Ali Mohammad Pur
4bf14715a1 LibLine: Recalculate the origin on resize 2021-06-23 19:04:08 +02:00
Ali Mohammad Pur
2f2b7814d1 LibVT+Terminal: Implement line wrapping
This commit implements line wrapping in the terminal, and tries its best
to move the cursor to the "correct" position.
2021-06-23 19:04:08 +02:00
Ali Mohammad Pur
424965954f LibVT: Keep track of the 'true' line endings 2021-06-23 19:04:08 +02:00
Aatos Majava
3b2a528b33 LibTextCodec: Add Turkish (aka ISO-8859-9, Windows-1254) encoding 2021-06-23 16:32:47 +01:00
Gunnar Beutner
21ee0ad6fc LibVT: Don't crash when clicking outside of the terminal's buffer area
When resizing a terminal window the number of columns may change.
Previously we assumed that this also affects lines which were in the
terminal's buffer while that is not necessarily true.
2021-06-23 16:26:40 +02:00
Linus Groh
c503a28e19 LibJS: Make AggregateError inherit from Error
This is our way of implementing the [[ErrorData]] internal slot, which
is being used in Object.prototype.toString().
2021-06-23 13:59:17 +01:00
Linus Groh
0e8cbfb7b5 LibJS: Fix AggregateError's class_name() 2021-06-23 13:55:43 +01:00
Andreas Kling
15faa13c95 LibJS: Add spec links to a bunch of the environment record methods 2021-06-23 13:25:57 +02:00
Andreas Kling
cf34313fad LibJS: Remove no-longer-needed environment record shape
We had a cached shape for environment records to make instantiating
them fast. Now that environment records don't inherit from JS::Object,
we can just get rid of this. :^)
2021-06-23 13:08:40 +02:00
Andreas Kling
9ccc2f6c4d LibJS: Make EnvironmentRecord inherit directly from Cell
Previously, EnvironmentRecord was a JS::Object. This was done because
GlobalObject inherited from EnvironmentRecord. Now that this is no
longer the case, we can simplify things by making EnvironmentRecord
inherit from Cell directly.

This also removes the need for environment records to have a shape,
which was awkward. This will be removed in the following patch.
2021-06-23 13:08:27 +02:00
Gunnar Beutner
7a87e920f2 HexEditor: Change name for unsaved files to 'Untitled' 2021-06-23 13:08:14 +02:00
Gunnar Beutner
b246221eac HexEditor: Prompt the user to save changes when opening a file 2021-06-23 13:08:14 +02:00
Andreas Kling
f1e1d9dd74 LibJS: Add EnvironmentRecord::global_object()
Our environment records are currently weird in that they inherit from
Object, but don't have a connection to the global object.

I'd like to remove this inheritance, and the first step is giving them
their own pointer to the global object.
2021-06-23 12:50:26 +02:00
Andreas Kling
9d49a5478a LibJS: Start implementing spec-compliant variable bindings
This patch adds the concept of variable bindings to the various
environment record classes. The bindings are not yet hooked up to
anything, this is just fleshing out all the operations.

Most of this is following the spec exactly, but in a few cases we are
missing the requisite abstract operations to do the exact right thing.
I've added FIXME's in those cases where I noticed it.
2021-06-23 12:50:21 +02:00
Anonymous
2822da8c8f LibJS: Correct behaviour of direct vs. indirect eval
eval only has direct access to the local scope when accessed through
the name eval. This includes locals named eval, because of course it
does.
2021-06-23 09:38:33 +01:00
Hendiadyoin1
5d24b5f4be UserspaceEmulator: Add a simple debugging Console
For now this only allows us to single-step through execution and inspect
part of the execution environment for debugging
This also allows to run to function return and sending signals to the VM

This changes the behavior of SIGINT for UE to pause execution and then
terminate if already paused

A way of setting a watchpoint for a function would be a good addition in
the future, the scaffold for this is already present, we only need to
figure out a way to find the address of a function

On a side note I have changed all occurences of west-const to east const
2021-06-23 12:41:37 +04:30
Xavier Defrang
9dfc96f89b DisplaySettings: Revert changes unless confirmed 2021-06-23 01:27:21 +02:00
Gunnar Beutner
40f7977508 LibGfx: Fix drawing rounded corners when using display scaling 2021-06-22 23:46:16 +02:00
Peter Elliott
49539abee0 ChessEngine: don't store board in non-leaf nodes in MCTS
Also make parameters static so they aren't in every node of the tree
this saves a substantial amount of memory.
2021-06-22 23:09:42 +02:00
Peter Elliott
34433f5dc4 LibChess: Compact the Defenitions of various chess related types
before:
sizeof(Board)=344, sizeof(Move)=36, sizeof(Piece)=4, sizeof(Square)=8

after:
sizeof(Board)=108, sizeof(Move)=9, sizeof(Piece)=1, sizeof(Square)=2
2021-06-22 23:09:42 +02:00
Peter Elliott
57bb4d1aec LibChess: Only save hash of board state for repetition checking
This more than doubles the number of nodes that MCTS can search for a
given time limit, and greatly reduces memory usage.
2021-06-22 23:09:42 +02:00
Timothy Flynn
675b8ba995 FlappyBug: Standardize on "high score" rather than "highscore"
"High score" should be two words, and this matches other games in the
system.
2021-06-22 23:05:10 +02:00
Timothy Flynn
1a2053781f FlappyBug: Persist high score to disk
Previously, the high score was only in-memory, so only persisted for as
long as the FlappyBug window was open.
2021-06-22 23:05:10 +02:00
Timothy Flynn
25c53e35e7 FlappyBug: Convert the main game widget to a GUI::Frame 2021-06-22 23:05:10 +02:00
Gunnar Beutner
928364e102 TextEditor: Don't open files when the user cancelled saving changes
Steps to reproduce:

1. Start TextEditor and make some changes to the document.
2. Try to open an existing file.
3. When prompted choose to save the changes to the existing document.
4. Close the file picker by clicking 'Cancel'.
5. Note how the file was opened anyway and your changes were lost.

Same applies to the 'New File' action.
2021-06-22 22:56:22 +02:00
Gunnar Beutner
92fdc5bd69 Playground: Prompt to save changes after the user picked a file to open
There's no point in saving the file - and potentially having to ask the
user for a file name - if the user abandons the 'Open' action by
clicking 'Cancel' in the file picker. This now also matches TextEditor's
behavior.
2021-06-22 22:56:22 +02:00
Gunnar Beutner
c2ae25967a Playground: Add a menu action to save the file
There was already 'Save As' and now we also have 'Save'.
2021-06-22 22:56:22 +02:00
Gunnar Beutner
de84b3fa1c Playground: Ask to save changes even when the document was never saved
This makes sure to ask the user whether they want to save changes to
their current document when opening a file even if the document has
never been saved before.
2021-06-22 22:56:22 +02:00
PAUL007
3d42297ecd Taskbar: Check if executable in .af exist in filesystem
This adds access X_OK check in discover_apps_and_categories()
to see executable specified in .af files exist before
registering them for start menu.
2021-06-22 22:48:32 +02:00
Andreas Kling
8a3c9d9851 LibJS: Remove direct argument loading since it was buggy
The parser doesn't always track lexical scopes correctly, so let's not
rely on that for direct argument loading.

This reverts the LoadArguments bytecode instruction as well. We can
bring these things back when the parser can reliably tell us that
a given Identifier is indeed a function argument.
2021-06-22 22:20:17 +02:00
Andreas Kling
1082e99e08 LibJS: Make GlobalEnvironmentRecord forward to the right function
This was accidentally deleting a property from the object record object
itself, rather than from the object record.

It's quite confusing that Environment Records are objects, but moving
away from that will require some large changes.
2021-06-22 22:18:23 +02:00
davidot
f7e2994f35 LibJS: Make string to integer parsing for properties more strict
This does break two TypedArray test262 test but those really were not
  correct because hasProperty was not implemented
2021-06-22 20:49:28 +01:00
davidot
105e72cdad LibJS: Add HasProperty to TypedArray 2021-06-22 20:49:28 +01:00
davidot
f102b56345 LibJS: Fix this_value in native setters and getters
This fixes getting values from double proxies:
var p = new Proxy(new Proxy([], {}), {});
p.length
2021-06-22 20:49:28 +01:00
davidot
9d1fd403af LibJS: Fix small issues in Array.prototype.concat 2021-06-22 20:49:28 +01:00
davidot
91de1135a5 LibJS: Fix a number of regressions in the test262 tests
In get_own_properties:
Entries which are deleted while iterating need to be skipped

In PropertyDescriptor::from_dictionary
If the getter/setter is undefined it should still mark it as present
2021-06-22 20:49:28 +01:00
davidot
733e8472fa LibJS: Make put_own_property_by_index closer to spec
Most of the code is taken from put_own_property however the attributes
  need to be handled slightly differently it seems
2021-06-22 20:49:28 +01:00
davidot
a770c26d54 LibJS: Use Set/CreateDataPropertyOrThrow in Array.prototype as in spec
Mapping:
  Set -> put (does not throw by default)
  CreateDataPropertyOrThrow -> define_property
2021-06-22 20:49:28 +01:00
davidot
15edad8202 LibJS: Make define_property always throw if specified
Now put uses is_strict_mode to determine define_property should throw
2021-06-22 20:49:28 +01:00
davidot
e10219a293 LibJS: Use the new force_throw_exception in delete_property 2021-06-22 20:49:28 +01:00
davidot
16b87b85e3 LibJS: Add parameter to delete_property since we need DeleteOrThrow 2021-06-22 20:49:28 +01:00
Linus Groh
8a06a93ce2 LibJS: Return non-object argument unaltered from Object.setPrototypeOf()
This was missing step 3 from the spec:

    3. If Type(O) is not Object, return O.

Also use RequireObjectCoercible() for a better error message and make
the rest of the code a bit easier to read and more similar to the spec
text.
2021-06-22 18:59:24 +01:00
Andreas Kling
1f8b6ac3c3 LibJS: Begin implementing GlobalEnvironmentRecord
These represent the outermost scope in the environment record
hierarchy. The spec says they should be a "composite" of two things:

- An ObjectEnvironmentRecord wrapping the global object
- A DeclarativeEnvironmentRecord for other declarations

It's not yet clear to me how this should work, so this patch only
implements the first part, an object record wrapping the global object.
2021-06-22 18:44:53 +02:00
Andreas Kling
1d20380859 LibJS: Split the per-call-frame environment into lexical and variable
To better follow the spec, we need to distinguish between the current
execution context's lexical environment and variable environment.

This patch moves us to having two record pointers, although both of
them point at the same environment records for now.
2021-06-22 18:44:53 +02:00
Andreas Kling
aabd82d508 LibJS: Bring function environment records closer to the spec
This patch adds FunctionEnvironmentRecord as a subclass of the existing
DeclarativeEnvironmentRecord. Things that are specific to function
environment records move into there, simplifying the base.

Most of the abstract operations related to function environment records
are rewritten to match the spec exactly. I also had to implement
GetThisEnvironment() and GetSuperConstructor() to keep tests working
after the changes, so that's nice as well. :^)
2021-06-22 18:44:53 +02:00
Andreas Kling
6ed6434bab LibJS: Remove home object from DeclarativeEnvironmentRecord
According to the spec, [[HomeObject]] is an internal slot on function
objects, and should always be accessed through there.
2021-06-22 18:44:53 +02:00
coderdreams
6bc7f2204e Tests: Run each test in their respective directories
This is so they can find their associated resources and it's
the same behavior as in Lagom.

This also required changing some tests so that they could
write their resources in a writable location.
2021-06-22 18:54:40 +04:30
Linus Groh
714a96619f LibJS: Disallow whitespace or comments between regex literal and flags
If we consumed whitespace and/or comments after a RegexLiteral token,
the following token must not be RegexFlags - no whitespace or comments
are allowed between the closing / and the flag characters.

Fixes #8201.
2021-06-22 14:08:40 +01:00
Gunnar Beutner
f1ac0b6a5a WindowServer: Send events once when global cursor tracking is enabled
Previously we'd send mouse events twice if the target window had
global cursor tracking enabled.
2021-06-22 11:00:44 +02:00
Davipb
20b2c46019 PixelPaint: Allow copying arbitrary selections
This replaces the naive copy algorithm that only supported rectangular
and 100% opaque selections with a more general approach that supports
any shape and alpha value.

Note that we now make a brand new bitmap with a hardcoded format instead
of just cropping the layer's existing bitmap. This is done to ensure
that the final clipboard image will have an alpha channel.
2021-06-22 11:00:00 +02:00
Davipb
e58f78e667 PixelPaint: Add more options to RectangleSelectTool
A "feather" value sets by how much the borders of the selection will be
smoothed, and a "mode" value sets how the newly selected region will
interact with an existing image selection (if any).
2021-06-22 11:00:00 +02:00
Davipb
22585e2845 PixelPaint: Expose more complex selection operations
Now that we use RectMask internally to store the selection, we can
expose more powerful APIs to allow for better control over the image
selection.
2021-06-22 11:00:00 +02:00
Davipb
d922e35579 PixelPaint: Use Mask internally in Selection
While the external API has not changed, this will allow us to have
non-rectangular selections in the future.
2021-06-22 11:00:00 +02:00
Davipb
0828c75e57 PixelPaint: Add a Mask class
The Mask class represents an opacity mask over a rectangular section
of an image, linking every pixel to an alpha value ranging from 0 (not
selected) to 255 (fully selected). "Partially selected" pixels can be
used to simulate anti-aliased curves.

This class will be used as the basis for the new non-rectangular
selection feature.
2021-06-22 11:00:00 +02:00
FalseHonesty
4f0a75224c PDFViewer: Update the page number when scrolling between pages 2021-06-22 06:26:44 +04:30
Andreas Kling
395bee07e0 LibJS: Implement the NewObjectEnvironment() abstract operation 2021-06-22 01:17:15 +02:00
Andreas Kling
d8e9a176cd LibJS: Implement the NewDeclarativeEnvironment() abstract operation 2021-06-22 01:17:15 +02:00
Andreas Kling
c6baeca6d7 LibJS: Add ObjectEnvironmentRecord to Forward.h
And sort the forward declared classes alphabetically, for our friends
who enjoy alphabetically sorted things. :^)
2021-06-22 01:17:15 +02:00
bitwitch
7181943d8d LaunchServer: Fix regression in opening files with TextEditor
My previous PR had a small error in rebasing and removed a line in
open_file_url. This caused opening text files from the terminal to
always open with an empty TextEditor.

This commit fixes that problem!
2021-06-22 00:05:51 +02:00
Andreas Kling
08510a0c80 LibJS: Rename VM::current_scope() => current_environment_record()
And rename some related functions that wrapped this as well.
2021-06-21 23:49:50 +02:00
Andreas Kling
d407f247b7 LibJS: Rename virtuals in EnvironmentRecord
This patch makes the following renames:

- get_from_scope() => get_from_environment_record()
- put_to_scope() => put_into_environment_record()
- delete_from_scope() => delete_from_environment_record()
2021-06-21 23:49:50 +02:00
Andreas Kling
5edd259b0a LibJS: Rename EnvironmentRecord::parent() => outer_environment()
This name matches the spec (corresponds to the [[OuterEnv]] slot.)
2021-06-21 23:49:50 +02:00
Andreas Kling
46f2c23030 LibJS: Convert EnvironmentRecord & friends to east-const style 2021-06-21 23:49:50 +02:00
Andreas Kling
6c6dbcfc36 LibJS: Rename Environment Records so they match the spec :^)
This patch makes the following name changes:

- ScopeObject => EnvironmentRecord
- LexicalEnvironment => DeclarativeEnvironmentRecord
- WithScope => ObjectEnvironmentRecord
2021-06-21 23:49:50 +02:00
Felix Rauch
8d91dbf6c0 PixelPaint: Add loading and saving of color palettes
Color palettes can now be stored in and read from files. The default
palette will be read from `/res/color-palettes/default.palette`
instead of being hard-coded in PaletteWidget.

The file format is one color per line, in any format that can be
understood by `Gfx::Color::from_string`.
2021-06-21 22:32:58 +02:00
bitwitch
5ac9494483 LaunchServer: Make all file handlers configurable including directories
This commit gets rid of hard coded file handlers in Launcher.cpp in
favor of using values in the LaunchServer.ini config file.

The previous commit adds checks for the existence of handler programs
while registering handlers. This commit takes advantage of that and
ensures that LaunchServer will not attempt to open a file with a
nonexistent program and can properly report failure before spawning a
new child process.

Resolves #8120
2021-06-21 22:30:41 +02:00
bitwitch
f29980a15b LaunchServer: Check if handler programs exist when registering them
This adds checks in load_handlers() and load_config() to see if the
programs specified in the config files exist before registering them as
handlers.

Resolves #8121
2021-06-21 22:30:41 +02:00
Ali Mohammad Pur
c4b82ace74 LibWasm: Limit the call stack depth and the number of executed insts
These limits are described in the spec, and we're supposed to stop
execution at some point.
The limits are arbitrarily chosen.
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
9971d13844 LibWasm: Trap if a non-Value is used as a Value
Otherwise we'd just crash, which is not a good thing
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
9c5d38b7db Meta+LibWasm: Add support for module linking tests
This commit makes the linking tests in the wasm spec test run.
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
5c90c389c3 LibWeb: Implement the WebAssembly Memory object and Memory imports 2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
eb5c92d4e2 LibJS: Don't assert for empty reciever if AllowSideEffects::No is given
This parameter is only used if AllowSideEffects::Yes, so there's no
reason to pass anything to it if that's not used.
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
e523e530fc LibWeb: Cache the WebAssembly objects that we hand out to JS
The spec requires this behaviour, and it's generally faster to do this
instead of re-resolving and re-creating the instances anyway.
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
a256997064 LibWeb: Use SignedBigInteger::create() to create wasm i64 values
...instead of the terrible from_base10(...to_base10()) hack.
2021-06-22 00:26:25 +04:30
Ali Mohammad Pur
baa4195daa LibWeb: Avoid resolving the wasm call address type on every invocation
This is a waste of time, and it's not a cheap operation.
2021-06-22 00:26:25 +04:30
Andreas Kling
0d2aba07aa LibJS: Add VM::dump_scope_chain()
This is a handy helper that dumps the current scope chain, starting at
the innermost scope.
2021-06-21 20:58:55 +02:00
Andreas Kling
4c8df58e08 LibJS: Rename Parser::m_parser_state => m_state
Also remove the "m_" prefix from all the public data members.
2021-06-21 20:58:55 +02:00
Andreas Kling
5b16b5d7c1 LibJS: Fix spelling mistake in VariableDeclaration::execute() 2021-06-21 20:58:55 +02:00
Tom
08e2dc22be WindowServer: Fix animated cursor regression 2021-06-21 16:52:29 +02:00
Sam Atkins
e79ef6461a cp: Copy sources into destination if it is already a directory
Previously, copying a file to a directory, like this:
```cp README.md Desktop```
correctly copied it to Desktop/README.md, but would fail if the
source was also a directory, for example:
```cp -R Documents Desktop```
Now, that correctly copies it to Desktop/Documents, as you would
expect. :^)
2021-06-21 16:50:29 +02:00
Max Wipfli
ac9003bb70 WindowServer: Focus windows blocked by a modal window
If a window which has an active modal window is focused, the modal
window starts blinking. In this case, the window (and modal) should
still be focused. For this, the order of the checks in
process_mouse_event_for_window has to be changed.

This fixes #8183.
2021-06-21 16:46:01 +02:00
Daniel Bertalan
e5afe7a8a3 LibC: Add P_tmpdir macro 2021-06-21 12:21:03 +02:00
Nick Miller
9a2c80c791 SoundPlayer: Handle any input file sample rate
This commit addresses two issues:
1. If you play a 96 KHz Wave file, the slider position is incorrect,
   because it is assumed all files are 44.1 KHz.
2. For high-bitrate files, there are audio dropouts due to not
   buffering enough audio data.

Issue 1 is addressed by scaling the number of played samples by the
ratio between the source and destination sample rates.

Issue 2 is addressed by buffering a certain number of milliseconds
worth of audio data (instead of a fixed number of bytes).
This makes the the buffer size independent of the source sample rate.

Some of the code is redesigned to be simpler. The code that did the
book-keeping of which buffers need to be loaded and which have been
already played has been removed. Instead, we enqueue a new buffer based
on a low watermark of samples remaining in the audio server queue.

Other small fixes include:
1. Disable the stop button when playback is finished.
2. Remove hard-coded instances of 44100.
3. Update the GUI every 50 ms (was 100), which improves visualizations.
2021-06-21 03:13:59 +04:30
Nick Miller
34a3d08e65 LibAudio: Sleep less when the audio buffer is full
When using `aplay` to play audio files with a sample rate of 96000,
there were occasional one-second gaps in playback. This is
because the Audio::ClientConnection sleeps for a full second when
the audio buffer is full.

One second is too long to sleep, especially for high-bitrate files.
Changing the sleep to a more reasonable value like 100 ms ensures
we attempt to enqueue again before the audio buffer runs empty.
2021-06-21 03:13:59 +04:30
Nick Miller
dec9ed066d LibAudio: Avoid reading past the end of sample data
Prior code in `WavLoader::get_more_samples()` would attempt to
read the requested number of samples without actually checking
whether that many samples were remaining in the stream.
This was the cause of an audible pop at the end of a track, due
to reading non-audio data that is sometimes at the end of a Wave file.

Now we only attempt to read up to the end of sample data, but no
further.

Also, added comments to clarify the meaning of "sample", and how it
should be independent of the number of channels.
2021-06-21 03:13:59 +04:30
Matthew Olsson
df65ff8a1e LibJS: Add bytecode support for regexp literals 2021-06-21 00:28:07 +02:00
yeeter-the-dog
3ccf4dc7ad
js: Insert newline after each line in REPL mode
This makes ASI work in the REPL.
2021-06-20 21:58:57 +01:00
Marcus Nilsson
54852832b1 LibGUI/TabWidget: Make sure we don't act on two mouseup events
Make sure that even if we get two mouseup events, we do not try to
remove the same widget twice.
2021-06-20 21:48:29 +02:00
Gil Mendes
12f3aa9faa LibWeb: Fix redirects when a response has no data
This makes redirects work when the HTTP server responds with just
headers and no data.
2021-06-20 19:40:46 +01:00
Linus Groh
e9388408db LibJS: Implement support for the [[IsHTMLDDA]] internal slot
Best regards from Annex B and document.all :^)
2021-06-20 17:52:09 +01:00
Marcus Nilsson
f2aa5efbeb PixelPaint: Add basic support for closing tabs
This enables closing of tabs in PixelPaint, for the moment
very basic with no checking if the image is modified or saved.
2021-06-20 15:16:26 +02:00
Marcus Nilsson
32fc8da917 Browser: Enable close button on tabs 2021-06-20 15:16:26 +02:00
Marcus Nilsson
49d40a908c LibGUI/TabWidget: Add close button to tabs
This adds an optional close button to tabs, useful in
for example browser and pixelpaint.
2021-06-20 15:16:26 +02:00
Gunnar Beutner
fbaf763e2a LibJS: Let if yield undefined for branches that don't yield a value
According to 13.6.7 the return value for if expressions should be
undefined when the branch statements don't yield a value.
2021-06-20 15:01:11 +02:00
Tom
75dc94064d WindowServer: Reload icons on scale changes
Since MultiScaleBitmaps only loads icons for the scales in use, we need
to unconditionally reload them so that we pick up the correct bitmaps
for a scale that hasn't been previously used.
2021-06-20 14:57:26 +02:00
Tom
14fe7283e1 WindowServer: Update compositor reference to cursor on reload
When we reload a cursor we should make sure the compositor has a
valid reference to the updated cursor.
2021-06-20 14:57:26 +02:00
Tom
f232cb8efe WindowServer: Enable screen capture to span multiple screens
This enables the shot utility to capture all screens or just one, and
enables the Magnifier application to track the mouse cursor across
multiple screens.
2021-06-20 14:57:26 +02:00
Tom
61af9d882e WindowServer: Load multiple scaled versions of Bitmaps and Cursors
This enables rendering of mixed-scale screen layouts with e.g. high
resolution cursors and window button icons on high-dpi screens while
using lower resolution bitmaps on regular screens.
2021-06-20 14:57:26 +02:00
Tom
aa15bf81e4 WindowServer: Add API to set/get screen layouts
This sets the stage so that DisplaySettings can configure the screen
layout and set various screen resolutions in one go. It also allows
for an easy "atomic" revert of the previous settings.
2021-06-20 14:57:26 +02:00
Tom
34394044b3 WindowServer: Validate that all screens can be reached
If there are any screens that are detached from other screens it would
not be possible to get to them using the mouse pointer. Also make sure
that none of the screens are overlapping.
2021-06-20 14:57:26 +02:00
Tom
0547e0329a WindowServer: Fix artifacts after window resize in some cases
We were calculating the old window rectangle after changing window
states that may affect these calculations, which sometimes resulted
in artifacts left on the screen, particularily when tiling a window
as this now also constrains rendering to one screen.

Instead, just calculate the new rectangle and use the window's
occlusion information to figure out what areas need to be invalidated.
2021-06-20 14:57:26 +02:00
Tom
229b541e5d WindowServer: Constrain rendering windows to one screen in some cases
When a window is maximized or tiled then we want to constrain rendering
that window to the screen it's on. This prevents "bleeding" of the
window frame and shadow onto the adjacent screen(s).
2021-06-20 14:57:26 +02:00
Tom
4392da970a WindowServer: Add initial support for rendering on multiple screens
This allows WindowServer to use multiple framebuffer devices and
compose the desktop with any arbitrary layout. Currently, it is assumed
that it is configured contiguous and non-overlapping, but this should
eventually be enforced.

To make rendering efficient, each window now also tracks on which
screens it needs to be rendered. This way we don't have to iterate all
the windows for each screen but instead use the same rendering loop and
then only render to the screen (or screens) that the window actually
uses.
2021-06-20 14:57:26 +02:00
Tom
499c33ae0c LibGfx: Add a Line class and a Rect<T>::RelativeLocation class
These helpers will be useful in preparation for supporting multiple
displays, e.g. to measure distances to other screens or figure out
where rectangles are located relative to each other.
2021-06-20 14:57:26 +02:00
Ali Mohammad Pur
20c066b8e0 LibCore: Call optional did_construct() method when constucting objects
Some objects need to perform tasks during construction that require
the object to be fully constructed, which can't be done in the
constructor. This allows postponing such tasks into a did_construct
method that will be called right after the object was fully
constructed.
2021-06-20 14:57:26 +02:00
Linus Groh
ade85d980b FlappyBug: Add missing component declaration
The PR for this pre-dates the concept of components, so it was forgotten
to add one.
2021-06-20 11:13:30 +01:00
Linus Groh
8f6ac0db1c LibJS: Use OrdinaryCreateFromConstructor() in a bunch of constructors
Resolves various FIXMEs :^)
2021-06-20 12:12:39 +02:00
Linus Groh
e5753443ae LibJS: Consistently make prototype the last argument in Object ctors
This is so that we can reliably allocate them in a template function,
e.g. in ordinary_create_from_constructor():

    global_object.heap().allocate<T>(
        global_object, forward<Args>(args)..., *prototype);

The majority of objects already take the prototype as the last argument,
so I updated the ones that didn't.
2021-06-20 12:12:39 +02:00
Linus Groh
df095afbcc LibJS: Implement the OrdinaryCreateFromConstructor() abstract operation 2021-06-20 12:12:39 +02:00
Linus Groh
500818e73d LibJS: Implement the GetPrototypeFromConstructor() abstract operation 2021-06-20 12:12:39 +02:00
Linus Groh
6312627218 LibJS: Implement the GetFunctionRealm() abstract operation 2021-06-20 12:12:39 +02:00
Linus Groh
55db9539a5 LibJS: Introduce AbstractOperations.{cpp,h} and move various AOs there
Value.{cpp,h} has become a dumping ground, let's change that.

Things that are directly related to Values (e.g. bitwise/binary ops,
equality related functions) can remain, but everything else that's not a
Value or Object method and globally required (not just a static function
somewhere) is being moved.

Also convert to east-const while we're here.

I haven't touched IteratorOperations.{cpp,h}, it seems fine to still
have those separately.
2021-06-20 12:12:39 +02:00
Adam Hodgen
c03a3dc5b7 LaunchServer: Correctly open file URLs with line numbers
PR #5665 updated TextEditor to open files at a specific line/column
location using the file:line:col argument, rather than the -l flag.

This change updates LaunchServer to use that convention, though note it
does only pass the line number and not a column number, as per all
previous behaviour.
2021-06-20 12:07:55 +02:00
Mim Hufford
ddc855ffcd FlappyBug: Add cloud and sky graphics
We now have a nice sunset sky and some random cloud graphics.
The obstacles will get graphics at some point too :)
2021-06-20 10:54:27 +01:00
Mim Hufford
28e08f08c2 FlappyBug: Add new graphics and tweak colors
This adds some actual graphics to the game, and tweaks the obstacle and
sky colors. Eventually there will be graphics for those elements too.
2021-06-20 10:54:27 +01:00
Mim Hufford
f50003bdd2 FlappyBug: Add an input cooldown after game over
This makes sure the player doesn't accidentally start a new game after
they bump into an obstacle.
2021-06-20 10:54:27 +01:00
Mim Hufford
018344bb07 FlappyBug: Keep track of score and highscore
Better information is now shown to the player. Instructions are shown
when first loading the program, and any available scores are shown on
the game over screen.
2021-06-20 10:54:27 +01:00
Mim Hufford
3f603ab082 FlappyBug: Start obstacles off the screen
Previously obstacles were respawning fully on-screen which caused a
discontinuous look. Now they smoothly move into view from off-screen.
2021-06-20 10:54:27 +01:00
Mim Hufford
444fcfd0d2 FlappyBug: Make the obstacle gap position random
The position of the gap in the obstacle is now randomly generated each
time it spawns. The game is more fun to play now :)
2021-06-20 10:54:27 +01:00
Mim Hufford
811d9722f9 FlappyBug: Introduce a new Flappy Bug game
This introduces a Flappy Bug game. It's pretty simple currently, but is
playable.
2021-06-20 10:54:27 +01:00
Gunnar Beutner
25c73159ce LibCoreDump: Don't subtract one from the first stack frame's EIP
The first stack frame represents the current instruction pointer
rather than the return address so we shouldn't subtract one
from it.

Fixes #8162.
2021-06-20 10:19:02 +01:00
Linus Groh
34b338702a LibWasm: Remove empty AbstractMachine/Interpreter.cpp
This was moved to BytecodeInterpreter.cpp, so this is unused now.
2021-06-20 01:49:56 +01:00
Jan de Visser
87bd69559f LibSQL: Database layer
This patch implements the beginnings of a database API allowing for the
creation of tables, inserting rows in those tables, and retrieving those
rows.
2021-06-19 22:06:45 +02:00
Jan de Visser
267eb3b329 LibSQL: Hash index implementation for the SQL storage layer
This patch implements a basic hash index. It uses the extendible hashing
algorith. Also includes a test file.
2021-06-19 22:06:45 +02:00
Jan de Visser
224804b424 LibSQL: BTree index, Heap, and Meta objects for SQL Storage layer
Unfortunately this patch is quite large.

The main functionality included are a BTree index implementation and
the Heap class which manages persistent storage.

Also included are a Key subclass of the Tuple class, which is a
specialization for index key tuples. This "dragged in" the Meta layer,
which has classes defining SQL objects like tables and indexes.
2021-06-19 22:06:45 +02:00
Jan de Visser
2a46529170 LibSQL: Basic dynamic value classes for SQL Storage layer
This patch adds the basic dynamic value classes used by the SQL Storage
layer. The most elementary class is Value, which holds a typed Value
which can be converted to standard C++ types. A Tuple is a collection
of Values described by a TupleDescriptor, which specifies the names,
types, and ordering of the elements in the Tuple.

Tuples and Values can be serialized and deserialized to and from
ByteBuffers. This is mechanism which is used to save them to disk.

Tuples are used as keys in SQL indexes and rows in SQL tables.

Also included is a test file.
2021-06-19 22:06:45 +02:00
Gunnar Beutner
a6ba05b02b LibSymbolication+Utilities: Show inlined functions for bt 2021-06-19 22:04:19 +02:00
Idan Horowitz
c31392510a LibJS: Add the Number.prototype.toFixed method 2021-06-19 16:13:59 +01:00
Itamar
3a4017b419 LibDebug: Convert LibDebug to east-const style 2021-06-19 14:51:18 +02:00
Itamar
03ef2a479a LibCoreDump: Include source locations of inlined functions in backtrace 2021-06-19 14:51:18 +02:00
Itamar
a45b5ccd96 LibDebug: Add DebugInfo::get_source_position_with_inlines
This function returns the source position of a given address in the
program. If that address exists in an inline chain, then it also returns
the source positions that are in the chain.
2021-06-19 14:51:18 +02:00
Itamar
835efa1b6a LibDebug: Add DwarfInfo::get_cached_die_at_offset
This function returns a DIE object from the cache with the given offset
in the debug_info section.
2021-06-19 14:51:18 +02:00
Itamar
fb31aae20d LibDebug:: Add DwarfInfo::get_die_at_address
This function returns the die object whose address range intersects
with the given address.

This function will also construct the DIE cache, if it hasn't been
constructed yet.
2021-06-19 14:51:18 +02:00
Itamar
92d4962d04 LibDebug: Add caches of DIE objects to DwarfInfo
There is one cache that indexes DIE objects by the start address of
their range, and another cache that indexes by their offset in the
debug_info section.

Both caches are implemented with RedBlackTree, and are optional - they
will only be populated if 'build_cached_dies' is invoked.
2021-06-19 14:51:18 +02:00
Itamar
a5f69efa5c LibDebug: Store optional parent_offset in Dwarf::DIE objects
In the current implementation, only DIE objects that are created via
DIE::for_each_child() will have parent offsets.

DIE objects that are created with CompilationUnit::get_die_at_offset()
do not currently store a parent offset.

We may improve this in the future, but this is enough for what we
currently need.
2021-06-19 14:51:18 +02:00
Itamar
84609aecc1 LibDebug: Add AttributeForm field to Dwarf::AttributeValue
In some contexts, it's helpful to also know the "Attribute Form",
in addition to the "Attribute Type".

An example for such context is the interpretation of the
"DW_AT_high_pc" attribute, which has different meaning if the form
is an address or a constant.
2021-06-19 14:51:18 +02:00
Itamar
a45ce0c6eb LibCoreDump: Use "eip - 1" when creating backtrace entries
We need to do this because the return address from a function frame is
the instruction that comes after the 'call' instruction.
2021-06-19 14:51:18 +02:00
Itamar
98a774a68d LibDebug: Add LineProgram::get_directory_and_file(size_t)
This function returns the directory path & filename for a given file
index.
2021-06-19 14:51:18 +02:00
Itamar
0d89f70b66 LibDebug: Move Dwarf::LineProgram into Dwarf::CompilationUnit
Previously, the LineProgram objects were short-lived, and only created
inside DebugInfo::prepare_lines() to create a vector of sorted LineInfo
data.

However, Dwarf::LineProgram also contains other useful data, such as
index-to-string mapping of source directories and filenames.

This commit makes each Dwarf::CompilationUnit own its
Dwarf::LineProgram.
DebugInfo::prepare_lines() then iterates over the compilation units to
prepare its sorted vector of lines.
2021-06-19 14:51:18 +02:00
Itamar
e9e4358a93 LibDebug: Store LibDebug objects on the heap & make them non-copyable
This fixes an issue were some LibDebug objects (for example,
Dwarf::CompilationUnit) held a reference to their parent
Dwarf::DwarfInfo object, which was constructed on the stack and later
moved to the heap.
2021-06-19 14:51:18 +02:00
Itamar
edd79ddd00 LibDebug: Move Dwarf::AttributeValue to a separate file 2021-06-19 14:51:18 +02:00
Itamar
fea9bb8c51 LibDebug: Move get_die_at_offset to Dwarf::CompilationUnit 2021-06-19 14:51:18 +02:00
Itamar
15b3957885 LibDebug: Remove unused DebugInfo::for_each_source_position 2021-06-19 14:51:18 +02:00
Itamar
68ff0788e5 LibDebug: Fix typo in DebugInfo::get_source_position 2021-06-19 14:51:18 +02:00
Andreas Kling
f86e241699 LibJS: Object.getOwnPropertyNames() should enumerate String's .length
We were incorrectly aborting property name enumeration after generating
names for all the indexable properties in the underlying string.
2021-06-19 11:46:08 +02:00
Andreas Kling
686213c2b8 LibJS: Make Object.getOwnPropertyDescriptor() work on String subscripts
String objects are a bit special since the indexed properties are
overridden by the contents of the underlying PrimitiveString.

getOwnPropertyDescriptor() was not taking this into account, and would
instead return undefined when asked about an indexed property in a
String object.
2021-06-19 11:34:19 +02:00
Matthew Olsson
25baefdd1e LibJS: Support object rest elements in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson
57b9a228ab LibJS: Support array rest elements in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson
7983324639 LibJS: Implement array destructuring for the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson
14fff5df06 LibJS: Implement more IteratorOperations and organize file
Implemented IteratorComplete and IteratorValue, and sorted functions
based on their spec ordering.
2021-06-19 09:38:26 +02:00
Matthew Olsson
1f8e643ef0 LibJS: Support object destructuring in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson
f39ab2e60a LibJS: Add JumpUndefined bytecode 2021-06-19 09:38:26 +02:00
Matthew Olsson
3ee627909a LibJS: Ensure GetBy{Id,Value} never load <empty> into the accumulator 2021-06-19 09:38:26 +02:00
Matthew Olsson
ce04c2259f LibJS: Restructure and fully implement BindingPatterns 2021-06-19 09:38:26 +02:00
Matthew Olsson
10372b8118 LibJS: Remove bad spread check in declaration parsing
This would allow assignments such as `let ...{ a } = { a: 20 }`
2021-06-19 09:38:26 +02:00
Linus Groh
fba3c77a04 LibJS: Add missing exception checks to Number() constructor 2021-06-19 02:03:37 +01:00
Linus Groh
8e26c7a1dd LibJS: Make Number() constructor spec compliant
By using to_numeric() and adding BigInt handling, we get support for
`Number(123n)`.

Fixes #8125.
2021-06-19 01:34:17 +01:00
Linus Groh
7f8245439b LibJS: Add a bunch more missing ECMA-262 section/title/URL comments 2021-06-19 00:38:41 +01:00
Matthew Olsson
7f97e33778 LibJS: Disallow 'yield' identifier initializer in GeneratorFunctions 2021-06-19 00:04:57 +01:00
Matthew Olsson
9253fa1bad LibJS: Implement GeneratorFunctionConstructor::construct 2021-06-19 00:04:57 +01:00
Matthew Olsson
22b17219ff LibJS: Add the remaining generator objects
- %GeneratorFunction%
- %GeneratorFunction.prototype%
- %GeneratorFunction.prototype.prototype%
- %Generator%.prototype
2021-06-19 00:04:57 +01:00
DexesTTP
b205c9814a LibCrypto: Fix Hash::MD5's movability
Because MD5 stored a "Bytes {}" wrapper to its internal data buffer,
it was not actually movable. However, its use in several parts of
the system (such as HashManager) assumed it was, leading to crashes.

Fixes #8135
2021-06-19 01:29:21 +04:30
Idan Horowitz
4dc63896de LibJS: Add and use the ArraySpeciesCreate abstract operation
This ensures that the Array.prototype methods produce results using the
constructor of the derived object if it is one instead of always using
the default constructor.
2021-06-18 21:25:16 +01:00
Idan Horowitz
271eeadf25 LibJS: Bring FlattenIntoArray closer to the specification
This fixes the incorrect exception order and missing exception checks
that were caused by the implementation not conforming exactly to the
specification.
2021-06-18 21:25:16 +01:00
Linus Groh
597cf88c08 LibJS: Implement the 'Hashbang Grammar for JS' proposal
Stage 3 since August 2019 - we already have shebang stripping
implemented in js(1), so this removes it from there in favor of adding
support to the lexer directly.

Most straightforward proposal and implementation I've ever seen :^)

https://github.com/tc39/proposal-hashbang
2021-06-18 20:35:23 +01:00
Linus Groh
299c3069c1 LibJS/Tests: Use eval() for toEvalTo(), not Function()
Since we have had eval() for a while now, we can finally use it here -
this allows us to get rid of the confusing return statements in tested
source code.
2021-06-18 20:35:23 +01:00
Idan Horowitz
2e9f665bda LibJS: Throw on detached viewed ArrayBuffer when validating TypedArrays 2021-06-18 20:17:45 +01:00
Idan Horowitz
d5c836dd64 LibJS: Add the TypedArray.prototype.toString property
This is initialized to be the same function object as the initial value
of the Array.prototype.toString generic function.
2021-06-18 20:17:45 +01:00
Idan Horowitz
57db27bcc4 LibJS: Add the TypedArray.prototype.join method 2021-06-18 20:17:45 +01:00
Idan Horowitz
2922a6c053 LibJS: Add the TypedArray.prototype[Symbol.toString] getter accessor 2021-06-18 20:17:45 +01:00
sin-ack
c5073cb287 LibJS: Do not trim whitespace from property names when they're numbers
Fixes #7803.
2021-06-18 19:18:15 +01:00
Luke
8be7bdaac3 LibJS: Add %TypedArray%.prototype.some 2021-06-18 18:13:31 +01:00
Luke
68f11a272b LibJS: Add %TypedArray%.prototype.forEach 2021-06-18 18:13:31 +01:00
Luke
91af985718 LibJS: Add %TypedArray%.prototype.findIndex 2021-06-18 18:13:31 +01:00
Luke
61a8c19556 LibJS: Add %TypedArray%.prototype.find 2021-06-18 18:13:31 +01:00
Luke
65ca2d98af LibJS: Add %TypedArray%.prototype.every 2021-06-18 18:13:31 +01:00
Andreas Kling
de8aa1b17d WindowServer: Move key event handling to its own function
Instead of making WindowManager::event() all about key events.
2021-06-18 18:00:08 +02:00
Andreas Kling
4895f46d8c WindowServer: Make various functions take MouseEvent by const reference
Some paths of the mouse event processing code will upgrade the event
from a regular MouseDown to a MouseDoubleClick. That's why we were
passing `MouseEvent&` everywhere.

For the paths that don't need to do this, passing `MouseEvent const&`
reduces the cognitive burden a bit, so let's do that.
2021-06-18 17:55:41 +02:00
Andreas Kling
82f1ac7390 WindowServer: Don't include frame when determining hovered window
We only consider a window "hovered" if its *content area* is hovered.
2021-06-18 17:40:05 +02:00
Andreas Kling
1537172a6b WindowServer: Simplify handling of the window resize candidate
Always clear the current resize candidate when starting new mouse
event processing (instead of trying to be smart about it.)
2021-06-18 17:40:05 +02:00
Andreas Kling
b5251a70c6 WindowServer: Reorder and annotate the mouse event processing code
Hopefully people can now follow and understand how this works. :^)
2021-06-18 17:40:05 +02:00
Andreas Kling
fa9846ec6f WindowServer: Simplify how we determine the hovered window
Instead of plumbing a Window* through the entire mouse event processing
logic, just do a hit test and say that the window under the cursor is
the hovered window.

It's funny how much easier this is now that we have a way to hit test
the entire window stack with one call.
2021-06-18 17:40:05 +02:00
Andreas Kling
7b3fdd178e WindowServer: Simplify processing of window-specific mouse events
Move the logic for processing a mouse event that hits a specific window
into its own function.

If the window is blocked by a modal child, we now get that out of the
way first, so we don't have to think about it later.
2021-06-18 17:40:05 +02:00
Andreas Kling
2f9e8a982c WindowServer: Unify hit testing between fullscreen/regular windows
Even if a window is in fullscreen mode, we still want hit testing to
walk the window stack. Otherwise child windows of the fullscreen
window will not receive mouse events.
2021-06-18 17:40:05 +02:00
Andreas Kling
09dacf4cd1 WindowServer: Move titlebar button mouse event handling to a function
The button widgets internally rendered by WindowServer are only used
in titlebars, and require a bit of mouse event handling. Instead of
mixing it with the window-oriented mouse event handling, get the
button event stuff out of the way first.
2021-06-18 17:40:05 +02:00
Andreas Kling
5d73e16edf WindowServer: Make deliver_mouse_event() perform coordinate translation
Instead of expecting callers to provide a window-relative position,
just take care of it inside deliver_mouse_event() instead.
2021-06-18 17:40:05 +02:00
Andreas Kling
300711d013 WindowServer: Preserve all members in MouseEvent::translated()
We were forgetting to preserve the m_drag and m_mime_data members of
WindowServer::MouseEvent when making a translated copy.

This didn't affect any reachable code paths before this change.
2021-06-18 17:40:05 +02:00
Andreas Kling
bac200885c LibGUI: Don't restart AbstractView drag on mousemove after escape key
Previously, if a drag operation was aborted by pressing the escape key
(handled by WindowServer), the drag would immediately restart if you
moved the mouse cursor before releasing the mouse button.
2021-06-18 17:40:05 +02:00
Andreas Kling
58823c474e WindowServer: Don't let super key open system menu while tracking input
Previously it was possible to open the system menu while tracking mouse
input after a mousedown event.
2021-06-18 17:40:05 +02:00
Andreas Kling
82a945fa7e WindowServer: Always send mouse events to active input tracker first
If a window is currently actively tracking input events (because
sent it a MouseDown and haven't sent it a MouseUp yet), we now simply
send mouse events to that window right away before doing any other
event processing.

This makes it much easier to reason about mouse events.
2021-06-18 17:40:05 +02:00
Andreas Kling
69dad3b996 WindowServer: Remove an unnecessary temporary variable 2021-06-18 17:40:05 +02:00
Andreas Kling
ad828b3cfc WindowServer: Split up WindowFrame::handle_mouse_event()
Break this function into a couple of smaller functions, one for each
of these areas:

- The titlebar
- The titlebar icon
- The menubar
- The border
2021-06-18 17:40:05 +02:00
Andreas Kling
f88361fc28 WindowServer: Add WindowStack::window_at() and use it a bunch
This performs a hit test on the window stack to find the window under
a given cursor position.
2021-06-18 17:40:05 +02:00
Andreas Kling
4133caba78 WindowServer: Make hit test results richer
Instead of just answering hit/no-hit when hit testing windows, we now
return a HitTestResult object which tells you which window was hit,
where it was hit, and whether you hit the frame or the content.
2021-06-18 17:40:05 +02:00
Andreas Kling
370d3749e5 WindowServer: Remove weird feature where Ctrl+Wheel changed opacity
This feature had been there since early on and was not actually useful
for anything. I just added it because it was fun. In retrospect, it's
not a very good feature and I only ever activated it by accident.
2021-06-18 17:40:05 +02:00
Andreas Kling
e4e94cd43d WindowServer: Allow each WindowStack to have an active window
A window with an inner stack needs to keep track of which inner window
is active.
2021-06-18 17:40:05 +02:00
Andreas Kling
2b0e0b602c WindowServer: Keep track of which WindowStack a Window is part of
Each Window now knows which WindowStack it's part of. We call this the
Window::outer_stack(), in preparation for supporting inner stacks. :^)
2021-06-18 17:40:05 +02:00
Andreas Kling
d0bc3d6002 WindowServer: Convert WindowManager to east-const style 2021-06-18 17:40:05 +02:00
Andreas Kling
d257f58306 WindowServer: Add WindowStack concept
This patch moves the window stack out of WindowManager and into its own
WindowStack class.

A WindowStack is an ordered list of windows with an optional highlight
window. The highlight window mechanism is used during Super+Tab window
switching to temporarily bring a window to the front.

This is mostly mechanical, just moving the code to its own class.
2021-06-18 17:40:05 +02:00
Jesse Buhagiar
906d3e9f44 LibUSBDB: Fix vendor id decoding
This was broken because the whole line was being passed in instead
of a substring..
2021-06-18 19:41:25 +04:30
Gunnar Beutner
cf79b499f6 LibC: Add definition for PRIuPTR 2021-06-18 16:35:15 +02:00
Jesse Buhagiar
01cd474930 Userland/Libraries: Add LibUSBDB library
Simple clone of LibPCIDB to support USB IDs instead of PCI
ones. The format is basically identical, besides a few changes
of the double tab fields.
2021-06-18 17:04:57 +04:30
Jesse Buhagiar
119b8a2692 Userland: Add lsusb :^) 2021-06-18 17:04:57 +04:30
Luke
02de3cbce3 LibJS: Add Number.parseInt
This is initialized to be the same function object as the initial value
of the parseInt function on the global object.
2021-06-18 10:29:33 +01:00
Idan Horowitz
b6a74b6bd9 LibJS: Use existing attributes if any are missing in the new descriptor
The specification defines that we should only change attributes that
exist in the incoming descriptor, but since we currently just overwrite
the existing descriptor with the new one, we can just set the missing
attributes to the existing values manually.
2021-06-18 10:22:09 +02:00
Luke
50f33bb98e LibJS: Add missing exception check in Date.prototype.toJSON
It was missing an exception check on the call to to_primitive.
This fixes test/built-ins/Date/prototype/toJSON/called-as-function.js
from test262 crashing, but does not fix the test itself.
2021-06-18 10:21:29 +02:00
Marco Cutecchia
24c243942d Browser: Add setting to change homepage URL 2021-06-18 10:20:24 +02:00
Elliot Maisl
90873781c1 PixelPaint: Add new selection moving modes
If you press "spacebar" while moving a selection, it will now move the
origin point of the selection; and if you press "control" it will move
it relatively to the center.
2021-06-17 23:02:53 +02:00
brapru
c62804df46 passwd: Do not allow empty passwords
The user should use the delete flag when wanting to issue an empty
password. passwd should return an error after receiving empty input.
2021-06-17 19:54:38 +02:00
brapru
1a9d0dee2c passwd: Provide more verbose output regarding status of changed passwd
passwd should explicitly indicate the status of the password change.
2021-06-17 19:54:38 +02:00
brapru
4fd842f566 passwd: Retype password to confirm
Previously passwd would accept the first password input by the user. It
should ask the user to re-type the password to check for mismatches and
prevent typos in the password.
2021-06-17 19:54:38 +02:00
brapru
b0f8bccd08 passwd: Prompt for the current password before setting new password
This changes passwd to authenticate non-root users before prompting for
new password.
2021-06-17 19:54:38 +02:00
Erik Sommer
96588adbd4
PixelPaint: Update debug message in the copy action to the used method (#8113) 2021-06-17 19:53:45 +02:00
Idan Horowitz
cc5c1df64b LibJS: Add the TypedArray.of() method 2021-06-17 18:13:20 +01:00
Idan Horowitz
dcb55db99b LibJS: Replace boolean without_side_effects parameters with an enum 2021-06-17 16:52:15 +02:00
Idan Horowitz
864beb0bd5 LibJS: Remove the unused IndexedProperties::append_all method 2021-06-17 16:52:15 +02:00
stelar7
22851287b1 Spreadsheet: Pledge 'fattr' to avoid crashing after exporting as csv 2021-06-17 18:49:44 +04:30
Ali Mohammad Pur
2fe9c81b30 Everywhere: Replace the multiple impls of print_buffer() with :hex-dump 2021-06-17 18:44:00 +04:30
sin-ack
10f56166e5 LibJS: Cast to i64 for is_integral_number
This fixes the built-ins/Number/isInteger/integers.js test.
9007199254740991 is still an integer, though not a safe one.
2021-06-17 13:44:01 +01:00
Idan Horowitz
a85a95fe8d LibJS: Stop overwriting existing accessors in Object::define_property 2021-06-17 13:20:18 +01:00
Idan Horowitz
1cf5663e38 LibJS: Add the Object.prototype.__lookup{Getter, Setter}__ methods
These are a part of the Annex B extension of the specification.
2021-06-17 13:20:18 +01:00
Idan Horowitz
f98c0ca528 LibJS: Add the Object.prototype.__define{Getter, Setter}__ methods
These are a part of the Annex B extension of the specification.
2021-06-17 13:20:18 +01:00
Idan Horowitz
37340aa599 LibJS: Add the Object.prototype.__proto__ native accessor property
This is part of the Annex B extension of the specification.
2021-06-17 13:20:18 +01:00
Linus Groh
d1c109be96 LibJS: Fix .length attributes of various native functions
Namely the Proxy revocation, Promise resolving, Promise then/catch
finally, and Promise GetCapabilitiesExecutor functions.
They were all missing an explicit 'Attribute::Configurable' argument
and therefore incorrectly used the default attributes (writable,
enumerable, configurable).
2021-06-17 13:10:06 +01:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Gunnar Beutner
0ca5a393d1 SystemServer: Improve error message when execv() fails
Previously perror() would just tell us that the file specified
for execv() doesn't exist.
2021-06-17 11:03:51 +02:00
Idan Horowitz
70697a5999 LibJS: Throw a syntax error when an identifier is a reserved word
From the specification:
It is a Syntax Error if StringValue of IdentifierName is the same
String value as the StringValue of any ReservedWord except for yield
or await.
It is a Syntax Error if this phrase is contained in strict mode code
and the StringValue of IdentifierName is: "implements", "interface",
"let", "package", "private", "protected", "public", "static", or
"yield".
2021-06-17 10:56:11 +02:00
Idan Horowitz
d6df955305 LibJS: Add missing to_property_key exception check in ClassExpression 2021-06-17 10:56:11 +02:00
Luke
9cbd90fdb6 LibJS: Add BigInt64Array and BigUint64Array
This fixes ~297 test262 test cases :^)
2021-06-17 02:20:03 +01:00
Luke
411c72da27 js: Add print_number method and use it to print out TypedArray values
We can't construct Values with u64 and i64.
I tried adding these constructors, but then it refuses to build in
lagom.
2021-06-17 02:20:03 +01:00
Luke
8d90e137a5 LibJS: Fix check for byteOffset instead of byteLength in byteLength test 2021-06-17 02:20:03 +01:00
Luke
9c2eff8859 LibJS: Make TypedArray use numeric_to_raw_bytes and raw_bytes_to_numeric
It was previously writing directly to the underlying buffer instead of
using these methods. This has a benefit of dealing with BigInt64 and
BigUint64 for us already.
2021-06-17 02:20:03 +01:00
Luke
80edf6f5b6 LibJS: Refactor numeric_to_raw_bytes and raw_bytes_to_numeric
This is to make use of the new Value conversion methods.
This also moves the clamped u8 tag to ArrayBuffer from TypedArray and
the conversion to these methods, as the spec does it here.
2021-06-17 02:20:03 +01:00