Commit graph

28753 commits

Author SHA1 Message Date
Bastiaan van der Plaat
5e7a82a853 LibWeb: Create canvas bitmap when not existing in toDataURL and toBlob 2023-09-28 13:09:25 +02:00
Andreas Kling
d24e07579f LibJS: Use a Vector<u8> for BasicBlock instruction storage
This reduces the minimum size of a basic block from 4 KiB to 0 bytes.
With this change, memory usage at the end of Speedometer is 1.2 GiB,
down from 1.8 GiB.
2023-09-28 11:25:19 +02:00
Aliaksandr Kalenik
32be413f4e LibWeb: Add missing visit_edges() for ImageStyleValue
ImageStyleValue has a visit_edges() method, although it is not a
GC-allocated object. This is necessary because it owns a GC-allocated
ImageRequest that we want to visit, instead of using JS::Handle, to
avoid leaks. In the future, we might want to make StyleValue be
GC-allocated.

For now, this change adds missing visit_edges() calls for objects that
own ImageStyleValue.
2023-09-28 06:11:17 +02:00
Aliaksandr Kalenik
b43b3d2f8d LibWeb: Null check container while creating srcdoc navigation params
Fixes https://github.com/SerenityOS/serenity/issues/21205
Fixes https://github.com/SerenityOS/serenity/issues/21240
2023-09-28 06:09:52 +02:00
Andreas Kling
feedbd6a01 LibJS: Put __builtin_unreachable() in unused bytecode opcode handlers
For the opcodes that are handled directly in the interpreter loop,
we want the compiler to know that there's nothing to inline here.
2023-09-28 06:09:16 +02:00
Andreas Kling
f3606adc58 LibJS: Inline bytecode ops for direct local/register access
These can do a lot less stuff if we put them directly in the interpreter
loop and allow them to access the locals/registers arrays directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
ae1ac9871b LibJS: Move all bytecode instruction implementations to Interpreter.cpp
This allows aggressive inlining without LTO.
2023-09-28 06:09:16 +02:00
Andreas Kling
e5474c384d LibJS: Inline flow control ops in the bytecode interpreter loop
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
39cfb64269 LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
2023-09-28 06:09:16 +02:00
Andreas Kling
c9eff35b96 LibJS: Use goto instead of bool will_jump in interpreter loop
This is honestly less spaghetti-ish.
2023-09-28 06:09:16 +02:00
Andreas Kling
9fe38245b2 LibJS: Move bytecode interpreter's inner loop to its own function 2023-09-28 06:09:16 +02:00
Andreas Kling
951a85992b LibJS: Mark the exception path as [[unlikely]] in the interpreter loop 2023-09-28 06:09:16 +02:00
Andreas Kling
031ec98803 LibJS: Streamline InstructionStreamIterator
Nuke all the per-instruction bounds checking when iterating instructions
by using raw pointers instead of indexing into a ReadonlyBytes.

The interpreter loop already checks that we're in-bounds anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling
213b835b57 LibJS: Remove Bytecode::Interpreter::debug_position()
This was only used in one place, and that place is already covered
by a VERIFY anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling
0c746366cc LibJS: Keep return value in a call frame register 2023-09-28 06:09:16 +02:00
Andreas Kling
c833885fb5 LibJS: Keep cached this value in a call frame register
Just moving more things to call frame registers..
2023-09-28 06:09:16 +02:00
Andreas Kling
3887b840a3 LibJS: Keep current exception in a call frame register
Instead of keeping it in a Bytecode::Interpreter member, move it into
a dedicated call frame register.
2023-09-28 06:09:16 +02:00
Tim Ledbetter
ebb822def9 less: Add the -F option to quit if the input fits on one screen 2023-09-27 20:00:34 +02:00
Tim Ledbetter
938a287d3e ls: Left justify owner and group information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter
cb1851f3cc ls: Add the -g option to omit owner information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter
d618ef58fb ls: Display results in long format when -n or -o are used 2023-09-27 19:58:17 +02:00
Aliaksandr Kalenik
dc19de58d0 LibWeb: Do not use JS::Handle for "scripts to execute" in DOM::Document
Using JS::Handle in members of GC-allocated object almost always leaks.
Instead we should visit these members in visit_edges().
2023-09-27 19:39:57 +02:00
Aliaksandr Kalenik
cad2d2c85b LibWeb: Use JS::HeapFunction for DocumentObserver callbacks
If GC-allocated object wants to own a function it should use
HeapFunction because using SafeFunction will almost always lead to a
leak.
2023-09-27 19:39:57 +02:00
Tim Ledbetter
12adaac08d GameOfLife: Don't toggle cells on mouse move when placing patterns
Previously, it was very easy to inadvertently toggle cells when
placing a pattern by dragging the mouse slightly.
2023-09-27 19:12:14 +02:00
Tim Ledbetter
6eaae726fa GameOfLife: Clear the selected pattern when the game starts running 2023-09-27 19:12:14 +02:00
Tim Ledbetter
4b48757586 GameOfLife: Allow ctrl+click to place multiple patterns 2023-09-27 19:12:14 +02:00
Aliaksandr Kalenik
15629e8925 LibWeb: Do not use JS::Handle for mutation observers
Using JS::Handle in WebEngineCustomData means that mutation observers
will live as long as VM while actually they should be deallocated as
soon as they are no longer used in a script that created them.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik
e7a3040c9f LibWeb: Do not use JS::Handle for TimerHandler
There is no need to use JS::Handle for timer handler because it is
visited from JS::HeapFunction in HTML::Timer.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik
3a1f617fbf LibJS: Use Function as callback type in define_native_function/accessor
There is not need to use SafeFunction because
define_native_function or define_native_accessor will pass callback
forward to NativeFunction that uses HeapFunction to visit it.
2023-09-27 16:33:21 +02:00
circl
3e1a154440 Browser: Add support for color pickers 2023-09-27 12:16:41 +01:00
circl
2995a2e212 LibWeb+LibWebView+WebContent: Add support for <input type="color">
This commit introduces 3 things:
- Support for the color type in HTMLInputElement itself
- A mechanism for handling non event loop blocking dialogs in Page
- The associated plumbing up to ViewImplementation

