Commit graph

36514 commits

Author SHA1 Message Date
Andreas Kling
65629d26fe LibGfx: Use Font::pixel_size() instead of glyph_height() when painting
This gives us correct height metrics for both bitmap and scalable fonts.
2022-03-27 01:14:56 +01:00
Andreas Kling
ff951c89fe LibGfx: Add Font::pixel_size() and Font::point_size()
We've gotten ourselves into a bit of a mess by mixing pixel and point
sizes in multiple places. Step one towards getting out of this mess
is adding explicit accessors for the unit you're trying to fetch.

The core of the issue comes from bitmap fonts storing integer pixel
sizes and scaled (TTF) fonts storing float point sizes.
2022-03-27 01:14:56 +01:00
Andreas Kling
d5bba91a16 LibWeb: Don't round font sizes when looking them up
We previously had a rounding error which sometimes led to asking LibGfx
for fonts with slightly wrong sizes.
2022-03-27 01:14:56 +01:00
Andreas Kling
ee883372f6 LibGfx: Make FontDatabase lookups take font (point) sizes as float
This will allow web content to ask for fractional sizes, which becomes
important when converting between px/pt.
2022-03-27 01:14:56 +01:00
circl
eeeaf410fb WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held
items using the scroll wheel. In order to implement this, they
previously would have to either add a hard-coded division by 4, or look
up your mouse settings to adjust correctly.

This commit adds an MouseEvent.wheel_raw_delta_x() and
MouseEvent.wheel_raw_delta_y().
2022-03-27 01:11:27 +01:00
Lenny Maiorani
148f8169a4 LibWeb: Use date constants
Make the code DRY (Don't Repeat Yourself) by using the `AK`-provided
month name constants instead of copying them.
2022-03-27 00:45:12 +01:00
Andreas Kling
83a2aa1832 LibWeb: Include negative margins in height:auto computation for BFC root
...but never allow the resulting height to become negative. This solves
an issue seen on Acid3 where elements with negative vertical margins
expanded the size of their height:auto container instead of shrinking
it, which is the correct behavior. This now works :^)
2022-03-26 22:51:10 +01:00
Andreas Kling
0d9c28add9 LibWeb: Don't collapse horizontal margins between floating boxes
CSS 2.2 says "Horizontal margins never collapse."

So instead of collapsing them, we now add them together, which makes
negative margins between floating boxes work beautifully.
2022-03-26 22:12:21 +01:00
Andreas Kling
80f1749196 Browser: Make the main browser window a little bit bigger by default 2022-03-26 20:49:42 +01:00
Andreas Kling
1883efe010 Base: Add Acid3 to default Browser bookmarks 2022-03-26 20:47:52 +01:00
Andreas Kling
516fbad408 LibWeb: Remove debug spam about not executing empty script elements 2022-03-26 20:35:49 +01:00
Andreas Kling
d8be441978 LibWeb: Fix typo in SVGSVGElement::apply_presentational_hints()
Regressed in 7df62c64b7.

Thanks to Dex for spotting this! :^)
2022-03-26 20:10:36 +01:00
Andreas Kling
fa99259412 LibWeb: Simplify text chunk iteration a little bit
Instead of TextNode::ChunkIterator having two bool members to remember
things across calls to next(), this patch reorganizes the loop in next()
so that preserved newline/whitespace chunks are emitted right away
instead of in an awkward deferred way.
2022-03-26 20:04:56 +01:00
Andreas Kling
dd6a0dd0f7 LibWeb: Remove unused declarations from Layout::TextNode 2022-03-26 20:04:56 +01:00
Andreas Kling
aefe1727fc LibWeb: Make text newlines in "pre" mode emit a ForcedBreak item
Instead of emitting a Text item with the "should_force_break" flag set
to true, newlines in newline-preserving text content now timply turn
into ForcedBreak items. This makes the <pre> element work again.
2022-03-26 20:04:56 +01:00
Andreas Kling
d32630e17b LibWeb: Don't append collapsible whitespace to start of new line
After performing a required line break, and the next text chunk is
all collapsible whitespace, simply discard the whitespace.
2022-03-26 20:04:56 +01:00
Linus Groh
de53eb825a LibWeb: Make HTML{Button,Select,TextArea}Element focusable
From the HTML spec:

    Modulo platform conventions, it is suggested that the following
    elements should be considered as focusable areas and be sequentially
    focusable:

      ...
    - button elements
    - select elements
    - textarea elements
      ...

