Commit Graph

6243 Commits

Author SHA1 Message Date
Luke
f3f2170ac6 LibWeb: Add the cloning steps in clone_node
This will be used in HTMLTemplateElement later to clone template
contents.

This makes the clone functions non-const in the process, as the cloning
steps can have side effects.
2021-07-05 12:39:46 +02:00
Luke
e4ae1cdd1f LibWeb: Use the element factory in clone_node
It was directly creating a new Element object instead of creating the
appropriate element.

For example, document.body.cloneNode(true) would return an Element
instead of an HTMLBodyElement.
2021-07-05 12:39:46 +02:00
Luke
5430bc8963 LibWeb: Make clone_node capable of cloning document fragments
Used by Web Components Polyfills.
2021-07-05 12:39:46 +02:00
Luke
f7ad8c0f94 LibWeb: Add DOMParser
This allows you to invoke the HTML document parser and retrieve a
document as though it was loaded as a web page, minus any scripting
ability.

This does not currently support XML parsing.

This is used by YouTube (or more accurately, Web Components Polyfills)
to polyfill templates.
2021-07-05 12:39:46 +02:00
Luke
0ea50d44bf LibWeb: Check if scripting is disabled before running script
This is not a full check, it's just enough to prevent script execution
in DOMParser.
2021-07-05 12:39:46 +02:00
Tom
31a2f10927 LibGfx: Fix classic theme frame transparency check
We shouldn't use the title stripe or title shadow colors to determine
whether the frame itself is going to have alpha channels or not. This
caused e.g. the classic theme's window frame to be rendered as
transparency just because the stripe color had an alpha channel of 0.
2021-07-05 12:29:14 +02:00
ForLoveOfCats
ce6658acc1 KeyboardSettings+Kernel: Setting to enable Num Lock on login 2021-07-05 06:19:59 +02:00
Andreas Kling
7fdeb0ec74 LibJS: Fix logic typo in ArgumentsObject.[[Set]]
Thanks to Linus for spotting this! :^)
2021-07-05 02:53:57 +02:00
Andreas Kling
a0acb6f058 LibJS: Fix accidental west-const in ArgumentsObject 2021-07-05 02:49:55 +02:00
Andreas Kling
77fa33e61a LibJS: Finish implementing mapped arguments exotic objects :^)
Now that the Object rewrite is in place, we have enough tools to
implement the mapped `arguments` propreties according to spec.

The basic mechanism is that the `arguments` object installs a hidden
parameter mapping object that property accesses get filtered through.
This is how accessing numeric properties on `arguments` are proxied
to the named identifier in the function scope.

When `arguments` is instantiated, getters and setters are created
for all the numeric properties on the object that correspond to
function arguments. These getters and setters can be deleted from the
object. This is all pretty intricate, so refer to the spec for details.

Note that the `arguments` object itself is still lazily instantiated
on first access within a function. This is non-conforming, and we'll
have to revisit this once we get around to improving function calls.
2021-07-05 02:38:31 +02:00
Andreas Kling
36cc011ae4 Fire: Make the main widget a GUI::Frame 2021-07-05 02:38:31 +02:00
Timothy Flynn
9f0aef6051 LibJS: Implement most of String.prototype.replaceAll
This also renames ErrorType::StringMatchAllNonGlobalRegExp to
ErrorType::StringNonGlobalRegExp (removes "MatchAll") because this error
is now used in the same way from multiple operations.
2021-07-05 01:10:43 +01:00
Linus Groh
cb20baebae LibJS: Make ObjectPrototype an immutable prototype exotic object
To make this happen, this patch implements the SetImmutablePrototype
abstract operation (as a method on Object) and then overrides
[[SetPrototypeOf]] on ObjectPrototype.
2021-07-05 00:53:57 +01:00
Idan Horowitz
fac8f9a94d LibJS: Add the TypedArray.from() method 2021-07-05 00:27:03 +01:00
Marcus Nilsson
2183d01eb0 PixelPaint: Ask to preserve transparency when exporting
Previously the alpha channel was thrown away when exporting to BMP or
PNG in PixelPaint, instead let the user decide.
2021-07-05 00:43:00 +02:00
Marcus Nilsson
8324ffefe7 LibGfx/BMPWriter: Add support for V3 & V4 DIB headers
This adds very simple support for storing BMP files with
BITMAPV3INFOHEADER and BITMAPV4HEADER. This in turn allows us to
store alpha channels which is nice for our .pp file format. For
the moment no data regarding colorspace is saved, only the bare
minimum to make a valid file.

