Commit Graph

59947 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
6fc59039c4 LibWeb: Skip cells layout in table box width calculation
There is no need to run full table layout if we are only interested in
calculating its width.

This change reduces compute_table_box_width_inside_table_wrapper()
from ~30% to ~15% in profiles of "File changed" pages on github.
2024-03-19 11:51:49 +01:00
Xexxa
541161d5e0 Base: Add more emoji
🏴󠁢󠁱󠁢󠁯󠁿 - U+1F3F4 U+E0062 U+E0071 U+E0062 U+E006F U+E007F
BQ-BO Bonaire
🏴󠁢󠁱󠁳󠁡󠁿 - U+1F3F4 U+E0062 U+E0071 U+E0073 U+E0061 U+E007F
BQ-SA Saba
🏴󠁢󠁱󠁳󠁥󠁿 - U+1F3F4 U+E0062 U+E0071 U+E0073 U+E0065 U+E007F
BQ-SE Sint Eustatius
🏴󠁫󠁲󠀱󠀱󠁿 - U+1F3F4 U+E006B U+E0072 U+E0031 U+E0031 U+E007F
KR-11 Seoul
🏴󠁫󠁲󠀲󠀹󠁿 - U+1F3F4 U+E006B U+E0072 U+E0032 U+E0039 U+E007F
KR-29 Gwangju City
🏴󠁫󠁲󠀳󠀰󠁿 - U+1F3F4 U+E006B U+E0072 U+E0033 U+E0030 U+E007F
KR-30 Daejeon
🏴󠁫󠁲󠀴󠀱󠁿 - U+1F3F4 U+E006B U+E0072 U+E0034 U+E0031 U+E007F
KR-41 Gyeonggi
🏴󠁫󠁲󠀴󠀴󠁿 - U+1F3F4 U+E006B U+E0072 U+E0034 U+E0034 U+E007F
KR-44 South Chungcheong
🏴󠁫󠁲󠀴󠀶󠁿 - U+1F3F4 U+E006B U+E0072 U+E0034 U+E0036 U+E007F
KR-46 South Jeolla
🏴󠁫󠁲󠀴󠀸󠁿 - U+1F3F4 U+E006B U+E0072 U+E0034 U+E0038 U+E007F
KR-48 South Gyeongsang
🏴󠁫󠁲󠀴󠀹󠁿 - U+1F3F4 U+E006B U+E0072 U+E0034 U+E0039 U+E007F
KR-49 Jeju
🏴󠁮󠁬󠁢󠁱󠀱󠁿 - U+1F3F4 U+E006E U+E006C U+E0062 U+E0071 U+E0031 U+E007F
NL-BQ1 Bonaire
🏴󠁮󠁬󠁢󠁱󠀲󠁿 - U+1F3F4 U+E006E U+E006C U+E0062 U+E0071 U+E0032 U+E007F
NL-BQ2 Saba
🏴󠁮󠁬󠁢󠁱󠀳󠁿 - U+1F3F4 U+E006E U+E006C U+E0062 U+E0071 U+E0033 U+E007F
NL-BQ3 Sint Eustatius
🏴󠁮󠁬󠁤󠁲󠁿 - U+1F3F4 U+E006E U+E006C U+E0064 U+E0072 U+E007F
NL-DR Drenthe
🏴󠁮󠁬󠁦󠁬󠁿 - U+1F3F4 U+E006E U+E006C U+E0066 U+E006C U+E007F
NL-FL Flevoland
🏴󠁮󠁬󠁦󠁲󠁿 - U+1F3F4 U+E006E U+E006C U+E0066 U+E0072 U+E007F
NL-FR Friesland
🏴󠁮󠁬󠁧󠁥󠁿 - U+1F3F4 U+E006E U+E006C U+E0067 U+E0065 U+E007F
NL-GE Gelderland
🏴󠁮󠁬󠁧󠁲󠁿 - U+1F3F4 U+E006E U+E006C U+E0067 U+E0072 U+E007F
NL-GR Groningen
🏴󠁮󠁬󠁬󠁩󠁿 - U+1F3F4 U+E006E U+E006C U+E006C U+E0069 U+E007F
NL-LI Limburg
🏴󠁮󠁬󠁮󠁢󠁿 - U+1F3F4 U+E006E U+E006C U+E006E U+E0062 U+E007F
NL-NB North Brabant
🏴󠁮󠁬󠁮󠁨󠁿 - U+1F3F4 U+E006E U+E006C U+E006E U+E0068 U+E007F
NL-NH North Holland
🏴󠁮󠁬󠁯󠁶󠁿 - U+1F3F4 U+E006E U+E006C U+E006F U+E0076 U+E007F
NL-OV Overijssel
🏴󠁮󠁬󠁵󠁴󠁿 - U+1F3F4 U+E006E U+E006C U+E0075 U+E0074 U+E007F
NL-UT Utrecht
🏴󠁮󠁬󠁺󠁥󠁿 - U+1F3F4 U+E006E U+E006C U+E007A U+E0065 U+E007F
NL-ZE Zeeland
🏴󠁮󠁬󠁺󠁨󠁿 - U+1F3F4 U+E006E U+E006C U+E007A U+E0068 U+E007F
NL-ZH South Holland
🏴󠁵󠁳󠁡󠁬󠁿 - U+1F3F4 U+E0075 U+E0073 U+E0061 U+E006C U+E007F
US-AL Alabama
🏴󠁵󠁳󠁡󠁺󠁿 - U+1F3F4 U+E0075 U+E0073 U+E0061 U+E007A U+E007F
US-AZ Arizona
🏴󠁵󠁳󠁴󠁸󠁿 - U+1F3F4 U+E0075 U+E0073 U+E0074 U+E0078 U+E007F
US-TX Texas
👨‍🔬 - U+1F468 U+200D U+1F52C MAN SCIENTIST
🧤 - U+1F9E4 GLOVES
🧥 - U+1F9E5 COAT
2024-03-19 06:51:04 -04:00
Andreas Kling
08a956f544 LibWeb: Ignore all pseudo element rules when matching non-pseudo element 2024-03-19 09:44:25 +01:00
Andreas Kling
4679dbc9df LibWeb: Make Element::inline_style() return specific declaration type
This removes a bunch of RTTI checks in StyleComputer.
2024-03-19 09:44:25 +01:00
Andreas Kling
25c22bb5e5 LibWeb: Reorder MatchingRule members to make it smaller
By packing the members more efficiently, it goes from 64 to 56 bytes.
2024-03-19 09:44:25 +01:00
Andreas Kling
963aa213c5 LibWeb: Avoid two calls to Selector::specificity() when sorting rules 2024-03-19 09:44:25 +01:00
Andreas Kling
22465e80fe LibWeb: Avoid FlyString copy when matching tag selector namespace URI 2024-03-19 09:44:25 +01:00
Aliaksandr Kalenik
e3e6af39bc LibWeb: Add basic implementation of has_a_rendering_opportunity()
Return true only if we are ready to repaint. This fixes the issue where
requestAnimationFrame() was invoked more than once between repaints.
2024-03-19 07:54:14 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Andreas Kling
21bfa001b1 LibWeb: Make StyleProperties::m_property_values a bit smaller
Instead of wrapping every entry in Optional, use the null state of the
style pointer for the same purpose.

