Commit Graph

5227 Commits

Author SHA1 Message Date
Andreas Kling
eac31e21f2 LibWeb: Avoid some redundant calls to Layout::Box::absolute_rect()
Computing the absolute rect of a box requires walking the chain of
containing blocks and apply any offsets encountered. This can be slow in
deeply nested box trees, so let's at least avoid doing it multiple times
when once is enough.
2021-09-15 14:18:17 +02:00
Sam Atkins
1103eb8d44 LibWeb: Remove unused NodeWithStyle::m_position field 2021-09-15 13:55:25 +02:00
Sam Atkins
ee671a20cc LibWeb: Make flex-box ignore out-of-flow child boxes
Previously, out-of-flow children still took up space inside a flex-box
container, leaving an odd gap. Now they don't! :^)
2021-09-15 13:55:25 +02:00
Sam Atkins
2844f89a83 LibWeb: Implement "out-of-flow" property of Layout Box
In some situations, a layout box should not participate in the standard
layout process, for example when set to `position: absolute`.
2021-09-15 13:55:25 +02:00
Ali Mohammad Pur
741886a4c4 LibRegex: Make the optimizer understand references and capture groups
Otherwise the fork in patterns like `(1+)\1` would be (incorrectly)
optimized away.
2021-09-15 15:52:28 +04:30
Andreas Kling
7de23aede2 LibWeb: Parse the <svg viewBox> attribute
Just parse it into an SVG::ViewBox object for now, we don't actually use
it for anything yet.
2021-09-15 11:56:26 +02:00
Andreas Kling
63c4fcdc69 LibWeb: Add SVG::ViewBox to represent SVG view boxes
This also comes with a simple little parsing helper. :^)
2021-09-15 11:56:26 +02:00
Andreas Kling
8949b0def6 LibWeb: Add an SVG::AttributeNames namespace
There are a whole bunch of SVG attributes, and we shouldn't mix them in
with the HTML attributes. This patch adds some of them to the new
namespace, but there are more to be added. :^)
2021-09-15 11:56:26 +02:00
Ali Mohammad Pur
53d24fbd65 LibJS: Make References see into Environment's bindings as well
'bindings' is the spec-compliant version of 'variables', but we were
simply not even looking at them, which made things using bindings (such
as named function expressions) break in unexpected ways after the move
to using references in call expressions.

Co-Authored-By: davidot <david.tuin@gmail.com>
2021-09-15 11:56:00 +02:00
Sam Atkins
3f31f109b5 LibWeb: Speed up computed style calculation
Rather than destroying and rebuilding the entire document layout tree in
every call to `ComputedCSSStyleDeclaration::property()`, we now just
make sure that the layout tree exists.