Some small restructuring of the code is made to hopefully make it
easier to implement more DIB-headers and support for colorspace/gamma
correction in the future.
2021-07-05 00:43:00 +02:00
Linus Groh
9fe363eaad LibJS: Remove now unused IndexedPropertyIterator::value_and_attributes() 2021-07-05 00:03:25 +02:00
Linus Groh
9555ca99a0 LibJS: Remove unnecessary value_or() from get()
Object::get() never returns an empty value anymore, as per the spec, so
having a value_or() fallback is no longer needed.
2021-07-05 00:03:25 +02:00
Linus Groh
57f7e6e775 LibJS: Remove two unnecessary 'vm.argument(0).value_or(js_undefined())'
VM::argument() never returns an empty value.
2021-07-05 00:03:25 +02:00
Tom
fdf701ed96 WindowServer: Improve screen invalidation on window state changes
Because window states and various flags can affect the windows'
rendered areas it's safer to use the last computed occlusion rectangles
to invalidate areas on the screen that may have to be re-rendered due
to e.g. a window size change.

Fixes #6723
2021-07-05 00:03:13 +02:00
Tom
6e792553f2 WindowServer: Query driver for framebuffer offset
Depending on the driver, the second buffer may not be located right
after the first, e.g. it may be page aligned. This removes this
assumption and queries the driver for the appropriate offset.
2021-07-04 23:59:17 +02:00
Tom
fdae117600 WindowServer: Implement support for combined buffer flipping + flushing
Some devices may require DMA transfers to flush the updated buffer
areas prior to flipping. For those devices we track the areas that
require flushing prior to the next flip. For devices that do not
support flipping, but require flushing, we'll simply flush after
updating the front buffer.

This also adds a small optimization that skips these steps entirely for
a screen that doesn't have any updates that need to be rendered.
2021-07-04 23:59:17 +02:00
Andreas Kling
45a2bc27d5 Assistant: Don't index the /dev directory 2021-07-04 23:15:17 +02:00
Andreas Kling
085da369ff Assistant: Force the window to have a shadow despite being frameless 2021-07-04 23:15:17 +02:00
Andreas Kling
c2dfa9d54c WindowServer+LibGUI: Add a way to force a window to have a drop shadow 2021-07-04 23:15:17 +02:00
Andreas Kling
3368e54224 Magnifier: Make a custom 16x16 icon for this app + tweak 32x32 version
Stop piggybacking on the generic "find" icon and make a custom one. :^)
2021-07-04 23:15:17 +02:00
Andreas Kling
3e63633e1c Magnifier: Make the main widget a GUI::Frame
This makes the magnifier window look slightly nicer. :^)
2021-07-04 23:15:16 +02:00
Andreas Kling
782a5c88ce WindowServer: Make most remaining WindowServer IPC calls async
The only remaining sync call from client to server is now the call
that switches a window's backing store. That one actually relies on
the synchronization to hand over ownership of the backing stores,
so it has to stay synchronous for now.
2021-07-04 23:15:16 +02:00
Linus Groh
70c6090fef LibJS/Tests: Enable Array tests that now just work :^) 2021-07-04 22:07:36 +01:00
Linus Groh
8ade0df4c3 LibWeb: Change WrapperGenerator to emit acessor properties
This is how the Web IDL spec defines it. We might eventually not need
native properties anymore, but that's another change for another day.

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 22:07:36 +01:00
Linus Groh
09bd5f8772 LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.

This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.

What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.

Key changes include:

- 1:1 matching function names and parameters of all object-related
  functions, to avoid ambiguity. Previously we had things like put(),
  which the spec doesn't have - as a result it wasn't always clear which
  need to be used.
- Better separation between object abstract operations and internal
  methods - the former are always the same, the latter can be overridden
  (and are therefore virtual). The internal methods (i.e. [[Foo]] in the
  spec) are now prefixed with 'internal_' for clarity - again, it was
  previously not always clear which AO a certain method represents,
  get() could've been both Get and [[Get]] (I don't know which one it
  was closer to right now).
  Note that some of the old names have been kept until all code relying
  on them is updated, but they are now simple wrappers around the
  closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
  storage are now prefixed with 'storage_' to make their purpose clear,
  and as they are not part of the spec they should not contain any steps
  specified by it. Much functionality is now covered by the layers above
  it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
  by PropertyDescriptor - a concept similar to the current
  implementation, but more aligned with the actual spec. See the commit
  message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
  introduced more inline comments with the exact steps from the spec -
  this makes it super easy to verify correctness.
- East-const all the things.

As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.

Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 22:07:36 +01:00
Linus Groh
4e5362b7cb LibJS/Tests: Remove 'requires at least one argument' Array tests
These will be removed in favour of just taking the argument and
'risking' a ToObject on null or undefined - this is how the spec does
it.
While that will make the message slightly less specific, it'll bring
the code closer to the spec and reduce complexity, which are both
preferable at the moment.

