Commit graph

2226 commits

Author SHA1 Message Date
Aliaksandr Kalenik
e464d484c4 LibWeb: Implement getBoundingClientRect() for inline paintables
This fixes the issue that occurred when, after clicking an inline
paintable page would always scroll to the top. The problem was that
`scroll_an_element_into_view()` relies on `get_bounding_client_rect()`
to produce the correct scroll position and for inline paintables we
were always returning zero rect before this change.
2023-12-14 16:25:27 +01:00
Nicolas Ramz
cd6c7f3fc4 LibGfx/ILBMLoader: Add support for PC DeluxePaint files 2023-12-13 10:39:13 +00:00
stelar7
dd391d5e8c LibWeb: Add test for week_number_of_the_last_day microsyntax 2023-12-11 14:04:27 -07:00
Aliaksandr Kalenik
6b79508c08 LibWeb: Use offset of nearest scrollable ancestor for positioned boxes
Because positioned descendants are painted out-of-order we need to
separately apply offset of nearest scrollable box for them.

Fixes https://github.com/SerenityOS/serenity/issues/20554
2023-12-11 20:37:05 +01:00
Shannon Booth
ed97946975 LibWeb: Support obsolete but required -webkit- CSS parsing quirk
As outlined in: https://www.w3.org/TR/selectors-4/#compat

We now do not treat unknown webkit pseudo-elements as invalid at parse
time, and also support serializing these elements.

Fixes: #21959
2023-12-11 16:54:59 +01:00
Shannon Booth
74284abcba LibWeb/Tests: Rename css-attr-ref.html reference to text-div.html
This is currently only used by CSS attr ref tests, but is useful outside
of attr ref tests as well. Give a more generic name to this ref file for
this usage.
2023-12-11 16:54:59 +01:00
Andreas Kling
6994ea5885 LibWeb: Skip out-of-flow boxes when wrapping inlines in anonymous block
Out-of-flow boxes (floating and absolutely-positioned elements) were
previously collected and put in the anonymous block wrapper as well, but
this actually made hit testing not able to find them, since they were
breaking expectations about tree structure that hit testing relies on.

After this change, we simply let out-of-flow boxes stay in their
original parent, preserving the author's intended box tree structure.
2023-12-11 13:19:12 +01:00
Bastiaan van der Plaat
d025d207d9 LibWeb: Hide input placeholder when input already has a value 2023-12-10 20:56:19 +01:00
Aliaksandr Kalenik
df57d7ca68 LibGfx+LibWeb: Update for_each_glyph_position to use font cascade list
This change updates function that builds list of glyphs to use font
cascade list to find font for each code point.
2023-12-10 17:32:04 +01:00
Kyle Pereira
60c7ff9db1 Tests: Add a test for LibPDF pattern rendering
This is based largely on Adobe's EXAMPLE 2 on p176 of the specification,
manually edited slightly and then cleaned up with mutool.

https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf
2023-12-10 16:44:24 +01:00
Bastiaan van der Plaat
f621dc464b LibWeb: Add internal use_pseudo_element to DOM Element 2023-12-10 16:44:12 +01:00
Andreas Kling
cfe9577b48 LibWeb: Bring HTMLElement.offset{Left,Top,Parent} closer to spec
(Or rather, bring offsetLeft and offsetTop closer to spec, and implement
the previously-missing offsetParent)

