Commit graph

1483 commits

Author SHA1 Message Date
Tim Ledbetter
9b524d043f LibWeb: Don't crash when SVG viewbox has a width of 0
Previously, `SVGSVGBox` would have a natural aspect ratio of 0 if it
had a viewbox with zero width. This led to a division by zero, causing
a crash.

Found by Domato.

(cherry picked from commit 4cdafea36334bcff8c4bbb083076ae55b599177c)
2024-07-22 18:27:26 -04:00
Tim Ledbetter
949ca71b31 LibWeb: Clamp paintable box maximum scroll offset to 0
Previously calling `PaintableBox::set_scroll_offset()` with a
PaintableBox whose content size was larger than its scrollble overflow
rect would cause a crash.

Found by Domato.

(cherry picked from commit 604f6040a180ac409cf338045c8709a171d920d5)
2024-07-22 18:27:26 -04:00
Tim Ledbetter
1146284d86 LibWeb: Implement Node.isDefaultNamespace()
This method accepts a namespace URI as an argument and returns true if
the given URI is the default namespace on the given node, false
otherwise.

(cherry picked from commit 055c902a375bb34b8c0e31f015c2815fe935c6a9)
2024-07-21 16:55:51 -04:00
Tim Ledbetter
e81cb6d41d LibWeb: Implement Node.lookupNamespaceURI()
This method takes a prefix and returns the namespace URI associated
with it on the given node, or null if no namespace is found.

(cherry picked from commit 27d429a85f359b9c87bf9807e4dea33f7092308a)
2024-07-21 16:55:51 -04:00
Jamie Mansfield
2ad1fa17fb LibWeb/SVG: Implement SVGAElement.relList
(cherry picked from commit 6ca4c2beb08a81bc4aaa2571ee8c5b3207d0b3a2)
2024-07-21 16:55:11 -04:00
Jamie Mansfield
40eaf964d2 LibWeb/SVG: Implement SVGElement.ownerSVGElement
(cherry picked from commit 6f3c5f5ae9f0ee055c44ace5efab0c443626bb5d)
2024-07-21 16:55:11 -04:00
Tim Ledbetter
f05163b00e Tests/LibWeb: Add some tests for Node.isEqualNode
(cherry picked from commit 7e8d71f7fcd530edafef7f4f4356cd233ed2d20b)
2024-07-21 16:54:29 -04:00
Aliaksandr Kalenik
2f6c12cd15 LibWeb: Fix flexible track sizing in GFC
- Change min track sizing function to be "auto" when flex size is
  specified.
- Never check if min track sizing funciton is flexible, because only
  max is allowed to be flexible.
- Address FIXME in automatic_minimum_size to avoid regressions after
  making two fixes mentioned above.

(cherry picked from commit 3270df476dd46b140e1b9de1e8328647744b56ab)
2024-07-21 14:19:12 -04:00
Aliaksandr Kalenik
409e3ae994 LibWeb: Subtract left inset from size_available_for_margins for abspos
Fixes https://github.com/LadybirdBrowser/ladybird/issues/712

(cherry picked from commit 0be57df54dd57d1544eead1c1bc8fe117c0a3450)
2024-07-21 14:13:42 -04:00
Aliaksandr Kalenik
c82f41dac8 LibWeb: Change grid item placement to look for area by boundary lines
Areas are disassembled into boundary lines on `build_grid_areas()` step,
so we can always use them to find grid item's position during placement.
This way we support both ways to define area: `grid-template-areas` and
implicitly using `-start` and `-end` boundary line names.

(cherry picked from commit 7a1f3f7ae3af2744e2f99df29baf09153d631b24)
2024-07-21 14:08:37 -04:00
Andreas Kling
c6038071a4 LibWeb: Allow splitting surrogate pairs in CharacterData.replaceData()
We're expected to handle this situation gracefully, and certainly not
by falling apart like we were.

Found by Domato.

(cherry picked from commit 33207174a9c1c87657e2ae0875cc85cbf41075f8)
2024-07-21 14:07:57 -04:00
Andreas Kling
1484dbffae LibWeb: Don't try to set selection with anchor/focus in different roots
If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.

Found by Domato.