Doing this is a previous, separate commit is simply an attempt to make
the object rewrite commit smaller.
2021-07-04 22:07:36 +01:00
Linus Groh
777a93918f LibJS: Handle invalid and symbol PropertyName in its AK::Formatter
This would previously crash as we used to_string() without checking the
type first. Circumvent that by handling invalid and numeric ones
separately and then using to_string_or_symbol().
2021-07-04 22:07:36 +01:00
Linus Groh
c81001f920 LibJS: Add Value::operator==()
This is needed for MarkedValueList::contains_slow() to work.
2021-07-04 22:07:36 +01:00
Linus Groh
c9d8aa6139 js: Handle detached ArrayBuffer in print_typed_array()
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 22:07:36 +01:00
Linus Groh
bb1a98d809 LibJS: Add new PropertyDescriptor class and related abstract operations
This is an implementation of 'The Property Descriptor Specification
Type' and related abstract operations, namely:

- IsAccessorDescriptor
- IsDataDescriptor
- IsGenericDescriptor
- FromPropertyDescriptor
- ToPropertyDescriptor
- CompletePropertyDescriptor

It works with Optional<T> to enable omitting certain fields, which will
eventually replace the Attribute::Has{Getter,Setter,Configurable,
Enumerable,Writable} bit flags, which are awkward to work with - being
able to use an initializer list with any of the possible attributes is
much more convenient.

Parts of the current PropertyAttributes implementation as well as the
much simpler PropertyDescriptor struct in Object.h will eventually be
replaced with this and completely go away.

Property storage will still use the PropertyAttributes bit flags, this
is for the layers above.

Note that this is currently guarded behind an #if 0 as if conflicts with
the existing PropertyDescriptor struct, but it's known to compile and
work just fine - I simply want to have this in a separate commit, the
primary object rewrite commit will be large enough as is.
2021-07-04 22:07:36 +01:00
Linus Groh
a3c8ebd709 LibJS: VERIFY() that property name is valid in Value::get{,_method}() 2021-07-04 22:07:36 +01:00
Linus Groh
1ac3d253c5 LibWeb/WebAssembly+test-wasm: Use get_without_side_effects() more 2021-07-04 22:07:36 +01:00
Linus Groh
9fd9e424ff LibJS: Avoid unnecessary PropertyName creation in MarkupGenerator 2021-07-04 22:07:36 +01:00
Tobias Christiansen
e18e2af826 LibWeb: Add roman numerals as a list-style for ol's
This patch adds support for the identifiers upper-roman and lower-roman
of the list-style property.
2021-07-04 22:17:03 +02:00
Andreas Kling
24e122590c Taskbar: Simplify quick launch widget layout
Use shrink-to-fit instead of manually calculating the widget size.
2021-07-04 22:03:47 +02:00
Andreas Kling
48982a08f1 Taskbar: Give the "Show/Hide Desktop" button an icon :^) 2021-07-04 21:54:50 +02:00
Andreas Kling
49d0b9e808 LibTTF: Memory map TTF fonts instead of reading them into heap memory
All GUI applications currently load all TTF fonts on startup
(to populate the Gfx::FontDatabase. This could probably be smarter.)

Before this patch, everyone would open the files and read them into
heap-allocated storage. Now we simply mmap() them instead. :^)
2021-07-04 21:34:26 +02:00
Andreas Kling
560109bd42 LibTTF: Make TTF::Font loading API return error strings 2021-07-04 21:34:26 +02:00
Idan Horowitz
301c1a3a58 Everywhere: Fix incorrect usages of AK::Checked
Specifically, explicitly specify the checked type, use the resulting
value instead of doing the same calculation twice, and break down
calculations to discrete operations to ensure no intermediary overflows
are missed.
2021-07-04 20:08:28 +01:00
Idan Horowitz
3f70efed9c LibC: Convert LengthModifier & ConversionSpecifier to enum classes
These were preventing some AK classes from using the AK Concepts header
due to the non-strictly namespaced ConversionSpecifier::Unsigned, and
are not used as their underlying value, so enum classes are more
appropriate anyways.
2021-07-04 20:08:28 +01:00
Tom
814195b060 WindowServer: Only run window animation for windows on current desktop
We should only run the minimize and launch animations for windows that
are actually rendered on the currently visible virtual desktop.
2021-07-04 20:23:56 +02:00
Tom
812ee194b7 WindowServer: Toggling desktop should only toggle current desktop
We should only show/hide the windows on the current virtual desktop.
2021-07-04 20:23:56 +02:00
zawwwu
f6cca0b8f0 Spreadsheet: Move down a cell when Return is pressed in the cell editor
If Return key is pressed when using cell value editor in a top bar,
cursor is automatically moved one line down. Fixes #8287.
2021-07-04 21:54:50 +04:30
zawwwu
cf91815654 Spreadsheet: Add function for moving cursor
This function allows to access cursor movement functionality outside of
SpreadsheetView class.
2021-07-04 21:54:50 +04:30
Andreas Kling
e8579ed24a LibThreading: Wake up the background worker thread when there's work
The worker thread used for BackgroundAction was going to sleep for
1 second at a time (when there was nothing to do.) This made using
background actions for anything interactive quite unresponsive since
you had to wait up to 1 second before it even started on your task.

