Commit graph

15280 commits

Author SHA1 Message Date
Andreas Kling d77dfc6b48 LibWeb: Rename FormattingContext::compute_position() => compute_inset()
This function computes the used inset properties, not the position of a
box per se, so let's call it something more accurate.
2022-03-27 18:16:08 +02:00
Andreas Kling c49c036c84 LibWeb: Stop allowing position:relative to affect layout
Relatively positioned boxes should not affect the *layout* of their
siblings. So instead of applying relative inset as a layout-time
translation on the box, we now perform the adjustment at the paintable
level instead.

This makes position:relative actually work as expected, and exposes some
new bugs we need to take care of for Acid2. :^)
2022-03-27 18:16:08 +02:00
Enver Balalic 4ecc695a65 LibWeb: Take borders and padding into account when doing Flex layout
Before this the flex layout didn't take into account the applied
borders or padding while laying out the items.

The child's top and left borders would get painted over the
parent's borders, also due to it not taking borders into account,
children with borders would overlap each other.

Due to it not taking padding into account, the children would get
drawn outside the parent element.
2022-03-27 17:43:47 +02:00
Timur Sultanov 46710d9efa LookupServer: Use case-insensitive comparison for domain names
Some ISPs may MITM DNS requests coming from clients, changing the case
of domain name in response. LookupServer will refuse responses from
any DNS server in that case. This commit changes the behaviour to
perform a case-insensitive equality check.
2022-03-27 17:36:13 +02:00
Kenneth Myhra f38076e596 disk_benchmark: TRY more stuff :^) 2022-03-27 08:33:24 -04:00
Kenneth Myhra c0f15ebcbb disk_benchmark: Core::ArgsParser to parse arguments 2022-03-27 08:33:24 -04:00
Kenneth Myhra 23a87a41ff LibCore: Add Vector<size_t> variant of add_option()
This adds a Vector<size_t> variant of add_option(). The signature
includes a separator parameter which defaults to ','.
2022-03-27 08:33:24 -04:00
Andreas Kling 269f9c6863 LibWeb: Add fast-paths for wrapping already-wrapped C++ objects
If a C++ object already has a JS wrapper, we don't need to go through
the expensive type checks to figure out which kind of wrapper to create.
Instead, just return the wrapper we already have!

This gives a noticeable increase in smoothness on Acid3, where ~10% of
CPU time was previously spent doing RTTI type checks in wrap(). With
these changes, it's down to ~1%.
2022-03-27 03:21:29 +02:00
Andreas Kling 5c5e4b5ae5 Revert "LibGfx: Remove bogus baseline adjustment in Painter's draw_text_line()"
This reverts commit 2b2915656d.

While this adjustment is bogus, it is currently responsible for putting
CenterLeft aligned scalable text in the right position.

This is going to take a bunch of work to get right.
2022-03-27 03:01:09 +02:00
Andreas Kling 2b2915656d LibGfx: Remove bogus baseline adjustment in Painter's draw_text_line()
This didn't achieve anything other than a slight vertical misalignment
for scalable fonts.
2022-03-27 01:14:56 +01:00
Andreas Kling b0208f38f6 LibWeb: Use Gfx::Font::pixel_size() when we want pixel metrics
This gives us consistent results with both bitmap and scalable fonts.
2022-03-27 01:14:56 +01:00
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 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
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 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