Commit graph

28 commits

Author SHA1 Message Date
Tim Ledbetter
1821896ecf LibWeb: Implement the HTMLLinkElement.sheet attribute
This returns the link element's associated style sheet.
2025-03-17 14:47:20 +01:00
Andreas Kling
6606eecce5 LibWeb: Invalidate style (and rule cache) on MediaList changes
This makes dynamic changes to a style sheet's media attribute actually
take effect immediately.
2025-03-04 19:07:40 +01:00
Andreas Kling
fe2b752083 LibWeb: Don't begin link element fetch until browsing-context connected
Note that "becomes browsing-context connected" is defined as:

> When the insertion steps are invoked with it as the argument and it is
> now browsing-context connected.

This fixes an issue where WPT editing tests would clone the entire DOM
thousands of times and re-fetch all the linked CSS files once per clone.
2025-03-03 14:49:20 +01:00
Andreas Kling
043e96946f LibWeb: Block rendering until linked stylesheets are loaded
This commit implements the main "render blocking" behavior for link
elements, drastically reducing the amount of FOUC (flash of unstyled
content) we subject our users to.

The document will now block rendering until linked style sheets
referenced by parser-created link elements have loaded (or failed).

Note that we don't yet extend the blocking period until "critical
subresources" such as imported style sheets have been downloaded
as well.
2025-02-27 21:36:40 +01:00
Tim Ledbetter
a4ee3fb1f0 LibWeb: Use type attribute to determine HTMLLinkElement mime type
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Previously, the type attribute was ignored on link elements.
2025-02-21 13:52:27 +01:00
Luke Wilde
cae0ab2139 LibWeb: Make PolicyContainer GC allocated
This is required to store Content Security Policies, as their
Directives are implemented as subclasses with overridden virtual
functions. Thus, they cannot be stored as generic Directive classes, as
it'll lose the ability to call overridden functions when they are
copied.
2025-02-21 12:43:48 +00:00
Andrew Kaster
8760825bb4 LibWeb: Don't store Page on ResourceLoader
We only need a Page for file:// urls. At some point we probably
needed it for other kinds of requests, but the current functionality
doesn't need to store the Page pointer on the ResourceLoader.
2025-02-18 11:26:34 -07:00
Sam Atkins
6a4d80b9b6 LibWeb/CSS: Integrate ParsingContext into the Parser
This is not really a context, but more of a set of parameters for
creating a Parser. So, treat it as such: Rename it to ParsingParams,
and store its values and methods directly in the Parser instead of
keeping the ParsingContext around.

This has a nice side-effect of not including DOM/Document.h everywhere
that needs a Parser.
2025-02-06 16:47:25 +00:00
Gingeh
59ba2fb2ee LibWeb: Clear stylesheet pointer when disabling link element
This fixes a crash when enabling an already disabled link element.
Fixes a crash when changing mdbook themes.
2025-02-01 08:11:37 +00:00
Shannon Booth
22a7cd9700 LibWeb: Port Document encoding_parse_url and parse_url to Optional<URL>
This ports two more APIs away from URL::is_valid.
2025-01-27 00:03:07 +00:00
Andreas Kling
7269fc3e52 LibWeb: Pass old parent's root to Node::removed_from()
This will allow nodes to access the root they've just been removed from.
2025-01-23 21:38:31 +01:00
Shannon Booth
fd27eef0d1 LibWeb: Return OptionalNone from DOMURL::parse on failure
This ports one more function away from needing to use the awkward
valid state of the URL class.
2025-01-22 12:33:55 +00:00
Shannon Booth
ef793d8679 LibWeb/HTML: Support blob URLs in HTMLLinkElement
We are meant to apply the 'URL parser' here, which indicates that
this should work with Blob URLs.
2025-01-21 10:49:39 +00:00
Gingeh
bf36d829ef LibWeb: Only reload link on rel change if it became a stylesheet 2025-01-20 18:21:20 +01:00
Timothy Flynn
fe891727dc LibWeb: Use correct URL parsing methods throughout LibWeb
There are essentially 3 URL parsing AOs defined by the spec:
1. Parse a URL
2. Encoding parse a URL
3. Encoding parse a URL and serialize the result

Further, these are replicated between the Document and the ESO.

This patch defines these methods in accordance with the spec and updates
existing users to invoke the correct method. In places where the correct
method is ambiguous, we use the encoding parser to preserve existing ad-
hoc behavior.
2024-12-10 10:37:01 -08:00
Shannon Booth
0fa54c2327 LibURL+LibWeb: Make URL::serialize return a String
Simplifying a bunch of uneeded error handling around the place.
2024-12-04 16:34:13 +00:00
Tim Ledbetter
4ad8ba11d5 LibWeb: Use the [Reflect] attribute to implement HTMLLinkElement.as
Also ensure that all valid potential destinations are allowed permitted.
2024-11-29 09:48:59 +01:00
Shannon Booth
a4b43cae9a LibWeb: Implement HTMLLinkElement.sizes 2024-11-17 22:12:29 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Timothy Flynn
d4f8b598cb LibWeb: Consolidate the attribute change handlers
We currently have 2 virtual methods to inform DOM::Element subclasses
when an attribute has changed, one of which is spec-compliant. This
patch removes the non-compliant variant.
2024-11-14 15:39:02 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Luke
e8a9e8aed5 LibWeb: Add namespace to Element 2020-10-22 15:24:42 +02:00
Andreas Kling
7daeddb9e9 LibWeb: Move the CSS parser into CSS/Parser/ 2020-07-28 19:23:18 +02:00
Andreas Kling
c46439f240 LibWeb: Move HTML classes into the Web::HTML namespace 2020-07-28 18:55:48 +02:00
Andreas Kling
1f008c95b6 LibWeb: Move CSS classes into the Web::CSS namespace 2020-07-26 20:05:15 +02:00
Andreas Kling
11ff9d0f17 LibWeb: Move DOM classes into the Web::DOM namespace
LibWeb keeps growing and the Web namespace is filling up fast.
Let's put DOM stuff into Web::DOM, just like we already started doing
with SVG stuff in Web::SVG.
2020-07-26 20:05:15 +02:00
Andreas Kling
a565121793 LibWeb: Move HTML object model stuff into LibWeb/HTML/
Take a hint from SVG and more all the HTML classes into HTML instead of
mixing them with the DOM classes.
2020-07-26 17:51:00 +02:00
Renamed from Libraries/LibWeb/DOM/HTMLLinkElement.cpp (Browse further)