Commit graph

18699 commits

Author SHA1 Message Date
Linus Groh ef5e2eb794 LibWeb: Implement Fetch::Infrastructure::Response::clone() 2022-09-27 14:56:17 +01:00
Linus Groh b5e8e9b30b LibWeb: Support ReadonlyBytes as argument for extract_body()
This now matches the spec's requirement of "a byte sequence or BodyInit
object object".
2022-09-27 14:56:17 +01:00
Linus Groh 426e32e5c0 LibWeb: Add WebIDL::ExceptionOr constructor for wrapped ValueType
This is copied from JS::ThrowCompletionOr and will allow using them
interchangeably with types wrapped by JS::Value such as JS::Object*.
2022-09-27 14:56:17 +01:00
Linus Groh 4461234898 LibWeb: Support plain (throw) JS::Completion in WebIDL::ExceptionOr
This makes it possible to propagate exceptions from a function that
returns JS::ThrowCompletionOr via TRY() in another function that returns
WebIDL::ExceptionOr.
2022-09-27 14:56:17 +01:00
Linus Groh fd52119ca3 LibWeb: Add getters and setters for Fetch::Header's members 2022-09-27 14:56:17 +01:00
Linus Groh dc6fb43d26 LibWeb: Add referrer policy to Fetch::Infrastructure::Request
The enum is in its own directory and namespace as there's a standalone
spec for it, that will later also house AOs.

- https://w3c.github.io/webappsec-referrer-policy/
- https://www.w3.org/TR/referrer-policy/
2022-09-27 14:56:17 +01:00
Linus Groh a602a4c780 LibWeb: Heap-allocate returned Fetch::Infrastructure::{Request,Response}
A Request/Response instance should always be heap-allocated and have
clear ownership, so let's also wrap it in a NonnullOwnPtr instead of
putting them on the stack.
2022-09-27 14:56:17 +01:00
Linus Groh 88ee15a497 LibWeb: Mark two Fetch::Infrastructure::Request getters as const 2022-09-27 14:56:17 +01:00
Linus Groh 37972e9f0c LibWeb: Implement most WebIDL promise operations 2022-09-27 14:56:17 +01:00
Linus Groh e68e92b304 LibJS: Make JS::NativeFunction use JS::SafeFunction internally
This still needs a project-wide cleanup to remove handles captured in
lambdas, which is now longer required.
For now, this will be used in the next commit implementing promise AOs
from Web IDL, which make heavy use of deferred callbacks.
2022-09-27 14:56:17 +01:00
Linus Groh 00fa71725b LibWeb: Implement JS value <-> JSON parsing/serialization AOs 2022-09-27 14:56:17 +01:00
Linus Groh 4e536eaf98 LibJS: Add JSON.stringify function to the intrinsics
This is needed for some Web APIs.
2022-09-27 14:56:17 +01:00
Linus Groh b42b950688 LibWeb: Implement MimeType serialization 2022-09-27 14:56:17 +01:00
ne0ndrag0n d463b8e6fb SQLStudio: Save and load blank files without failing assertion 2022-09-27 14:38:50 +01:00
kleines Filmröllchen 5294fd671e PixelPaint: Use the parallel ImageProcessor to apply filters
The main advantage of this change is that heavy-weight filters do not
lock up the GUI anymore.

This first cut has several flaws:
- We do not account for modification of the referenced images while the
  filter is running. Depending on the exact filter behavior this might
  have all sorts of weird effects. A simple fix would be to show a
  progress dialog to the user, preventing them from performing other
  modifications in the meantime.
- We do not use the image processor for previews. Preview behavior has a
  couple of other considerations that are intentionally not addressed in
  this commit or pull request.
2022-09-27 14:23:11 +01:00
kleines Filmröllchen ade868aa56 PixelPaint: Add a general-purpose parallel image processing pipeline
The ImageProcessor singleton is intended to be used by all sorts of
image processing which might take some time to complete; or other
background actions. We're not using BackgroundTask here because this
system is specifically designed to work with task queues and PixelPaint
interaction; e.g. it provides common image processing tasks such as
filter application.
2022-09-27 14:23:11 +01:00
kleines Filmröllchen 9483adee46 PixelPaint: Expose the GUI event loop from the ImageEditor
This allows processing threads to call back into the GUI.
2022-09-27 14:23:11 +01:00
kleines Filmröllchen 056b081e2d PixelPaint: Reference-count filters
For multi-threading filter application, shared ownership is much easier
to work with.
2022-09-27 14:23:11 +01:00
Marco Santos 5f76ab9836 Spreadsheet: Add toolbar actions to change the cell style 2022-09-27 13:38:11 +03:30
Sam Atkins 42f36d4865 LibGUI: Make "Home" key behavior comfier on wrapped lines :^)
There's a big comment explaining it because it's somewhat confusing, but
the behavior I'm copying from other editors is, when you repeatedly
press the `Home` key:

1. Go to the start of the visual line, where it wraps.
2. Go to the first non-whitespace character on the logical line, which
   is what happens in non-wrapped lines.
3. Go to column 0.
4. GOTO 2
2022-09-26 23:12:31 +02:00
Enver Balalic 55c099c953 LibHTTP: Null out on_ready_to_read on socket close
This fixes the segfault reported in #15283.