(cherry picked from commit 416c4788763baa778465d1d004080d322462c0bf)
2024-07-21 14:07:57 -04:00
Andreas Kling
7ddd8bac62 LibWeb: Cap HTML dimension values at 17895700 (same as Firefox)
Instead of allowing arbitrarily large values (which could eventually
overflow an i32), let's just cap them at the same limit as Firefox does.

Found by Domato.

(cherry picked from commit 4e0edd42b95abf8ad707c64414dbe618313ce89e)
2024-07-21 14:07:57 -04:00
Andreas Kling
e99c005c80 LibWeb: Propagate exceptions from setAttribute() in DOMStringMap setter
We were incorrectly assuming that setAttribute() could never fail here,
even when passed an invalid name.

Found by Domato.

(cherry picked from commit 093f1dd805f699801079f55d0d490d80b463ccbb)
2024-07-21 14:07:57 -04:00
Andreas Kling
d2ae01f8ad LibWeb: Fix StringView OOB access when parsing 3-character legacy color
Found by Domato.

(cherry picked from commit 1c00e5688d3330626f809e758bb63c8348776971)
2024-07-21 14:07:57 -04:00
Andreas Kling
e1e05d5c6b LibWeb: Make getElementById() always return first match in tree order
We had a const and non-const version of this function, with slightly
different behavior (oops!)

This patch consolidates the implementations and keeps only the correct
behavior in there.

Fixes an issue where comments were not collapsible on Hacker News.

(cherry picked from commit 98f88d49de852e1e524655accb39724f1134a23f)
2024-07-21 12:37:18 -04:00
Colin Reeder
8908038f96 LibWeb: Add support for indexed setter of HTMLOptionsCollection
(cherry picked from commit 99824eae142b02c7bce84b9e98d10fc6428f31fe)
2024-07-21 11:29:07 -04:00
BenJilks
456a09e8c7 LibWeb: Propagate margin and offset when computing a box's baseline
When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.

(cherry picked from commit 3c897e7cf3594f02f559599e1bf28747c9edba13)
2024-07-21 11:28:55 -04:00
Diego Frias
e4d3b9060a LibWeb: Implement the :has() pseudo-class
See https://drafts.csswg.org/selectors-4/#relational.

(cherry picked from commit f63a945ba0300551417c740e450957f29c9b73d1)
2024-07-21 11:10:11 -04:00
circl
24fa7ae18f Tests/LibWeb: Add test for MouseEvent and WheelEvent bubbling
(cherry picked from commit 89531fb115b0df23967a29ffdeda15a738e6f9d5)
2024-07-16 15:04:06 -04:00
Kenneth Myhra
0d9429e383 LibWeb: Implement min option for ReadableStreamBYOBReader.read()
When the min option is given the read will only be fulfilled when there
are min or more elements available in the readable byte stream.

When the min option is not given the default value for min is 1.

(cherry picked from commit 907dc84c1e8c3c236ade581f46dabdb144915c1d)
2024-07-15 09:05:07 -04:00
Luke Warlow
e8bcd3842d LibWeb: Implement support for scrollbar-gutter
This property is now correctly parsed.

Ladybird always uses overlay scrollbars so this property does nothing.

(cherry picked from commit 662317726549cd2dde4c7902b99f0b83397a3396)
2024-07-14 20:44:46 -04:00
Bastiaan van der Plaat
6ab28fd568 LibWeb/CSS: Serialize transform scale percentage values as numbers
(cherry picked from commit c81a640f3ed424b11830fbe9777f1a267240577f)
2024-07-14 19:34:39 -04:00
BenJilks
2e95c03ca6 LibWeb: Change flex remaining space distribution to include gap
The remaining space is in addition to, not of in place of the
main gap.

(cherry picked from commit 47aee289d87add9784a2d722cb529774cdfb54e2)
2024-07-14 18:12:55 -04:00
Jamie Mansfield
c14af45628 LibWeb: Implement SVGElement.className
(cherry picked from commit 9d1ea4c7e013629d432a4c3559a5919462fd4c71)
2024-07-14 18:12:26 -04:00
Tim Ledbetter
4b00926a66 LibWeb: Update Range::set_base_and_extent() to the latest spec text
This allows it to work with content inside shadow roots.

