Commit graph

56638 commits

Author SHA1 Message Date
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
Timothy Flynn
16ac2089e3 Meta: Port recent changes to GN build
4ab2903e25
70353b79af
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
Karol Kosek
963a6b3d3d LibAudio: Speed up WavWriter by buffering output data
We were calling write syscall twice for every sample, which effectively
hurt the writer's performance.

With this change exporting a melody in the Piano app now takes less than
a second, which previously took about 20 seconds on my machine.

Additionally, I've removed an unused `WavWriter::file()` getter.
2023-11-23 18:05:22 -05:00
Andrew Kaster
fbf87299a2 LibWeb: Align choose a navigable AO closer to the spec
This will make window.open a lot easier to implement. As written, the
implementation of Navigable::choose_a_navigable now looks a lot closer
to the old BrowsingContext::choose_a_browsing_context. With the notable
exception that we still crash in many cases, and don't properly handle
multiple top-level traversables in the same WebContent process.
2023-11-23 21:32:45 +01:00
Andrew Kaster
18fc3a1e26 LibWeb: Update window.open to match the current spec steps 2023-11-23 21:32:45 +01: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
Nico Weber
eb1c99bd72 LibPDF+LibGfx: Make SMasks on jpeg images work
SMasks are greyscale images that get used as alpha channel for a
different image.

JPEGs in PDFs are stored as streams with /DCTDecode filters, and
we have a separate code path for loading those in the PDF renderer.
That code path just calls our JPEG decoder, which creates bitmaps
with format BGRx8888.

So when we process an SMask for such a bitmap, we have to change
the bitmap's format to BGRA8888 in addition to setting alpha values
on all pixels.
2023-11-23 12:13:03 +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
Andreas Kling
21d9da0f3b LibWeb: Unregister IntersectionObserver from registration document
Before this change, there was some confusion possible where an IO would
try to find its way back to the document where we registered it.
This led to an assertion failure in the test I'm adding in the next
commit, so let's fix this first.

IOs now (weakly) remember the document where they are registered, and
only unregister from there.
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
8f47acee6a LibTextCodec: Add PDFDocEncoding decoder 2023-11-22 09:08:06 -07:00
Nico Weber
e39a790c82 LibPDF: Stop converting encodings in object parser
Per 1.7 spec 3.8.1, there are multiple logical text string types:
* text strings
* ASCII strings
* byte strings

Text strings can be in UTF-16BE, PDFDocEncoding, or (since PDF 2.0)
UTF-8.

But byte strings shouldn't be converted but treated as binary
data.

This makes us no longer convert strings used for drawing page text.
TABLE 5.6 "Text-showing operators" lists the operands for text-showing
operators as just "string", not "text string" (even though these strings
confusingly are called "text strings" in the body text), so not doing
this there is correct (and matches other viewers).

We also no longer incorrectly convert strings used for cypto data
(such as passwords), if they start with an UTF-16BE or UTF-8 marker.

No behavior change for outlines and info dict entries.

https://pdfa.org/understanding-utf-8-in-pdf-2-0/ has a good overview of
this.