on_ready_to_read gets re-registered on every job start anyways.
I see no reason why this could be bad.
2022-09-26 23:11:28 +02:00
Roberto Bampi 69f7a59a34 Magnifier: Add the option to save captures 2022-09-26 17:28:54 +01:00
MacDue f6264523b9 LibWeb: Fix destination bitmap edge clip case in transform painting
This fixes an edge case, where the destination rect falls partly
outside the painter, so is clipped to a smaller size in
`get_region_bitmap()` (which needs to be accounted for with an extra
offset).
2022-09-26 01:38:30 +02:00
Linus Groh bbaa05fcf9 LibWeb: Move DOMException from DOM/ to WebIDL/ 2022-09-25 19:13:31 +01:00
Linus Groh ad04d7ac9b LibWeb: Move ExceptionOr from DOM/ to WebIDL/
This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
2022-09-25 19:13:31 +01:00
MacDue e3537e4374 LibWeb: Fix shadow painting when the target painter is translated 2022-09-25 18:37:31 +02:00
MacDue 3fad64dfbc LibWeb: Sample the destination when painting element opacity/transform
This now copies the area under the destination to a new bitmap, that
is then scaled to the size of the source. The element is then painted
into that bitmap, which is then scaled and painted back to
the destination. This is done as many effects such as shadows, border
radii, filters, etc require being able to read pixels from the painter.

This does work (and is not that noticeable in many cases), but it does
mean there may be a few scaling artifacts in the background
around transformed elements. Though that was already the case before
anyway for the elements (since it is just a bitmap scale).

What we really want is to (where possible) just scale the paintable
and its descendants, then paint things normally, which would give
much nicer results (but is much more tricky to achieve).

This also now makes it so only a bitmap of the size of the paintable is
copied/created, rather than the whole page.
2022-09-25 18:37:31 +02:00
MacDue 8967fe9d92 LibWeb: Add PaintableBox::absolute_paint_rect()
This method returns the total area this element will paint to.
Currently, this just means accounting for box-shadows, though
there are likely more effects that need to be accounted for here.
2022-09-25 18:37:31 +02:00
Andreas Kling 0843960235 LibWeb: Use CSS::Size for computed size and max-size values
This patch changes the *computed* representation of the following CSS
properties to use CSS::Size:

- width, min-width, max-width
- height, min-height, max-height

A few things had to change in order for things to keep working,
but I tried to keep the diff to a minimum.

The main trouble was that `min-width` and `max-width` can't actually be
`auto`, but they *can* be `none`. We previously treated `auto` as a
valid value (and it behaved mostly like `none`).
2022-09-25 17:51:43 +02:00
Andreas Kling 844321d89f LibWeb: Teach CSS::StyleProperties to create CSS::Size values
You can now use StyleProperties::size_value(CSS::PropertyID) to extract
a CSS::Size for a given property.
2022-09-25 17:51:43 +02:00
Andreas Kling ba78fe008f LibWeb: Add CSS::Size to represent the full range of CSS size values
Until now, we've been using CSS::LengthPercentage, sometimes wrapped in
Optional, to represent CSS sizes.

This meant we could not support modern values like `min-content`,
`max-content`, `fit-content(<length>)`. We were also conflating `none`
and `auto` which made the `min-*` and `max-*` properties confusing.

The new CSS::Size class covers all possible size values as individual
substates. It'll be quite a bit of work to make all layout code aware of
the additional features, this patch merely makes the new type available.
2022-09-25 17:51:43 +02:00
Andreas Kling 022a49e9ac LibWeb: Only notify PageClient about top-level browsing context loads
We don't need to notify the web views that some deeply nested iframe
has started loading a new URL (and we don't want it showing up in the
browser location bar either!)
2022-09-25 12:28:40 +02:00
Andreas Kling d89dc6e24c LibGUI: Add Model::unsafe_create_index()
This will be used by Ladybird to translate between LibGUI and Qt models.
2022-09-25 12:16:12 +02:00
Andreas Kling 05985b51f2 LibWebView: Make DOMTreeModel usable outside of SerenityOS
Two issues made this class unusable on other platforms:
- Hardcoded /res paths to icons
- It required a GUI::TreeView for palette access

This patch simply patches out those features on non-Serenity systemsf
for now.
2022-09-25 12:11:02 +02:00
Andreas Kling f36cbd3b65 LibWeb: Invalidate layout when a DOM node is removed from the tree 2022-09-25 02:26:36 +02:00
Andreas Kling 5c6621547c LibWeb: Compute StackingContext transform origin only once
When mousing over twitter, 17% of time was spent computing stacking
context transform origins. Since this never changes after the stacking
context is created, we can cache it and avoid all that work.
2022-09-24 23:06:09 +02:00
thankyouverycool 901b80f988 LibGUI: Update calculated_min_size() for TextEditor
Defer to AbstractScrollableWidget when TextEditor is multi-line.
Otherwise, as "vertical_content_size" was unused, simply return
margins for now.
2022-09-24 22:59:12 +02:00
thankyouverycool 961a225316 LibGUI: Include scrubber and gutter in Scrollbar's calculated_min_size() 2022-09-24 22:59:12 +02:00
thankyouverycool b50bce3cb9 LibGUI: Don't draw Scrollbar button triangles if they'd be off-center 2022-09-24 22:59:12 +02:00
thankyouverycool cbd9cf93be LibGUI: Implement calculated_min_size() for StackWidget 2022-09-24 22:59:12 +02:00
thankyouverycool f0a5ce6d11 LibGUI: Implement calculated_min_size() for ListView 2022-09-24 22:59:12 +02:00
thankyouverycool d495405e53 LibGUI: Implement calculated_min_size() for AbstractScrollableWidget 2022-09-24 22:59:12 +02:00
martinfalisse 521e19444c LibWeb: Make CSS Grid work again
Fixes bug after the automatic_content_height() changes where the height
of the grid container was not being calculated correctly.
2022-09-24 20:57:28 +02:00
Linus Groh 2b2ccb3815 LibWeb: Replace 'heycam.github.io' links with 'webidl.spec.whatwg.org' 2022-09-24 19:32:09 +01:00
Linus Groh 56d8c4ff26 LibWeb: Move WindowProxy from Bindings/ to HTML/ 2022-09-24 19:31:39 +01:00
Linus Groh 86f68eb3c3 LibWeb: Move IDLOverloadResolution from Bindings/ to WebIDL/ 2022-09-24 19:31:39 +01:00
Linus Groh 6480faacb6 LibWeb: Move IDLAbstractOperations from Bindings/ to WebIDL/ 2022-09-24 19:31:39 +01:00
Linus Groh 4f73851afc LibWeb: Move CallbackType from Bindings/ to WebIDL/
Let's stop putting generic types and AOs from the Web IDL spec into
the Bindings namespace and directory in LibWeb, and instead follow our
usual naming rules of 'directory = namespace = spec name'. The IDL
namespace is already used by LibIDL, so Web::WebIDL seems like a good
choice.
2022-09-24 19:31:39 +01:00
Linus Groh dc44effd44 LibWeb: Move cross-origin AOs from Bindings/ to HTML/CrossOrigin/
These are from the HTML spec and therefore belong in the HTML/ directory
in LibWeb. Bindings/ has become a bit of a dumping ground, so this is a
first step towards cleaning that up.
2022-09-24 19:31:39 +01:00
MacDue c3841e1667 LibWeb: Restore clipping of positioned descendants
63c727a was meant to stop clipping absolutely positioned descendants,
but used `is_positioned()` rather than `is_absolutely_positioned()`,
which meant it disabled clipping in many more cases that it should
have.
2022-09-24 19:06:57 +02:00
Itamar 7165dbce5c LibGfx: Fix affine transformations in TrueType composite glyphs
This fixes an issue where, when looping over the components of a
composite glyph, we used to mutate the affine transformation of the
glyph itself when computing the transformations of its components.

