Commit Graph

18780 Commits

Author SHA1 Message Date
Linus Groh
886ca9c7b6 LibWeb: Add missing Request::policy_container() getter and setter 2022-10-05 09:14:49 +01:00
Linus Groh
16d6c62193 LibWeb: Make Fetch::Infrastructure::Request::set_client() take a pointer 2022-10-05 09:14:49 +01:00
Linus Groh
72a752685f LibWeb: Add missing link to Fetch::Infrastructure::Response member 2022-10-05 09:14:49 +01:00
Linus Groh
7b50e96434 LibWeb: Add missing links to Fetch::Infrastructure::Request members 2022-10-05 09:14:49 +01:00
Linus Groh
32ad939e44 LibWeb: Rename HighResolutionTime/{CoarsenTime => TimeOrigin}.cpp/h
This is being used for more than just time coarsening now, so let's use
the spec's section title for the name.
2022-10-05 09:12:59 +01:00
Linus Groh
4ea6cc56be LibWeb: Move unsafe_shared_current_time() to HighResolutionTime
This doesn't belong on the EventLoop at all, as far as I can tell.
2022-10-05 09:12:59 +01:00
Linus Groh
ff9a80f54f LibWeb: Implement 'coarsened shared current time' 2022-10-05 09:12:59 +01:00
Linus Groh
5c4eb90d65 LibWeb: Add DOMHighResTimeStamp typedef 2022-10-05 09:12:59 +01:00
Linus Groh
398e44b27b LibWeb: Pass status code to ResourceLoader error callback when available 2022-10-05 09:12:59 +01:00
Linus Groh
25909dcc05 LibWeb: Prepare to run callback in host_enqueue_promise_job()
...and clean up afterwards, of course. Additionally to preparing to run
a script, we also prepare to run a callback here. This matches WebIDL's
invoke_callback() / call_user_object_operation() functions, and prevents
a crash in host_make_job_callback() when getting the incumbent settings
object.

Running the following JS no longer crashes after this change:

```js
new Promise((resolve) => {
    setTimeout(resolve, 0);
}).then(() => {
    return Promise.reject();
});
```

See further discussion/investigation here:
https://discord.com/channels/830522505605283862/830525031720943627/995019647214694511
https://discord.com/channels/830522505605283862/830525031720943627/1026824624358576158
https://discord.com/channels/830522505605283862/830525031720943627/1026922985581457458

Many thanks to Luke for doing the hard work here, tracking this down,
and suggesting the fix!

Co-authored-by: Luke Wilde <lukew@serenityos.org>
2022-10-05 09:12:59 +01:00
Nico Weber
2af028132a AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places
Doesn't use them in libc headers so that those don't have to pull in
AK/Platform.h.

AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is
defined in clang builds as well.) Using AK_COMPILER_GCC simplifies
things some.

AK_COMPILER_CLANG isn't as much of a win, other than that it's
consistent with AK_COMPILER_GCC.
2022-10-04 23:35:07 +01:00
Nico Weber
ff4b912b7c LibGfx: Remove a workaround for clang before 11
This bug has long been fixed.
2022-10-04 23:35:07 +01:00
Andrew Kaster
636602a54e LibWeb: Implement <input type=file> behavior
This includes punting on the actual file picker implementation all the
way out to the PageClient. It's likely that some of the real details
should be implemented somewhere closer, like the BrowsingContext or the
Page, but we'll get there.

For now, this allows https://copy.sh/v86 to load the emulation of the
preselected images all the way until it hits a call to
URL.createObjectURL.
2022-10-04 22:05:14 +02:00
Andrew Kaster
ffab9fb44e LibWeb: Add FileList from the FileAPI spec 2022-10-04 22:05:14 +02:00
Andreas Kling
162e4179fc LibWeb: Implement a simple version of Element.scrollIntoView()
We parse the arguments that come in, but since we don't yet track
scrollable overflow, we can't do the full "scroll an element into view"
algorithm. For now, we just call out to the PageClient and ask it to
bring the nearest principal box into the visible viewport.
2022-10-04 21:46:56 +02:00
Andreas Kling
f5844b85ff LibWeb: Let FFC parent context "handle" sizing of child FFC container
When we have nested flexbox layouts within one another, and the child
context wants to call up to the parent context and ask for help with
dimensioning the child flex container, we now simply do nothing.

