Commit graph

24800 commits

Author SHA1 Message Date
Andreas Kling
590723aa3b LibWeb: Implement the "The html element fills the viewport quirk"
Fixes #18037.
2023-05-03 20:44:30 +02:00
Andreas Kling
508927cae2 LibWeb: Take floats into account when measuring automatic width of IFC
When there are floats present inside an IFC, we must coordinate with
the parent BFC to calculate the automatic width of the IFC's block box.
This is because the IFC is not directly aware of floats. Only the BFC
knows enough about them to account for them in automatic sizing.
2023-05-03 19:49:43 +02:00
Andreas Kling
610a7603a2 LibWeb: Implement more box type transformation edge cases
In particular, we now blockify layout internal boxes (e.g table parts)
by turning them into `block flow`. This fixes a crash when viewing
our GitHub repo :^)
2023-05-03 16:04:30 +02:00
Nico Weber
9c3e36e72c ICC: Implement TRC inversion in from_pcs for point curves
This allows converting to a color space that uses a non-parametric
curve, for example:

    Build/lagom/image -o foo.png \
        --convert-to-color-profile .../profiles/sRGB-v2-micro.icc \
        input.jpg

...where profiles/sRGB-v2-micro.icc is from
https://github.com/saucecontrol/Compact-ICC-Profiles/

(Parametric curves are new in ICC v4, which means all v2 profiles
use point curves.)
2023-05-03 15:05:13 +02:00
Nico Weber
926c0d8676 ICC+image: Add conversion between color spaces for images :^)
For now, only for color spaces that are supported by Profile::to_pcs()
and Profile::from_pcs(), which currently means that all matrix profiles
(but not LUT profiles) in the source color space work, and that
matrix profiles with parametric curves in the destination color
space work.

This adds Profile::convert_image(Bitmap, source_profile), and
adds a `--convert-to-color-profile file.icc` flag to `image`.

It only takes a file path, so to use it with the built-in
sRGB profile, you have to write it to a file first:

% Build/lagom/icc -n sRGB --reencode-to serenity-sRGB.icc

`image` by default writes the source image's color profile
to the output image, and most image viewers display images
looking at the profile.

For example, take `Seven_Coloured_Pencils_(rg-switch_sRGB).jpg`
from https://commons.wikimedia.org/wiki/User:Colin/BrowserTest.

It looks normal in image viewers because they apply the unusual
profile embedded in the profile. But if you run

% Build/lagom/image -o huh.png --strip-color-profile \
    'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'

and then look at huh.png, you can see how the image's colors
look like when interpreted as sRGB (which is the color space
PNG data is in if the PNG doesn't store an embedded profile).

If you now run

% Build/lagom/image -o wow.png \
    --convert-to-color-profile serenity-sRGB.icc --strip-color-profile \
    'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'

this will convert that image to sRGB, but then not write
the profile to the output image (verify with `Build/lagom/icc wow.png`).
It will look correct in image viewers, since they display PNGs without
an embedded color profile as sRGB.

(This works because 'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'
contains a matrix profile, and Serenity's built-in sRGB profile
uses a matrix profile with a parametric curve.)
2023-05-03 15:05:13 +02:00
Aliaksandr Kalenik
09d698e0a0 LibWeb: Exclude table-wrapper margins from table available width
Table should not take up more width than is available inside wrapper
after margins are taken in account.
2023-05-03 15:03:56 +02:00
Aliaksandr Kalenik
4d971b5bc5 LibWeb: Use appropriate containing block width to get width of table
This solves the issue that previously width table-wrapper containing
block were used in the places were containing block of table-root
should be used.
2023-05-03 15:03:56 +02:00
Andreas Kling
da768e7c46 LibWeb: Don't crash on unresolvable line-height: calc() value
Instead, log the calc() value we failed to resolve, so we can debug it.
2023-05-03 13:59:05 +02:00
Andreas Kling
968db96101 LibWeb: Show formatting context roots in layout tree dumps
This patch does three things:

- Factors out the code that determines whether a box will create a new
  formatting context for its children (and which type of context)

- Uses that code to mark all formatting context roots in layout tree
  dumps. This makes it much easier to follow along with layout since
  you can now see exactly where control is transferred to a new
  formatting context.

- Rebaselines all existing layout tests, since the output format has
  changed slightly.
2023-05-03 13:14:36 +02:00
Joel Petersson
42e118e6a9 AudioServer: Dequeue all buffers when clearing a ClientAudioStream
Previously we would exit the dequeuing loop after just one buffer
had been dequeued due to some bogus logic. This would manifest
when stopping and starting a track in SoundPlayer, where a few
miliseconds of 'old' audio would play when restarting the playback.

This commit makes sure we clear the entire queue.
2023-05-03 10:01:14 +02:00
Joel Petersson
23bc306f99 SoundPlayer: Clear client buffer when playback is stopped
Previously we would not clear the client buffer of the
ConnectionToServer when playback was stopped. This would
cause old samples to be buffered and played when playback
was restarted.

With this commit we now perform this clearing of the client
buffer correctly.
2023-05-03 10:01:14 +02:00
PrestonLTaylor
5563ebab5a profile: Prevent crash when -p is supplied a non-integer value
Instead of crashing we give a helpful warning message to the user.

This also removes a fixme! :^)
2023-05-03 09:57:43 +02:00
PrestonLTaylor
6811ab9c3b profile: Add -a to warning message when -e, -d, -w xor -f is not set
-a and -p both require only one of the flags.
We will inform the user of this for both -a and -p <PID>.
2023-05-03 09:57:43 +02:00
Aliaksandr Kalenik
e1c1aaa956 LibWeb: Implement "create navigation params from a srcdoc resource"
Implements:
https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-from-a-srcdoc-resource