Frontends may add support for the color picker with the
ViewImplementation.on_request_color_picker function
2023-09-27 12:16:41 +01:00
Andreas Kling
759ad905de LibWeb: Remove FIXME about spec bug in page visibility
Because the spec bug got fixed \o/
2023-09-27 09:31:27 +02:00
Sönke Holz
c42e8ddc48 LibELF: Calculate size of relocation table correctly in all cases
RELASZ might include the PLT table as well. Check if that is the case
and correct the size of the non-PLT relocation table.
2023-09-27 03:33:36 +02:00
kleines Filmröllchen
968038aa79 LibAudio: Use mapped files for audio playback
This is 10-20% of a speed increase on platforms with fast I/O (Linux)
and not a slowdown on Serenity. Again, the file system layer is the
limit for us :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen
d6571f54d8 LibCore: Make MappedFile a Stream
The internal reuse of FixedMemoryStream makes this straightforward.
There alread is one user of the new API, demonstrating the need for this
change beyond what I said out to use it for :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen
062e0db46c LibCore: Make MappedFile OwnPtr-based
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
Tim Ledbetter
09099cc9a3 du: Prevent multiple counting of the same file
Previously, the same file would be counted more than once if its
containing directory was visited multiple times, or there were
multiple hard links pointing to it.

We now keep track of every visited inode to ensure that files aren't
evaluated multiple times. This matches the behavior of `du` on FreeBSD
and Linux.
2023-09-26 21:27:25 +02:00
Aliaksandr Kalenik
46254101f7 LibWeb: Change DOM::Position to be GC-allocated 2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
35623ad52e LibWeb: Visit IntersectionObserverRegistration instead of using Handle
This fixes GC-leak caused by JS::Handle<IntersectionObserverver>
preventing an element that owns the handle from being deallocated.
2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
ac5c4705fd LibWeb: Do not use JS::Handle for captures of AbortSignal callbacks
There is no need to use JS::Handle for captures because AbortSignal
will visit them anyway because it uses JS::HeapFunction to store the
callback.
2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
3bcd368703 LibWeb: Do not pass JS::Handle into NativeFunction callback captures
NativeFunction uses JS::HeapFunction for the callback so GC-allocated
captures will be visited anyway.
2023-09-26 21:25:54 +02:00
Sam Atkins
90aaa8ab40 LibWeb: Handle shorthands in ResolvedCSSStyleDeclaration generically
Most shorthands can be reconstructed this way, using our generated
property data, so let's use them instead of manually implementing the
code.

Some of these were previously doing some form of error checking or
defaulting, but both of those are unnecessary. (And actually, would
crash if there wasn't a value available due to calling release_nonnull()
on a null RefPtr.) At this point, the CSS machinery has already made
sure each property has a value, and that the value is valid for that
property.
2023-09-26 21:19:42 +02:00
Sam Atkins
c103269a8e LibWeb: Fill out font property data 2023-09-26 21:19:42 +02:00
Sam Atkins
2e3f63fe3b LibWeb: Correct longhands for grid property
These three are the ones that ShorthandStyleValue uses to serialize
`grid`, so let's use them here.