This speeds up the DOM Inspector significantly, from taking several
seconds to select an element, to almost instant. :^)
2021-09-15 11:24:11 +02:00
Zyper
12e76bb3df LibGfx: Add method for calculating square aspect ratio end point 2021-09-15 00:10:14 +00:00
Linus Groh
88a31f3bac LibJS: Fix [[TimeZoneOffsetString]] value in ParseTemporalInstantString
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/78c3b8b
2021-09-15 00:23:11 +01:00
Andreas Kling
70398645f3 LibWeb: Improvements to error handling in HTML foreign content parsing
Follow the spec more closely when encountering an invalid start or end
tag during foreign content parsing.
2021-09-14 23:49:45 +02:00
Tobias Christiansen
fad825e94e LibWeb: Flexbox: Avoid division by zero
This is not a good thing, one should not divide by zero! :^)
2021-09-14 22:52:48 +02:00
Tobias Christiansen
85af2ac450 LibWeb: Flexbox: Change the name of a variable to correspond to spec
The spec used two different names for the same thing, and it was
confusing to read the spec on the one side and have the other name in
the code.
2021-09-14 22:52:48 +02:00
Tobias Christiansen
15b61ce143 LibWeb: Flexbox: Resolve relative size of flex-items more correctly
This is still very much not the right thing to do, but at least
relatively sized flex-items get the right size.
2021-09-14 22:52:48 +02:00
Ali Mohammad Pur
8e3fe80c06 LibRegex: Avoid using GenericLexer::consume() when at eof
Fixes #10027.
2021-09-14 22:02:25 +02:00
kleines Filmröllchen
047c013be0 LibWeb: Add several computed CSS styles
These are mostly combined styles such as background, as well as handling
the Invalid and Custom property IDs (which both make no sense).
2021-09-14 22:02:14 +02:00
kleines Filmröllchen
6865a5a447 LibWeb: Add CombinedBoderRadiusStyleValue for CSS border-radius
This style value can hold all four border radii and format them into
valid CSS for the `border-radius` property.
2021-09-14 22:02:14 +02:00
Andreas Kling
20fb900937 LibJS+LibWeb: Move script parse time logging from JS::Script to LibWeb
Let's only log HTML::ClassicScript parse times for now. Otherwise things
will get excessively noisy in test-js and the test262 runner.
2021-09-14 21:41:51 +02:00
Andreas Kling
0a09eaf3a1 LibJS+LibTest: Use JS::Script and JS::SourceTextModule in test-js
Instead of creating a Parser and Lexer manually in test-js, we now
use either JS::Script::parse() or JS::SourceTextModule::parse()
to load tests.
2021-09-14 21:41:51 +02:00
Andreas Kling
10c489713d LibJS+LibWeb: Let JS::Script::parse() return a list of errors (on error)
These are really supposed to be a list of SyntaxError objects, but for
now we simply return all the Parser::Error objects we got from Parser.
2021-09-14 21:41:51 +02:00
Andreas Kling
5fa02b8a9e LibJS: Add a barebones SourceTextModule class
This corresponds to "Source Text Module Record" from the spec.
2021-09-14 21:41:51 +02:00
Andreas Kling
405b8e7915 LibTest: Decorate cleanup_and_exit() with [[noreturn]] 2021-09-14 21:41:51 +02:00
Andreas Kling
f08a46bd9e LibJS: Make JS::Script keep the VM alive
Script has a Handle member (m_realm), and for handles to remain valid,
the VM must stay alive.
2021-09-14 21:41:51 +02:00
Andreas Kling
d553fd7f4f LibJS: Add a barebones Module class
This corresponds to the "Abstract Module Record" from the spec.
2021-09-14 21:41:51 +02:00
Andreas Kling
df5414f47f LibJS: Reorganize ExecutionContext a little bit
- Move it to a separate header file
- Annotate the members that represent spec slots
- Reorganize the members (by spec vs non-spec)
2021-09-14 21:41:51 +02:00
Ali Mohammad Pur
72ddaa31e3 LibJS: Implement parsing and execution of optional chains 2021-09-14 20:03:27 +01:00
Ali Mohammad Pur
4f7e14e0aa LibJS: Reorder the global eval function call detection conditions a bit
This just makes it clearer, since the actual check is off-screen, making
the reader wonder what that check is for.
2021-09-14 20:03:27 +01:00
Ali Mohammad Pur
f7a68ae998 LibJS: Mark two JS::Reference functions const
These two are inherently const, and the next commit needs to call them
on a const object, so let's just mark them const.
2021-09-14 20:03:27 +01:00
Ali Mohammad Pur
bf0315ff8f LibRegex: Avoid excessive Vector copy when compiling regexps
Previously we would've copied the bytecode instead of moving the chunks
around, use the fancy new DisjointChunks<T> abstraction to make that
happen automagically.
This decreases vector copies and uses of memmove() by nearly 10x :^)
2021-09-14 21:33:15 +04:30
Andreas Kling
910de95e7a LibJS: Add a fast failure path to try_parse_arrow_function_expression()
The save/load of parser state performed by lookahead parsing is quite
expensive so let's try to avoid it in the most common case.

This is a 15-20% speedup on various chunks of JS I've tested. :^)
2021-09-14 02:51:16 +02:00
Linus Groh
a50e33abe3 LibJS: Skip ID_{Start,Continue} property lookup for any ASCII characters
Before this change, Lexer::is_identifier_{start,middle}() would do a
Unicode property lookup via Unicode::code_point_has_property() quite
frequently, especially for common characters like .,;{}[]() etc.