(AffineTransform::multiply() is non-const).
2022-09-24 17:06:29 +02:00
Liav A 13e9947b4b WindowServer: Fallback to safe mode-setting in case of mapping overflow
In case of possible framebuffer mapping overflow, just fallback to the
safe mode-setting of the DisplayConnector, because in that state we know
for sure that we can map a usable framebuffer (otherwise it is a bug in
the Kernel, and not WindowServer).
2022-09-24 15:38:56 +01:00
Liav A d5b97eb41e Kernel+Userland: Provide bytes count for a DisplayConnector framebuffer
This value will be used later on by WindowServer to reject resolutions
that will request a mapping that will overflow the hardware framebuffer
max length.
2022-09-24 15:38:56 +01:00
Liav A 50ed50752f LibEDID: Remove head index when retrieving an EDID from DisplayConnector
We simply don't need that field anymore, as it was used when one
FramebufferDevice could contain multiple framebuffers within it, each
for a connected screen head.
2022-09-24 15:36:19 +01:00
Andreas Kling c04b107e26 LibWeb: Treat replaced % sizes as 0 if containing block is indefinite 2022-09-24 14:41:18 +02:00
Andreas Kling 416fa7bd4f LibWeb: Bring flex basis calculation a little closer to spec
This ends up having a big impact on performance, as we now correctly
treat a used flex-basis of `content` as `max-content` which means
we can use cacheable intrinsic sizes for flex items in the majority
of cases.
2022-09-24 14:09:56 +02:00
Andreas Kling f0ac687823 LibWeb: Remove awkward BFC::compute_theoretical_height() function
This was used by FFC to estimate the height of flex items after
performing layout inside them.

Now that we have automatic_content_height(), we no longer need this
awkward API and we can fold it into BFC's own height calculation.
2022-09-24 13:53:23 +02:00
MacDue 4d7e4e5da8 LibWeb: Avoid overflow and OOB indexing in get_buffer_source_copy()
Previously, this would overflow when both length and offset were
zero, leading to an OOB index into es_array_buffer. This would lead to
a crash on a few MDN pages.
2022-09-24 13:49:15 +02:00
Andreas Kling ba065faa54 LibWeb: Remove unused capture in queue_a_microtask() 2022-09-24 13:48:38 +02:00
Andreas Kling a8e1599ae1 LibWeb: Use automatic_content_height() in flex item internal layouts 2022-09-24 13:47:58 +02:00
Andreas Kling 5656173e00 LibWeb: Use automatic_content_height() when computing intrinsic heights 2022-09-24 13:47:17 +02:00
Andreas Kling 62974160da LibWeb: Add FormattingContext::automatic_content_height()
This function should return the automatic height of the formatting
context's root box.

Until now, we've been relying on some magical handshakes between parent
and child context, when negotiating the height of child context root
boxes. This is a step towards something more reasonable.
2022-09-24 13:41:08 +02:00
Andreas Kling b52165c5d7 LibWeb+LibGfx: Move the blit image through 2D transfrom to Gfx::Painter
Even though this code is obnoxiously slow, it still belongs in LibGfx
and should not be hidden away in LibWeb's CanvasRenderingContext2D.
2022-09-24 13:00:53 +02:00
Andreas Kling 37ea6de772 LibWeb: Remove now-unnecessary JS::Handles in microtask capture lists 2022-09-24 12:23:29 +02:00
Andreas Kling 874e64d664 LibWeb: Make queue_an_element_task() use JS::SafeFunction 2022-09-24 12:23:29 +02:00
Andreas Kling 2ccb9bef49 LibWeb: Remove now-unnecessary JS::Handles in HTML task capture lists
JS::SafeFunction will protect anything captures for HTML tasks now.
2022-09-24 12:23:29 +02:00
Andreas Kling d505192014 LibWeb: Use JS::SafeFunction in the HTML task queues
This means that HTML tasks automatically protect anything in their
capture lists, and we no longer need to jump through hoops with
JS::Handle etc.
2022-09-24 12:23:29 +02:00
Andreas Kling 131c3f50de LibJS: Add JS::SafeFunction, like Function but protects captures from GC
SafeFunction automatically registers its closure memory area in a place
where the JS garbage collector can find it.

This means that you can capture JS::Value and arbitrary pointers into
the GC heap in closures, as long as you're using a SafeFunction, and the
GC will not zap those values!

