Commit graph

823 commits

Author SHA1 Message Date
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Timothy Flynn
4a30446999 LibWeb: Support displaying HTMLInputElement placeholder values
This adds support for parsing the ::placeholder pseudo-element and
injecting an anonymous layout node with that element when the input
element's data is empty.
2022-12-01 11:18:11 -05:00
Andreas Kling
c266284559 LibWeb: Support creating Path2D objects from SVG path strings
This reuses the SVG path parsing code.
2022-11-30 14:43:22 +01:00
MacDue
6daef6303a LibWeb: Use AntiAliasingPainter for canvas painting 2022-11-30 07:58:44 +01:00
Timothy Flynn
99d8c115a0 LibWeb: Remove outdated FIXME regarding application cache selection
This algorithm, and window.applicationCache, was removed from the spec:
https://github.com/whatwg/html/commit/e4330d5

This also adds a spec link and comments to the affected parser method.
2022-11-29 19:04:31 +01:00
Kyle Lanmon
31290c8527 LibSyntax: Teach each highlighter about it's comment syntax 2022-11-27 18:28:43 -07:00
Daniel Ehrenberg
09841f56ed LibWeb: Add initial implementation of structured clone
This implementation only works for cloning Numbers, and does not try to
do all the spec steps for structured serialize and deserialize.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-11-26 00:47:23 +01:00
Baitinq
d6bb110d89 LibWeb: Handle disabling of StyleSheet HTMLLinkElements
We now can handle dynamic updating of the disabled attribute of a <link>
of the stylesheet type.

We do this by hooking the adding and removing attribute's handlers and
dynamically loading/removing the stylesheet if it has been
enabled/disabled.
2022-11-25 22:52:05 +01:00
Andreas Kling
2157745093 LibWeb: Add missing [SameObject] extended attributes in IDL files 2022-11-25 22:49:59 +01:00
Andreas Kling
8540c4e574 LibWeb: Implement [SameObject] for HTMLTableElement.{rows,tBodies} 2022-11-25 22:49:59 +01:00
Andreas Kling
ad36bc72f4 LibWeb: Implement [SameObject] behavior for HTMLTableSectionElement.rows 2022-11-25 22:49:59 +01:00
Andreas Kling
d7c58aa58d LibWeb: Implement [SameObject] behavior for HTMLFormElement.elements 2022-11-25 22:49:59 +01:00
Andreas Kling
7d8ff0c581 LibWeb: Implement [SameObject] behavior for HTMLTableRowElement.cells 2022-11-25 22:49:59 +01:00
Timothy Flynn
1f08cb7020 LibWeb+WebContent: Move pending dialog handling from PageHost to Page
Currently, all handling of pending dialogs occurs in PageHost. In order
to re-use this functionality to run WebDriver in a headless move, move
it to Page.
2022-11-24 00:10:56 +00:00
Andreas Kling
3503c658fb LibJS+LibWeb: Move JS::ModuleRequest to its own header file
This allows us to not include LibJS/AST.h in a couple more places.
2022-11-23 16:05:59 +00:00
Andreas Kling
38c7fdaac1 LibWeb: Avoid including LibJS/Parser.h in a handful of cpp files 2022-11-23 16:05:59 +00:00
Andreas Kling
b81816a539 LibJS+LibWeb: Make CyclicModule.h not include AST.h
This led to some fallout as many things in LibJS and LibWeb were pulling
in other things via CyclicModule.h
2022-11-23 16:05:59 +00:00
Andreas Kling
e6331031c4 LibJS: Make Parser::Error a standalone ParserError class
This allows us to forward declare it and reduce the number of things
that need to include Parser.h.
2022-11-23 16:05:59 +00:00
Andreas Kling
b0b022507b LibJS: Reduce AST memory usage by shrink-wrapping source range info
Before this change, each AST node had a 64-byte SourceRange member.
This SourceRange had the following layout:

    filename:       StringView (16 bytes)
    start:          Position (24 bytes)
    end:            Position (24 bytes)

The Position structs have { line, column, offset }, all members size_t.

