Commit Graph

771 Commits

Author SHA1 Message Date
Andreas Kling
7d863174b3 LibWeb: Use a JS::NonnullGCPtr for DOMTokenList::m_associated_element
Both Element and DOMTokenList are GC-allocated objects so they can just
mark each other instead of using the old strong/weak pattern we use in
ref-counting ownership models.
2023-01-01 17:51:51 +01:00
Timothy Flynn
ba86011fab LibWeb: Add missing return statement in an element scrolling error case 2022-12-26 09:56:22 -05:00
Baitinq
6a72a4df96 LibWeb: Propagate errors in Element::scroll_into_view()
This patch will allow us to handle scrolling errors in the WebDriver
implementation :)
2022-12-25 17:24:52 +01:00
MacDue
88e50869f1 LibWeb: Fix crash when serializing nodes for DOM inspector
Noticed this trying to inspect GitHub, you'd get a segfault due to the
parent node being null here.
2022-12-19 11:37:56 -05:00
Alexander Narsudinov
45525d4f85 LibWeb: Add NamedNodeMap::setNamedItemNS() method
This patch adds implementation of the missing `setNamedItemNS()` method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
530d5adc62 LibWeb: Add NamedNodeMap::removeNamedItemNS() method
This patch adds implementation of the missing `removeNamedItemNS()`
method.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
7679d38c5f LibWeb: Fix incorrect behaviour in NamedNodeMap::removeNamedItem()
According to the spec we should return removed attribute, but the old
implementation returned nullptr instead.

Now we return the element's removed attribute.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
f2d7690702 LibWeb: Add NamedNodeMap::getNamedItemNS()
This patch allows us to use method getNamedItemNS() of NamedNodeMap API.
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
ce6cf5bab8 LibWeb: Make method NamedNodeMap::set_attribute() closer to the spec
This patch eliminates 1 FIXME that I've got during fixme roulette! :^)
2022-12-17 18:27:57 +01:00
Alexander Narsudinov
1a0fbe1e85 LibWeb: Add internal get_attribute_ns() methods of NamedNodeMap
This patch adds methods for querying element by namespace and
local name.

These methods are defined by the spec for internal
usage, but weren't implemented in LibWeb yet.
2022-12-17 18:27:57 +01:00
Linus Groh
111a38c464 LibJS: Convert new_object_environment() to NonnullGCPtr 2022-12-16 09:59:56 +01:00
Linus Groh
22089436ed LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr 2022-12-15 06:56:37 -05:00
Sam Atkins
ab49dbf137 LibWeb: Convert Paintable coordinates to new pixel units
This fixes a few sizing issues too. The page size is now correct in most
cases! \o/

We get to remove some of the `to_type<>()` shenanigans, though it
reappears in some other places.
2022-12-14 16:47:57 +00:00
Andreas Kling
b005e816a3 LibWeb: Implement Node.isEqualNode() for ProcessingInstruction nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
8b0ace6289 LibWeb: Add Document.createProcessingInstruction()
These nodes don't really do anything interesting yet, but let's allow
creating them. :^)
2022-12-14 15:21:48 +01:00
Andreas Kling
bf759ce5e3 LibWeb: Make sure ProcessingInstruction objects have the right prototype 2022-12-14 15:21:48 +01:00
Andreas Kling
de2c302cdb LibWeb: Implement Node.isEqualNode() for Attr nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
a004d3043f LibWeb: Implement Node.cloneNode for Attr nodes 2022-12-14 15:21:48 +01:00
Andreas Kling
d5ed07fdc4 LibJS+LibWeb: Remove NonnullGCPtr<T>::operator=(GCPtr<T>) footgun
GCPtr can be null so it's not safe to assign it to a NonnullGCPtr unless
you know it to be non-null.

This exposed a number of wrong uses in LibWeb which had to be fixed as
part of this change.
2022-12-14 15:21:15 +01:00
Andreas Kling
4abdb68655 LibJS: Remove Object(Object& prototype) footgun
This constructor was easily confused with a copy constructor, and it was
possible to accidentally copy-construct Objects in at least one way that
we dicovered (via generic ThrowCompletionOr construction).

This patch adds a mandatory ConstructWithPrototypeTag parameter to the
constructor to disambiguate it.
2022-12-14 15:11:57 +01:00
Linus Groh
73efdb1cc4 LibJS: Convert ECMAScriptFunctionObject::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Thomas Queiroz
eacfcac932 LibWeb: Use HashMap::try_ensure_capacity in StyleComputer 2022-12-10 14:29:46 +01:00
Sam Atkins
3c7bd5a317 LibWeb+WebContent+headless-browser: Use CSSPixels for PageClient events
...and also for hit testing, which is involved in most of them.