There's probably some performance impact from this, and there's a lot of
things that could be nicer/smarter about it, but let's build something
that ensures safety first, and we can worry about performance later. :^)
2022-09-24 12:23:29 +02:00
MacDue f5052e5017 LibWeb: Don't trigger page_did_layout() on non-active documents
PageHost assumes page_did_layout() to be called when the layout
of the active document changes, however, it seems that sometimes
the layout can change on another document before the layout of
the active document has been calculated. This leads to a VERIFY()
being hit.

This commit now makes it so page_did_layout() is only called when
the document is the active document.

Fixes #15328
2022-09-24 00:38:10 +02:00
Luke Wilde 7b8a6b8e7a LibWeb: Set HTMLParser::m_scripting_enabled as according to the spec
This allows <noscript> elements to display their content as proper HTML
instead of raw text when scripting is disabled.
2022-09-23 22:25:09 +01:00
Luke Wilde dfe57543a4 LibWeb: Keep message alive in postMessage task callback lambda
Tasks can run at any time in the future and GC can run in the time
between postMessage and running the task, meaning the message can be
reaped if we don't keep a handle to it.

Fixes Google Syndication ads crashing 100% of the time on rpcs3.net
2022-09-23 17:23:55 +01:00
Liav A 36f2e85823 WindowServer: Fix mapping the correct framebuffer size
If we don't support double buffering for a certain type of hardware,
don't try to map with size calculated with (pitch * height * 2), as it
will result in trying to map more memory than is available in the
framebuffer memory range.
2022-09-23 14:04:00 +01:00
Linus Groh 76ace3629a LibWeb: Make Fetch::Infrastructure::Body::stream() const 2022-09-22 21:01:13 +01:00
Linus Groh c7c6d7d9e1 LibWeb: Make FileAPI::Blob::create() buffer/type overload infallible 2022-09-22 21:01:13 +01:00
Linus Groh 54a987ad45 LibWeb: Update extract_body() to use BodyInit 2022-09-22 21:01:13 +01:00
Linus Groh 8f5620b5d9 LibWeb: Add BodyInit union type 2022-09-22 21:01:13 +01:00
Linus Groh 571f4e3ebb LibWeb: Move extract_body() into Fetch 2022-09-22 21:01:13 +01:00
Linus Groh f98ce156c4 LibWeb: Remove ReadableStreamDummy in favor of ReadableStream 2022-09-22 21:01:13 +01:00
Linus Groh 87654f5b51 LibWeb: Start fleshing out the ReadableStream interface
This is so we can just assume it exists in Fetch APIs (while still
skipping functionality that relies on a full implementation, of
course).
2022-09-22 21:01:13 +01:00
Linus Groh 1ace80235b LibWeb: Move XMLHttpRequestBodyInit into Fetch
https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
2022-09-22 21:01:13 +01:00
thankyouverycool 1bba8589fe LibGUI: Hide unnecessary Scrollbars in ComboBox windows
And simplify rect calculations using content size.
2022-09-22 21:37:26 +02:00
thankyouverycool 7858f885fe LibGUI: Update ListView content size on relevant layout changes
Fixes incorrect content sizing when unnecessary scrollbars are hidden.
2022-09-22 21:37:26 +02:00
thankyouverycool 8b4bf96db3 LibGUI: Apply horizontal padding evenly for ListView items 2022-09-22 21:37:26 +02:00
thankyouverycool 930e5c27df ClockSettings: Increase max visible items for time zone ComboBox 2022-09-22 21:37:26 +02:00
thankyouverycool f86c5b1fa7 LibGUI: Allow setting max visible items for ComboBoxes
This will govern the maximum number of items ComboBox windows display
before scrolling content.
2022-09-22 21:37:26 +02:00
thankyouverycool aa8e7aba42 LibGUI: Don't show empty ComboBox windows 2022-09-22 21:37:26 +02:00
thankyouverycool a0de3860cc LibGUI: Make ListView item_count() public 2022-09-22 21:37:26 +02:00
thankyouverycool 04a9562601 LibGUI: Don't open windows for editable ComboBoxes when typing
Fixes inability to type custom values into ComboBox editors.

CaptureInput preempts typing while the ListView window is open.
For now, searching can still be done by manually opening the window.
2022-09-22 21:37:26 +02:00
thankyouverycool 7c2edd232d LibGUI: Reset Windows as visible for timer purposes on show()
Fixes scrolling timers failing to fire if a ComboBox window
had previously become occluded.
2022-09-22 21:37:26 +02:00
thankyouverycool db2a1d3620 LibGUI: Always activate ComboBox ListView selections on MouseUp
Fixes having to doubleclick selected items to activate them if
the selection index hasn't changed since last activation.
2022-09-22 21:37:26 +02:00
thankyouverycool 7ac30f53a0 LibGUI: Block ComboBox windows from using CommandPalette 2022-09-22 21:37:26 +02:00
Andrew Kaster 8f38367d46 LibCore: Only include Account.h on Serenity in EventLoop and System
Core::Acount is only used within ``#ifdef __serenity__`` blocks in these
files, so guard the inclusion of Account.h in the same way.

This fixes the Android build of these files.
2022-09-22 11:07:21 -04:00
Andreas Kling a52d346839 LibWeb: Take coordinate spaces into account when clearing past floats
We were forgetting to convert to and from BFC root relative coordinates
when calculating how much clearance was needed to get past floats.

This fixes the last remaining issue on Acid1, which is now perfect. :^)
2022-09-22 17:06:49 +02:00
Andreas Kling 5efd63741f LibWeb: Perform horizontal inline alignment based on available space
Previously, we were using the full containing block width as a reference
for text-align values "right" and "center". This didn't take intruding
floats into account.
2022-09-22 17:06:48 +02:00
Andreas Kling d43ef27761 LibWeb: Only include containing blocks in coordinate space translation
Layout box offset coordinates are always relative to their containing
block. Therefore, the functions that convert between coordinate spaces
should only visit containing blocks and apply their offsets, not *every*
box in the parent chain.