We now use a simple Unix pipe to signal the worker thread that a new
work item is available.

This makes Assistant way more responsive when typing. :^)
2021-07-04 18:56:08 +02:00
Andreas Kling
d114ba4c4e LibJS: Make the with statement evaluation follow the spec even more
This was almost entirely up-to-spec already, just missing exception
checks, and we now leave the lexical environment in the modified state
if an exception occurs during statement evaluation.
2021-07-04 18:56:08 +02:00
LuK1337
0486e5895d Terminal: Grey out color scheme widget when there's nothing to select
By default we only include one color scheme.
2021-07-04 17:58:33 +02:00
Itamar
2af5bb9083 CppLanguageServer: Add test for "get_parameters_hint" 2021-07-04 17:50:33 +02:00
Itamar
f26f764c7d HackStudio: Show tooltip with parameters hint when pressing Ctrl+P
When you press Ctrl+P while the cursor is inside the parameters list of
a function call site, HackStudio will request the C++ language server
to retrieve the parameters of the called function.

The result is displayed in a tooltip window, with the current argument
in bold font.
2021-07-04 17:50:33 +02:00
Itamar
32be65a8b4 CppLanguageServer: Add "get_parameters_hint" capability
Given a call site, the C++ language server can now return the declared
parameters of the called function, as well as the index of the
parameter that the cursor is currently at.
2021-07-04 17:50:33 +02:00
Itamar
232013c05b LibCpp: Add Parser::tokens_in_range(start, end)
This function returns the tokens that exist in the specified range.
2021-07-04 17:50:33 +02:00
Itamar
9a31fb6673 LibCpp: Fix positional information of Pointer types 2021-07-04 17:50:33 +02:00
Itamar
1dfdfcf820 LibCpp: Fix parsing of ellipsis
Previously the positional information for the node of an ellipsis was
incorrect.
2021-07-04 17:50:33 +02:00
timre13
55dd568583 Assistant: Show a border around the window 2021-07-04 14:48:54 +02:00
Aziz Berkay Yesilyurt
11ff3c11f4 Userland: Add pgrep 2021-07-04 14:27:47 +02:00
Gunnar Beutner
3bbe86d8ea Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Gunnar Beutner
ea8ff03475 LibELF: Fix loading objects with a non-zero load base
My previous patch (1f93ffcd) broke loading objects whose first PT_LOAD
entry had a non-zero vaddr.

On top of that the calculations for the relro and dynamic section were
also incorrect.
2021-07-04 14:23:52 +02:00
Idan Horowitz
2f60508ae0 LibWeb: Hook on_call_stack_emptied after m_interpreter was initialized
We must hook `on_call_stack_emptied` after the interpreter was created,
as the initialization of the WindowsObject can invoke some internal
calls, which will eventually lead to this hook being called without
`m_interpreter` being fully initialized yet.
2021-07-04 14:23:25 +02:00
ForLoveOfCats
d73f53d1de Assistant: Prevent window from being minimized 2021-07-04 13:58:56 +02:00
ForLoveOfCats
cefa2e3dd2 Taskbar: Add show desktop button to toggle showing of the desktop 2021-07-04 13:58:56 +02:00
ForLoveOfCats
271840ca22 WindowServer: Add show desktop toggle IPC call
Differentiates between normal minimization and hidden windows. A window
which is hidden is still minimized, but can be seen as another stage
of being minimized.
2021-07-04 13:58:56 +02:00
LuK1337
62d4b4abf3 LibGUI: Make tooltip height line count aware
Previously multiline was not handled properly thus in case of the
Network applet the tooltip would be drawn improperly.
2021-07-04 11:31:01 +02:00
Timothy
e42484bb65 AK+LibIPC: Make all enums codable
If an enum has a supported underlying type we can provide encoding and
decoding for the enum as well.
2021-07-04 13:48:20 +04:30
Timothy
60f84f3154 LibCore: Add method to leak fd from File
This will let other code use the fd while making sure the fd isn't
automatically closed by Core::File's destructor
2021-07-04 11:44:47 +04:30
Daniel Bertalan
6c0b9919ce FileManager: Remove explicit T to Optional<T> conversion 2021-07-04 07:24:41 +04:30
Idan Horowitz
e480d69130 LibJS: Bring ArrayCreate and ArrayConstructor closer to spec
Specifically, this now explicitly takes the length, adds missing
exceptions checks to calls with user-supplied lengths, takes and uses
the prototype argument, and fixes some spec non-conformance in
ArrayConstructor and its native functions around the use of ArrayCreate
2021-07-04 00:51:43 +01:00
Idan Horowitz
5ee1ae37b2 LibJS: Add the IteratorStep abstract iterator operation
As well as add 2 missing exception checks in the IteratorComplete and
IteratorValue abstract iterator operations.
2021-07-04 00:51:43 +01:00
Erik Biederstadt
ba4d367dea HackStudio: Remove old form editing logic
In the past Hack Studio had the ability to design GUI widgets via `.frm`
files. We now use the GML playground for this purpose, and the old code
can be removed. `.frm` files are now treated as plain text files.