The spec also mentions `grid-auto-*` properties as being set by `grid`,
but I'll leave that for someone who understands grid better.
2023-09-26 21:19:42 +02:00
Sam Atkins
28dbe8eb10 LibWeb: Use SVGPresentationAttribute mode for SVG attributes
This replaces the previous TemporarilyEnableQuirksMode hack, which has
now been removed. :^)
2023-09-26 20:01:55 +02:00
Sam Atkins
79a30c209d LibWeb: Add SVG-presentation-attribute-parsing mode to CSS parser
When parsing these, <number> is allowed anywhere that would usually
allow a <length>, <length-percentage>, or <angle>. The spec is not
clear on exactly how this should work
(see https://github.com/w3c/svgwg/issues/792 ) so I'm using some
artistic license until things are clearer:
- If we expected a <length>, treat the <number> as pixels.
- If we expected an <angle>, treat the <number> as degrees.
- Only allow direct <number> tokens, not calc() or other functions.

From what I can tell this is what the spec *intended* but I may be very
wrong. In any case, telling the ParsingContext whether we're parsing
one of these attributes is a cleaner approach and more correct than
temporarily enabling quirks mode, which we did previously.
2023-09-26 20:01:55 +02:00
Aliaksandr Kalenik
c46ce53ce3 LibJS: Declare HeapFunction::function() with [[nodiscard]] 2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
4e8654e31b LibWeb: Use JS::HeapFunction for HTML::Timer callback
Before the completion_steps for timer were casted from JS::SafeFunction
to Function in HTML::Timer constructor, which is incorrect because then
callback's captured GC-allocated objects are not protected from being
deallocated. Let's modify HTML::Timer to use JS::HeapFunction for the
callback instead.
2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
883a97984c LibWeb: Use Core::Timer instead of Platform::Timer in HTML::Timer
By using Core::Timer that accepts Function instead of JS::SafeFunction
in Platform::Timer does we fix memory leak caused by circular
dependency of timer's callback and timer itself.
2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
67c727177e LibWeb: Clear all active timers when document is destroyed
This change implements a step from the document's destroy procedure in
the specification, saying that all active timers should be cleared.

By doing this, we also fix the leaking of a document in case where we
have navigated away from a page that has scheduled timers that haven't
yet been triggered.
2023-09-26 19:42:59 +02:00
stelar7
73ef102b01 LibCrypto: Add Chacha20Poly1305 2023-09-26 13:22:04 +03:30
Andreas Kling
4c5b9fa6a2 LibJS: Remove unused SetVariable::InitializationMode::InitializeOrSet 2023-09-26 09:38:32 +02:00
Tim Ledbetter
ba40526db2 ls: Add the -p option to append a trailing slash to directories
This overrides the `-F` option and vice-versa.
2023-09-26 07:19:02 +02:00
Ali Mohammad Pur
6820e0e175 LibWasm: Make sure to place imported functions before the module's
aafef1e92d broke this while trying to
make the global import available in initialisation, this commit makes
sure we place the module's own functions after all resolved imports.
2023-09-26 07:47:20 +03:30
Aliaksandr Kalenik
78f56a0908 LibJS: Use JS::HeapFunction in NativeFunction 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
0c46d79e78 LibWeb: Use JS::HeapFunction for resumption steps in HTMLImageElement 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
67aa86b5b6 LibWeb: Use JS::HeapFunction for AbortSignal callback 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
baf37af09c LibWeb: Use JS::HeapFunction for callbacks in FetchController
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
df86e52d75 LibWeb: Use JS::HeapFunction for callbacks in SharedImageRequest
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
2023-09-25 21:14:53 +02:00
Andreas Kling
4f488f7e07 LibJS: Avoid creating empty environment for catch without parameter
When there is no `catch` parameter to bind the error, we don't need
to allocate an environment, since there's nothing to add to it.

This avoids one environment allocation every time we catch like this:

    try {
        ...
    } catch {
        ...
    }
2023-09-25 19:47:24 +02:00
Cubic Love
4c64c0b61e Base+Maps: Add manpage for Maps
Also, list Maps in Applications.md and add a link to the manpage in
Map's Help menu.
2023-09-25 16:20:20 +01:00
Shannon Booth
47514e07b4 LibWeb: Make Element attribute getters take a StringView
These functions are deferring to NamedNodeMap::get_attribute which
already takes a StringView. This changes also leads to finding some
places which were passing though a const char* instead of an entry from
Attribute names. Fix that where applicable, and switch to has_attribute
in some of those places instead of deprecated_attribute where
equivalent.

Ideally this should be taking a 'FlyString const&', but to continue
porting away from DeprecatedString, just leave a FIXME for now.
2023-09-25 15:39:29 +02:00
Shannon Booth
dbf8ff64fb LibWeb: Add AttributeNames::list 2023-09-25 15:39:29 +02:00
Shannon Booth
3458a53cb4 LibWeb: Make Element::get_elements_by_class_name take a StringView
We only make use of the view of the view in this function.
2023-09-25 15:39:29 +02:00
Shannon Booth
79f97da4b4 LibWeb: Make Element::has_attribute take a StringView
It calls Element::get_attribute which takes a StringView. Ultimately,
this should be taking a FlyString, but to help in porting away from
DeprecatedString, just leave a FIXME for that for now.
2023-09-25 15:39:29 +02:00
Shannon Booth
52fccae654 LibWeb: Make Element::set_inner_html take a StringView
It delegates to DOMParsing::inner_html_setter, which already takes a
StringView.
2023-09-25 15:39:29 +02:00
Shannon Booth
dbd46f240b LibWeb: Make DOMParsing::parse_fragment take a StringView
It calls HTMLParser::parse_html_fragment which already accepts a
StringView.
2023-09-25 15:39:29 +02:00
Shannon Booth
ab674f3bf6 LibWeb: Make Element::remove_attribute take a StringView
It already delegates to a function which accepts a StringView, so there
is no advantage here in taking a FlyString. Ideally, both of these
functions should be taking a 'FlyString const&', so leave a FIXME for
that. In the meantime, this should help in porting away from
DeprecatedString.
2023-09-25 15:39:29 +02:00
Shannon Booth
fc7f79e0e7 LibWeb: Use Element::namespace_ instead of ELement::namespace_uri
These are equivalent, and should make our lives a little eaiser porting
over this IDL interface to new String.
2023-09-25 15:39:29 +02:00
Shannon Booth
3bd04d2c58 LibWeb: Port Attr interface from DeprecatedString to String
There are an unfortunate number of DeprecatedString conversions required
here, but these should all fall away and look much more pretty again
when other places are also ported away from DeprecatedString.

Leaves only the Element IDL interface left :^)
2023-09-25 15:39:29 +02:00
Aliaksandr Kalenik
a41f23a0fc LibWeb: Fix document leak in SVGDecodedImageData
The SVGDecodedImageData creates a new Page and replaces its document
with a new one that contains SVG content. This change adds a destroy
call on the replaced document. Without this addition, all tasks
scheduled on the event loop during navigation, initiated while the
page's traversable is being created, will never execute, as the
initial replaced document will become inactive. This leads to a
document leak because the tasks use JS::Handle to hold document
pointer. Making the destroy call resolves the issue because it removes
all tasks associated with the destroyed document from the queue.
2023-09-25 14:31:20 +02:00
Hendiadyoin1
12c6692611 LibJS: Defer GC during cell construction
This stops us from trying to collect not fully constructed Cells,
which's vtables are not fully initialized, which would cause issues
during GC.
2023-09-25 13:19:25 +02:00
Hendiadyoin1
87e063db65 LibJS: Make GC deferral friendship based 2023-09-25 13:19:25 +02:00
Matthias Zimmerman
9871bd4bec LibJS: Fix spelling in VM.cpp 2023-09-25 10:58:58 +02:00
Tim Ledbetter
f34b1c7a7e PixelPaint: Make tool properties widget construction non-fallible
`Tool::get_properties_widget()` now also returns a NNRP to a widget
rather than a raw pointer.
2023-09-25 10:58:31 +02:00
Tim Ledbetter
5df88dab07 FileManager: Make PropertiesWindow::make_button() non-fallible 2023-09-25 10:58:31 +02:00
Tim Ledbetter
b4e134cb52 Userland: Use non-fallible EventReceiver::add() where possible 2023-09-25 10:58:31 +02:00
Aliaksandr Kalenik
707ca984bd LibWeb: Fix memory leak in CSS::ImageStyleValue
Before this change, whenever ImageStyleValue had a non-null
`m_image_request`, it was always leaked along with everything related
to the document to which this value belongs. The issue arises due to
the use of `JS::Handle` for the image request, as it introduces a
cyclic dependency where `ImageRequest` prevents the `CSSStyleSheet`,
that owns `ImageStyleValue`, from being deallocated:
- ImageRequest
- FetchController
- FetchParams
- Window
- HTMLDocument
- HTMLHtmlElement
- HTMLBodyElement
- Text
- HTMLHeadElement
- Text
- HTMLMetaElement
- Text
- HTMLTitleElement
- Text
- HTMLStyleElement
- CSSStyleSheet