This fixes an issue where some floating boxes were unexpectedly far away
from their containing block.
2022-09-22 16:54:12 +02:00
Andreas Kling 54fb5af9ee LibWeb: Use entire margin box of floats when testing for intrusions 2022-09-22 16:54:12 +02:00
Andreas Kling 389f47f6fe LibWeb: Check both top and bottom of float position when looking for fit
We have to check that there's enough space at both the top and bottom of
the float's margin box, otherwise we risk overlapping existing content.
2022-09-22 16:54:12 +02:00
Timothy Flynn 82e730eba1 LibJS: Change default time display options to "always" for digital style
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/d28076b
2022-09-22 14:39:24 +01:00
Timothy Flynn 73fcaaeda4 Taskbar: Add a context menu to open clock settings from the clock widget 2022-09-22 11:46:53 +01:00
Sam Atkins c64a5ccf29 LibWeb: Avoid unnecessary copies in CSS Parser 2022-09-22 02:04:23 +02:00
Sam Atkins a211c06e99 LibWeb: Use llroundf() when rounding floats 2022-09-22 02:04:23 +02:00
Sam Atkins 188d9f1326 LibWeb: Resolve some trivial clang-tidy warnings in the CSS Parser
Issues resolved:
- Unnecessary `move()`s
- `else` after `return`
- `auto&` that could be `auto const&`

Why yes, I did just get clang-tidy set up. :^)
2022-09-22 02:04:23 +02:00
Linus Groh edfef8e2f5 Everywhere: Rename WrapperGenerator to BindingsGenerator
This code generator no longer creates JS wrappers for platform objects
in the old sense, instead they're JS objects internally themselves.
Most of what we generate now are prototypes - which can be seen as
bindings for the internal C++ methods implementing getters, setters, and
methods - as well as object constructors, i.e. bindings for the internal
create_with_global_object() method.

Also tweak the naming of various CMake glue code existing around this.
2022-09-21 23:06:08 +01:00
Linus Groh 4270ede7c4 LibWeb: Remove WRAPPER_HACK() macro
We no longer access Bindings::FooWrapper anywhere for a Foo platform
object, so these can be removed :^)
2022-09-21 21:12:24 +01:00
Linus Groh 6055b0e850 LibWeb: Remove no-op impl() methods from the WEB_PLATFORM_OBJECT macro
These are leftovers from when wrapper objects still had an internal
implementation, which is no longer the case.
2022-09-21 21:12:24 +01:00
Linus Groh 38b3ce8f03 LibIDL+LibWeb: Remove stale references to "wrapper class" concept
There are no wrappers for the platform object types anymore :^)
2022-09-21 21:12:24 +01:00
Sam Atkins fb2e1c4611 headless-browser: Install EventLoop and Font plugins so it doesn't crash 2022-09-21 20:42:36 +01:00
Sam Atkins 6b2a916069 LibWeb+WebContent: Move Serenity EventLoop and Font plugins into LibWeb
These are exactly what's wanted by headless-browser too, so this saves
us some duplication. LibWeb already links LibCore so it should not
cause any issues for Ladybird.
2022-09-21 20:42:36 +01:00
Sam Atkins 69dd158f91 LibJS: Create Console using a Realm instead of a VM 2022-09-21 20:03:49 +01:00
Sam Atkins 7a2da4cabf Browser+WebContent+LibJS: Support %c specifiers in Console.log()
...and the other Console methods.

This lets you apply styling to a log message or any other text that
passes through the Console `Formatter` operation.

We store the CSS on the ConsoleClient instead of passing it along with
the rest of the message, since I couldn't figure out a nice way of
doing that, as Formatter has to return JS::Values. This way isn't nice,
and has a risk of forgetting to clear the style and having it apply to
subsequent messages, but it works.

This is only supported in the Browser for now. REPL support would
require parsing the CSS and figuring out the relevant ANSI codes. We
also don't filter this styling at all, so you can `position: absolute`
and `transform: translate(...)` all you want, which is less than
ideal.
2022-09-21 20:03:49 +01:00
Sam Atkins a875713f2e Browser: Ignore whitespace-only input in the JS console 2022-09-21 20:03:49 +01:00
Sam Atkins a1f1369775 LibJS: Implement Console Formatter operation
This matches the recent changes to `Formatter` and `Logger`.

`%s`, `%d`, `%i`, and `%f` are all implemented. `%o`, `%O`, and `%c`
will come later.
2022-09-21 20:03:49 +01:00
Andreas Kling 010be491a9 LibWeb: Fix e-mail address mishap 2022-09-21 18:42:09 +02:00
davidot 4912b22e3b LibWeb+WebContent: Setup the js console client earlier
This allows us to print messages in inline scripts. Also add an example
of this in the welcome page to test this.
2022-09-21 17:34:32 +01:00
davidot 446a10a1ac LibJS: Implement normative change in String.prototype.substr
And add spec comments while we're in the neighborhood.
2022-09-21 16:59:58 +01:00
Timothy Flynn 60a6bae53d LibJS: Change digital default style from "narrow" to "short"
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/4c24876
2022-09-21 16:09:38 +01:00
Andreas Kling a5bb30d2ba LibWeb: Make Node.childNodes vend the same NodeList every time 2022-09-21 13:51:58 +02:00
Andreas Kling 4814e1bd65 Browser: Ignore title updates when history has no current item
The Browser::History class is oblivious to the state of the browsing
context's session history over on the LibWeb side. We need to hook a lot
more thing up here, but for now just ignore updates when there's no
current history item. This fixes a VERIFY() error on startup.
2022-09-21 13:06:17 +02:00
Daniel Bertalan 2b69af2dfe AK+LibJS: Handle NaN-boxing pointers on AArch64
JS::Value stores 48 bit pointers to separately allocated objects in its
payload. On x86-64, canonical addresses have their top 16 bits set to
the same value as bit 47, effectively meaning that the value has to be
sign-extended to get the pointer. AArch64, however, expects the topmost
bits to be all zeros.