This commit also fixes a crash when opening `.frm` files.
`m_form_inner_container` was never instantiated, and caused a null
pointer dereference.
2021-07-04 01:14:54 +02:00
Gunnar Beutner
e1ff30a360 Toolchain+Userland: Enable TLS for x86_64
This is not technically a toolchain change, but it does require
rebuilding the toolchain for x86_64 (and just that).
2021-07-04 01:07:28 +02:00
Gunnar Beutner
371c852fc0 LibELF: Swap the arguments for negative_offset_from_tls_block_end
Now that m_tls_offset points to the start of the TLS block the argument
order makes more sense this way.
2021-07-04 01:07:28 +02:00
Gunnar Beutner
251eaad8f0 LibELF: Fix relocation support for 'static __thread' variables 2021-07-04 01:07:28 +02:00
Gunnar Beutner
5f6ee4c539 LibELF: Save the negative TLS offset in m_tls_offset
This makes it unnecessary to track the symbol size which just isn't
available for unexported symbols (e.g. for 'static __thread').
2021-07-04 01:07:28 +02:00
Gunnar Beutner
a0a38e1e84 LibELF: Implement TLS relocation support for x86_64 2021-07-04 01:07:28 +02:00
Gunnar Beutner
e8a25f3795 DynamicLoader: Remove -fbuilding-libgcc hack
This won't be necessary anymore after a toolchain rebuild.
2021-07-04 00:35:35 +02:00
Gunnar Beutner
f52bf15f8d Assistant: Make more of the classes final 2021-07-03 22:38:53 +02:00
Gunnar Beutner
52a3226f6d Assistant: Make the bitmap accessor pure virtual
Assistant looks broken when a result doesn't have an icon.
2021-07-03 22:38:53 +02:00
Gunnar Beutner
6af08f950a Assistant: Add missing bitmap accessor for terminal actions 2021-07-03 22:38:53 +02:00
Edwin Hoksberg
a4b4397a10 Assistant: Skip URL provider if query is empty or provider specific 2021-07-03 22:38:40 +02:00
Andreas Kling
c06f72c264 Assistant: Don't index the /proc and /sys directories
Roughly 20% of indexing time in a fresh install was spent on traversing
these kernel-generated directories. Let's just not. :^)
2021-07-03 22:14:09 +02:00
Andreas Kling
94def5ae9d Assistant: Avoid copying the result vectors when providers finish
Just move() them instead to cut down on the copying. :^)
2021-07-03 22:14:09 +02:00
Andreas Kling
e4199beccc Assistant: Keep the set of providers in a Vector for easy iteration 2021-07-03 22:14:09 +02:00
Andreas Kling
4fce72a967 Assistant: Use fstatat() while building FileProvider path cache
Using fstatat() allows the kernel to do relative path resolution as
opposed to absolute path resolution, which is significantly faster
and allows us to build the path cache sooner. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
801f74362e Assistant: Use StringView more in FileProvider fuzzy matching code
By not allocating new String objects, the fuzzy matcher becomes a lot
faster and more responsive while typing. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
d640031214 Assistant: Use FileIconProvider for FileProvider query results
Instead of showing the default "folder" icon for all file results,
we now show an appropriate icon for the given file. :^)
2021-07-03 20:03:53 +02:00
Andreas Kling
513e67e2eb Assistant: Make Result bitmaps virtual/lazy
Result classes now return their bitmap via a virtual Gfx::Bitmap*
getter. This effectively makes bitmap fetching lazier, since only
results that end up on screen actually get asked for their bitmap.

This drastically reduces the amount of work done by the FileProvider
background worker.
2021-07-03 20:03:53 +02:00
Marcus Nilsson
e0cf6f3cf0 TextEditor: Reset editor width when disabling preview mode
When disabling preview mode, reset the fixed width of m_editor so that
it fills out the window again even after resizing the splitter.
2021-07-03 17:36:50 +02:00
Marcus Nilsson
2264de9921 LibGUI/TextEditor: Set cut and copy actions to disabled on init
We can presume that there is nothing to cut or copy on init since
nothing is selected yet.
2021-07-03 17:36:50 +02:00
Andreas Kling
e4a55404f1 LibCore: Avoid duplicate '/' in DirIterator::next_full_path()
When the root path of a DirIterator ends with '/', we don't need to
add another '/' before appending the file name.

