Commit graph

2065 commits

Author SHA1 Message Date
Michiel Visser
39409438b2 LibWeb: Send Origin on WebSocket connection
Some services using WebSockets require that the request contains the
Origin header, otherwise these services will return a 403 Forbidden
response. WebSocketServer already supports sending the Origin header,
however LibWeb did not send the origin with the IPC request.
2022-03-02 21:38:17 +01:00
Andreas Kling
9888e29c14 LibWeb: Streamline Node::enclosing_link_element() somewhat
No need to verify_cast repeatedly once we've confirmed the type.
2022-03-02 17:40:18 +01:00
Andreas Kling
ad9f3f7ae6 LibWeb: Add fast_is<T> for HTML::HTMLAnchorElement
We were spending 20% of style computation time on the HTML spec on
deciding whether DOM nodes were HTML anchor (a) tags or not.
2022-03-02 17:40:18 +01:00
Andreas Kling
65b38f2623 LibWeb: Don't skip position:relative elements in inline-level layout
InlineLevelIterator was wrongly skipping over all positioned elements,
instead of just the absolutely positioned ones.
2022-03-02 17:40:18 +01:00
Sam Atkins
973f3c3642 LibWeb: Correct handling of negative step values in nth-foo() selectors
This should be 1% on Acid3. :^)

Added the `-5n+3` case to all `nth-of-whatever()` selector test pages,
so we can easily check that it works.
2022-03-02 17:39:57 +01:00
Andreas Kling
1061c863f8 LibWeb: Fix issue where double-quoted doctype system ID was not captured
We were storing double-quoted system ID's in the public ID field.

1% progression on ACID3. :^)
2022-03-02 12:30:15 +01:00
Andreas Kling
bfa7aad0f6 LibWeb: Support (and validate) prefixes in Document.createElementNS()
1% progression on ACID3. :^)
2022-03-02 10:55:16 +01:00
Andreas Kling
4fb67c1621 LibWeb: Fix logic error in Document::validate_qualified_name()
We were mixing up the "name character" and "name start character"
validation checks. Also, we were not checking the first character after
a colon against the "name start character" set.
2022-03-02 10:53:38 +01:00
Andreas Kling
7231c1c895 LibWeb: Fix bogus result from "validate and extract" DOM operation
We were returning a QualifiedName with the localName and namespace
fields swapped.
2022-03-02 10:21:57 +01:00
Andreas Kling
05e9dceba6 LibWeb: Support DOMImplementation.createDocument() doctype parameter
1% progression on ACID3. :^)
2022-03-02 09:18:19 +01:00
Andreas Kling
fa43a4118e LibWeb: Handle height:auto separately for BFC root vs other block boxes
I was wrong in 56df05ae44, there are
situations where floating children should not affect the auto height of
their parent.

It turns out we were using the "height:auto for BFC roots" algorithm for
all height:auto blocks. This patch fixes that by splitting it into two
separate functions, and implementing most of the two different variants.

Note that we don't support vertical margin collapsing here yet.

Thanks to Tim for noticing the error! :^)
2022-03-01 23:26:35 +01:00
Luke Wilde
4fa270d81f LibWeb: Implement <button>'s activation behaviour
This allows us to submit forms from <button> elements and not just
<input type="submit">

This allows Discord to progress past the username registration :^)
2022-03-01 23:19:41 +01:00
Luke Wilde
46c0d0f7ae LibWeb: Associate form elements with a form in parsing and dynamically
This makes it available for all form associated elements and not just
select and input elements. It also makes it more spec compliant,
especially around the form attribute.

The main thing missing is re-associating form elements with a form
attribute when the form attribute changes or an element with an ID
is inserted/removed or has its ID changed.
2022-03-01 23:19:41 +01:00
Luke Wilde
29f9947ff9 LibWeb: Implement HTMLButtonElement.type 2022-03-01 23:19:41 +01:00
Luke Wilde
432d496ed6 LibWeb: Add form associated element categories 2022-03-01 23:19:41 +01:00
Luke Wilde
d2e18175ef LibWeb: Move enabled() to FormAssociatedElement and follow the spec 2022-03-01 23:19:41 +01:00
Luke Wilde
0f660760ed LibWeb: Fix incorrect check in BrowsingContext::is_top_level
A top level browsing context is a browsing context with no parent
browsing context.