To reduce memory consumption, AST nodes now only store the following:

    source_code:    NonnullRefPtr<SourceCode> (8 bytes)
    start_offset:   u32 (4 bytes)
    end_offset:     u32 (4 bytes)

SourceCode is a new ref-counted data structure that keeps the filename
and original parsed source code in a single location, and all AST nodes
have a pointer to it.

The start_offset and end_offset can be turned into (line, column) when
necessary by calling SourceCode::range_from_offsets(). This will walk
the source code string and compute line/column numbers on the fly, so
it's not necessarily fast, but it should be rare since this information
is primarily used for diagnostics and exception stack traces.

With this, ASTNode shrinks from 80 bytes to 32 bytes. This gives us a
~23% reduction in memory usage when loading twitter.com/awesomekling
(330 MiB before, 253 MiB after!) :^)
2022-11-22 21:13:35 +01:00
Andreas Kling
849499988e LibJS+LibWeb: Make JS::ExecutionContext protect its Web::HTML::ESO owner
We can't be nuking the ESO while its owned execution context is still on
the VM's execution context stack, as that may lead to a use-after-free.

This patch solves this by adding a `context_owner` field to each context
and treating it as a GC root.
2022-11-21 19:22:09 +00:00
Baitinq
2f16198bd6 LibWeb: Remove unused should_invalidate_styles_on_attribute_changes()
This getter and setter were previously labelled as a "hack" and used to
disable style invalidation on attribute changes during the HTML parsing
phase (as it caused big sites's loading to be slow). These functions
are currently not used, so they can be removed:^)
2022-11-21 10:12:07 +01:00
Andreas Kling
e54ae1bd11 LibWeb: Don't implement bogus assertion in prepare-the-script-element
The HTML spec is asking us to make a possibly-bogus assertion, so let's
disable it for now.

Spec bug: https://github.com/whatwg/html/issues/8534
2022-11-21 10:08:50 +01:00
Andreas Kling
b21b27fda3 LibWeb: Update the HTML parser part that deals with text in <script>
This commit adds inline spec comments to the part of the parser that
ends up calling HTMLScriptElement::prepare().

The code is tweaked to match the spec more closely.
2022-11-21 10:08:50 +01:00
Andreas Kling
1aac1085b3 LibWeb: Update HTMLScriptElement prepare and execute to latest HTML spec
The net result is some nice simplification of the prepare algorithm
and a bit of initial scaffolding for import maps support.
2022-11-21 10:08:50 +01:00
Andreas Kling
7d45927d41 LibWeb: Rename HTMLScriptElement "non-blocking" to "force async"
This has been renamed in the spec, so let's do it here too.
2022-11-21 10:08:50 +01:00
Andreas Kling
7b9138be55 LibWeb: Add spec links to HTMLScriptElement member variables
This makes it much easier to see which members represent something in
the spec, and which ones are LibWeb implementation details.
2022-11-21 10:08:50 +01:00
MacDue
8a5d2be617 Everywhere: Remove unnecessary mutable attributes from lambdas
These lambdas were marked mutable as they captured a Ptr wrapper
class by value, which then only returned const-qualified references
to the value they point from the previous const pointer operators.

Nothing is actually mutating in the lambdas state here, and now
that the Ptr operators don't add extra const qualifiers these
can be removed.
2022-11-19 14:37:31 +00:00
MacDue
66a428ae03 LibJS+LibWeb: Return non-const types from Ptr class operators
Even if the pointer value is const, the value they point to is not
necessarily const, so these functions should not add the qualifier.

This also removes the redundant non-const implementations of these
operators.
2022-11-19 14:37:31 +00:00
MacDue
862320828f LibWeb: Fix clicking on links
Since ff2f31b LibWeb has segfaulted when clicking on links, as the
browsing context (a GCPtr) in the lambda was captured by reference
and was out of scope by the time the callback fired.
2022-11-18 10:08:43 +00:00
Timothy Flynn
4b8729aea6 LibWeb: Add a flag to pause an HTML event loop's execution
This will be used to unblock the WebContent IPC event loop while waiting
for a dialog response.
2022-11-16 17:23:56 +00:00
Andreas Kling
e9eba66361 LibWeb: Adjust foreignobject to foreignObject in HTML parser
This conversion was missing from the table we copied from the spec
for whatever reason.
2022-11-16 13:01:21 +01:00
Idan Horowitz
a63c7549e1 LibWeb: Implement window.open
This implementation is some-what complete, with the most common missing
/broken feature being opening pages in new tabs using the "_blank"
target.