As far as I can tell, this works out just fine, since the child flex
container will already be dimensioned by the flex layout algorithm.
2022-10-04 21:30:58 +02:00
Andreas Kling
97ca45d9c6 LibWeb: Store HTML tag name token data as FlyString while parsing
This makes checking if a token is a specific tag O(1) instead of O(n).
2022-10-04 21:30:58 +02:00
Andreas Kling
d39f4edc99 LibWeb: Avoid a bunch of unnecessary copying in CSS::ComputedValues 2022-10-04 21:30:58 +02:00
Linus Groh
58b0edef7d LibWeb: Remove redundant JS::Value() calls in XMLHttpRequest::response() 2022-10-04 20:05:09 +01:00
Linus Groh
183462acfd LibWeb: Use Infra AO for JSON parsing in XMLHttpRequest::response() 2022-10-04 20:05:09 +01:00
Linus Groh
d2e9faf2da LibWeb: Run 'UTF-8 decode' in parse_json_bytes_to_javascript_value() 2022-10-04 20:05:09 +01:00
Linus Groh
0db55693a9 LibWeb: Fix ReadableStream's WEB_PLATFORM_OBJECT() class name 2022-10-04 20:05:09 +01:00
Timothy Flynn
08ce8cb996 Applications: Use title-case for group box titles in settings
Capitalization was quite inconsistent, even amongst single settings
applications. This aligns group box titles to all be title case.
2022-10-04 18:19:45 +01:00
Timothy Flynn
5d15fdd6e6 BrowserSettings: Remove overly verbose dbgln statement
This is a bit much, especially with 850+ filters.
2022-10-04 18:19:45 +01:00
Tobias Christiansen
4fdd916f26 LibGUI: Shade Weekends in a slightly different background color
Now, weekends can finally be displayed in the Calender Widget as they
are supposed to. They even update when the settings are changed!
2022-10-04 12:13:54 -04:00
Tobias Christiansen
170b8cad04 LibGUI: Teach Calendar about the new Config Items
Now the Calendar living in LibGUI knows about FirstDayOfWeekend and
WeekendLength.
2022-10-04 12:13:54 -04:00
Tobias Christiansen
eca559d65d CalendarSettings: Add Weekend-specific settings
In some calendars, weekends start on other days than saturday and can
also have different lengths than 2 days. This patch allows you to set
these values, however they don't do anything yet as Serenity's Calendar
doesn't care about Weekends at the moment.
2022-10-04 12:13:54 -04:00
Andreas Kling
2a0a274898 LibWeb: Identify as "Ladybird" instead of "Browser"
Here's a small step towards integrating Ladybird and Browser. We now
identify ourselves as "Ladybird" to websites.
2022-10-04 15:27:04 +02:00
Andreas Kling
c48931d15c LibWeb: Only calculate intrinsic size in the desired flex axis
Previously, FlexFormattingContext would calculate intrinsic sizes in
both axes simultaneously, despite only one being needed.

This patch reduces the amount of unnecessary work by only calculating
the requested intrinsic size.
2022-10-04 11:56:59 +02:00
Andreas Kling
4d84e349ae LibWeb: Recreate flex lines before calculating intrinsic cross size
This will allow us to do intrinsic cross sizing without depending on
intrinsic main sizing happening first.
2022-10-04 11:55:58 +02:00
Andreas Kling
181fc6cead LibWeb: Pack flex container from opposite end in *-reverse directions 2022-10-04 09:42:17 +02:00
Andreas Kling
b13a8706e1 LibWeb: Make intrinsic heights dependent on available width
After speaking with fantasai at CSSWG about this, it turns out I had
misunderstood intrinsic heights. I originally believed all intrinsic
sizes had to be computed with no influence from the surrounding context.