This shrinks StyleProperties by 1752 bytes per instance.
2024-03-18 13:42:16 +01:00
Andreas Kling
7be0aed4b6 LibWeb: Keep StyleProperties animated properties in a HashMap
Instead of a gigantic array with space for every possible CSS property
being animated at the same time.

This shrinks StyleProperties by 3480 bytes per instance.
2024-03-18 13:42:16 +01:00
Andreas Kling
dd8504c68d LibWeb: Store "text for rendering" in TextPaintable
Instead of TextPaintable fragments being an offset+length view into the
layout node, they are now a view into the paintable instead.

This removes an awkward time window where we'd have bogus state in text
fragments after layout invalidation but before relayout. It also makes
the code slightly nicer in general, since there's less mixing of layout
and painting concepts.
2024-03-18 13:42:16 +01:00
Andreas Kling
2be47c3d7a LibWeb: Add fast_is<TextPaintable>() 2024-03-18 13:42:16 +01:00
Andreas Kling
1987318cc2 LibWeb: Move selection state from layout tree to paint tree
Where we paint the selection is obviously paint-related information,
so let's keep it in the paint tree.
2024-03-18 13:42:16 +01:00
Andreas Kling
d18a5b904d LibWeb: Remove unused LineBoxFragment member 2024-03-18 13:42:16 +01:00
Andreas Kling
9c5da0eed0 LibWeb: Remove unused PaintableFragment member 2024-03-18 13:42:16 +01:00
Andreas Kling
94e55768f6 LibWeb: Ensure layout is up-to-date before blinking the input cursor 2024-03-18 13:42:16 +01:00
Andreas Kling
a7d7c5b7b4 LibWeb: Don't force relayout after every keyboard input event
Instead, just rely on the invalidation and lazy relayout that happens as
a consequence of mutating the DOM.