Also add a spec link to the existing HTMLAnchorElement::is_focusable().

Note that this still doesn't allow triggering keyboard-focused buttons,
checkboxes, or radio buttons - we don't seem to run the expected
activation behavior for any of them.
2022-03-26 19:42:58 +01:00
Linus Groh
80506a161f LibWeb: Make any HTMLInputElement with type != hidden focusable
From the HTML spec:

    Modulo platform conventions, it is suggested that the following
    elements should be considered as focusable areas and be sequentially
    focusable:

      ...
    - input elements whose type attribute are not in the Hidden state
      ...
2022-03-26 19:42:58 +01:00
Linus Groh
4923e4d406 LibWeb: Make HTMLInputElement::TypeAttributeState an enum class 2022-03-26 19:42:58 +01:00
Kenneth Myhra
122778b9ac tee: Port to LibMain and move to SerenityOS code patterns
This patch ports the utility 'tee' to LibMain and converts a larger part
of its code to our SerenityOS patterns.
2022-03-26 18:39:58 +00:00
Simon Danner
90fc28152b Chess: On pgn import avoid losing piece promotion info
Fixes #13268
2022-03-26 18:30:12 +00:00
Simon Danner
1888e60015 Spreadsheet: Update Undo / Redo button state 2022-03-26 18:29:21 +00:00
MacDue
593aa9aff1 Demos/LibGfxScaleDemo: Use BGRA8888 bitmap in canvas
Previously BGRx8888 was used, which produces artifacts with the new
antialiased window frames with border radii, which require alpha
blending whilst painting.
2022-03-26 18:24:11 +00:00
MacDue
3c0e17f29f LibGfx: Support scaling in AntiAliasingPainter::draw_circle()
Previously the painter would crash if scaling was enabled.
2022-03-26 18:24:11 +00:00
Sam Atkins
6edea1d59f LibWeb: Assign limits to CSS properties that cannot be negative
I believe this is all of them, but I may have missed some.

Several properties technically do not allow negative numbers but the
description says to accept these as valid, and then clamp them
afterwards to the desired range. As such, we don't reject them during
parsing.
2022-03-26 18:15:08 +01:00
Sam Atkins
d6901d2119 Meta: Add range checking to all numeric CSS types
We did already have range checking for the `<integer>` and `<number>`
types, but this patch adds this functionality to all numeric types
(dimensions and percentages).

The syntax in Properties.json is taken from the spec:
https://www.w3.org/TR/css-values-3/#numeric-ranges

eg, `length [0,∞]` defines that a Length is allowed as long as it has a
positive value.

The implementation here allows for any number to be the positive or
negative limit, even though only 0 and positive/negative infinity are
meaningful values without a unit.
2022-03-26 18:15:08 +01:00
Michael Manganiello
16ff2d339a Ports: Enable MP3 support for SDL2_mixer
`SDL2_mixer` needs `libmpg123` to support MP3 playback. By adding
it as a dependency, its compilation now outputs:

```
checking mpg123.h usability... yes
checking mpg123.h presence... yes
checking for mpg123.h... yes
checking for mpg123_replace_reader_handle in -lmpg123... yes
-- dynamic libmpg123 -> libmpg123.so.0
```

