Commit Graph

23101 Commits

Author SHA1 Message Date
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
stelar7
ce314c54bd JsonParser: Bring parser more to spec 2021-07-05 12:36:19 +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
Gunnar Beutner
8c14488106 Kernel: Get rid of of some of the duplicate kernel base address macros 2021-07-05 12:28:45 +02:00
Gunnar Beutner
040fe0054b Kernel: Merge the x86 and x86_64 boot code into a single file
They're mostly the same apart from some x86_64-specific parts.
2021-07-05 12:28:45 +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
7fdf902e4a Kernel: Implement buffer flipping for VirtIOGPU framebuffers
This solves tearing issues and improves performance when updating the
VirtIOGPU framebuffers.
2021-07-04 23:59:17 +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
7efc52c3d3 Meta: Remove the LibJS OBJECT_DEBUG debug macro
I didn't add any debug logging to the object rewrite, so this is now
unused. It's much more correct though, so we can get away with adding
ad-hoc logging, should that ever be necessary :^)

Side note: this should have a prefix, i.e. JS_OBJECT_DEBUG. The previous
name is too generic.
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
f35c25a7eb Tests: Add test for String::roman_number_from() 2021-07-04 22:17:03 +02:00
Tobias Christiansen
36a420a6a6 Browser: Add Test-Page for lists
This test page showcases all our supported ol and ul list-styles.
2021-07-04 22:17:03 +02: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
Tobias Christiansen
87033ce7d1 AK: Add generation of roman numerals to AK::String
We now can generate roman numbers using String::roman_number_from()
similar to String::bijective_base_from().
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