This commit gates sign extension behind `#if ARCH(X86_64)`, and adds an
`#error` for unsupported architectures, so that we do not forget to
think about pointer handling when porting to a new architecture.

Fixes #15290
Fixes SerenityOS/ladybird#56
2022-09-21 11:55:57 +02:00
Andreas Kling 62fed2a31d LibWeb: Add id field to Environment
This is a unique string that identifies the environment. We just use a
simple incrementing number for now.
2022-09-21 11:51:18 +02:00
Andreas Kling 1f95943274 LibWeb: Remove confusing NOTE in WindowEnvironmentSettingsObject
HTML::Window has absorbed what was formerly known as WindowObject.
2022-09-21 11:51:18 +02:00
Andreas Kling 66f4e2b3b0 LibWeb: Add two more scheme helpers to the Fetch infrastructure 2022-09-21 11:51:18 +02:00
Andreas Kling b02402e116 LibWeb: Fix null dereference in ResourceClient::set_resource()
If resource_did_load() results in the ResourceClient being destroyed,
we can't dereference the weak ResourceClient right after.
2022-09-21 11:51:18 +02:00
Andreas Kling 68d0f30368 LibWeb: Abort the active document when navigating a browsing context 2022-09-21 11:51:18 +02:00
Andreas Kling 51d7ea7ece LibWeb: Make WESO allow cross-origin isolated APIs for now
Instead of panicking in a TODO(), let's just allow them and leave the
FIXME's in this function.
2022-09-21 11:51:18 +02:00
Andreas Kling 6c33dea6a6 LibWeb: Implement the "close" algorithm for browsing contexts
This is used by window.close() programmatically, but of course the user
can also decide to close a top-level browsing context at any time by
closing the tab.
2022-09-21 11:51:18 +02:00
Andreas Kling 0c7ab663c1 LibWeb: Flesh out most of the "unload" algorithm for documents
Yet another small steps towards spec-compliant document lifecycles.
2022-09-21 11:51:18 +02:00
Andreas Kling 797d28adca LibWeb: Save begin/end timestamps for load and DOMContentLoaded events 2022-09-21 11:51:18 +02:00
Andreas Kling d4fc1367f6 LibWeb: Save document load timing when creating browsing context 2022-09-21 11:51:17 +02:00
Andreas Kling 270de12d59 LibWeb: Save document load timing when updating document readiness 2022-09-21 11:51:17 +02:00
Andreas Kling 67559b1279 LibWeb: Add load/unload timing structures to Document
We don't populate these with information just yet, but we will soon!
2022-09-21 11:51:17 +02:00
Jan Metzger 931458c337 LibWeb: Update visibility when Node was invisible before 2022-09-21 10:47:41 +01:00
Orel d8474805e8 SystemMonitor: Save configuration of columns
Save the columns configuration from the last run in the respective
config file, and add a function to check whether a column should be
visible by default.
2022-09-21 10:14:40 +01:00
Andreas Kling 92deba7197 LibWeb: Implement Document/BrowsingContext hookup according to spec
We now implement the browsing context's "set active document" algorithm
from the spec, as well as the "discard" algorithm for browsing contexts
and documents.
2022-09-20 23:44:59 +02:00
Andreas Kling ab8432783e LibWeb: Implement aborting the HTML parser
This is roughly on-spec, although I had to invent a simple "aborted"
state for the tokenizer.
2022-09-20 23:44:59 +02:00
Olivier De Cannière d3601aedc5 Calendar: Add Settings button to configure the Calendar 2022-09-20 13:12:00 -04:00
Olivier De Cannière 6f69f4bb5e Calendar: Update month view on first_day_of_week setting change
Now when the user changes their preferred first day of the week in the
Calendar Settings, the Calendar application and applet views are update
accordingly without needing to restart them.
2022-09-20 13:12:00 -04:00
Olivier De Cannière a1d98b825d Calendar: Add setting to choose default view
This commit adds an entry to the Calendar Settings to allow the user to
select between the month and year views as the startup default.
2022-09-20 13:12:00 -04:00
Olivier De Cannière 0eceed4fd7 Calendar: Add a Calendar settings dialog for the first day of the week
This commit adds a new settings dialog for the Calendar application and
applet. It allows the user to specify their preferred first day of the
week.
2022-09-20 13:12:00 -04:00
Olivier De Cannière 9414525d75 Calendar: Support preferred first day of the week 2022-09-20 13:12:00 -04:00
Andreas Kling aa4dd6c1bc LibWeb: Implement Element.insertAdjacentHTML() from DOM Parsing
One edge case is left as a TODO() for now, since I'm not entirely sure
how to construct an element to those specifications.