Fixes an issue where files found by Assistant had 2 leading slashes.
2021-07-03 16:43:08 +02:00
Timothy Flynn
27fe2b45e5 Assistant: Convert all Vector<NonnullRefPtr> to NonnullRefPtrVector 2021-07-03 15:41:35 +02:00
Timothy Flynn
d69691a26b Assistant: Add provider to run a command in a terminal
Prefix text with "$" in the Assistant text box to run a command in a
forked terminal. For example, "$ top" or "$ top -s pid".
2021-07-03 15:41:35 +02:00
Edwin Hoksberg
d5dfc255ed Assistant: Add new URLProvider to open URL's in the browser 2021-07-03 15:27:19 +02:00
Tom
0fcb048448 WindowServer: Rename Window::outer_stack -> Window::window_stack
Also, make it return a reference as aside from only three special
situations (creating, destroying, and moving a window between stacks)
a window should always be on a window stack. Any access during those
brief situations would be a bug, so we should VERIFY this.
2021-07-03 12:27:23 +02:00
Tom
6ec35c91bc WindowServer: Improve occlusion calculations
This solves two problems:
* A window was sometimes deemed occluded when the window rect was
  entirely covered by other rectangles, transparent or opaque. This
  caused a window to stop rendering even if a small portion was still
  visible, e.g. when it was merely covered by a window shadow.
* The window switcher is interested in window updates even when a
  window is entirely covered by another one, or when it is on another
  desktop. This forces windows to be not occluded in those cases.
2021-07-03 12:27:23 +02:00
Tom
c06e765a5a WindowServer: Show window's desktop in window switcher if needed
If there are windows on more than one desktop then the window switcher
should show on which one they are located.
2021-07-03 12:27:23 +02:00
Tom
cc707270ae Taskbar: Only show the current desktop's window buttons
By tracking what virtual desktop a window is on, and what desktop is
being viewed we can show or hide the window buttons accordingly.
2021-07-03 12:27:23 +02:00
Tom
5acee4b4d0 DisplaySettings: Add new Desktop tab with virtual desktop settings
This allows the user to configure the virtual desktop setup as desired.
2021-07-03 12:27:23 +02:00
Tom
6472ee0eff WindowServer: Support two window switcher modes: all or current desktop
When using the Super+Tab hotkey then all windows will be displayed,
and we will switch to another virtual desktop if needed.

When using the Alt+Tab hotkey then only the windows on the current
desktop will be displayed.
2021-07-03 12:27:23 +02:00
Tom
7984c2836d WindowServer: Add API to change virtual desktop settings
This also adds the ability to query how many virtual desktops are
set up, and for the Taskbar to be notified when the active virtual
desktop has changed.
2021-07-03 12:27:23 +02:00
Tom
584b144953 WindowServer: Add basic virtual desktop support
This creates a 2-dimensional array of WindowStack instances, one for
each virtual desktop. The main desktop 0,0 is the main desktop, which
is the desktop used for all stationary windows (e.g. taskbar, desktop).
When adding windows to a desktop, stationary windows are always added
to the main desktop.

When composing the desktop, there are usually two WindowStacks
involved. For stationary windows, the main desktop will be traversed,
and for everything else the current virtual desktop will be iterated.
Iteration is interweaved to preserve the correct order. During the
transition animation, two WindowStacks will be iterated at the same
time.
2021-07-03 12:27:23 +02:00
Timothy
944e5cfb35 Everywhere: Use IPC include syntax
Remove superfluous includes from IPCCompiler's generated output and
add include directives in IPC definitions where appropriate.
2021-07-03 12:16:00 +02:00
Timothy
83fb97c301 IPCCompiler: Add include parsing for endpoints
This will find all lines at the start of the file beginning with # and
copy them straight through.
2021-07-03 12:16:00 +02:00
Noah Rosamilia
2feaf59ab2 3DFileViewer: Add primitive mouse controls 2021-07-03 04:02:52 +02:00
Andreas Kling
e8430cf0d3 LibJS: Don't allow delete super.property
This should throw a ReferenceError, since `delete` is not allowed
on super references.
2021-07-03 01:30:30 +02:00
Andreas Kling
1270df257b LibJS: Bring the super keyword in line with the spec
This patch implements spec-compliant runtime semantics for the following
constructs:

- super.property
- super[property]

The MakeSuperPropertyReference AO is added to support this. :^)
2021-07-03 01:12:12 +02:00
Daniel Bertalan
b9f30c6f2a Everywhere: Fix some alignment issues
When creating uninitialized storage for variables, we need to make sure
that the alignment is correct. Fixes a KUBSAN failure when running
kernels compiled with Clang.

In `Syscalls/socket.cpp`, we can simply use local variables, as
`sockaddr_un` is a POD type.