This is currently broken due to 2 reasons:
 - We currently always claim the Window does not have transient
   activation, as we do not track the transient activation timestamp
   yet. This means that all such window.open calls are detected as
   pop-ups, and as such they are blocked. This can be easily bypassed
   by unchecking the 'Block Pop-ups' checkbox in the debug menu.
 - There is currently no mechanism for the WebContent process to
   request a new tab to be created by the Browser process, and as
   such the call to BrowsingContext::choose_a_browsing_context does not
   actually open another tab.
2022-11-15 21:48:19 +00:00
Idan Horowitz
d15d7636e5 LibWeb: Add window.open feature detection abstract operations 2022-11-15 21:48:19 +00:00
Idan Horowitz
ff2f31bc81 LibWeb: Bring BrowsingContext::choose_a_browsing_context closer to spec 2022-11-15 21:48:19 +00:00
Idan Horowitz
c948873c5b LibWeb: Add the 'opener browsing context' BrowsingContext property
This will also be used by the window.open algorithm steps.
2022-11-15 21:48:19 +00:00
Idan Horowitz
b27f855107 LibWeb: Add the 'is popup' BrowsingContext property
This will also be used by the window.open algorithm steps.
2022-11-15 21:48:19 +00:00
Idan Horowitz
efe94d9040 LibWeb: Support parsing a URL relative to environment settings object 2022-11-15 21:48:19 +00:00
Idan Horowitz
f69c135796 LibWeb: Implement the 'Entry Realm/{settings,global} object' concepts 2022-11-15 21:48:19 +00:00
Idan Horowitz
c9f9fcd8fd LibWeb: Remove accidentally commited dbglns 2022-11-15 21:48:19 +00:00
Aliaksandr Kalenik
7f527ddde3 LibWeb: Support device-height and device-width media query values 2022-11-14 16:08:35 +00:00
Moustafa Raafat
6ff9a88c3b LibWeb: Support animated backgrounds 2022-11-13 16:53:22 -07:00
Igor Pissolati
bfdb30c74a LibWeb: Implement bare-bones HTMLElement.dir 2022-11-13 16:37:09 -07:00
Timothy Flynn
941bc47538 LibWeb: Define method to check if an attribute is a boolean attribute 2022-11-10 17:02:11 +00:00
Timothy Flynn
21c1494ac5 LibWeb: Define a few missing attribute names
These are specifically boolean attributes that will be referred to in
following commits.
2022-11-10 17:02:11 +00:00
Nico Weber
6911c5545c Everywhere: Fix a few comment typos 2022-11-09 16:00:32 +00:00
Timothy Flynn
2d5381fd91 LibWeb: Add a flag to track when a browsing context has been discarded 2022-11-08 19:58:34 -05:00
Luke Wilde
fd6bb41519 LibWeb: Apply the current transform in CRC2D.stroke()
This makes the Google Docs spelling and grammar squiggles appear in the
correct position.
2022-11-08 18:47:31 +00:00
Luke Wilde
009f04fa46 LibWeb: Implement HTMLTableRowElement.deleteCell 2022-11-07 14:10:41 +01:00
Luke Wilde
6c9b3fb62e LibWeb: Implement HTMLTableRowElement.insertCell 2022-11-07 14:10:41 +01:00
Luke Wilde
1d0fe2325c LibWeb: Don't call load_src after process_the_iframe_attributes
process_the_iframe_attributes already causes a navigation, so this
would cause a double navigation and blow away any setup that JS may
have done from events fired in process_the_iframe_attributes.
2022-11-07 14:10:41 +01:00