However, we considered a top level browsing context to be a browsing
context with no associated browsing context container.
2022-03-01 21:21:42 +00:00
Andreas Kling
56df05ae44 LibWeb: Always include floats when computing height:auto for blocks
I'm not sure why we had two modes for this, but floats should always be
included in the auto height AFAICT.
2022-03-01 19:01:19 +01:00
Andreas Kling
6478b460fb LibWeb: Fix wrong height:auto computation for block with floating child
If an element with height:auto has any floating descendants whose bottom
margin edge is below the element's bottom content edge, then the height
is increased to include those edges.

Before this patch, we were stopping at the bottom *content* edge of
floating descendants.
2022-03-01 19:01:19 +01:00
Alex M
f0f2009170 LibWeb: Add origin property to window object 2022-03-01 13:38:20 +00:00
Linus Groh
4170fcb777 LibWeb: Also apply default button styles to <button>, not just <input> 2022-02-28 23:12:37 +00:00
Tobias Christiansen
8461791ce2 LibWeb: Add support for 'view-box' attribute to SVGs
This patch begins the support for the 'view-box' attribute that can be
attached to <svg>'s.
The FormattingContext determines the size of the Element according to
the specified 'width' and 'height' or if they are not given by the
'viewbox' or by the bounding box of the path if nothing is specified.
When we try to paint a SVG Path that belongs to a <svg> that has the
'view-box' and a specified 'height'/'width', all the parts of the path
get scaled/moved accordingly.

There probably are many edge cases and bugs still to be found, but this
is a nice start. :^)
2022-02-28 16:49:24 +01:00
Tobias Christiansen
4f1df48bd9 LibWeb: Make SVGSVGElement's view_box() const 2022-02-28 16:49:24 +01:00
Vrins
a8cfb34551 LibWeb: Allow <input type="button/submit/reset"> to be styled
Previously we used a native ui button to draw the buttons.
These buttons can however not be styled with css.
To allow these to be styled with css, we create a button with
the UA stylesheet that resembles the system ui button.
2022-02-28 15:46:06 +00:00
Andreas Kling
c8f6a20c02 LibWeb: Remove unused variable in required_box_type_transformation() 2022-02-28 15:14:32 +01:00
Andreas Kling
f8aa0c144f LibWeb: Store box's containing line box fragment in FormattingState
Layout should not change any properties of a box until the moment a
FormattingState is committed.
2022-02-28 14:17:44 +01:00
Andreas Kling
aa72ebf7aa LibWeb: Use copy-on-write to make cloning a FormattingState much cheaper
Instead of making a full copy of every NodeState when cloning a
FormattingState, we make NodeState ref-counted and implement a basic
copy-on-write mechanism.

FormattingState::get_mutable() now makes a deep copy of the NodeState
when first accessed *if* it is shared with other FormattingStates.
2022-02-28 14:17:44 +01:00
Andreas Kling
0a533da22f LibWeb: Don't crash on content with SVG elements outside of <svg>
We'll have to do something more proper to support this scenario
eventually, but for now let's at least not crash just because somebody
put an SVG <path> inside an HTML element.
2022-02-28 14:17:44 +01:00
Andreas Kling
ed089586ea LibWeb: Move some of PaintContext out of line 2022-02-28 14:17:44 +01:00
Andreas Kling
ee50a4e060 LibWeb: Don't blockify or inlinify boxes with already-correct type
If something is already a block on the outside, we don't want to
overwrite its inside display type.
2022-02-28 14:17:44 +01:00
Andreas Kling
c9ab9e2c64 LibWeb: Blockify children of parents with display:grid or display:flex 2022-02-28 14:17:44 +01:00
Andreas Kling
20caea2f86 LibWeb: Split CSS box type transformations into a helper function
Let's have one function that determines the type of transformation
needed, and another to actually perform the transformation.