This makes mouse inputs on https://nerget.com/fluidSim/ work properly.
2023-12-10 16:30:21 +01:00
Bastiaan van der Plaat
ea04a86715 LibWeb: Add fieldset elements property 2023-12-10 08:07:41 -05:00
Simon Wanner
5bcb019106 LibUnicode: Add IDNA::to_ascii
This implements the ToASCII operation of Unicode Technical Standard 46
2023-12-10 08:04:58 -05:00
Simon Wanner
cfd0a60863 LibUnicode: Add Punycode::encode 2023-12-10 08:04:58 -05:00
Simon Wanner
299d35aadc LibUnicode: Add Punycode::decode 2023-12-10 08:04:58 -05:00
Andreas Kling
7abb182fa3 LibWeb: Honor negative margins on atomic inlines
Sizing already worked correctly, but before this change, we were too
aggressive with inserting line breaks when negative margins would
still an atomic inline to fit on the line.
2023-12-10 11:09:22 +01:00
Bastiaan van der Plaat
466153e680 Ladybird+LibWeb: Add basic select element support 2023-12-09 22:06:20 +01:00
Andrew Kaster
512624f31a LibWeb: Add a basic MessageChannel test 2023-12-09 21:52:28 +01:00
Bastiaan van der Plaat
fef7571931 LibWeb: Add output element value 2023-12-09 21:50:17 +01:00
Bastiaan van der Plaat
f8509e2183 LibWeb: Add input number up down UI buttons 2023-12-09 21:49:38 +01:00
Lucas CHOLLET
234d084876 LibGfx/TIFF: Add support for bit-depth up to 32 bits per sample
This makes us support every "minisblack" and "rgb-contig" images from
the depth folder of libtiff's test suite:
https://libtiff.gitlab.io/libtiff/images.html
2023-12-09 21:47:33 +01:00
Lucas CHOLLET
25993cd93b Tests: Use TRY_OR_FAIL instead of MUST in TestImageDecoder.cpp
No need to panic the executable on a test failure.
2023-12-09 19:05:45 +01:00
Bastiaan van der Plaat
1b9a961fb0 LibWeb: Add input stepUp and stepDown functions 2023-12-07 16:46:28 -05:00
Andrew Kaster
39c4a5e948 LibWeb: Add config file for LibWeb tests that skips Worker-echo.html 2023-12-07 16:46:20 -05:00
Kemal Zebari
3a820ddbdf LibWeb/MimeSniff: Add sniffing in an audio or video context 2023-12-07 10:31:54 -07:00
Kemal Zebari
02ea85da2c LibWeb/MimeSniff: Add sniffing in an image context 2023-12-07 10:31:54 -07:00
Kemal Zebari
ea15501f37 LibWeb/MimeSniff: Add sniffing in a browsing context 2023-12-07 10:31:54 -07:00
Kemal Zebari
f6d3ea33fa LibWeb/MimeSniff: Add match an archive type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
d5e5a1138f LibWeb/MimeSniff: Add match an audio or video type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
62ca3b518b LibWeb/MimeSniff: Add the image type pattern matching algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
2babc08c17 LibWeb/MimeSniff: Add rules for identifying an unknown mime type
This also implements the pattern matching algorithm since it's
needed.
2023-12-07 10:31:54 -07:00
Kemal Zebari
04e19df06a LibWeb/MimeSniff: Implement Resource
See https://mimesniff.spec.whatwg.org/#resource
2023-12-07 10:31:54 -07:00
Dan Klishch
00928764e9 JSSpecCompiler: Add our first test :^) 2023-12-07 10:13:21 -07:00
Dan Klishch
107a3b44fa JSSpecCompiler: Add regression test runner 2023-12-07 10:13:21 -07:00
Nicolas Ramz
8d68f94282 LibGfx/ILBMLoader: Add HAM6/HAM8 support 2023-12-07 10:08:29 -07:00
Aliaksandr Kalenik
facdbe13c7 Tests/LibWeb: Add ref test for inline node styles
Turn Base/res/html/misc/inline-node.html into ref test.
2023-12-07 10:52:47 +01:00
Lucas CHOLLET
da134f6867 LibGfx/TIFF: Add support for grayscale images
Images with a single sample per pixel should be interpreted as
grayscale.
2023-12-07 08:17:46 +00:00
Sam Atkins
4c4daf4a62 LibWeb: Add tests for background-position
The css-backgrounds.html ref test file only tests the most basic usage
of this, which failed to catch some regressions, so let's add a more
extensive test. :^)
2023-12-05 09:55:16 +01:00
Aliaksandr Kalenik
b5f9c1d003 LibWeb: Use glyph run to represent text in PaintTextShadow command
Given that we have a glyph run where the position of each glyph is
calculated for text fragments during layout, we can reuse it to avoid
this work during painting.
2023-12-05 09:09:56 +01:00
Bastiaan van der Plaat
2107ab823d LibWeb: Add basic HTML meter element support 2023-12-04 19:54:43 +00:00
Timothy Flynn
965bd00cf3 LibWebView: Avoid trying to break a schemeless URL into renderable parts 2023-12-04 14:47:09 +00:00
Nico Weber
b2a1130556 LibGfx/ICC: Implement conversion between different connection spaces
If one profile uses PCSXYZ and the other PCSLAB as connection space,
we now do the necessary XYZ/LAB conversion.