With this patch, we can now run the Speedometer benchmark! :^)
2022-09-20 18:28:41 +02:00
Andreas Kling ac76df3d47 LibWeb: Implement Window.frameElement 2022-09-20 14:48:07 +02:00
Andreas Kling e4fd042041 LibWeb: Flesh out the default "quirks mode" style sheet
Import all the quirks mode rules from the HTML spec. There's more to
quirks mode, of course, but it's nice that we can just copy these.
2022-09-20 14:48:07 +02:00
Andreas Kling 77d947b8ad LibWeb: Initialize document referrer from Fetch Request if available 2022-09-20 14:48:07 +02:00
Andreas Kling 9683da4470 LibWeb: Add referrer accessors to Fetch Request 2022-09-20 14:48:07 +02:00
Ali Mohammad Pur 578d73943a LibC+LibRegex: Move central regex definitions into LibC/bits
This decouples LibRegex from the serenity LibC.
Fixes #15251.
2022-09-20 12:57:21 +01:00
Sam Atkins 120e5aeca4 LibCore: Actually tell people to stop using Core::File in new code
Otherwise, we keep getting new code merged that uses it, which requires
fixing later.
2022-09-20 07:48:45 -04:00
Sam Atkins f640921371 MasterWord: Port to Core::Stream 2022-09-20 07:48:45 -04:00
Sam Atkins 68032d2724 Profiler: Port to Core::Stream 2022-09-20 07:48:45 -04:00
Sam Atkins 183b054695 SoundPlayer: Port M3UParser to Core::Stream
Also make the path parameter a StringView, since that's what gets passed
in.
2022-09-20 07:48:45 -04:00
Sam Atkins 2dea636f33 Run: Use Core::Stream API for command history file 2022-09-20 07:48:45 -04:00
Sam Atkins aee52a458b PixelPaint: Remove unused Image::write_to_file() method
This seems to be a remnant from before FileSystemAccessClient was used.
2022-09-20 07:48:45 -04:00
Timothy Flynn a203e714ec LibGUI: Use fuzzy matching when searching for emoji by name
This allows the user to have slight typos in their search query.
2022-09-20 11:08:54 +01:00
Andreas Kling d4acdac317 LibWeb+WebContent+Browser: Plumb visibility state from GUI to web pages
OOPWV now reacts to show/hide events and informs LibWeb about the state
change. This makes visibilitychange events fire when switching tabs. :^)
2022-09-20 10:32:14 +02:00
Andreas Kling 5908873b45 LibGUI: Fire Show/Hide events when adding/removing widget from tree
This ensures that widgets always get an initial show event.
2022-09-20 10:32:13 +02:00
Andreas Kling 4ee5dfbe4b LibWeb: Flesh out a chunk of the HTML spec's frame navigation algorithms 2022-09-20 10:32:13 +02:00
Andreas Kling e5f6d36616 LibWeb: Keep more of the navigation parameters in Document 2022-09-20 10:32:13 +02:00
Andreas Kling 42b8656db3 LibWeb: Flesh out "document visibility" state a bit more
We can now "update the visibility state", which also causes
`visibilitychange` events to fire on the document.

This still needs GUI integration work at the BrowsingContext level.
2022-09-20 10:32:13 +02:00
Andreas Kling 5a500827b8 LibWeb: Move HistoryHandlingBehavior enum to its own header
This avoids a header cycle in a subsequent patch.
2022-09-20 10:32:12 +02:00
Andreas Kling 03375a3dc9 LibWeb: Implement more spec-compliant iframe/frame attribute processing
We're still missing the lazy loading attribute handling, and once we hit
the navigation step, we fall back to totally ad-hoc behavior instead of
going all the way with a Fetch Request.
2022-09-20 10:32:12 +02:00
Andreas Kling 0810e77d77 LibWeb: Set the document "completely loaded time" when appropriate 2022-09-20 10:32:12 +02:00
Andreas Kling 954da8fde5 LibWeb: Only create iframe nested context if iframe document has context
We had glossed over a condition in the spec that said we should only run
the nested context creation steps when the iframe's own containing
document has a browsing context.
2022-09-20 10:32:12 +02:00
Andreas Kling 8ead228202 LibWeb: Implement "browsing context group" concept from the HTML spec 2022-09-20 10:32:12 +02:00
Andreas Kling e36750d591 LibWeb: Remove unused Layout::Node::did_insert_into_layout_tree() 2022-09-20 10:32:12 +02:00
Andreas Kling 77628289c6 LibWeb: Consolidate code for resolving vertical box model metrics in BFC
We already had a helper for this, but compute_height() wasn't using it.
Tweak it so that compute_height() can use it, and remove the duplicated
code that's now redundant.
2022-09-20 10:32:12 +02:00
ne0ndrag0n b16704d4db GamesSettings: Always ensure last card back selected is saved 2022-09-20 07:59:13 +01:00
Brian Gianforcaro 42865b8975 LibCpp: Add .clang-format to disable clang-format for the LibCpp Tests
We don't format these files, as they might have been intentionally
formatted differently from the normal serenity style for testing.

So ignore them from our global style, so clang-format
doesn't pick them up by accident.
2022-09-19 15:52:37 -07:00
Sam Atkins ef507720f0 Applets/ResourceGraph: Port to Core::Stream 2022-09-18 18:57:28 -07:00
Sam Atkins 474a38bd3c Applets/Network: Stop marking methods virtual unnecessarily
None of these are overridden, and NetworkWidget is a final class.
2022-09-18 18:57:28 -07:00
Sam Atkins eacf017112 Applets/Network: Remove include_loopback parameter
This is always false, so we can do without it and simplify things a
little.
2022-09-18 18:57:28 -07:00
Sam Atkins c8bfb07b41 Applets/Network: Port to Core::Stream 2022-09-18 18:57:28 -07:00
Ben Wiederhake 078e4bde32 LibC: Fix misplaced #include in limits.h
posix1_lim.h only defines macros that start with _POSIX_*, and don't
mention anything that might be defined in limits.h. Likewise, limits.h
uses none of the _POSIX_* macros. Thus, it is okay to change the order
of imports.
2022-09-18 18:30:05 -07:00
Ben Wiederhake c214d31c5e Everywhere: Fix order of includes and #pragma once 2022-09-18 18:30:05 -07:00
Ben Wiederhake 929e46f360 WindowServer: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <WindowServer/SystemEffects.h>
    // That's it, this was enough to cause a compilation error.