This is supporting function for populating document in session history
entry.

This function populates navigation params response with HTML text
passed in document resource.
2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
c235ee380f LibWeb: Implement "create navigation params by fetching"
Implements:
https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching

This is supporting function for population of document in a session
history entry.

This function populates response in navigation params by fetching url
in navigation params and handling redirects if required.
2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
de2c016556 LibWeb: Implement "attempt to populate the history entry's document"
Implements:
https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document

This is going to be a replacement for `FrameLoader::load()` after
switching to navigables.

Brief description of `populate_session_history_entry_document`:
- If navigation params have url with fetch scheme then DOM document
  will be populated by fetching url and parsing response. This
  is going to be a replacement for `FrameLoader::load(AK::URL&)`.
- If url in navigation params is abort:srcdoc then DOM document
  will be populated by parsing HTML text passed in document resource.
  This is going to be a replacement for `FrameLoader::load_html()`
2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
804af38a96 LibWeb: Move document loading into separate file
In upcoming navigables refactor new function that uses fetch
instead of ResourceLoader to load document content is going to be
introduced:
https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching

`parse_document()` need to be separated from FrameLoader to reuse
code responsible for parsing HTTP response into DOM document.
2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
60a26077a7 LibWeb: Reuse ReferrerType from Fetch in HTML::DocumentState 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
a27a30898c LibWeb: Add fetch_controller property in HTML::NavigationParams 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
38a2d5ead3 LibWeb: Add navigable property in NavigationParams 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
0c919718ae LibWeb: Change id to be optional in HTML::NavigationParams 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
71b7a929db LibWeb: Fix typo in HTML::DocumentState
ever_navigable_target_name -> navigable_target_name
2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
f738a166f2 LibWeb: Add resource property in DocumentState 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
bccc687175 LibWeb: Add request_body property in HTML::POSTResource 2023-05-03 09:39:49 +02:00
Aliaksandr Kalenik
8be3de665b LibWeb: Introduce SourceSnapshotParams 2023-05-03 09:39:49 +02:00
Caoimhe
2adcf85d9d HexEditor: Remember all of the layout options in the configuration 2023-05-03 08:33:11 +01:00
Tim Ledbetter
336eae219b Chess: Spawn new engine process immediately after engine is selected
A new engine process is now started immediately, rather than waiting
until a move needs to be made.

This means that if the engine is playing as black, it can start up
while the human player is making a move. This is noticable with
stockfish, which can be slow to start up.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
79a204a56a Chess: Allow stockfish to be used if available
The stockfish chess engine can now be selected from the engine menu if
the port has been installed.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
56dde3df54 LibChess+ChessEngine: Don't crash on error when reading UCI commands
ChessEngine and the chess GUI will no longer crash on error while
reading UCI commands. ChessEngine will print a message to the standard
output, while the GUI will ignore unknown commands. Both will print
the error to the debug log if the UCI_DEBUG flag is enabled.

Trailing and preceding whitespace is now stripped from commands before
they are parsed. Commands which are just whitespace no longer produce
errors.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
25778d07e9 LibChess: Add optional ponder move to the BestMove command
The BestMove command can now include an optional ponder token, with
the move that the engine would like to ponder on.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
c885df98da LibChess: Flesh out InfoCommand implementation
UCI info commands can now be received and parsed. All info types from
the UCI specification are supported.