With this and the previous commits, we can now convert from profiles
that use PCSLAB with mAB, such as stress.jpeg from
https://littlecms.com/blog/2020/09/09/browser-check/ :

    % Build/lagom/icc --name sRGB --reencode-to serenity-sRGB.icc
    % Build/lagom/bin/image -o out.png \
        --convert-to-color-profile serenity-sRGB.icc \
        ~/src/jpegfiles/stress.jpeg
2023-12-04 08:02:36 +00:00
Timothy Flynn
18a4455d43 LibWeb: Do not assume a shadow root has a host
After commit ff48b7333c, we remove shadow
roots from elements that are removed from the DOM. Setting a node's
shadow root to null also sets that shadow root's host to null. Thus, the
comment in Node::is_shadow_including_descendant_of that assumes the host
is always non-null is not true.

The test added here would previously crash when interacting with a node
that is a descendant of a removed shadow root.
2023-12-04 01:33:57 +01:00
Timothy Flynn
fd297a3248 LibWeb: Run the unfocusing steps when a click does not focus anything
For example, when clicking the document body outside of a focused input
element, we should unfocus that element.
2023-12-04 01:33:57 +01:00
Timothy Flynn
48240a6fc3 LibWeb: Focus the document element when unfocusing an element
Otherwise, the currently focused element remains focused.
2023-12-04 01:33:57 +01:00
Timothy Flynn
08ee48606d LibWeb: Fire a change event on input elements in the focus update steps
This ensures the change event is received before the blur event.
2023-12-04 01:33:57 +01:00
Timothy Flynn
301d58e2d9 LibWeb: Fire the change event synchronously when committing changes
The spec does not say to do this asynchronously on a task queue.
2023-12-04 01:33:57 +01:00
Idan Horowitz
b749167506 LibCompress: Fix off-by-one error in generate_huffman_lengths
Previously we would calculate the index of the first parent node as
heap.size() (which is initialized to non_zero_freqs), so in the edge
case in which all symbols had a non-zero frequency, we would use the
Size-index entry in the array for both the first symbol's leaf node,
and the first parent node.

The result would either be a non-optimal huffman code (bad), or an
illegal huffman code that would then go on to crash due to an error
check in CanonicalCode::from_bytes. (worse)

We now store parent nodes starting at heap.size() - 1, which eliminates
the potential overlap, and resolves the issue.
2023-12-04 00:06:38 +01:00
Andreas Kling
ec081a2ef5 LibWeb: Don't crash on FormData.append() with emoji in name
If you can believe it, we were once again using StringBuilder's append()
when we really wanted append_code_point().
2023-12-04 00:04:04 +01:00
Andreas Kling
0d74ced9b5 LibWeb: Don't crash on Document.createElement() with emoji in tag name
Once again, we were mistakenly using StringBuilder's append(char) when
we really wanted append_code_point(u32).
2023-12-04 00:04:04 +01:00
Andreas Kling
1b81e0081d LibWeb: Don't crash on Element.setAttribute() with emoji in name
We were mistakenly using StringBuilder's append(char) when we really
wanted append_code_point(u32).
2023-12-04 00:04:04 +01:00
Andreas Kling
dbca63a1db LibWeb: Don't get stuck in TreeWalker.nextNode() when current detached
This fixes a hang on https://reddit.com/