This change solves this by visiting `m_image_request` from
`visit_edges` instead of introducing new heap root by using
`JS::Handle`.
2023-09-25 04:16:36 +02:00
Shannon Booth
d81b0e3c86 LibWeb/Streams: Make ReadIntoRequest GC-allocated
This ports the same change which was made in 9c3e9e8981 to
ReadRequest, although nothing actually implements this interface yet.
2023-09-24 20:10:50 -06:00
Shannon Booth
acda17ccc4 LibWeb/Streams: Handle BYOB reader in ReadableStreamError 2023-09-24 20:10:50 -06:00
Tim Ledbetter
24aa43f3fd LibGUI: Use floating rect when saving window state on exit
Previously, exiting a fullscreen application when
`save_size_and_position_on_close()` was used would lead to the
application having an unexpectedly large size when it was reopened.

Exiting a maximized application would lead to the restore button not
working as expected when the application was reopened.
2023-09-24 20:07:54 -06:00
Tim Ledbetter
50d0d6e710 WindowServer: Add an IPC call to get the window floating rect 2023-09-24 20:07:54 -06:00
Bastiaan van der Plaat
deb7ecfbe9 Maps: Add search panel 2023-09-24 20:05:33 -06:00
Bastiaan van der Plaat
2c2a1da306 Maps: Fix map rendering clipping issue when not full window size 2023-09-24 20:05:33 -06:00
Bastiaan van der Plaat
2bdd39f198 Maps: Add LatLngBounds struct 2023-09-24 20:05:33 -06:00
Bastiaan van der Plaat
baf2121636 LibGUI: Add more customization options to ListView 2023-09-24 20:05:33 -06:00
Bastiaan van der Plaat
6265c544f9 LibWeb: Add DOMMatrix rotate, rotateFromVector and rotateAxisAngle 2023-09-24 20:02:38 -06:00
Bastiaan van der Plaat
42c2a67c83 LibWeb: Add DOMMatrix scale and scale3d 2023-09-24 20:02:38 -06:00
Bastiaan van der Plaat
67f6a9ee12 LibWeb: Fix DOMMatrix fromMatrix to use complete DOMMatrixInit struct
DOMMatrix fromMatrix was using create_from_dom_matrix_2d_init to make
a DOMMatrix for it's init struct this is wrong because only the 2D
params of the DOMMatrix are put into the new matrix. I have added
a non 2D version of that function that takes the full DOMMatrixInit
so now fromMatrix works correctly again. I also have added some
text tests to test if it works correctly.

I split the dommatrix.html text tests into multiple files because that
file was becoming to big so now every sub function is a seperate file.
2023-09-24 20:02:38 -06:00
Bastiaan van der Plaat
5d37e1c220 Userland: Remember window state of productivity / editor applications 2023-09-24 20:00:00 -06:00
Bastiaan van der Plaat
04ee15a5ad Ladybird+LibWeb: Use old error.html template for navigation errors again 2023-09-24 19:59:00 -06:00
Bastiaan van der Plaat
8f2319e966 Ladybird+LibWeb: Rename FileDirectoryLoader to GeneratedPagesLoader 2023-09-24 19:59:00 -06:00
Sam Atkins
6ee6a2534d LibWeb: Expand shorthands containing CSS-wide keywords automatically
Now that shorthands use ShorthandStyleValue, the only bespoke code left
for them applies to CSS-wide keywords. We can automate expanding those,
so let's do so. :^)
2023-09-25 00:46:21 +01:00
Sam Atkins
1c4a05f8a4 LibWeb: Treat "revert" as a CSS-wide keyword
This isn't included in the base definition of a CSS-wide keyword, but
the CASCADE-4 spec which adds it says:

> The revert CSS-wide keyword rolls back the cascade to the cascaded
  value of the earlier origin.