This allows multiple keystrokes to coalesce into a single relayout if
necessary, dramatically improving performance when typing text into
form fields on complex pages.
2024-03-18 13:42:16 +01:00
Andreas Kling
c51a4cc007 LibWeb: Detach paintables from *all* DOM nodes before committing layout
Before this change, we were not detaching paintables from DOM nodes
within shadow subtrees.

This appears to be the main reason that keyboard editing was doing
immediate forced relayout: doing a full layout invalidation meant we'd
build a new layout tree, which then hid the problem with with
still-attached paintables.

By detaching them before committing a new layout, we make it possible
for keyboard editing to just use normal relayout, instead of full forced
invalidation & relayout.
2024-03-18 13:42:16 +01:00
Andreas Kling
a97e9f1d58 LibWeb: Don't mark CharacterData nodes for style update when changed
CharacterData nodes and their subclasses (most commonly Text) don't have
style, as style is specific to Elements. So there's no need to mark them
for a style update when their content is programmatically changed.
2024-03-18 13:42:16 +01:00
Tim Ledbetter
3a7a84f39b LibWeb: Limit progress element attribute values to the correct ranges
The max attribute is now clamped to ensure it is limited to positive
numbers and the value attribute is clamped to ensure it is non-negative.
2024-03-18 11:16:35 +01:00
Tim Ledbetter
ecbc686bc8 LibWeb: Allow progress element value to be set higher than the max value
Previously, we returned from the value setter if the specified value
was above the max value. This is not required, as the getter clamps the
returned value to the max value.
2024-03-18 11:16:35 +01:00
Tim Ledbetter
e795c24fdd LibWeb: Don't crash when modifying detached progress element attributes 2024-03-18 11:16:35 +01:00
MacDue
8057542dea LibGfx: Simplify path storage and tidy up APIs
Rather than make path segments virtual and refcounted let's store
`Gfx::Path`s as a list of `FloatPoints` and a separate list of commands.

This reduces the size of paths, for example, a `MoveTo` goes from 24
bytes to 9 bytes (one point + a single byte command), and removes a
layer of indirection when accessing segments. A nice little bonus is
transforming a path can now be done by applying the transform to all
points in the path (without looking at the commands).

Alongside this there's been a few minor API changes:

- `path.segments()` has been removed
  * All current uses could be replaced by a new `path.is_empty()` API
  * There's also now an iterator for looping over `Gfx::Path` segments
- `path.add_path(other_path)` has been removed
  * This was a duplicate of `path.append_path(other_path)`