Much of this is temporary conversions and other awkwardness, which
should resolve itself as the rest of LibWeb is converted to these new
types. Hopefully. :thousandyakstare:
2022-12-10 12:03:19 +00:00
Luke Wilde
b47aceb480 LibWeb: Add Document.getSelection 2022-12-10 00:21:10 +00:00
Luke Wilde
34c130b336 LibWeb: Stub Range.getBoundingClientRect
This seems to be used by Discord around the chat message box, but
didn't explore very far.
2022-12-10 00:21:10 +00:00
Linus Groh
525f22d018 LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was
misleading - it would not always create a rope string, only if both
sides are not empty strings. Use a three-argument create() overload
instead.
2022-12-07 16:43:06 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
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
fddbc2e378 LibWeb: Ensure the number of pseudo elements stays up-to-date
The ::placeholder pseudo element was added in commit 1fbad9c, but the
total number of pseudo elements was not updated. Instead of this manual
bookkeeping, add a dummy value at the end of the enumeration for the
count.
2022-12-01 11:18:11 -05:00
Andreas Kling
00a98c24a2 LibWeb: Update incorrect WEB_PLATFORM_OBJECT base class for two classes 2022-11-30 14:43:22 +01:00
Andreas Kling
2157745093 LibWeb: Add missing [SameObject] extended attributes in IDL files 2022-11-25 22:49:59 +01:00
Andreas Kling
15c324a70b Userland+Tests: Remove a few more LibJS/{AST.h,Parser.h} includes 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
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
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
Andreas Kling
0555684682 LibWeb: Sketch out basic support for SVG <foreignObject> elements
This patch adds basic DOM construction and IDL bindings for foreign
objects in SVG trees.
2022-11-16 13:01:21 +01:00
Idan Horowitz
43c5b94ea6 LibWeb: Implement document.open(string, string, string) 2022-11-15 21:48:19 +00:00
Luke Wilde
dfad2d4c13 LibWeb: Check that there's a head element before looking for favicons 2022-11-07 14:10:41 +01:00
Luke Wilde
a268026e4e LibWeb: Start implementing the Element scroll attributes
These are required for hit testing the document in Google Docs. If they
aren't defined, the Google Docs hit test code will add undefined to
certain values, causing them to turn into NaN. This causes NaNs to
propagate through their hit test code, which eventually makes it
infinitely loop.
2022-11-07 14:10:41 +01:00
Luke Wilde
6b0152e150 LibWeb: Stub Document.queryCommandSupported 2022-11-07 14:10:41 +01:00
Luke Wilde
8066a67da2 LibWeb: Implement Element.getAttributeNode 2022-11-07 14:10:41 +01:00
Luke Wilde
1473bc9169 LibWeb: Implement HTMLOrSVGElement.tabIndex 2022-11-07 14:10:41 +01:00
Daniel Bertalan
4296425bd8 Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so
there is no point in writing such functions by hand if all they do is
call through to `operator==`.

This fixes a compile error with compilers that implement P2468 (Clang
16 currently). This paper restores the C++17 behavior that if both
`T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be
rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators
makes the rewriting possible again.
See https://reviews.llvm.org/D134529#3853062
2022-11-06 10:25:08 -07:00
Baitinq
0758bc457e LibWeb: Replace some unnecessary ShadowRoot verify_cast with static_cast
These two occurrences of verify_cast happened right after a check on the
type of converted reference, making the verify_cast redundant.
2022-11-06 12:13:32 +00:00
Andreas Kling
5839ef2ed8 LibWeb: Render text inside <input type=password> as asterisks (*)
This makes it possible to enter passwords while recording YouTube
videos. :^)
2022-11-05 18:54:39 +01:00
Andreas Kling
87b0ddb354 LibWeb: Add DOM::Node::parent_or_shadow_host_element()
This will be used in style computation to inherit style across shadow
tree boundaries.
2022-11-05 18:54:39 +01:00
Andreas Kling
b400a34984 LibWeb: Cache the first <base href> (in tree order) in Document
When parsing relative URLs, we have to check the first <base href> in
tree order (if one is available). This was getting *very* costly on
large DOMs with many relative urls.

This patch avoids all that repeated traversal by letting Document cache
the first <base href> and invalidating the cache whenever a <base>
element is added/removed/edited in the DOM.

The browser was stuck doing this for a *very* long time when loading
the ECMA-262 spec, and this removes that problem entirely.
2022-11-05 00:30:10 +01:00
Timothy Flynn
e7412717b4 LibWeb: Make it obvious that DOM::Document makes a copy of its source 2022-11-03 14:52:16 +00:00
Timothy Flynn
13b8eeff54 LibWeb: Fully implement the fragment serializing algorithm
Rather than assuming the node's node document is an HTML document,
handle XML documents as well.
2022-11-03 14:48:04 +00:00
Linus Groh
acfb546048 LibWeb: Handle currently ignored WebIDL::ExceptionOr<T>s 2022-10-31 14:12:44 +00:00