As it turns out, intrinsic heights *are* influenced by the available
width, since it's needed to determine where lines break.

The APIs for calculating min-content and max-content heights now take
the available width as inputs. This instantly improves layout in many
cases where we'd previously make things way too wide.
2022-10-03 23:49:23 +02:00
Andreas Kling
b4f9db84ca LibWeb: Add missing null check while dispatching mouseenter events 2022-10-03 23:49:23 +02:00
Andreas Kling
3408f7a3c5 LibWeb: Get rid of FormattingContext::run_intrinsic_sizing()
Now that we have AvailableSpace, it's actually quite convenient to
simply set up the available space and call run() with that directly.
2022-10-03 23:49:23 +02:00
Kenneth Myhra
1464ce6fbb LibC: Remove stubbed out xattr.h and xattr.cpp
Serenity does not support extended attributes (xattr) and the only port
that needed those were the GLib port. The GLib port has now been updated
to compiled without xattr support.
2022-10-03 22:48:56 +01:00
Lucas CHOLLET
2ff773a6ba Calculator: Add a Shrinking action
This action allow the user to shrink a number to a finite number of
decimal.
2022-10-03 15:12:47 -04:00
Lucas CHOLLET
e3b22c395d Calculator: Add a "Custom" entry to the rounding menu
This entry pop a dialog to ask the user to enter a value. The Calculator
will automatically put itself in this mode if you enter a number with
more digits in the fractional part than the actual maximum length.
2022-10-03 15:12:47 -04:00
Lucas CHOLLET
de568f87fd Calculator: Add a Rounding menu
This menu has three actions. Each one of them enable a different level
of rounding: to 0, 2 or 4 digits.
2022-10-03 15:12:47 -04:00
Sam Atkins
164094e161 LibWeb: Bring CSS tokenization preprocessing closer to spec
This is based on an editorial change in the December 2021 version of
SYNTAX-3: https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/

They named this step "filter code points", so let's use that name.
2022-10-03 17:09:41 +01:00
Sam Atkins
97e174afcd LibWeb: Use the term "ident sequence" instead of "name"
This is an editorial change in the December 2021 version of SYNTAX-3:
https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/
2022-10-03 17:09:41 +01:00
Timothy Flynn
7cab86ad28 Userland: Unveil /proc/all in applications which require it
These were missed in 7af5eef. It is needed for any application using
e.g. FileSystemAccessServer.
2022-10-03 17:09:21 +01:00
Timothy Flynn
25e0ab3ee4 Userland: Tighten promises by removing 'proc' where it isn't used
This is a partial revert of commit 7af5eef. After 97d15e9, the 'proc'
promise is not needed for operations using getsid().

This also fixes launching several applications in which 7af5eef added
the 'proc' promise only in the second call to pledge().
2022-10-03 17:09:21 +01:00
Andreas Kling
0455af4441 LibWeb: Implement HTMLImageElement.complete
This was fairly straightforward, although a small part had to be ad-hoc
since we don't yet load images through Fetch.

With this, we can now see annotation labels on deskto.ps :^)
2022-10-03 17:22:08 +02:00
Andreas Kling
9749eda09f LibWeb: Dispatch mouseenter and mouseleave events when required
I've left a FIXME here about populating the events with mouse
coordinates, button states, etc. We also need to verify that the
dispatch order either doesn't matter or at least match other engines.
2022-10-03 17:22:08 +02:00
Andreas Kling
f260afedb1 LibWeb: Don't add half-leading twice to inline block boxes
Inline-level blocks already have the half-leading applied internally,
so by adding it twice, we were offsetting their baseline by the
half-leading of the line.

This fixes an issue where inline-blocks were vertically offset from
the line they're supposed to sit on.
2022-10-03 17:22:08 +02:00
Hendiadyoin1
e0a6ed4bc0 LibWasm: Use String::join in Printer where apropriate 2022-10-03 14:15:46 +01:00
Hendiadyoin1
8a9d4246f1 LibWasm: Use TRY in Module::parse 2022-10-03 14:15:46 +01:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
This commit does three things atomically:
- switch over Core::Account+SystemServer+LoginServer to sid based socket
  names.