So it is one. While I'm at it, rename `is_builtin()` to match the spec
terminology. It's not used currently, but will be in the next commit.
2023-09-25 00:46:21 +01:00
Sam Atkins
aea112da71 LibWeb: Replace OverflowStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
e905072e47 LibWeb: Replace GridTrackPlacementShorthandStyleValue with ShorthandSV 2023-09-25 00:46:21 +01:00
Sam Atkins
8efac89a16 LibWeb: Replace TextDecorationStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
d40b3f2a34 LibWeb: Fix "egde" typo 2023-09-25 00:46:21 +01:00
Sam Atkins
6e311902de LibWeb: Replace PlaceItemsStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
8143d48161 LibWeb: Replace PlaceSelfStyleValue with ShorthandStyleValue
Turns out we were parsing `place-self` as a PlaceItemsStyleValue
sometimes, whoops.
2023-09-25 00:46:21 +01:00
Sam Atkins
1b0939b418 LibWeb: Replace PlaceContentStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
6758decc74 LibWeb: Replace ListStyleStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
f5cb2e8dc2 LibWeb: Replace GridTrackSizeListShorthandStyleValue with ShorthandSV 2023-09-25 00:46:21 +01:00
Sam Atkins
48f3603119 LibWeb: Replace GridAreaShorthandStyleValue with ShorthandStyleValue 2023-09-25 00:46:21 +01:00
Sam Atkins
fe499681d9 LibWeb: Actually remove FontStyleValue
Whoops!
2023-09-25 00:46:21 +01:00
Sam Atkins
23d59a6caf LibWeb: Replace BorderStyleValue with ShorthandStyleValue
And also expand builtin values to the longhands, which we weren't doing
before.
2023-09-25 00:46:21 +01:00
Sam Atkins
66300794a6 LibWeb: Expand CSS builtin values in border shorthands 2023-09-25 00:46:21 +01:00
Sam Atkins
ae9eaeffc4 LibWeb: Remove unnecessary code from sided border shorthand expansion
I'm sure at some point we made use of `Edge::All` and this made sense,
but now it's just overly verbose.
2023-09-25 00:46:21 +01:00
Gabriel Nava Marino
3a071bc4dd AK: Replace unsafe offset_pointer usage in OpenType code
In OpenType code, replace unsafe Span::offset_pointer with Span::offset,
which includes bounds checks.
2023-09-25 00:19:38 +02:00
Sam Atkins
34940821f6 Utilities: Use new ArgsParser method for enum values 2023-09-24 23:41:22 +02:00
Sam Atkins
f71d74ed65 LibCore: Add ArgsParser::add_option for setting enum values from a flag
Previously, argument-less options could only set a boolean to true. This
lets them also set an enum variable to a specific value, as is currently
done by the `ls` utility.
2023-09-24 23:41:22 +02:00
Aliaksandr Kalenik
719a00df3a LibJS: Add source location for Handle nodes in GC graph dumper output
With this change JS::Handle root nodes will contain source location
where they were constructed like:
```
    "94675029575744": {
        "root": "Handle activate_event_handler \
           serenity/Userland/Libraries/LibWeb/DOM/EventTarget.cpp:564",
        "class_name": "HTMLButtonElement",
        "edges": [
            "94675025955904",
            "94675026899520",
            "94675030831168",
```
2023-09-24 14:55:32 +02:00
Tim Ledbetter
01ec695ae3 ls: Add the -S option to sort files by size
This option will override the `-t` option and vice-versa.
2023-09-24 08:22:11 +01:00
Aliaksandr Kalenik
f9520af71e LibWeb: Do page_did_start_loading if history state is pushed/replaced
page_did_start_loading need to be called when current history entry
changes to update URL in UI.
2023-09-23 17:59:10 -06:00
Aliaksandr Kalenik
7cdbd59e92 LibWeb: Update session history when History entry is pushed/replaced
With this change `shared_history_push_replace_state()` starts to
actually add/replace session history entry.
2023-09-23 17:59:10 -06:00
Aliaksandr Kalenik
699ead0939 LibWeb: Start fleshing out update document for history step application 2023-09-23 17:59:10 -06:00
Aliaksandr Kalenik
40cbe9e72b LibWeb: Add index and length into HTML::History 2023-09-23 17:59:10 -06:00
Andrew Kaster
0f8ae12d44 LibWeb: Implement fire a download request navigate event 2023-09-23 18:57:31 +02:00
Andrew Kaster
67bc3629a9 LibWeb: Implement fire a push/replace/reload navigate event 2023-09-23 18:57:31 +02:00
Andrew Kaster
5549371b52 LibWeb: Implement fire a traverse navigate event on Navigation 2023-09-23 18:57:31 +02:00
Andrew Kaster
3935105d0a LibWeb: Implement the inner navigate event firing algorithm
This algorithm is the meat of firing the NavigateEvent at navigation.
In order to implement it, we also need to add some getters/setters on
NavigateEvent. The implemetentation deviates from the spec in when
exactly the NavigateEvent is created. In following the pattern for other
events. we construct the event from the NavigateEventInit structure from
our native code. This makes the code a lot simpler than adding 10
getters to the NavigateEvent that are only ever used just after
construction. I'm not 100% conviced the promise resolution code is
correct, but we can add tests for that later :^).
2023-09-23 18:57:31 +02:00
Andrew Kaster
0650edc7d7 LibWeb: Implement Navigation AOs that are called during event firing
These Navigation API Method Tracker AOs are called by the inner navigate
event firing algorithm. Implement them beforehand to make the diff look
pretty :^).
2023-09-23 18:57:31 +02:00
Andrew Kaster
2a24dda44d LibWeb: Implement NavigateEvent AOs that are called during event firing
The potentially scroll/focus and finish AOs are called by the inner
navigate event firing algorithm. Implement them beforehand to make the
diff look pretty :^).
2023-09-23 18:57:31 +02:00
Andrew Kaster
e05a6f6aa2 LibWeb: Add getter to NavigationDestination to get its URL as an AK::URL
Other parts of LibWeb are going to want to mess with the URL object, not
its serialzied representation. So let's add a backdoor getter.
2023-09-23 18:57:31 +02:00
Andrew Kaster
a5e05c5082 LibWeb/WebIDL: Implement the wait for all AO
This abstract operation takes a list of IDL promises and chains them
together with .then() until all are completed or rejected.
2023-09-23 18:57:31 +02:00
Andrew Kaster
b07badb832 LibWeb: Make the can have its url rewritten AO publicly accessible
We'll need this from the Navigation API
2023-09-23 18:57:31 +02:00
Sam Atkins
f98659dd76 LibWeb: Remove UA style sheet rules from <symbol> presentational hints 2023-09-23 16:27:14 +02:00
Sam Atkins
ae4b8d86df LibWeb: Include standard SVG user agent style sheet
For now, part of this is commented-out. Our current implementations of
`<mask>` and `<symbol>` rely on creating layout nodes, so they can't be
`display: none`.
2023-09-23 16:27:14 +02:00
Andreas Kling
a6131634f1 LibWeb: Add fast_is<T>() for HTMLSlotElement
2.4x speed-up on StyleBench :^)
2023-09-23 13:04:38 +02:00
Shannon Booth
07b332e17c LibWeb: Add IDL definition for SVGScriptElement
It does not currently handle any of the actual scripting, but this
should at least allow us to create an instance of the element.