(cherry picked from commit 34741d09c6e69bd7cd8450668facd552cd69d21b)
2024-07-14 16:46:23 -04:00
Caitlin Potter
8de61581cf LibWeb: Implement WebIDL constructor flow for derived classes
Following the rules in the algorithm from
https://webidl.spec.whatwg.org/#js-platform-objects, "To Internally
create a new object implementing the interface interface", this change
incorporates the steps to load a prototype from new.target, and write
it to the created instance returned from constructor_impl(). This
mirrors the code for generate_html_constructor(), which incorporates
additional steps needed by Custom Elements.

Bug LadybirdBrowser/ladybird#334

(cherry picked from commit 80cd3712c2c52bf749a19cbd21af0c5c479a87c9)
2024-07-14 16:46:03 -04:00
Colin Reeder
bf0a7667a0 LibWeb: Handle inline-start and inline-end as float values
Should resolve #449 for LTR languages at least

(cherry picked from commit d427344f39581cd7789280949eb6d102b39218a3)
2024-07-14 16:45:48 -04:00
Tim Ledbetter
7d71a5483c LibWeb: Don't dispatch click events to disabled FormAssociatedElements
Disabled FormAssociatedElements also no longer receive focus when
clicked.

(cherry picked from commit e18501f67fb0361a10392bc626e6c43f26f1e9cc)
2024-07-14 16:45:21 -04:00
Jamie Mansfield
a09b52e40f LibWeb/HTML: Implement TextTrackList IDL interface
(cherry picked from commit ecad28657a0941c99870bdb72f3a6f09b6db6ee3)
2024-07-14 14:01:30 -04:00
simonkrauter
5838244afc LibWeb: Use correct default value for <input type=range>
Previously the input element was displayed with value 0, when no value
was set in the HTML. Now it uses `value_sanitization_algorithm()`, which
will calculate the default value.
In `value_sanitization_algorithm()` there was a logical mistake/typo.
The comment from the spec says "unless the maximum is less than the
minimum".
The added layout test would fail without the code changes.
Fixes #520

(cherry picked from commit 191531b7b18d2edf97dc7bf88a9c19903eeae2d5)
2024-07-14 14:01:21 -04:00
Tim Ledbetter
1506f72219 LibWeb: Populate filename in WindowOrWorkerGlobalScope.reportError()
Previously, when `WindowOrWorkerGlobalScope.reportError()` was called
the `filename` property of the dispatched error event was blank. It is
now populated with the full path of the active script.

(cherry picked from commit 34b987366449313c96a73ec1d70e88e60f2c4510)
2024-07-14 06:57:29 -04:00
Jamie Mansfield
0a1146c67a LibWeb/HTML: Stub TextTrack IDL interface
(cherry picked from commit 67e3ac8916d7354c8485b4bbe9c4162392e0e99c)
2024-07-14 06:57:14 -04:00
rmg-x
435bbb53f8 LibWeb: Ensure normal line-height on HTMLInputElement
Previously, setting CSS `line-height: 0` on an `input` element would
result in no text being displayed.

Other browsers handle this by setting the minimum height to the
"normal" value for single line inputs.

(cherry picked from commit 629068c2a7eb02db37ffb4fe8d536306ee71e156)
2024-07-14 06:56:56 -04:00
Tim Ledbetter
fe03f6b6a7 LibWeb: Implement Node.normalize()
This method puts the given node and all of its sub-tree into a
normalized form. A normalized sub-tree has no empty text nodes and no
adjacent text nodes.

(cherry picked from commit 0a0651f34ea927a0ca44dc5d2c7786f3dcf8da25)
2024-07-14 06:55:54 -04:00
BenJilks
aec3ab77ef LibWeb: When solving abspos lengths, use min max constrained height
Solving using the unconstrained height, when solving for bottom, would
either leave a gap over overflow its container.

(cherry picked from commit bee42160c5e2cdb949e6057f029391ee7e0fa9fa)
2024-07-13 22:52:34 -04:00
Maciej
1e41585416 LibWeb: Implement HTML DragEvent class
This just defines the class, drag events aren't actually fired yet.

(cherry picked from commit 65d8d205ee5d7ef356da58f8238e610949773683)
2024-07-13 22:52:06 -04:00
Andreas Kling
17c1a20f9b LibWeb: Don't fire resize event until document actually resizes once
The first time Document learns its viewport size, we now suppress firing
of the resize event.