- `path.ensure_subpath(point)` has been removed
  * Had one use and is equivalent to an `is_empty()` check + `move_to()`
- `path.close()` and `path.close_all_subpaths()` assume an implicit
  `moveto 0,0` if there's no `moveto` at the start of a path (for
  consistency with `path.segmentize_path()`).

Only the last point could change behaviour (though in LibWeb/SVGs all
paths start with a `moveto` as per the spec, it's only possible to
construct a path without a starting `moveto` via LibGfx APIs).
2024-03-18 07:09:37 +01:00
Space Meyer
14005f89a6 Meta: Correct gdb example in serenity.sh 2024-03-17 20:44:18 -06:00
Nico Weber
7650e657aa LibGfx/JBIG2: Implement support for TPGDON 2024-03-17 17:38:30 +01:00
Nico Weber
edec2b9baa Tests/LibGfx: Add a test jbig2 file using TPGDON
"TPGD" is short for "Typical Prediction for Generic Direct coding",
and the "ON" bit turns it on. In this mode, before decoding a line,
we decode a single bit first that controls if the current line is
just a copy of the previous line. If so, the line's pixels aren't
encoded, the decoder just copies the previous line.

I created this by running

    jbig2 -i Tests/LibGfx/test-inputs/bmp/bitmap -f bmp \
        -o bitmap -F jb2 -ini tpgdon.ini

where tpgdon.ini contained:

    -Gen -Seg 1
    -Gen -Param -TpGDon 1

See previous commits in this directory for details on the `jbig2` tool.

Sadly, the TPGDON writing path in `jbig2` wasn't implemented yet,
so I had to add this. See the PR that added this commit for my
local diff to `jbig2`.

I'm somewhat confident that my change to `jbig2` (and hence the
image added in this commit) is correct because:

1. `jbig2` succeeds in converting this file to a bmp file,
   while it failed without my patch (the decoding codepath in
   `jbig2` does have TPGDON support)

2. Other pdf viewers display the output of
   `Meta/jbig2_to_pdf.py -o foo.pdf path/to/bitmap-tpgdon.jbig2 399 400`
   the same way we do
2024-03-17 17:38:30 +01:00
Nico Weber
7d0e752590 Meta: Add a script that takes a JBIG2 file and writes a PDF embedding it
Most image viewers can't display JBIG2 files.
All PDF viewers can display JBIG2 files.