Along with moving the `alignas` specifier to the correct member,
`AK::Optional`'s internal buffer has been made non-zeroed by default.
GCC emitted bogus uninitialized memory access warnings, so we now use
`__builtin_launder` to tell the compiler that we know what we are doing.
This might disable some optimizations, but judging by how GCC failed to
notice that the memory's initialization is dependent on `m_has_value`,
I'm not sure that's a bad thing.
2021-07-03 01:56:31 +04:30
Daniel Bertalan
842249aff5 LibC: Don't use C++ attribute syntax in C-visible headers
Fixes errors when building Clang's compiler-rt, which compiles in C11
more.
2021-07-03 01:56:31 +04:30
Andreas Kling
fd43d1e205 LibJS: Improve ResolveBinding + add GetIdentifierReference
ResolveBinding now matches the spec, while the non-conforming parts
are moved to GetIdentifierReference.

Implementing this properly requires variable bindings.
2021-07-02 22:22:21 +02:00
Max Wipfli
9cc35d1ba3 AK: Implement String::find_any_of() and StringView::find_any_of()
This implements StringUtils::find_any_of() and uses it in
String::find_any_of() and StringView::find_any_of(). All uses of
find_{first,last}_of have been replaced with find_any_of(), find() or
find_last(). find_{first,last}_of have subsequently been removed.
2021-07-02 21:54:21 +02:00
Max Wipfli
3bdaed501e AK+Everywhere: Remove StringView::find_{first,last}_of(char) methods
This removes StringView::find_first_of(char) and find_last_of(char) and
replaces all its usages with find and find_last respectively. This is
because those two methods are functionally equivalent.
find_{first,last}_of should only be used if searching for multiple
different characters, which is never the case with the char argument.

This also adds the [[nodiscard]] to the remaining find_{first,last}_of
methods.
2021-07-02 21:54:21 +02:00
Andreas Kling
5ce9305c5f LibJS: Implement the PrepareForOrdinaryCall abstract operation
This is used by VM::call_internal() and VM::construct() which roughly
map to function objects' [[Call]] and [[Construct]] slots in the spec.

Reorganizing this code revealed something weird: NativeFunction gets
its strictness by checking VM::in_strict_mode(). In other words,
it inherits the strict flag from the caller context. This is quite
weird, but many test-js tests rely on it, so let's preserve it until
we can think of something nicer.
2021-07-02 21:44:08 +02:00
Hediadyoin1
f4072a5038 LibM: Add long double defines of Math Constants 2021-07-02 19:50:43 +02:00
Hendiadyoin1
c74d7adac6 LibM: Implement path for negative powers 2021-07-02 19:50:43 +02:00
Andreas Kling
71fc7ac7ac LibJS: Make SuperCall a proper AST node and clean up evaluation 2021-07-02 19:39:09 +02:00
Andreas Kling
d81f4d5228 LibJS: NewExpression doesn't need compute_this_and_callee()
Now that NewExpression is separated from CallExpression, it doesn't
have to use the ad-hoc compute_this_and_callee() logic.
2021-07-02 18:43:25 +02:00
Andreas Kling
814549b846 LibJS: Split out NewExpression evaluation from CallExpression
This patch adds an override for NewExpression::execute() in the AST
interpreter to separate the logic from CallExpression. As a result,
both evaluation functions are simplified.

Both expressions are still largely non-conforming, but this makes
it easier to work on improving that since we can now deal with them
separately. :^)
2021-07-02 18:25:32 +02:00
Andreas Kling
bad1acf137 LibJS: Break out ArgumentListEvaluation AO from CallExpression 2021-07-02 17:54:34 +02:00
Marcus Nilsson
05e8bea736 PixelPaint: Reset layer widgets when closing last tab
When closing the last tab the layer list widget and layer properties
widget did not reset since they still had a pointer to the image.
2021-07-02 17:54:01 +02:00
Marcus Nilsson
54d4df668a PixelPaint: Add layer to image before setting properties
Previously when opening an image with layers that had properties like
visibility set, PixelPaint would crash when trying to trigger
layer_did_modify_properties() without in image. Avoid this by
adding the layer to the image before setting the properties.
2021-07-02 17:54:01 +02:00
Spencer Dixon
48731e9f17 LibThreading: Add new detach() API to Thread
Sometimes you don't care about `joining()` the result of a thread. The
underlying pthread implementation already existed for detaching and
now we expose it to the higher level API.
2021-07-02 17:52:45 +02:00
Idan Horowitz
f8f3ff65fe LibJS: Bring %TypedArray%.prototype.set slightly closer to spec
Specifically, instead of using the internal {get, put}_by_index methods
we now use the GetValueFromBuffer and SetValueInBuffer abstract
operations, as required by the specification.