- change socket names with %uid to %sid.
- add/update necessary pledges and unveils.

Userland: Switch over servers to sid based sockets

Userland: Properly pledge and unveil for sid based sockets
2022-10-03 11:11:29 +02:00
Peter Elliott
1df4cc1926 Utilities/logout: Refactor to use Core::SessionManagement::logout 2022-10-03 11:11:29 +02:00
Peter Elliott
2c3caa7e17 LibCore: Create Core::SessionManagement for session management 2022-10-03 11:11:29 +02:00
Peter Elliott
76c67b7ae9 LibCore: Make usernames optional in ProcessStatisticsReader 2022-10-03 11:11:29 +02:00
Peter Elliott
71728f3ea6 LibCore: Add Core::System wrapper for getsid() 2022-10-03 11:11:29 +02:00
Andreas Kling
9f7a68136f LibWeb: It's AK_OS_MACOS, not AK_OS_MAC 2022-10-03 00:27:21 +02:00
Linus Groh
f27bc56e5e LibJS: Capture promise capability in new_promise_capability() executor
This is how the spec suggests implementing this; we need to be slightly
more verbose as our PromiseCapability implementation cannot hold
arbitrary JS values.

Unfortunately it makes the error message slightly more ambiguous as we
no longer expose the non-function value to the outer scope (we could!),
but at least we don't UAF the stack allocated values anymore :^)
2022-10-02 23:02:27 +01:00
Linus Groh
fc9d587e39 LibJS: Make PromiseCapability GC-allocated
A struct with three raw pointers to other GC'd types is a pretty big
liability, let's just turn this into a Cell itself.
This comes with the additional benefit of being able to capture it in
a lambda effortlessly, without having to create handles for individual
members.
2022-10-02 23:02:27 +01:00
Linus Groh
0585029c30 LibJS: Add Visitor::visit(GCPtr<T>) and Visitor::visit(NonnullGCPtr<T>)
Let's avoid reaching for ptr() as much as possible.
2022-10-02 23:02:27 +01:00
Linus Groh
d3b7c06712 LibJS: Add Value(GCPtr<T>) and Value(NonnullGCPtr<T>) constructors
Let's avoid reaching for ptr() as much as possible.
2022-10-02 23:02:27 +01:00
Linus Groh
c2326ec95a LibJS: Move PromiseCapability into its own cpp/h file
This is not strictly connected to PromiseReaction in any way.
Preparation before doing some actual work on it :^)
2022-10-02 23:02:27 +01:00
Linus Groh
4986fa262c LibJS: Update outdated PROMISE_DEBUG logging 2022-10-02 23:02:27 +01:00
Linus Groh
ed2aa6459d LibJS: Remove two outdated forward declarations 2022-10-02 23:02:27 +01:00
MacDue
7c8ce42593 LibWeb: Fix string whitespace splitting mistake
`.split_view(Infra::ASCII_WHITESPACE)` tries to split the string view on
the string "\t\n\f\r " (not any of the individual characters of that
string).