Since these and any other ASCII characters not covered by the alpha /
alphanumeric check are known to not have the ID_Start / ID_Continue
(except '_', which is special-cased now) properties, we can easily
avoid this function call.
2021-09-14 02:48:57 +02:00
Luke Wilde
e4d97add3d LibWeb: Implement ParentNode.children
Required by Web Platform Tests for the innerHTML/outerHTML tests.
2021-09-14 02:09:18 +02:00
Luke Wilde
8e0f3436a2 LibWeb: Make the innerHTML setter spec compliant
This adds innerHTML to ShadowRoot in the process.
2021-09-14 02:09:18 +02:00
Luke Wilde
f62477c093 LibWeb: Implement HTML fragment serialisation and use it in innerHTML
The previous implementation was about a half implementation and was
tied to Element::innerHTML. This separates it and puts it into
HTMLDocumentParser, as this is in the parsing section of the spec.

This provides a near finished HTML fragment serialisation algorithm,
bar namespaces in attributes and the `is` value.
2021-09-14 02:09:18 +02:00
Idan Horowitz
ed5128d759 LibWeb: Add the URL::{protocol, pathname, search, hash} attributes 2021-09-14 00:14:45 +02:00
Idan Horowitz
7f9818bcbc LibWeb: Add the URL::host, URL::hostname & URL:port attributes 2021-09-14 00:14:45 +02:00
Idan Horowitz
e89320887e LibWeb: Add the URL::username, URL::password & URL::origin attributes 2021-09-14 00:14:45 +02:00
Idan Horowitz
fe32c9c3bd LibWeb: Add the URL::searchParams attribute 2021-09-14 00:14:45 +02:00
Idan Horowitz
1841fbd3e4 LibWeb: Add the URL::href attribute and URL::to_json method 2021-09-14 00:14:45 +02:00
Idan Horowitz
e6abc1b44e LibWeb: Add a bare implementation of the URL built-in
This only has the constructor implemented for now.
2021-09-14 00:14:45 +02:00
Idan Horowitz
d6cfa34667 AK: Make URL::m_port an Optional<u16>, Expose raw port getter
Our current way of signalling a missing port with m_port == 0 was
lacking, as 0 is a valid port number in URLs.
2021-09-14 00:14:45 +02:00
Idan Horowitz
af5b62d8cd LibWeb: Move url_{encode, decode} to URL/URLSearchParams.{h, cpp}
The new URL built-in that will reside in URL.{h, cpp} will have an
URLSearchParams member, which means it has to include its header, and
as such URLSearchParams.h can't include URL's header, which it needs as
it uses the url_{encode, decode} functions.
2021-09-14 00:14:45 +02:00
Mustafa Quraish
0f749681a9 Everywhere: Use my fancy new serenityos.org email :^) 2021-09-13 20:51:50 +00:00
Andreas Kling
bf86419979 LibWeb: Use ComputedCSSStyleDeclaration to generate data for inspector 2021-09-13 22:21:57 +02:00
Andreas Kling
3ca2e701e6 LibJS: Log scripts parsed by JS::Script::parse() and how long it took 2021-09-13 22:21:57 +02:00
Tobias Christiansen
416559414c LibWeb: Use right dimension when positioning flex-items
Previously the cross-size was used to determine the position along the
main axis which is obviously wrong.
2021-09-13 21:20:35 +01:00
Linus Groh
8cd4a889fe LibWeb: Stop dumping selectors in ParentNode::query_selector{,_all}()
This isn't particularly useful (anymore), especially without any context
about _why_ this output suddenly appears in the debug console.
2021-09-13 21:16:33 +01:00
Linus Groh
35cc579264 LibJS: Also set ExecutionContext::realm in Bytecode::Interpreter::run()
I forgot to consider the bytecode Interpreter when adding a Realm to the
ExecutionContext. This should make it a lot less crashy again :^)
2021-09-13 21:06:18 +01:00