The info command is not currently used by our engine or GUI, but the GUI
can now receive an info command from a 3rd party engine without
complaining.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
77f3e9710b LibChess: Use the correct command type for InfoCommand 2023-05-03 08:31:34 +01:00
Emil Militzer
fe40a7b664 LibWeb: Only change inside value during blockification 2023-05-02 20:27:28 +02:00
Emil Militzer
31e1be0438 LibWeb: Support multi-keyword syntax for CSS display property
The Display class already supported all specific values, and now they
will be parsed too. The display property now has a special type
DisplayStyleValue.
2023-05-02 20:27:28 +02:00
Emil Militzer
81c11bc6f2 LibWeb: Expose list_item value in CSS display 2023-05-02 20:27:28 +02:00
Emil Militzer
b74940ffb7 LibWeb: Set max-values for display CSS property 2023-05-02 20:27:28 +02:00
Emil Militzer
3f7a37465d LibWeb: Add missing inline-grid for display CSS property 2023-05-02 20:27:28 +02:00
Aliaksandr Kalenik
f6ff37398c LibWeb: Fix intrinsic sizing when min or max width is specified
Fixes the problem that width is incorrectly computed in intrinsic
sizing mode when there are blocks that have min-width or max-width
specified.

Actually that is just the fix of a symptom of the larger problem that
Length::to_px() returns 0 when value is auto regardless of available
size.
2023-05-02 18:50:26 +02:00
Nico Weber
9bd35fda56 ICC: Implement TRC inversion in from_pcs for parametric curves 2023-05-02 17:15:48 +01:00
Nico Weber
4169c94ebe ICC: Implement some of Profile::from_pcs()
This implements conversion from profile connection space to the
device-dependent color for matrix-based profiles.

It only does the inverse color transform but does not yet do the
inverse tone reproduction curve transform -- i.e. it doesn't
implement many cases (LUT transforms), and it does the one thing
it does implement incorrectly. But to vindicate the commit a bit,
it also does the incorrect thing very inefficiently.
2023-05-02 17:15:48 +01:00
Nico Weber
2319b2ffb5 ICC: Use snake_case instead of matching spec's camelCase in to_pcs() 2023-05-02 17:15:48 +01:00
Nico Weber
72f0575fb0 LibGfx: Fix -Wdouble-promotion for float matrices 2023-05-02 17:15:48 +01:00
Nico Weber
82bd7c33d1 ICC: Make a "not yet implemented" string more precise 2023-05-02 17:15:48 +01:00
Nico Weber
103f818afc ICC: Rename tag_for_rendering_intent()
To make clear it's for forward transforms, it's now called
forward_transform_tag_for_rendering_intent().

No behavior change.
2023-05-02 17:15:48 +01:00
Daniel Bertalan
be7bc41470 LibJS: Fix mix-up between assignment and comparison 2023-05-02 07:03:57 -04:00
Zaggy1024
1422f7f904 LibVideo/VP9: Revert framebuffer size reduction to allow OOB blocks
The framebuffer size was reduced in f2c0cee, but this caused some niche
block layouts to write outside of the frame.

This could be fixed by adding checks to see if a block being predicted/
reconstructed is within the frame, but the branches introduced by that
reduce performance slightly. Therefore, it's better to keep the
framebuffer sized according to the decoded frame size in 8x8 blocks so
that any block can be decoded without bounds checking.

A test was added to ensure that this continues to work.
2023-05-02 07:00:46 -04:00
Aliaksandr Kalenik
6cec431720 LibWeb: Set zero underflow when calculating intrinsic width of block
This fix resolves issue where calculating the min size of a block could
result in incorrect value if width of the block's children was
compensated by margins to fit into container width (which is equal to 0
during min size calculation).
2023-05-02 12:41:45 +02:00
Andreas Kling
00e3e82bbd LibWeb: Account for box-sizing:border-box in layout-less definite sizes
When we determine that a size is definite because it can be resolved now
without performing layout, we also need to account for the box-sizing
property.

This lets us remove a hack from flex layout where box-sizing:border-box
was manually undone at one point in the layout algorithm.
2023-05-02 11:47:13 +02:00
Andreas Kling
deea7cbc11 LibWeb: Remove vestigial resolve_definite_width/height helper functions
These functions no longer do anything interesting and just forward to
content_width/content_height. Let's make the callers use those directly
instead and remove this indirection layer.
2023-05-02 11:47:13 +02:00
Joel Petersson
e98315de6b SoundPlayer: Fix glitchy visualization on pause/stop
Previously when pausing or stoping a track in SoundPlayer,
the visualizations would glitch out. This was caused by them
being updated with the same buffer over and over.
With this patch a pause action will freeze the visualization at the
point of the pause and a stop action will reset the visualization
so it displays nothing until a track is started.
2023-05-02 09:15:20 +02:00