While i was here i also replaced a couple custom detached array buffer
error messages with the existing ErrorType::DetachedArrayBuffer.
2021-07-02 15:53:51 +01:00
Spencer Dixon
e6f0b2d817 Assistant: Add a new FileProvider to assist in searching the filesystem
When searching in Assistant, we now dispatch some background jobs to
query the whole filesystem. Activating a result will use the Desktop
launcher's default way of opening that file or directory.
2021-07-02 16:47:14 +02:00
Spencer Dixon
00f93b2545 LibThreading: Add ability to cancel ongoing BackgroundActions
Handlers of the BackgroundAction are responsible for checking if the
action has been cancelled and returning early.
2021-07-02 16:47:14 +02:00
Spencer Dixon
4a3958c8ae Assistant: Remove Result::Kind in favor of native typeid
I was unaware of the `typeid` construct in C++ which can be used to
achieve the same thing I was doing with this extra Kind enum.
2021-07-02 16:47:14 +02:00
Ali Mohammad Pur
ccbc54358d LibJS: Allow patterns in parenthesized arrow function parameters 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur
2e00731ddb LibJS: Allow 'yield' and 'await' as function expression names
The spec says so, and test262 checks for this too.
2021-07-02 14:59:03 +02:00
Ali Mohammad Pur
a6fe27423a LibJS: Allow binding patterns as for in/of targets 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur
bd9f28bba6 LibJS: Allow 'yield' as a variable name outside of generator functions 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur
0292ad33eb LibJS: Make a slash after a curly close mean not-division
There's no grammar rule that allows this.
2021-07-02 14:59:03 +02:00
Ali Mohammad Pur
46ef333e9c LibJS: Parse generator functions in class expressions too 2021-07-02 14:59:03 +02:00
Spencer Dixon
609a0aa75d Assistant: Change to home directory when spawning applications
When launching Terminal via Taskbar we change to the users home
directory. For consistency, let's also `chdir` to `/home/anon` when
launching apps via Assistant's AppProvider.
2021-07-02 14:16:56 +02:00
Tom
26e9140ea1 WindowServer: Fix redrawing menu window that already existed
This fixes redrawing a menu where the window menu is reused at a
different location or with different content.
2021-07-02 13:12:29 +02:00
Brian Gianforcaro
179d8f6815 LibELF: Use StringView literal to avoid string allocations 2021-07-02 10:51:20 +04:30
Brian Gianforcaro
1498dcd9e1 DynamicLoader: Use string view literal to remove a allocation on startup
The ""sv operator switches a const char* to String conversion into
just a StringView literal.
2021-07-02 10:51:20 +04:30
Ali Mohammad Pur
b538e15548 LibWasm: Give traps a reason and display it when needed
This makes debugging wasm code a bit easier, as we now know what fails
instead of just "too bad, something went wrong".
2021-07-02 04:53:01 +04:30
Ali Mohammad Pur
62ca81fdcc LibJS: Implement the %TypedArray%.set() function 2021-07-02 04:53:01 +04:30
Ali Mohammad Pur
321db0159e LibWeb: Add the WebAssembly.Module constructor 2021-07-02 04:53:01 +04:30
Ali Mohammad Pur
8acc8339d1 LibWeb: Add the WebAssembly.Instance constructor 2021-07-02 04:53:01 +04:30
Ali Mohammad Pur
de4cbc8f08 LibWeb: Use the correct name to refer to WebAssembly.Memory.prototype
Otherwise `instanceof` wouldn't return the correct result.
2021-07-02 04:53:01 +04:30
Ali Mohammad Pur
bfb3d9e9d0 LibWeb: Split the WebAssemblyInstance object logic into multiple files
Now that we're adding a constructor to it, let's split it up like the
rest of LibWeb does.
2021-07-02 04:53:01 +04:30
Andreas Kling
a4897ed7b2 LibJS: Throw on failed PutValue into an environment reference
This should really be handled at a different layer of the stack, but
this allows us to make progress on the Object rewrite without breaking
strict mode assignment tests.
2021-07-02 00:32:23 +02:00
Andreas Kling
80170887db LibJS: Make Environment::put_into_environment() return a success bool
This code is non-conforming and will eventually get cleaned out once
we implement proper variable bindings. However, this will aid us in
improving other parts of the code right now.
2021-07-02 00:26:31 +02:00
Andreas Kling
57db058652 LibJS: Make ResolveBinding() produce strict References in strict mode 2021-07-02 00:25:52 +02:00
Timothy Flynn
1bbf3f1d09 LibWeb: Do not encode "internal_id" in DOM JSON
This is now unused.
2021-07-01 19:19:46 +02:00
Timothy Flynn
447ecc2155 LibWeb: Maintain a map of child-to-parent nodes in OOPWV DOM Inspector
Currently, each time parent_index() is invoked, two depth-first searches
are incurred to find the node's parent and grandparent. This becomes
particularly expensive, for example, when trying to scroll through a
large <ul> list.

Instead, upon creation, traverse the DOM JSON and create a map of child
nodes to their parent. Then those two lookups become hash map lookups
rather than a DFS traversal.
2021-07-01 19:19:46 +02:00