This is useful for checking that PDF viewers render JBIG2 files the
same way we do.
2024-03-17 17:38:30 +01:00
Kenneth Myhra
49d7719a04 LibWeb: Add and use serialize_enum() 2024-03-17 17:16:09 +01:00
Kenneth Myhra
94c6389fc0 LibWeb: Add {,de}serialization steps for DOMRect 2024-03-17 17:16:09 +01:00
Kenneth Myhra
9f5fa4f4a0 LibWeb: Add {,de}serialization steps for DOMRectReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
b7006b2423 LibWeb: Add {,de}serialization steps for DOMPoint 2024-03-17 17:16:09 +01:00
Kenneth Myhra
bf4fb39bfb LibWeb: Add {,de}serialization steps for DOMPointReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
8d2f7cfb58 LibWeb: Add {,de}serialization steps for DOMMatrix 2024-03-17 17:16:09 +01:00
Kenneth Myhra
181424377d LibWeb: Add {,de}serialization steps for DOMMatrixReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
57e7d6e989 LibWeb: Consolidate serialization of integral and floating point types
This consolidates serialization and deserialization of integral and
floating point types into two templated functions.
2024-03-17 17:16:09 +01:00
Bastiaan van der Plaat
4205ac778f LibWeb: Hide inner text of input element when showing placeholder 2024-03-17 10:20:36 -04:00
Bastiaan van der Plaat
b4bae912c9 LibWeb: Remove ByteString usage in input element placeholder_value() 2024-03-17 10:20:36 -04:00
Aliaksandr Kalenik
3fd1164171 LibWeb: Account for scroll offset in Element::get_client_rects() 2024-03-17 13:32:04 +01:00
Aliaksandr Kalenik
15524b97b6 LibWeb: Update paint-only props only when needed in get_client_rects()
There is no need to unconditionally resolve them whenever the function
is called.
2024-03-17 13:32:04 +01:00
Tim Ledbetter
e9383b9c86 LibWeb: Avoid division by zero when calculating SVG viewbox aspect ratio 2024-03-17 12:54:02 +01:00
Tim Ledbetter
b61aab66d9 LibWeb: Don't crash CPU painter if BorderRadiusSamplingConfig is invalid 2024-03-17 12:54:02 +01:00
Tim Ledbetter
a40c14462d LibWeb: Avoid division by zero when calculating scrollbar rect 2024-03-17 12:54:02 +01:00
Aliaksandr Kalenik
0afbd827e0 LibWeb: Skip page scrolling for wheel events consumed by scrollable box
Leftover from 90879a07ba
2024-03-17 09:33:16 +01:00
Timothy Flynn
a386ebde02 LibWeb: Do not return after ignoring a key event on an editable node
We do not want to blindly say we handled the key event. Otherwise, the
chrome is unable to handle shortcuts while an editable node is focused.
2024-03-17 09:32:37 +01:00
Timothy Flynn
4a476c3dd5 LibWeb: Ignore key presses when the OS super key is also pressed
Most shortcuts on macOS are activated with the super (command) key. For
now, we should ignore these like we ignore ctrl key modifiers.
2024-03-17 09:32:37 +01:00
MacDue
6c26ff567e LibGfx+LibWeb: Move HTML::CanvasPathClipper to Gfx::PathClipper
This does not depend on anything outside of LibGfx, and seems like it
may be useful elsewhere.

No behaviour change.
2024-03-17 09:30:53 +01:00
Timothy Flynn
a68b134e6d Meta: Do not place headless-browser and WebDriver in libexec
These are standalone applications meant to be run by the user directly,
as opposed to other libexec processes which are programmatically forked
by the browser. To do this, we simply remove these processes from the
`ladybird_helper_processes` list. We must also explicitly list the
dependencies for these processes.
2024-03-16 19:44:40 -04:00
Nico Weber
21917e7b1e LibPDF+PDFViewer+MacPDF: Don't draw hidden text by default
Text can be rendered in various ways in PDFs: Filled, stroked,
both filled and stroked, set as clipping path, hidden, or
some combinations thereof.

We don't implement any of this at the moment except "filled".

Hidden text is used in scanned documents: The image of the scan is
drawn in the background, and then OCRd text is "drawn" as hidden
on top of the scanned bitmap. That way, the (hidden) text can be
selected and copied, and it looks like you're selecting text from
the scanned bitmap. Find-in-page also works similarly. (We currently
have neither text selection nor find-in-page, but one day we will.)

Now that we have pretty good support for CCITT and are growing some
support for JBIG2, we now draw both the scanned background image
as well as the foreground text. They're not always perfectly aligned.

This change makes it so that we don't render text that's marked as
hidden. (We still do most of the coordinate math, which will probably
come in handy at some point when we implement text selection.)

This makes these scanned documents appear as they're supposed to
appear (at least in documents where we manage to decode the background
bitmap).

This also adds a debug option to force rendering of hidden text.
2024-03-16 13:10:48 -04:00
Andreas Kling
ead742886b LibWeb: Don't run HTMLImageElement timer when there is no animation
Before this change, we would wake up on every event loop iteration to
drive animations in single-frame images. This was a complete waste of
time and caused 100% CPU usage on our main GitHub repo page.

With this change, CPU usage is ~1% when idle on the same page. :^)
2024-03-16 16:35:54 +01:00