2022-09-18 13:27:24 -04:00
Ben Wiederhake a99cd09891 Libraries: Add missing includes, add namespace qualifiers
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibDNS/Question.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake 48d8aff436 LibJS: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibJS/Runtime/StringPrototype.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake d073a31c21 LibWeb: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
sin-ack e9d5d2f74b LibWeb: Remove the flex item size cache
This was overly permissive as the FIXME stated and was causing layout
issues.
2022-09-18 18:55:06 +02:00
Andreas Kling 97b5230413 LibWeb: Subtract border & padding when using flex line size as item size
The flex line cross size includes the margin boxes of items, so when
we're taking the flex line's cross size to use as an item cross size,
we have to subtract the margin, border padding from both sides.

Previous we only subtracted the cross margins, which led to oversized
items in some cases.
2022-09-18 18:34:42 +02:00
Andreas Kling 7bf3b40867 LibWeb: Remove bogus main space restriction in wrapping flex layouts 2022-09-18 18:34:42 +02:00
Timothy Flynn 887dac0929 LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"
This is a normative change to the Intl NumberFormat V3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/4751da5
2022-09-18 09:45:40 -04:00
Andreas Kling 0ca1b4b123 LibWeb: Don't replace existing Content-Type header in outgoing XHRs
This fixes an issue where Twitter was HTTP 400'ing some of our XHRs.
2022-09-18 12:53:06 +02:00
Andreas Kling 575e3bf37d LibWeb: Check document fully active status in "element cannot navigate"
This resolves a FIXME and brings us closer to spec.
2022-09-18 12:53:06 +02:00
Andreas Kling e6ef366859 LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
2022-09-18 02:17:29 +02:00
Andreas Kling 3df9861814 LibWeb: Capture self as a WeakPtr in ResourceClient::set_resource()
It's not safe to capture `this` as a raw pointer here, since nothing
is guaranteed to keep the ResourceClient alive (even if the Resource
stays alive.)
2022-09-18 02:15:01 +02:00
Andreas Kling fa2dd4cbe3 LibWeb: Make Document vend the same HTMLCollections every time 2022-09-18 02:08:01 +02:00
Andreas Kling 1903dff365 LibWeb: Support getting and setting Attr.textContent 2022-09-18 02:08:01 +02:00
Andreas Kling 530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Andreas Kling 3c3ae3a768 LibWeb: Only uppercase qualified names in HTML documents
This takes care of an old FIXME now that we can distinguish between HTML
and non-HTML documents.
2022-09-18 00:53:26 +02:00
Andreas Kling dc6e625680 LibWeb: Make ParentNode.children vend the same HTMLCollection every time
Instead of creating a new HTMLCollection every time you access
.children, we now follow the spec and vend the same object.

This was annoyingly difficult before, and trivial now that the DOM is
garbage-collected. :^)
2022-09-18 00:42:33 +02:00
Andreas Kling 6b3293a74b LibWeb: Support getElementsByTagName() properly in non-HTML documents 2022-09-18 00:39:42 +02:00
Andreas Kling bd0648a492 LibWeb: Simplify getElementsByTagName{,NS}() filters
Everything below the collection root is a descendant of the collection
root, so there's no need to check is_descendant_of() :^)
2022-09-18 00:37:24 +02:00
Andreas Kling e72896e35e LibWeb: Get default fonts via Platform::FontPlugin
Instead of asking Gfx::FontDatabase for the "default font" and the
"default fixed-width font", we now proxy those requests out via
the Platform::FontPlugin. This will allow Ladybird to use other default
fonts as fallback.
2022-09-17 21:27:32 +02:00
Sam Atkins ebc29842c8 LibWeb: Start implementing the IDL Overload Resolution Algorithm :^)
There are a *lot* of FIXME's here. :yakoverflow:
2022-09-17 21:27:17 +02:00
Sam Atkins 0d2d5ba02c LibIDL: Implement EffectiveOverloadSet
This requires a little explanation. The overload resolution algorithm,
where this is used, repeatedly has steps like this:

> Otherwise: if V is a platform object, and there is an entry in S that
> has one of the following types at position i of its type list,
>  - an interface type that V implements
>  - object
>  - a nullable version of any of the above types
>  - an annotated type whose inner type is one of the above types
>  - a union type, nullable union type, or annotated union type that has
>    one of the above types in its flattened member types
> then remove from S all other entries.

So, the API here tries to match that. We save the matching entry when
checking through them and then use that in `remove_all_other_entries()`.

Removing all those entries when all we actually care about is looking at
that one matching entry feels silly, but sticking to the spec is more
important while things are still half-implemented. :^)
2022-09-17 21:27:17 +02:00
Sam Atkins 8b4cc07a54 LibIDL+WrapperGenerator: Implement Type::is_distinguishable_from()
As part of this, I've moved a couple of methods for checking for
null/undefined from UnionType to Type, and filled in more of their
steps.

This now detects more, and so causes us to hit a `TODO()` which is too
big for me to go after right now, so I've replaced that assertion with
a log message.
2022-09-17 21:27:17 +02:00
Sam Atkins 7c8ef79898 LibIDL+WrapperGenerator: Make it easier to work with IDL::Type classes
Track the kind of Type it is, and use that to provide some convenient
`is_foo()` / `as_foo()` methods. While I was at it, made these all
classes instead of structs and made their data private.
2022-09-17 21:27:17 +02:00
Sam Atkins c4668053d1 LibIDL+WrapperGenerator: Move IDL code into a library
IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
2022-09-17 21:27:17 +02:00
Jelle Raaijmakers 6c87c98ed0 LibGL: Remove GL::present_context
No need for a static method if all it does is invoke the object method.
2022-09-17 19:38:30 +02:00
Andreas Kling 83c69fa62e LibWeb: Handle JavaScript source code with non-UTF-8 encoding
When fetching scripts in HTMLScriptElement's "prepare a script"
algorithm, we now re-encode the script sources to UTF-8.
2022-09-17 18:53:26 +02:00