This makes it much easier to read, and we don't have to duplicate the
logic for doing the transformation.
2022-02-28 14:17:44 +01:00
Andreas Kling
cd5c17d88e LibWeb: Improve Layout::Box has-definite-size? computation
We now consider a layout box as having definite size in these cases:

- The size is a <length>.
- The size is a <percentage> and the containing block has definite size.

This is not complete, but a bit more accurate than what we had before.
2022-02-28 14:17:44 +01:00
Andreas Kling
c6cf240f9a LibWeb: Store bottom edge location with each LineBox
Previously we were computing the bottom edge of a line box by finding
the bottommost fragment on the line.

That method didn't give correct results for line boxes with no fragments
(which is exactly what you get when inserting a bunch of <br> elements.)

To cover all situations, we now keep track of the bottommost edge in the
LineBox object itself.
2022-02-28 14:17:44 +01:00
Andreas Kling
4b6295e667 LibWeb: For height:auto blocks, measure from top of *top* line box
We were incorrectly checking for negative top edges in the *last* line
box only.
2022-02-28 14:17:44 +01:00
Andreas Kling
19954dfdf8 LibWeb: Add FormattingState::clone()
This makes a deep copy of a FormattingState.
2022-02-28 14:17:44 +01:00
Andreas Kling
1d05823810 LibWeb: Store Layout::Box overflow data in Optional instead of OwnPtr 2022-02-28 14:17:44 +01:00
Andreas Kling
916bbf5910 LibWeb: Use Vector<LineBoxFragment> instead of NonnullOwnPtrVector
This removes one step of indirection, but more importantly, makes it
easy to copy these objects. :^)
2022-02-28 14:17:44 +01:00
Andreas Kling
16a47165ee LibWeb: Use coordinate instead of WeakPtr for box->fragment connection
Using WeakPtr to remember which LineBoxFragment owns which Box was
imposing some annoying constraints on the layout code. Importantly, it
was forcing us to heap-allocate fragments, which makes it much harder to
clone a FormattingState.

This patch replaces the WeakPtr with a coordinate system instead.
Fragments are referred to by their line box index + fragment index
within the line box.
2022-02-28 14:17:44 +01:00
Andreas Kling
726edd2d3b LibWeb: Pass state to create_independent_formatting_context_if_needed()
Instead of using the current m_state implicitly, make this function take
a FormattingState&. This will allow us to use it for throwaway layouts.
2022-02-28 14:17:44 +01:00
Idan Horowitz
feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
Andreas Kling
262488ea33 LibWeb: Validate the qualified name in createDocumentType()
1% progression on ACID3. :^)
2022-02-26 17:26:37 +01:00
Andreas Kling
f855cbac92 LibWeb: Add simple ad-hoc version of window.postMessage()
This allows us to use the wpt.live copy of the ACID3 test, which is kept
updated, unlike the acidtests.org version.
2022-02-26 17:21:40 +01:00
Andreas Kling
fc5e414596 LibWeb: Reorganize window.parent so it looks a bit more like the spec 2022-02-26 16:03:06 +01:00
Sam Atkins
a57128467a LibWeb: Implement :nth-of-type and :nth-last-of-type selectors :^) 2022-02-26 15:30:24 +01:00
Luke Wilde
ad5fb1fd7e LibWeb: Implement Range.comparePoint 2022-02-26 12:53:32 +01:00
Luke Wilde
62b76e0658 LibWeb: Implement Range.isPointInRange 2022-02-26 12:53:32 +01:00
Luke Wilde
386ee5ab17 LibWeb: Implement Range.intersectsNode 2022-02-26 12:53:32 +01:00
Luke Wilde
4c08757ff9 LibWeb: Add Range.detach 2022-02-26 12:53:32 +01:00
Luke Wilde
8a755726ad LibWeb: Implement Range.selectNodeContents 2022-02-26 12:53:32 +01:00