The test being added here isn't actually testing much, but before the
previous commit we used to crash parsing the page due to a TODO().
2023-09-23 11:41:57 +02:00
Shannon Booth
60c32f39a1 LibWeb: Do not crash when parsing a SVG script element
Just leave a FIXME dbgln message instead. This works around a crash seen
in html5test.com.
2023-09-23 11:41:57 +02:00
Shannon Booth
6de9d2820f LibWeb: Add spec comments to 'process the rules for foreign content' 2023-09-23 11:41:57 +02:00
Andrew Kaster
5949e3c3e8 LibWeb: Implement named property access AOs on Window
These allow accessing embeds, forms, images and objects with a given
name attribute, and any element with a given id attribute, as top level
properties on the global object.

It also allows accessing NavigableContainers by target name as top level
properties on the global object.

The current implementation feels very expensive. It's likely that
these values will need smarter caching in the future.
2023-09-22 19:55:59 -06:00
Andrew Kaster
247f12d7b0 LibWeb: Insert WindowProperties object into Window's prototype chain
And implement WindowProperties, the "named properties object" for Window
according to the spec.

This involves moving an AO out of LegacyPlatformObject and into a common
place that the WindowProperties class can access.

This doesn't implement the AOs on Window that actually name lookup for
the unenumerable named properties on the window yet, just the
scaffolding.
2023-09-22 19:55:59 -06:00
Andrew Kaster
64899dba44 LibWeb: Implement document-tree child navigable target name property set
This AO allows accessing child navigables by their name as named
properties on the WindowProxy object.
2023-09-22 19:55:59 -06:00
Andrew Kaster
7e277797ad LibWeb: Add about base url to the various AOs that construct documents
And some assorted cleanup along the way. The browsing context and
document AOs in particular need re-alignment with the spec.
2023-09-22 19:45:11 -06:00
Andrew Kaster
dc0f7c4c54 LibWeb: Align NavigationParams and the creation AOs to the spec
And remove assorted spec FIXMEs along the way. Also align
populate_session_history_entry_document to the spec, with a bonus spec
bug to be filed.

This involves creating a new NonFetchSchemeNavigationParams spec, and
having the associated AOs take a Variant rather than Optional to
accomodate the fact that this extra struct could be returned by the
algorithm. We don't actually *do* anything with these params, but the
scaffolding is there now, with less TODOs.
2023-09-22 19:45:11 -06:00
Andrew Kaster
f296382e1a LibWeb: Implement inform the navigation api about aborting navigation
This also requires implementing the abort the ongoing navigation AO on
Navigation, which will be used from other NavigateEvent AOs.
2023-09-22 19:45:11 -06:00
Andrew Kaster
25ffe6becb LibWeb: Correct spelling of UserNavigationTiming enum
With luck we can Naviagate these typo-filled waters.
2023-09-22 19:45:11 -06:00
Aliaksandr Kalenik
06d05b3c55 LibWeb: Boxes that establish FFC or GFC should avoid overlapping floats
Before, we only ensured that boxes establishing BFC did not overlap
with floats because that is what CSS 2.2 specification says. However,
we should also apply the same for boxes establishing FFC or GFC as this
aligns with the behavior of other browsers.

Fixes https://github.com/SerenityOS/serenity/issues/21095
2023-09-22 16:48:28 +02:00
Andreas Kling
3d5cd23393 LibJS: Remove unused Instruction::is_terminator() 2023-09-21 16:19:13 +02:00
Andreas Kling
3ccac0cf6e LibJS: Remove unused realm parameter from run_and_return_frame() 2023-09-21 16:19:13 +02:00
Andreas Kling
d6e959686d LibJS: Remove automatic ExecutionContext creation in BC interpreter
This was a remnant from the AST/BC hybrid interpreter times. We've had
a VERIFY in here for weeks now that would catch anything depending on
this behavior, and nothing has hit it, so let's remove the unnecessary
code (but leave the VERIFY) :^)
2023-09-21 16:19:13 +02:00
Shannon Booth
30ab198b40 LibJS: Create const variables in ForIn/OfBodyEvaluation in strict mode
Our implementation of environment.CreateImmutableBinding(name, true)
in this AO was not correctly initializing const variables in strict
mode. This would mean that constant declarations in for loop bodies
would not throw if they were modified.

To fix this, add a new parameter to CreateVariable to set strict mode.
Also remove the vm.is_strict mode check here, as it doesn't look like
anywhere in the spec will change strict mode depending on whether the
script itself is running in script mode or not.

This fixes two of our test-js tests, no change to test262.
2023-09-21 16:19:05 +02:00
Shannon Booth
e67dd54878 LibJS: Add spec comments to ScopeNode::block_declaration_instantiation 2023-09-21 16:19:05 +02:00
Tim Ledbetter
3aa49f268c Userland: Make Window::set_main_widget() non-fallible 2023-09-21 10:20:23 +02:00
Liav A
c9297126db SystemServer: Use correct unix device numbers for null, full and random
This fixes regression made in 446200d6f3
2023-09-20 13:27:09 -06:00
Sam Atkins
0634d11318 LibWeb: Stop adding extra whitespace when serializing CSS Functions
Otherwise `attr(|name, "fallback")` becomes `attr(| name ,  "fallback")`