This fixes an issue on multiple websites that were not expecting resize
events to fire so early in the loading process.

(cherry picked from commit 4e7558c88b7a993686bb3dc173731e677efe5e26)
2024-07-13 22:03:32 -04:00
Maciej
6673dcc960 LibWeb: Prepare script when src is set the first time
From https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:
When a script element el that is not parser-inserted experiences one
of the events listed in the following list, the user agent must
immediately prepare the script element el:
- [...]
- The script element is connected and has a src attribute set where
  previously the element had no such attribute.

(cherry picked from commit d890be6e0f7db08ab39ba546cb3421b50b687cda)
2024-07-13 21:52:51 -04:00
Luke Warlow
85b5be0a20 LibWeb: Implement :modal pseudo class
Adds the :modal pseudo class which matches dialogs opened with
showModal().

(cherry picked from commit 63a5ff70e5f3bee10839415885a158e304719fec)
2024-07-13 21:52:41 -04:00
Gingeh
0979766fb7 LibWeb/CSS: Add tests for color functions
(cherry picked from commit e1c61d654f543f30a35b74b5d2cf2be3e6a79ed9)
2024-07-13 21:43:38 -04:00
Natsuki Ikeguchi
fceb6e021f LibWeb: Add initial implementation of global.reportError()
(cherry picked from commit ccb3a2f7add22105a92ca997b67bbe02ec65b535)
2024-07-13 21:40:50 -04:00
Aziz Berkay Yesilyurt
32f513fc1c LibWeb/HTML: Update Text Input Styling
So that it is closer to the spec.
https://www.w3.org/TR/css-ui-4/#input-rules

(cherry picked from commit 13cd653d1ccf9ef486f4622e350614361e275a0c)
2024-07-13 18:22:56 -04:00
Arthur Hartwig Carlsson
fd35cb2730 LibWeb: Don't insert out-of-flow elements into block pseudo elements
Like 1132c858e9, out-of-flow elements such
as float elements would get inserted into block level `::before` and
`::after` pseudo-element nodes when they should instead be inserted as a
sibling to the pseudo element. This change fixes that.

This fixes a few layout issues on the swedish tax agency website
(skatteverket.se). :^)

(cherry picked from commit 9ed2669fc801a3475c9f383ae7221b6a2b1a7fa5)
2024-07-13 18:22:38 -04:00
simonkrauter
f5c55abd78 LibWeb: Extend meter test
(cherry picked from commit cbc4832a53aad4a63b0e0d3aba2fe96fe771bad2)
2024-07-13 18:22:04 -04:00
Aliaksandr Kalenik
40a570e237 LibWeb+WebContent: Move scrollbar painting into WebContent
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.

Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
  corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.

After:
- Page's scrollbar is painted on WebContent side using the same style as
  currently used for elements with `overflow: scroll` and
  `overflow: auto`. A nice side effects: scrollbars are now painted for
  iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().

(cherry picked from commit 5285e22f2aa09152365179865f135e7bc5d254a5)

Co-authored-by: Jamie Mansfield <jmansfield@cadixdev.org>
Co-authored-by: Nico Weber <thakis@chromium.org>
2024-07-07 11:32:25 +02:00
Bastiaan van der Plaat
52023e38dc LibWeb/Geometry: Make DOMRect doubles unrestricted
(cherry picked from commit bff6c0680aff5862e05c68af03a653f2250328b4)
2024-07-01 23:03:47 +02:00
Tim Ledbetter
d9245bc5ac LibWeb: Implement the HTMLTrackElement.kind attribute
This reflects the HTML `kind` attribute.

(cherry picked from commit bdaa7f0e8ed738ad0bd6e19878f296436fe40377)
2024-07-01 12:45:34 +02:00
Andreas Kling
225108c830 LibWeb: Set the correct prototype for SVGAElement instances
(cherry picked from commit 4db05ecf69bee07a060f2e4513e9d53b6110dcc4)
2024-06-28 23:43:59 +02:00
Andreas Kling
bdf3071bd9 Tests/LibWeb: Add test that dumps all global JS constructors
(cherry picked from commit a84261ee7a5e0b76a03225d71ec64424d4865a78)
2024-06-28 23:43:59 +02:00