The correct way to split this string views here is
`.split_view_if(Infra::is_ascii_whitespace)`, this is a little
inconsistent with String, so probably should be addressed.
2022-10-02 22:47:28 +01:00
Lucas CHOLLET
b8c42365f0 mount: Report error instead of crashing on failure
Being unable to `open` on the source caused mount to crash. The error is
now properly reported to the user.
2022-10-02 21:33:35 +02:00
implicitfield
6c86b40724 test: Support more options
Adds -g, -G, -k, -O and -u options.
2022-10-02 21:33:01 +02:00
implicitfield
caab6ac968 test: Print the correct operator on error 2022-10-02 21:33:01 +02:00
Linus Groh
7760c00714 LibWeb: Move strip_and_collapse_whitespace() to Infra/
...and make it spec compliant by considering all ASCII whitespace,
greatly simplifying it in the process :^)
2022-10-02 21:32:49 +02:00
Linus Groh
b86c264975 LibWeb: Replace incorrect uses of split_view() for whitespace splitting 2022-10-02 21:32:49 +02:00
Linus Groh
b9220a18d1 LibWeb: Replace incorrect uses of String::trim_whitespace() 2022-10-02 21:32:49 +02:00
Linus Groh
fb21271334 LibWeb: Replace incorrect uses of AK::is_ascii_space() 2022-10-02 21:32:49 +02:00
Linus Groh
87ac38c78b LibWeb: Add is_ascii_whitespace() function
This matches the Infra spec's definition of 'ASCII whitespace', and we
can at last stop using AK::is_ascii_space(), which has a different idea
about what 'whitespace' means.
2022-10-02 21:32:49 +02:00
matcool
cb9b004ff8 Snake: Show message box on game over
Previously the game would immediately reset on game over, but now it'll
pause the game and show a message box with your score.
2022-10-02 21:28:37 +02:00
Monroe Clinton
67300af248 Games: Wrong parent window passed to GUI::MessageBox
We were passing the wrong parent window to GUI::MessageBox making
it impossible to exit the message window.
2022-10-02 21:28:26 +02:00
MacDue
e697a72c99 LibWeb: Support painting the hue-rotate() filter effect 2022-10-02 21:17:41 +02:00
MacDue
df6b7fff90 LibGfx: Implement HueRotateFilter
This implements a simple and fairly efficient hue rotation filter.
It is based off the SVG feColorMatrix "hueRotate" matrix operation.
https://drafts.fxtf.org/filter-effects-1/#elementdef-fecolormatrix
2022-10-02 21:17:41 +02:00
MacDue
6b167c8427 LibGfx: Add [[nodiscard]] to Matrix operators 2022-10-02 21:17:41 +02:00
MacDue
3d532571bb LibGfx: Add Matrix::operator*(T scalar) 2022-10-02 21:17:41 +02:00
MacDue
95878688a7 LibGfx: Add Matrix::operator+(Matrix const & other) 2022-10-02 21:17:41 +02:00
Andreas Kling
6aa82f8b0b LibWeb: Report the current OS instead of always saying SerenityOS 2022-10-02 21:14:02 +02:00
Andreas Kling
de6d012367 LibWeb: Improve placement of abspos boxes with dual-auto insets
When an absolutely positioned box has auto insets on both sides of an
axis, it's placed according to the "static position rectangle". This is,
roughly, the rectangle a box would occupy if it were position:static
instead of position:absolute or position:fixed.

This patch implements a rough, but still significantly better,
estimation of such static positions. It gets pretty hairy in the case
where an abspos box has a parent whose children are inline.
2022-10-02 21:14:02 +02:00
Andreas Kling
95a3da86c3 LibWeb: Reset painter translation when painting fixed-position elements
This makes nested position:fixed elements work, previously we'd apply
the viewport scroll offset once at every nesting level.
2022-10-02 21:14:02 +02:00
Andreas Kling
a494bd24f1 LibGfx: Add a way to get the Painter's current 2D translation 2022-10-02 21:14:02 +02:00
Andreas Kling
46a13c3d2e LibWeb: Add helpful locals in layout_absolutely_positioned_element()
This code had some obnoxiously repetetive call chains.
2022-10-02 21:14:02 +02:00
Andreas Kling
d1d99fda32 LibWeb: Vertical % margins are relative to containing block width
We were messing this up on absolutely positioned elements by using the
containing block height instead.
2022-10-02 21:14:02 +02:00
Andreas Kling
9c44634ca5 LibWeb: Reorganize layout algorithms around available space
This is a big and messy change, and here's the gist:

- AvaliableSpace is now 2x AvailableSize (width and height)

- Layout algorithms are redesigned around the idea of available space

- When doing layout across nested formatting contexts, the parent
  context tells the child context how much space is available for the
  child's root box in both axes.

- "Available space" replaces "containing block width" in most places.

- The width and height in a box's UsedValues are considered to be
  definite after they're assigned to. Marking something as having
  definite size is no longer a separate step,