(ASCII strings only contain ASCII characters and behave the same
anyways.)
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
Nico Weber
14bcb5219d LibPDF: Tolerate comments before drawing operators
Necessary to be able to render
https://github.com/pdf-association/pdf20examples/blob/master/pdf20-utf8-test.pdf
2023-11-22 08:56:43 +00:00
Nico Weber
9e8cf4fc1a LibPDF: Tolerate comment after last dict item
Necessary to be able to open
https://github.com/pdf-association/pdf20examples/blob/master/pdf20-utf8-test.pdf
2023-11-22 08:56:43 +00:00
Nicole
7ca4e4a967 Base: Add some emojis
Adds:
U+1F390 fully-qualified     # 🎐 E0.6 wind chime
U+1F54D fully-qualified     # 🕍 E1.0 synagogue
U+1F54B fully-qualified     # 🕋 E1.0 kaaba
U+1F95C fully-qualified     # 🥜 E3.0 peanuts
U+1F3E6 fully-qualified     # 🏦 E0.6 bank
U+1F690 fully-qualified     # 🚐 E1.0 minibus
2023-11-22 08:52:58 +00:00
Sam Atkins
f69d38a346 LibWeb: Use ComponentValue::is_ident("..."sv) helper 2023-11-22 09:45:51 +01: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
Sam Atkins
1f6e13d8fe LibWeb: Don't assume repeat() contents are Tokens
This stops `grid-template-rows: repeat({})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
5e54ff1858 LibWeb: Don't assume rect() contents are Tokens
This stops `clip: rect({});` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
aba2946b1e LibWeb: Use ComponentValue::is_function("..."sv) helper 2023-11-22 09:45:51 +01:00
Xexxa
bd8b907f53 Base: Adjust emoji
🏂 - U+1F3C2 SNOWBOARDER
Reuse snow colour from U+1F3BF.

🍨 - U+1F368 ICE CREAM
Reuse ice cream colour from U+1F366.

🧨 - U+1F9E8 FIRECRACKER
Make the lit fuse reflect on the firecracker.

🤖 - U+1F916 ROBOT
🗑️ - U+1F5D1 WASTEBASKET
Make shadow more symmetrical.

💂 - U+1F482 GUARD
💂‍♂️ - U+1F482 U+200D U+2642 MAN GUARD
💂‍♀️ - U+1F482 U+200D U+2640 WOMAN GUARD
👸 - U+1F478 PRINCESS
Make colors more consistent with U+1F468_U+200D_U+1F9B1.

🐳 - U+1F433 SPOUTING WHALE
Reuse water colour from U+1F3C4_U+200D_U+2642, adjust foam color to
not be #FFFFFF.

🪿 - U+1FABF GOOSE
🍊 - U+1F34A TANGERINE
🍋 - U+1F34B LEMON
🍎 - U+1F34E RED APPLE
🍏 - U+1F34F GREEN APPLE
🎨 - U+1F3A8 ARTIST PALETTE
Add shadow.

🍐 - U+1F350 PEAR
Add shadow, remove unnecessary padding.

🕯️ - U+1F56F CANDLE
Make flame reflect on the candle, remove unnecessary padding.

🐣 - U+1F423 HATCHING CHICK
🍶 - U+1F376 SAKE
💺 - U+1F4BA SEAT
🖍️ - U+1F58D CRAYON
Remove unnecessary padding.
2023-11-21 20:16:06 -05:00
Aliaksandr Kalenik
d9990c6ea9 LibWeb: Remove opacity parameter for DrawScaledBitmap painting command
Every usage of this command specifies opacity equal to 1.
2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
a5cf875e23 LibWeb: Fix typo in FillEllipse painting command name 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
790bfd7ef9 LibAccelGfx: Skip glyphs with missing bitmaps
Fixes crashing when we can't produce a bitmap for a glyph.
2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
48faa0e706 LibAccelGfx: Ensure capacity of vertices vector in draw_glyph_run() 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
2471f07356 LibWeb: Skip painting of empty borders in GPU painter 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
01058dac95 LibWeb: Skip execution of painting commands with empty bounding rect 2023-11-21 17:00:56 +01:00
implicitfield
00c1da8cbc LibWeb: Support cellpadding attribute on table elements 2023-11-21 16:54:02 +01:00
implicitfield
3d1fbcb26b LibWeb: Support valign attribute on tr elements 2023-11-21 16:54:02 +01:00
implicitfield
468b2a5ace LibWeb: Support size attribute on font elements 2023-11-21 16:54:02 +01:00
implicitfield
5df52a5082 LibWeb: Use LibwebLeft and LibwebRight to align table cells 2023-11-21 16:54:02 +01:00
implicitfield
ccea69ad40 LibWeb: Add special handling for text-align when applied to tables
This matches what other engines do, and stops table content from being
misaligned.
2023-11-21 16:54:02 +01:00
implicitfield
a54e62bea0 LibWeb: Support align attribute on table elements 2023-11-21 16:54:02 +01:00
implicitfield
7a766bdb83 LibWeb: Respect the document's link_color for Linktext identifiers 2023-11-21 16:54:02 +01:00
Nico Weber
ec190baa55 MacPDF: Replace newlines with spaces in outline titles
Else, outline items that have newlines in them end up with a weird
vertical offset.

(This does affect the outline item's tooltip, which shows the whole
title. But not having a newline there seems alright, arguably
preferable.)
2023-11-21 10:07:41 +01:00
Nico Weber
e13954410a MacPDF: Show tooltip with full title on elided outline titles 2023-11-21 10:07:41 +01:00
Nico Weber
fac0a456e6 MacPDF: Use correct encoding for outline titles
The title of an OutlineItem is already in UTF-8.

This is currently done in LibPDF's Parser::parse_string(). I think
that's not quite the right place (it shouldn't be done for all strings)
and not done quite right (text strings should convert from
PDFDocEncoding to UTF-8 unless prefixed by an UTF-8 BOM), but even if
that changes, I think we'll keep OutlineItem.title in UTF-8.
2023-11-21 10:07:41 +01:00
Sam Atkins
148f873321 LibWeb: Merge background-position parsing into position code
Implemented by adding the extra 3-value syntax as its own case and only
running it when parsing background-position. I'm sure it could be
implemented in a smarter way but this is still a bunch less code than
before. :^)
2023-11-21 01:29:26 +01:00
Sam Atkins
26d6ba6f58 LibWeb: Parse the CSS position type automatically
This means `object-position` will no longer incorrectly accept the
3-value background-position syntax.

Remove the now-ambiguous and unused `position` enum while we're at it.
(This enum only existed as a hack.)
2023-11-21 01:29:26 +01:00
Sam Atkins
19da17f07e LibWeb: Allow calc() in CSS position values 2023-11-21 01:29:26 +01:00
Aliaksandr Kalenik
1b0cc67a28 LibAccelGfx+LibWeb: Add basic push/pop stacking context implementation
With basic PushStackingContext and PopStackingContext commands
implementation scrolling works again after changes being made in:
4e04f81626
2023-11-20 23:44:19 +01:00