The test here is slightly aspirational. There are other rules for
serialization we don't follow (like stripping whitespace entirely from
many places) so these are marked with FIXMEs.
2023-09-20 18:29:37 +02:00
Andreas Kling
f31b39ca18 LibWeb: Remove unused BrowsingContext::for_each_child() 2023-09-20 18:29:17 +02:00
Andreas Kling
413cc1774e LibWeb: Remove unused BrowsingContext::scroll_offset_did_change() 2023-09-20 18:29:17 +02:00
Andreas Kling
93e4a0de16 LibWeb: Move has_a_rendering_opportunity() to Navigable 2023-09-20 18:29:17 +02:00
Andreas Kling
a02d42dea2 LibWeb: Remove two unused BrowsingContext member variables 2023-09-20 18:29:17 +02:00
Andreas Kling
8e669c14c8 LibWeb: Remove unused BrowsingContext::document_family*() 2023-09-20 18:29:17 +02:00
Andreas Kling
38cb15ff49 LibWeb: Move system visibility state to TraversableNavigable
This no longer belongs in BrowsingContext.
2023-09-20 18:29:17 +02:00
Andreas Kling
046ae7fe86 LibWeb: Remove unused BrowsingContext::scroll_to_anchor() 2023-09-20 18:29:17 +02:00
Andreas Kling
94236c2532 LibWeb: Remove unused "frame nesting" tracking from BrowsingContext 2023-09-20 18:29:17 +02:00
Andreas Kling
51caa14381 LibWeb: Remove FrameLoader
This class is no longer used, now that we've moved to navigables.
2023-09-20 18:29:17 +02:00
Aliaksandr Kalenik
693d602b2f LibWeb: Fix infinite loop in GFC growth limit distribution
This change is bd85e1b30b ported from
base size to growth limit distribution.

Fixes https://github.com/SerenityOS/serenity/issues/21056
2023-09-20 18:28:11 +02:00
Sam Atkins
9b4ddff6a9 LibWeb: Replace FontStyleValue with ShorthandStyleValue
Also, actually include font-variant since we were already parsing it but
throwing it away.
2023-09-20 12:17:16 +01:00
Sam Atkins
34591549b1 LibWeb: Replace BorderRadiusShorthandStyleValue with ShorthandStyleValue 2023-09-20 12:17:16 +01:00
Sam Atkins
34e0899ab0 LibWeb: Replace BackgroundStyleValue with ShorthandStyleValue
The `to_string()` for this is modified a little from the original,
because we have to calculate what the layer-count is then, instead of
having it already calculated.
2023-09-20 12:17:16 +01:00
Sam Atkins
1ae515c0b7 LibWeb: Replace FlexFlowStyleValue with ShorthandStyleValue 2023-09-20 12:17:16 +01:00
Sam Atkins
aa45b3dfe3 LibWeb: Replace FlexStyleValue with ShorthandStyleValue
We still need the custom parsing and to_string() logic, but nothing
else. :^)
2023-09-20 12:17:16 +01:00
Sam Atkins
a72788b889 LibWeb: Return after expanding ShorthandStyleValues
We don't want to carry on doing things after we've handled these.
2023-09-20 12:17:16 +01:00
Sam Atkins
d20254f1bc LibWeb: Rename CompositeStyleValue -> ShorthandStyleValue
It's a shorthand, so let's call it that. :^)
2023-09-20 12:17:16 +01:00
Aliaksandr Kalenik
4ff4ac11b9 LibJS: Remove alreadyDeclared check in FunctionDeclarationInstantiation
We don't need to check if a function parameter is already declared
while creating bindings for them because we deduplicate their names by
storing them in a hash table in one of the previous steps.

This change makes React-Redux-TodoMVC test in Speedometer run 2%
faster.
2023-09-19 16:58:25 +02:00
Shannon Booth
b603e860af LibWeb: Port CharacterData from DeprecatedString to String
The existing implementation has some pre-existing issues where it is
incorrectly assumes that byte offsets are given through the IDL instead
of UTF-16 code units. While making these changes, leave some FIXMEs for
that.
2023-09-19 10:54:07 +02:00
Shannon Booth
3b12a13f17 LibWeb: Add String variants of functions in ChildNode
This is required in porting over CharacterData from DeprecatedString to
String.

Unfortunately, as with ParentNode, we cannot yet remove the
DeprecatedString variants of these functions as the Element interface
includes ChildNode and has not yet been ported over from
DeprecatedString.
2023-09-19 10:54:07 +02:00
MacDue
909bcfe9a4 LibWeb: Resolve and paint simple SVG masks
This allows applying SVG <mask>s to elements. It is only implemented for
the simplest (and default) case:

	- mask-type = luminance
 	- maskContentUnits = maskContentUnits
 	- maskUnits = objectBoundingBox
	- Default masking area

It should be possible to extend to cover more cases. Though the layout
for maskContentUnits = objectBoundingBox will be tricky to figure out.
2023-09-19 10:46:05 +02:00
MacDue
650180811e LibWeb: Flesh out SVGMaskElement a bit
- Add method to resolve the masking area (based on the target element
  size)