This probably introduces various regressions, but the big win here is
that our layout system now works with available space, just like the
specs are written. Fixing issues will be much easier going forward,
since you don't need to do nearly as much conversion from "spec logic"
to "LibWeb logic" as you previously did.
2022-10-02 21:14:02 +02:00
Andreas Kling
b55c4ccdf7 LibWeb: Don't try to format inline-block boxes in BFC
Inline-level block boxes are handled by IFC. BFC doesn't have to worry
about these.
2022-10-02 21:14:02 +02:00
MacDue
e852aff9e3 LibWeb: Fix crash when loading a HTML string that contains an iframe
The HTMLIFrameElement does not create the nested browsing context on
insertion if the document does not have browsing context, which is not
set unless it's the active document.

Previously, in FrameLoader the document was not set as active until
after parsing, which led to iframes without nested browsing contexts,
and crashes.

Fixes #14207
2022-10-02 19:58:26 +01:00
Hendiadyoin1
3e65afa41a LibJS: Show class name in the dump from the NewClass instruction 2022-10-02 18:49:17 +01:00
Hendiadyoin1
baa4d69668 LibJS: Set class' source text in NewClass instruction
This fixes the classes toString method.
2022-10-02 18:49:17 +01:00
Monroe Clinton
086fccc2af Calendar: Fix crash when changing event date
We were capturing by reference which lead to the variables going
out of scope even when used in the lambda. Due to this the
update_starting_day_range lambda crashes when called.
2022-10-02 15:43:37 +02:00
Hendiadyoin1
e68309144b LibWeb: Don't scale by x, x when a scale x, y is provided as a transform 2022-10-01 21:08:50 +01:00
Andrew Kaster
691a7070f4 LibWeb: Remove the internal window object from WebEngineCustomData
Now that no one needs a Window just to create prototypes, we can remove
the internal window Object from the main thread VM and get rid of the
HTML::Window include for it.

This finally solves the reference binding to nullptr error in ladybird
that shows up when compiling it with ASAN.
2022-10-01 21:05:32 +01:00
Andrew Kaster
56b381aac0 LibWeb: Cleanup unecessary uses and includes of HTML::Window
The big global refactor left some stragglers behind for atomicity.

Clean up the rest, and remove a ton of includes of LibWeb/HTML/Window.h
2022-10-01 21:05:32 +01:00
Andrew Kaster
45838579c3 LibWeb: Remove unused DOM::Node::window helper method
This was a crutch for the initial GC conversion that we can get rid of
thanks to moving web prototypes and constructors off of Window.
2022-10-01 21:05:32 +01:00
Andrew Kaster
a1286f5120 LibWeb: Ensure that replaced documents keep the Window of their sibling
The note in the spec says that we're supposed to make sure this new
document has the same Window as the old about:blank document, but we
forgot to actually assign to the Window pointer.
2022-10-01 21:05:32 +01:00
Andrew Kaster
394f1b3836 LibWeb: Remove prototype and constructor helpers from Window 2022-10-01 21:05:32 +01:00
Andrew Kaster
f1367e0e4c LibWeb: Use prototype and constructor methods from new Intrinsics
This will let us remove the helpers from Window that simply defer to the
Intrinsics that are hanging off the [[HostDefined]] slot on the realm
2022-10-01 21:05:32 +01:00
Andrew Kaster
beb3519a49 LibWeb: Remove unecessary dependence on Window from WebGL and WebSocket
These classes only needed Window to get at its realm. Pass a realm
directly to construct WebGL and WebSocket classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
4bb6345b2f LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
4878a18ee7 LibWeb: Remove unecessary dependence on Window from Fetch, XHR, FileAPI
These classes only needed Window to get at its realm. Pass a realm
directly to construct Fetch, XMLHttpRequest and FileAPI classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
6a10352712 LibWeb: Remove unecessary dependence on Window from UIEvents classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct UIEvents classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
d0efc7734a LibWeb: Remove unecessary dependence on Window from WebAssembly classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct WebAssembly classes.
2022-10-01 21:05:32 +01:00