Spec bug: https://github.com/whatwg/dom/issues/1102
2023-12-03 23:16:26 +01:00
Andreas Kling
8b7d27b349 LibJS+LibWeb: More bringing module loading closer to spec
In particular, this patch removes three host hooks on JS::VM in favor
of the new JS-side module loading stuff.
2023-12-03 20:46:55 +01:00
Bastiaan van der Plaat
fb7b03d162 LibWeb: Add support for the input size attribute 2023-12-03 20:29:14 +01:00
Kenneth Myhra
d9fb116bcc Tests/LibWeb: Initialize Blob with string and read it from arrayBuffer() 2023-12-03 20:28:10 +01:00
Kenneth Myhra
b72489409a Tests/LibWeb: Initialize Blob with string and read it from text() 2023-12-03 20:28:10 +01:00
Shannon Booth
a8caa3edbc LibWeb/Tests: Add a test to cover byte stream enqueue and respond 2023-12-03 20:26:14 +01:00
Aliaksandr Kalenik
681771d210 LibGfx+LibWeb: Calculate and save glyph positions during layout
Previously, we determined the positions of glyphs for each text run at
the time of painting, which constituted a significant portion of the
painting process according to profiles. However, since we already go
through each glyph to figure out the width of each fragment during
layout, we can simultaneously gather data about the position of each
glyph in the layout phase and utilize this information in the painting
phase.

I had to update expectations for a couple of reference tests. These
updates are due to the fact that we now measure glyph positions during
layout using a 1x font, and then linearly scale each glyph's position
to device pixels during painting. This approach should be acceptable,
considering we measure a fragment's width and height with an unscaled
font during layout.
2023-12-02 22:06:11 +01:00
Tim Ledbetter
aa54007943 LibGfx/TinyVG: Avoid OOM if header contains a bogus color table size
This change limits the amount of memory that is initially allocated for
the color table. This prevents an OOM condition if the file contains an
incorrect color table size.
2023-12-02 10:47:39 +01:00
Lucas CHOLLET
4994609af0 LibGfx/TIFF: Add support for the ICCProfile tag 2023-12-02 10:36:02 +01:00
Kemal Zebari
24b9d05ea8 LibWeb/HTML: Implement text attribute in HTMLTitleElement 2023-12-02 10:35:43 +01:00
Timothy Flynn
7edfeb7056 LibWeb: Support committing changes to <input> elements
We currently fire the change event on <input> elements when they lose
focus. The spec allows for us to also fire the event when changes are
"committed", so long as such an action makes sense for the input type.

This patch detects when the return key is entered in an <input> element
and uses that as the commit action for text-related types. If no change
has occurred since the last commit, no change event is fired.
2023-12-02 10:34:22 +01:00
Tim Schumacher
cb03d3d78f AK: Allow rejecting BitStream reads beyond EOF 2023-12-01 12:48:18 +01:00
Tim Schumacher
270b1176de Tests: Add a test to codify BitStream behavior beyond stream limits 2023-12-01 12:48:18 +01:00
Sam Atkins
9c12112916 LibWeb: Re-enable the css-background-repeat.html ref test
Assuming that my changes to make iframes delay the load event are
correct, and that nothing else was causing the flakiness, this test
should be OK now! (Famous last words.)
2023-12-01 10:28:02 +01:00
Timothy Flynn
a7073c3f1f LibJS: Skip test262 tests with the CanBlockIsFalse flag
From test262 documentation, this flag means:

    The test file should only be run when the [[CanBlock]] property of
    the Agent Record executing the file is `false`.

This patch stubs out the accessor for that internal slot and skips tests
with the CanBlockIsFalse if that internal slot is true.
2023-11-30 09:51:46 -05:00
Timothy Flynn
ff48b7333c LibWeb: Remove shadow roots from elements that are removed from the DOM
We currently create a shadow tree once for each DOM element that renders
with a shadow tree (e.g. <input>, <details>). If such an element is
removed from the DOM, we must remove its shadow tree. Otherwise, the
shadow tree will refer to the old document in perpetuity.