- Parse the maskUnits and maskContentUnits attributes
2023-09-19 10:46:05 +02:00
MacDue
0af8d81f48 LibWeb: Layout SVG <mask> elements (but don't paint them)
This allows SVG mask elements to have layout computed, but not connected
to the main paint tree. They should only be reachable if (and painted)
if referenced by the "mask" attribute of another element.

This is controlled by the forms_unconnected_subtree() function on the
paintable, which (if it returns true) prevents the paintable from being
added as a child to what would be its parent.
2023-09-19 10:46:05 +02:00
MacDue
c5b50ec2f4 LibWeb: Create paintables for nodes whose parents don't have paintables
A Paintable is not created for an SVG <defs> element (nor should it),
but it can contain SVG <mask> elements that need a paintable.

This change forces those paintables to be created (without a parent).
The masks are then only painted by being referenced from another
element.
2023-09-19 10:46:05 +02:00
MacDue
b340a85523 LibWeb: Make StackingContext functions static where possible
These don't need to be member functions, and this will make it easier
to use these to paint <mask> elements (into an off-screen mask bitmap).
2023-09-19 10:46:05 +02:00
MacDue
dc58b5f418 LibWeb: Add CSS mask property and make it form a stacking context 2023-09-19 10:46:05 +02:00
MacDue
b69e8ee893 LibGfx: Add Gfx::Bitmap::apply_mask()
This allows applying an alpha or luminance mask to a bitmap (of the same
size) inplace.
2023-09-19 10:46:05 +02:00
Kemal Zebari
93e230ba58 LibWeb/URL: Use the correct spec URL comment for URL::port()
Since in the previous snapshot we were using the hostname setter's
spec URL.
2023-09-19 08:18:45 +02:00
Andreas Kling
9ccf25fdbe LibJS: Avoid StringView->DeprecatedFlyString conversions in FDI 2023-09-19 07:17:27 +02:00
Andreas Kling
e32a597d78 LibJS: Fix VariableNameToInitialize name spelling 2023-09-19 07:11:17 +02:00
Andreas Kling
e03f43e1b5 LibJS: Remove unused HashTable in function_declaration_instantiation() 2023-09-19 07:06:50 +02:00
Aliaksandr Kalenik
edd2f8b37f LibJS: Run reusable steps of FunctionDeclarationInstantiation only once
This change moves steps that can be executed only once and then reused
in subsequent function instantiations from
`function_declaration_instantiation` to the ECMAScriptFunctionObject:
- Determine if there are any parameters with duplicate names.
- Determine if there are any parameters with expressions.
- Determine if an arguments object needs to be created.
- Create a list of distinct function names for which bindings need to
  be created.
- Create a list of distinct variable names for which bindings need to
  be created.

This change makes React-Redux-TodoMVC test in Speedometer
run 10% faster :)
2023-09-19 06:54:10 +02:00
Bastiaan van der Plaat
aed25991e6 Maps: Add MapsSettings with multiple tile providers options 2023-09-18 12:46:41 -06:00
Bastiaan van der Plaat
264782557e Maps: Fix bug when opening attribution url by adding launch unveil 2023-09-18 12:46:41 -06:00
Tim Ledbetter
9cd3477763 GameOfLife: Replace DeprecatedString with String 2023-09-18 11:12:25 -06:00
Bastiaan van der Plaat
e3cd789ea8 Maps: Add context menu to the map widget 2023-09-18 11:12:04 -06:00
Bastiaan van der Plaat
9939b028c6 LibWeb: Add basic Navigator send beacon support 2023-09-18 11:08:26 -06:00
Hendiadyoin1
d262670729 LibWeb: Use more CSSPixelFractions in GFC::expand_flexible_tracks
Also contains a drive-by expression simplification, and accidental
double truncation fix.
2023-09-18 18:02:51 +02:00
Tim Ledbetter
9b30dea889 LibGUI: Remove Action::try_create_checkable() 2023-09-18 18:00:45 +02:00
Tim Ledbetter
f570a0f0b8 LibGUI: Remove ItemListModel::try_create() 2023-09-18 18:00:45 +02:00
Tim Ledbetter
a6f6a1afd2 Userland: Prefer non-fallible construction for LibGUI objects 2023-09-18 18:00:45 +02:00
Aliaksandr Kalenik
a4a94de942 LibJS: Get initial_value from local variables if id represents a local
If identifier represents local variable we should get its value from
`local_variables` in `ExecutionContext` instead of environment.
2023-09-18 17:57:56 +02:00
Andreas Kling
675d919dd2 LibWeb: Handle custom ident values for the CSS font-family property
We were parsing these all right, but ignoring them in StyleComputer.

No test unfortunately, since we don't currently have a way to delay
the load event until a @font-face has been fully loaded. (Any test
of this right now would be flaky.)
2023-09-18 16:34:01 +02:00
Andreas Kling
1f69e9cddf LibWeb: Remove Layout::Node::m_visible and compute it on the fly
This fixes an issue where the value would be out of sync with reality
in anonymous wrapper block boxes, since we forgot to compute m_visible
after assigning the computed values to them.

Fixes #21106
2023-09-18 14:45:20 +02:00
Andreas Kling
0a133ccba4 LibWeb: Remove the HTML blink element
Support for this element has been removed from all major engines years
ago already, and it's currently the only reason we have a weird
"visible" flag on Layout::Node (which we toggle on a timer here..)
2023-09-18 14:45:20 +02:00
Daniel Bertalan
1f747b9132 CMake: Use CMAKE_POSITION_INDEPENDENT_CODE instead of explicit -fpic
This makes CMake pass `-fpie` instead of `-fpic` to the compiler when
building the Kernel and userland *executables*. This allows the compiler
to make certain optimizations based on the fact that the code will be
used in an executable, such as not having to emit `.localalias` symbols.
This leads to a 450 KiB decrease in the size of the Kernel binary.
2023-09-18 10:26:42 +02:00
Andrew Kaster
78c2fad89c LibTimeZone: Include generated files before checked-in files
This is a rickety solution to a problem when using LibTimeZone as a
static archive, like we do for Android. When pulling symbols from an
archive into a shared library, lld will pick the weak symbols for our
timezone helpers and keep them. Even if there's a strong symbol in
another object file in the same archive, it ignores them. However,
if we make sure that the strong symbols for the generated files are
first in the list, then we avoid the problem altogether by relying
on linker specifics.
2023-09-17 19:22:29 -06:00
Andrew Kaster
091a0e0b78 LibWeb: Report Android 10 as OS_STRING in user agent on Android
Some websites, such as m.youtube.com, sniff for a version after the
Android OS version. Chrome has recently taken to always reporting
Android 10, so let's follow suit.
2023-09-17 19:22:29 -06:00
Cubic Love
2767fa78f8 Solitaire: Rearrange Help Menu
Rearrange the Help menu actions so they're in the same order as other
application's Help menus.
2023-09-17 17:26:32 -06:00
Tim Ledbetter
784ac6b9f2 less: Allow quitting with uppercase 'Q' 2023-09-17 17:10:50 -06:00
Tim Ledbetter
c9e4a82c04 WebServer: Return 403 for a GET request to an inaccessible path
Previously, trying to access a non-readable file would cause a
connection reset in the browser; trying to access a non-executable
directory would show a completely empty directory listing.
2023-09-17 17:10:04 -06:00
Tim Ledbetter
b2f0c50376 WebServer: Don't display file on directory listing if stat call fails
Previously, the program would crash when attempting to display a symlink
which pointed outside of the permitted directory.
2023-09-17 17:10:04 -06:00