Sound output was tested with
[an implementation](https://gist.github.com/cdave1/10563386) found
online.
2022-03-26 18:13:46 +01:00
Michael Manganiello
7dfb167b18 Ports: Add libmpg123 port
Add `libmpg123` port, for dependant projects to be able to use it.

This port doesn't include the entire `mpg123` project, just the
`libmpg123` library.
2022-03-26 18:13:46 +01:00
Ali Mohammad Pur
f12d81ddf5 Shell: Limit the access of processes spawned for autocompletion
This commit limits the autocomplete processes to effectively have
readonly access to the fs, and only enough pledges to get the dynamic
loader working.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
8233da3398 Kernel: Add a 'no_error' pledge promise
This makes pledge() ignore promises that would otherwise cause it to
fail with EPERM, which is very useful for allowing programs to run under
a "jail" so to speak, without having them termiate early due to a
failing pledge() call.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
37073437c1 Base: Regenerate automatically generated manpages 2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
da12acfa78 LibCore: Allow marking options as 'hidden' in ArgsParser
This removes them from the main invocation example in --help, as well as
hides them from autocomplete results (we were previously special-casing
"help" and "version").
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
ef5523231c Shell+LibCore: Provide argument help strings as display trivia 2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
d995be428a LibLine: Add a display trivia field to suggestions
These strings will be shown next to the completions as an optional hint
or description.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
9453e0e6d2 Shell: Add an ArgsParser-based argument parser builtin
Afterall, why _shouldn't_ Shell functions have nice interfaces?
also helps with autocompletion :^)
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
7e4cc187d9 Shell: Implement program-aware autocompletion
A program can either respond to `--complete -- some args to complete`
directly, or add a `_complete_<program name>` invokable (i.e. shell
function, or just a plain binary in PATH) that completes the given
command and lists the completions on stdout.
Should such a completion fail or yield no results, we'll fall back to
the previous completion algorithm.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
fc4d36ccd0 LibCore: Make ArgsParser perform some completion if passed --complete
This makes it possible to autocomplete flags and options via the Shell.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
e6bd1f8807 Shell: Add the 'join' and 'filter_glob' immediate functions
'split' was missing its other half, and to avoid globbing the
filesystem, let's keep the globbing to shell-internal state.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur
4a331c73f8 ls: Remove leading dashes from ArgsParser argument name
Otherwise the full argument would be "----ignore-backups", which is most
certainly not correct :^)
2022-03-26 21:34:56 +04:30
Andreas Kling
fda25f9505 LibWeb: Move HTML dimension value parsing from CSS to HTML namespace
These are part of HTML, not CSS, so let's not confuse things.
2022-03-26 17:31:01 +01:00
Andreas Kling
434970f022 LibWeb: Remove the totally ad-hoc parse_html_length()
All clients of this API have been migrated to HTML dimension value
parsing instead.
2022-03-26 17:31:01 +01:00
Andreas Kling
7df62c64b7 LibWeb: Treat width/height on <svg> element as HTML dimension values
This might not be entirely correct, but neither was using the completely
ad-hoc parse_html_length(), and this is the last user of that API so
let's move off of it.
2022-03-26 17:31:01 +01:00
Andreas Kling
e96b3315ad LibWeb: Treat width/height on td/th elements as non-zero dimension value 2022-03-26 17:31:01 +01:00
Andreas Kling
71e89fe134 LibWeb: Treat width/height on table elements as non-zero dimension value 2022-03-26 17:31:01 +01:00
Andreas Kling
28c929e85c LibWeb: Add parser for the HTML "non-zero dimensions value" microsyntax 2022-03-26 17:31:01 +01:00
Andreas Kling
fe908e7db2 LibWeb: Rename "offset" in box model metrics to "inset"
The CSS Positioned Layout spec refers to the top/left/bottom/right
properties as "inset" properties, so let's use the same terminology.
2022-03-26 17:31:01 +01:00
Andreas Kling
54c3053bc3 LibWeb: Preserve paint state when painting stacking contexts indirectly
For layers that require indirect painting (due to opacity, transform,
etc.) we create a nested PaintContext. Until now, that PaintContext
was created fresh without transferring all the state from the parent
PaintContext.
2022-03-26 17:31:01 +01:00
Andreas Kling
2a8c6361aa LibWeb: Support navigator.javaEnabled() (always false)
This removes exception spam about javaEnabled() on apple.com.
2022-03-26 17:31:01 +01:00
Andreas Kling
0e806f58fe LibWeb: Support the hspace and vspace attributes on img elements
These map HTML dimension values to CSS margin values.
2022-03-26 17:31:01 +01:00
Andreas Kling
c92d28b4ea LibWeb: Treat img width/height attributes as HTML dimension values 2022-03-26 17:31:01 +01:00