If the node is added back to a DOM, then recreate the shadow tree.
2023-11-30 08:49:15 +00:00
Kenneth Myhra
e3f5bbcbbe Tests/LibWeb: Move existing XHR Text tests in under the XHR folder 2023-11-29 21:51:35 +01:00
Kenneth Myhra
3d86e16407 Tests/LibWeb: Verify instantiation behavior of Blob w/empty constructor
This verifies that a Blob instantiated with an empty constructor creates
a Blob with Blob.size equal to 0 and Blob.type equal to "".
2023-11-29 21:51:35 +01:00
Kenneth Myhra
36fddab68e Tests/LibWeb: Verify XHR.response is an instance of Blob
This verifies that XHR.response is an instance of Blob when
XHR.responseType is set to 'blob'.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
09487679eb Tests/LibWeb: Verify XHR.response is an instance of Document
This verifies that XHR.response is an instance of Document when
XHR.responseType is set to 'document' and the response contains HTML.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
990f73708d Tests/LibWeb: Verify XHR.response is an instance of ArrayBuffer
This verifies that XHR.response is an instance of ArrayBuffer when
XHR.responseType is set to 'arraybuffer'.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
68fa8f52b4 Tests/LibWeb: Verify XHR.open() throws on forbidden method
This verifies that XHR.open() throws a Security Error when 'CONNECT',
'TRACE', or 'TRACK' is passed as the method argument.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
eb6a7ccc59 Tests/LibWeb: Verify XHR.open() throws on illegal token in method arg
This verifies that XHR.open() throws a Syntax Error if an illegal token
is passed to the method argument.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
ff05f19c84 Tests/LibWeb: Verify XHR.send() throws when called twice
This verifies that XHR.send() throws an Invalid State Error when called
twice.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
ac82585ae7 Tests/LibWeb: Verify XHR.send() throws when XHR.readyState is UNSENT
This verifies that an Invalid State Error is being thrown when
XHR.open() has not been called before calling XHR::send().
2023-11-29 21:51:35 +01:00
Shannon Booth
d777b279e3 LibUnicode+Tests: Remove now unused to_unicode_*_full methods
Relocating all of the tests for these in LibUnicode over to the AK
String testsuite.
2023-11-28 17:15:27 -05:00
Timothy Flynn
6aa334767f AK: Ensure assigned-to Strings are dereferenced if needed
If we assign to an existing non-short string, we must dereference its
StringData object to prevent leaking that data.
2023-11-28 16:38:18 +01:00
Michiel Visser
bc9cdd4394 LibCrypto+LibTLS: Switch to the generic SECPxxxr1 implementation 2023-11-27 09:43:07 +03:30
Michiel Visser
59c22c0349 Tests/LibCrypto: Add tests for SECP384r1 curve 2023-11-27 09:43:07 +03:30
Aliaksandr Kalenik
afe24883b7 LibWeb: Remove exit for javascript urls in anchor activation_behavior()
This early return is no longer needed because Navigable::navigate()
can process `javascript:` urls.

Fixes https://github.com/SerenityOS/serenity/issues/22052
2023-11-25 16:33:54 +01:00
Shannon Booth
673329e1bd LibWeb: Use ArrayBufferView for ReadableStreamBYOBReader
Which means that we now have support for DataViews.

Using the ArrayBufferView class also seems to make this read a whole
bunch nicer as well.
2023-11-24 08:43:35 +01:00
timmot
9f2ee86e4d Tests/LibWeb: Test canvas fillStyle parsing of rgb strings 2023-11-24 08:42:18 +01:00
Andrew Kaster
1602663b9e LibWeb+WebWorker: Implement a first cut of post_message for Workers
This implementation completely ignores MessagePorts, and manually plumbs
data through LocalSockets.
2023-11-24 08:41:38 +01:00
Andrew Kaster
79fa892ca1 Tests: Add stub for the internals object when not running in test mode
This allows developers to open LibWeb test html files in Ladybird or in
other browsers to observe their behavior without the internals object.
2023-11-24 08:41:38 +01:00
Timothy Flynn
b5162ceabd LibWeb: Remove special handling of disclosure-open/closed markers
Setting the marker's content width here is causing the text that follows
the marker to be indented a bit too much. This is noticeable when a line
with a disclosure marker is followed by a line with any other marker. It
previously would look something like:

    >    Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker

Now the disclosure marker line matches other marker types:

    > Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker
2023-11-24 08:37:19 +01:00
Martin Janiczek
58d0577a02 AK: Fix bugs in Complex += -= + - * / operators
There were two issues:

1) the C+=R and C-=R operators expected arithmetic types to have .real()

2) the R+C, R-C, R*C and R/C operators applied the operation in wrong
   order (did C+R, C-R, C*R and C/R instead). This wouldn't matter for
   + and * which are commutative, but is incorrect for - and /.
2023-11-23 19:54:39 -05:00
Sam Atkins
8fe38f04a3 LibWeb: Skip flakey ref test for now
We currently do not wait for iframes to finish loading before triggering
the document's load event, which creates a race condition for any ref
tests that include iframes. Until that gets fixed, let's skip the one
affected test.

See issue #22012.
2023-11-23 18:50:58 +00:00
Shannon Booth
decc071060 LibWeb: Return a scroll offset of 0 for colgroup elements
Ideally we would not create a layout node at all for these elements so
that every layout node would always have a paintable associated with it.
But for now, to fix the crash, just leave a FIXME and special case this
element.

Also leave a VERIFY to make it easier to debug this type of crash in the
future.

Fixes a crash seen on codecov.io for my 'patch' project.
2023-11-23 13:06:48 +01:00
Andreas Kling
ef809eea1e LibWeb: Don't assume IO.unobserve() called on observed element
It's perfectly possible for JavaScript to call unobserve() on an element
that hasn't been observed. Let's stop asserting if that happens. :^)

Fixes #22020
2023-11-23 09:37:12 +01:00
Nico Weber
57e2b5ef59 LibPDF+Tests: Correctly decode text strings without explicit encoding 2023-11-22 09:08:06 -07:00
Nico Weber
8ee0c75f43 LibPDF: Add (automated!) test for outline encoding
Manually added an Outlines dict with three items, one each for
every text string encoding in its title.

(Preview.app apparently can't handle UTF-8 in outlines either.)
2023-11-22 09:08:06 -07:00
Nico Weber
d345c5b793 LibPDF: Add (automated!) test for info dict encoding
Manually added an info dict with the three text string encoding
methods to encoding.pdf.

(Preview.app apparently can't handle UTF-8 in info dicts!)
2023-11-22 09:08:06 -07:00
Nico Weber
65b895595a LibPDF: Add an encoding test file
For now, this uses UTF-16BE and UTF-8 marked strings in page body text.
These markings should be ignored in body text.

Hand-written, with `set fenc=latin1` and `set binary` in vim, and
xref etc fixed up by running

    mutool clean Tests/LibPDF/encoding.pdf  Tests/LibPDF/encoding.pdf

as usual.
2023-11-22 09:08:06 -07:00
Nico Weber
4c6afd4763 Tests: Install recently added PDF test files
These aren't needed for any automated tests, but it's still nice to have
them in the OS for manual testing.
2023-11-22 09:08:06 -07:00
Sam Atkins
6cd6186399 LibWeb: Don't assume grid size is always Function or Token
This stops `grid-template-columns: minmax({},{})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
1a17b8a304 LibWeb: Don't assume grid-area parts are Tokens
This stops `grid-area: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
ab9d39bf4a LibWeb: Don't assume grid-row/grid-column parts are Tokens
This stops `grid-column: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
314a30b12e LibWeb: Don't assume grid-line parts are Tokens
This stops `grid-row-start: {}` from crashing.

Also tidy up the parsing code a little.
2023-11-22 09:45:51 +01:00