Commit graph

15567 commits

Author SHA1 Message Date
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
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
Andreas Kling 075bdfdef8 LibWeb: Add a parser for the HTML "dimension value" microsyntax 2022-03-26 17:31:01 +01:00
Andreas Kling 2e6f5fddef LibWeb: Transfer flex item box model metrics to paintable
Until now, flex items has 0/0/0 margin/border/padding values.
2022-03-26 17:31:01 +01:00
Karol Kosek 44bfca369a LibWeb: Resolve style values from the element inline style
This will set the background color in the project header on GitHub! :^)
2022-03-26 17:30:49 +01:00
Karol Kosek 0934573deb LibWeb: Set CSS custom properties from the element inline style 2022-03-26 17:30:49 +01:00
sin-ack aaa954f900 LibWeb: Bring handling of anchor elements closer to spec
This commit moves the regular handling of links to the anchor elements'
activation behavior, and implements a few auxiliary algorithms as
defined by the HTML specification.

Note that certain things such as javascript links, fragments and opening
a new tab are still handled directly in EventHandler, but they have been
moved to handle_mouseup so that it behaves closer to how it would if it
was entirely up-to-spec.
2022-03-26 14:01:17 +01:00
Max Trussell 034c57f1f9 FlacLoader: Use seektable for performing seek operations
As a fallback, we perform primitive seek if there's no seektable.

Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2022-03-26 11:04:25 +01:00
Max Trussell 346696ffbb FlacLoader: Parse SEEKTABLE header
Populates m_seektable attribute with FlacSeekPoints.

For more information see:
https://datatracker.ietf.org/doc/html/draft-ietf-cellar-flac#section-11.13

Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2022-03-26 11:04:25 +01:00
Liav A d7c7e6e496 Utilities/ps: Don't assume the kernel can provide real TTY paths 2022-03-26 11:01:49 +01:00
Linus Groh 1e23fd94b1 LibWeb: Use ThreedShadow1 palette color for input border in Default.css
This is a bit easier on the eye than black.
2022-03-26 01:35:39 +00:00
Linus Groh 9bc7912f84 LibWeb: Paint the focus outline using Painter::draw_focus_rect()
Now it actually looks like a classic focus outline and not some
misplaced border :^)
2022-03-26 01:35:39 +00:00
Linus Groh 642491fc74 LibWeb: Paint the focus outline actually *outside* the element
Instead of using the absolute_rect(), use absolute_border_box_rect() -
at least for PaintableBox - and inflate it by 2px on each side.

This looks much nicer for text input elements, especially when they have
padding, which would be applied outside the focus rect previously.
2022-03-26 01:35:39 +00:00
kleines Filmröllchen faf7331999 SoundPlayer: Don't crash when the reported buffer is unexpected
It seems like this happens in quite some valid situations, so my
initially sensible failsafe doesn't make sense. As the buffer system is
hopefully gone soon, it won't be an issue in the future either way.
2022-03-25 18:34:30 -07:00
kleines Filmröllchen 9cca9f5204 SoundPlayer: Fix jump to slider behavior for playback slider
This was regressed at some point though I never saw it working.
Basically, while jump to slider works correctly it doesn't even get
actioned. While the user is clicking the slider it's very likely that a
buffer finishes playing and the callback for that changes the slider
value. This means that the user click just gets lost. There's some
additional weird behavior where values are lost in even more cases, so
an additional fix that is needed is to store the slider value in the
AutoSlider while we're dragging and apply it on mouse up.
2022-03-25 18:34:30 -07:00
Andreas Kling 925c34cf43 LibWeb: Include floats in height:auto for BFC root with inline children
BFC roots with children_are_inline()==true can still have floating boxes
as well. children_are_inline() is only concerned with in-flow children.

For this reason, we have to always consider floats when calculating
height:auto for BFC roots.
2022-03-26 00:15:25 +01:00
Andreas Kling 618273b48d LibWeb: Include children-are-inline state in layout tree dumps
Sometimes it's really helpful to know if a box considers its children to
be inline or not.
2022-03-26 00:15:25 +01:00
Michiel Visser 37da5cb3b3 LibCrypto: Correctly add length to SHA384 and SHA512 hashes
The SHA384 and SHA512 hashes would produce incorrect results for data
where the length % 128 was in the range 112-119. This was because the
total number of bits in the hashed values was added at the end as a
64-bit number instead of a 128-bit number. In most cases this would not
cause any issues, as this space was padded with zeroes, however in the
case that the length % 128 was 112-119, some incorrect data ended up
where this 128-bit length value was expected.

This change fixes the problems in LibTLS where some websites would
result in a DecryptError on handshake.
2022-03-26 02:25:23 +04:30
James Bellamy 7ab62ecd16 LibWeb: When painting, reduce computation cost by using the reciprocal
Rather than dividing the rect width and high by the border lengths,
this change multiples those lengths by the reciprocal of the width
and height because this is a faster operation. When mousing around on
the html spec website, the profile showed that inline painting
went from ~15% to ~3%
2022-03-25 21:32:19 +01:00
Timothy Flynn e5db67d6dd LibWeb: Attach BackgroundAttachment::Fixed to the window view port
This fixes the placement of several background images on Acid2, most
notably the background of the eyes and the red rectangle near the bottom
of the head.
2022-03-25 20:11:04 +01:00
Linus Groh a5ea066693 LibJS: Fix number types in GetISOPartsFromEpoch
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c5b645d

This means we now have to pass a global object and construct a BigInt
object just for the assertion, but oh well. We might want to have an
assertion macro that's optimized away in release builds at a later
point, however.
2022-03-25 18:33:55 +00:00
Linus Groh 9950f06623 LibJS: Update spec comment in BuiltinTimeZoneGetPlainDateTimeFor
This is an editorial change in the Temporal spec from a long time ago.

See: https://github.com/tc39/proposal-temporal/commit/e480d40
2022-03-25 18:30:33 +00:00
kleines Filmröllchen 8fe899e90d LibCore: Fix enum copy mistakes in REGISTER_TEXT_ALIGNMENT_PROPERTY 2022-03-25 08:17:28 -04:00
kleines Filmröllchen e9a286f9e7 LibCore: Make EventLoop connect to InspectorServer if requested
I regressed this at some point by inverting the condition here.
2022-03-25 12:05:17 +01:00
Andreas Kling bd44d9d641 LibWeb: Show correct element margin values in Inspector "Box Model" view
We were showing the margin-top value for all 4 margin values.
2022-03-25 11:57:30 +01:00
Lenny Maiorani f268a91227 Utilities: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-24 20:09:26 -07:00
Lenny Maiorani dd05934539 Shell: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-24 20:09:26 -07:00
Lenny Maiorani 0b7baa7e5a Services: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-24 20:09:26 -07:00
Ben Wiederhake d13283f952 LibVT: Fix tooltip condition, properly reset when tooltip not available 2022-03-25 02:33:23 +01:00
Andreas Kling c02e6f991a LibWeb: Improve vertical margin collapse between adjacent blocks
Collect all the preceding block-level siblings whose vertical margins
are collapsible. Both margin-top and margin-bottom now (previously,
we only considered the margin-bottom of siblings.)

Use the right margin in part-negative and all-negative situations.
2022-03-25 00:10:09 +01:00
Andreas Kling c2d7ef057d WebContent: Remove accidentally committed unveil() call 2022-03-24 23:17:49 +01:00
Andreas Kling 6cffabef03 LibWeb: Support CSS vertical-align values "top" and "bottom" 2022-03-24 22:57:01 +01:00
Andreas Kling 195ef5e26f LibWeb: Bring CSS line-height implementation closer to spec
We now distribute the line-height evenly between the space above and
below inline-level boxes. This noticeably improves our baseline
alignment in many cases.

Note that the "vertical-align: <length>" case is quite awkward, as the
extra height added by the offset baseline must count towards the line
box height.

There's a lot of room for improvement here, but this makes the buckets
container on Acid3 show up in the right place, with the right size.
2022-03-24 22:52:44 +01:00
Timothy Flynn 430559ea51 LibWeb: Weakly store a reference to the Window object in timer tasks
This prevents a crash when refreshing or navigating away from the Acid3
test page while it is actively running.
2022-03-24 21:37:58 +01:00
Idan Horowitz 02004b7055 LibWeb: Handle XML MIME types in HTMLObjectElement 2022-03-24 21:37:49 +01:00
Idan Horowitz 215432c3e8 LibWeb: Discard ObjectElement's nested browsing context on image load 2022-03-24 21:37:49 +01:00
Idan Horowitz f82d4d001d LibWeb: Implement getSVGDocument() for BrowsingContextContainer
Specifically HTMLIFrameElement and HTMLObjectElement. HTMLEmbedElement
will gain it automatically once it's also converted to inherit from
BrowsingContextContainer.
2022-03-24 21:37:49 +01:00
Idan Horowitz fed11e625e LibWeb: Expose contentDocument on HTMLObjectElement 2022-03-24 21:37:49 +01:00
Idan Horowitz 5626e1b324 LibWeb: Rename PARSER_DEBUG => HTML_PARSER_DEBUG
Since this macro was created we gained a couple more parsers in the
system :^)
2022-03-24 21:37:49 +01:00
Sam Atkins 1499d2421e LibWeb: Align text shadows the same way we align text
This makes the shadow line-up correctly on Acid3. :^)
2022-03-24 20:30:26 +01:00
Sahan Fernando 05f9146af8 3DFileViewer: Enable smooth shading in viewer + teapot model 2022-03-24 19:22:27 +01:00
Andreas Kling ed1576eea8 LibWeb: Align baseline of inline-block with non-zero top border/padding
We were not adjusting the fragment baseline for inline-blocks that had
some border and/or padding size up top.
2022-03-24 18:30:56 +01:00
Andreas Kling 54ffe79d70 LibWeb: Fix missing line-height & font-size on some anonymous blocks
Make sure we use the create_anonymous_wrapper() helper function whenever
wrapping inline content in anonymous wrapper blocks. We were forgetting
to do this in one case, which led to some wrapper blocks having 0px
font-size and line-height.
2022-03-24 18:30:56 +01:00
Andreas Kling d5aca1c6c4 LibWeb: Treate SVG paintable coordinates as relative to <svg> element
Normally, paintable coordinates are relative to the nearest containing
block, but in the SVG case, since <svg> doesn't form a containing block,
we have to specialize the computation of SVGPaintable::absolute_rect().
2022-03-24 18:14:01 +01:00
Andreas Kling 88aca4c996 LibWeb: Add fast-path for absolute lengths in Length::to_px()
Absolute lengths can be resolved immediately without looking up the
viewport size, etc.
2022-03-24 18:14:01 +01:00
Andreas Kling 30b1772eeb LibWeb: Rename "specified_style" to "computed_style" in Layout::Node
The specified style was turned into computed style long before it
arrived here (StyleComputer took care of that.)
2022-03-24 18:14:01 +01:00
Andreas Kling 40af665a49 LibWeb: Add margin box helpers to Layout::FormattingState 2022-03-24 18:14:01 +01:00
Andreas Kling 329f06d59a LibWeb: Add Layout::Node::line_height()
This allows you to call line_height() on any layout node, even if it's a
text node (in which case we'll ask the parent node for its line-height.)
2022-03-24 18:14:01 +01:00
Sam Atkins c914e732d2 LibWeb+Base: Fix An+B of foo parsing
When I wrote the An+B parser, it was guaranteed to have no
non-whitespace tokens after it. This is no longer true with the `of
foo` syntax, so this patch corrects the logic when there is no `+B`
segment.

This makes this case shown on Twitter work correctly. :^)
https://twitter.com/simevidas/status/1506657566012678151
2022-03-24 18:08:45 +01:00
Sam Atkins 5aad32b504 LibWeb: Implement text-shadow painting
We don't yet take the spread-distance parameter into account, since we
don't have a way to "inflate" the text shadow.

Also, I'm not sure if we need to inflate the shadow slightly anyway.
Blurred shadows of our pixel fonts seem very faint. Part of this is
that a blur of < 3px does nothing, see #13231, but even so we might
want to inflate it a little.
2022-03-24 18:08:34 +01:00
Sam Atkins 03daa4653f LibWeb: Parse and compute text-shadow property 2022-03-24 18:08:34 +01:00
Sam Atkins f078bb8294 LibWeb: Implement disallowing inset when parsing shadows
`text-shadow` does not support this, so this way we can still use the
same parsing code.

It's OK that we still assign a ShadowPlacement value to the
ShadowStyleValue, since it will just get ignored when painting
text-shadows, but if it appears in the property value then that is a
syntax error.
2022-03-24 18:08:34 +01:00
Sam Atkins 1094654adc LbWeb: Rename BoxShadowFoo => ShadowFoo
The `text-shadow` property is almost identical to `box-shadow`:
> Values are interpreted as for box-shadow [CSS-BACKGROUNDS-3].
> (But note that the inset keyword are not allowed.)

So, let's use the same data structures and parsing code for both. :^)
2022-03-24 18:08:34 +01:00
Timothy Flynn f9367a5fdb LibWeb: Ignore application objects until we can support them
The HTMLObjectElement spec is set up to ignore application/octet-stream
MIME types only. For this to work, we need to implement the MIME type
sniffing algorithm so that all unknown MIME types become mapped to the
application/octet-stream type. Until then, ignore all application/ MIME
types as we won't be able to display them anyways.
2022-03-24 16:56:38 +01:00
Timothy Flynn d744f04a03 LibWeb: Discard an object's nested browsing contexts when falling back 2022-03-24 16:56:38 +01:00
Timothy Flynn 23915d0977 LibWeb: Implement falling back early to an object's child representation 2022-03-24 16:56:38 +01:00
Timothy Flynn a002c8156b LibWeb: Conditionally update an object's children when its state changes
We should only update the object children of an object when the parent's
representation changes to/from falling back to its children.
2022-03-24 16:56:38 +01:00
Timothy Flynn f11d6e137c LibWeb: Correctly handle unknown MIME types in HTMLObjectElement
We were using the literal string "unknown" as the unknown MIME type,
which caused us to treat the object as a nested browsing context (as
"unknown" does not start with "image/"). Use an Optional instead to
prevent this mishap.
2022-03-24 16:56:38 +01:00
Jelle Raaijmakers c0513999d6 LibGfx: TrueTypeFont cleanup
No functional changes.
2022-03-24 16:53:21 +01:00
Jelle Raaijmakers b17fb76ace LibGfx: Implement TTF kerning tables
If a TTF font contains kern tables, we now read through all of them and
apply any kerning values to character rendering.
2022-03-24 16:53:21 +01:00
Simon Wanner e72f59cd23 Profiler: Render signposts behind histograms
Since signposts render along the full height they could hide CPU usage
spikes. This way that won't be an issue. :^)
2022-03-24 14:35:47 +01:00
Simon Wanner 3d80d38954 LibWeb: Emit signposts for resource loads 2022-03-24 14:35:47 +01:00
Nukiloco b47bd95087 LibWeb: Add missing spec comment in focusing logic 2022-03-24 08:39:26 -04:00
Nicholas Cellino 626ea5007a sql: Re-prompt user for input after unrecognized command
This fixes a bug in the SQL REPL where after a user enters an
unrecognized command, the REPL would not print another "> " prompt and
would not accept any more input.
2022-03-24 07:25:04 -04:00
Kenneth Myhra 546a6a80a7 readlink: Use StringView instead of const char* 2022-03-24 11:57:51 +01:00
Kenneth Myhra 45ac5e90b7 readlink: Port to LibMain 2022-03-24 11:57:51 +01:00
Kenneth Myhra 4a57be824c Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to
ErrorOr<String>.

The rest of the change is to support the potential of an Error being
returned and subsequent release of the value when no Error is returned.
Unfortunately at this stage none of the places affected can utililize
our TRY() macro.
2022-03-24 11:57:51 +01:00
Timothy Flynn 69749b044c LibWeb: Begin supporting non-image HTMLObjectElement data representation
We currently only supported loading image data from an HTMLObjectElement
node. This adds (some) support for non-image data. A big FIXME is to
actually paint that data. We will need to make FrameBox and
NestedBrowsingContextPaintable work with HTMLObjectElement for this
(they currently only work with HTMLIFrameElement).
2022-03-24 03:35:11 +01:00
Timothy Flynn f733385cc4 LibWeb: Move automatic browsing context creation to HTMLIFrameElement
We will soon have two DOM nodes which contain nested browsing contexts:
HTMLIFrameElement and HTMLObjectElement. Only HTMLIFrameElement should
have its nested context created automatically upon insertion, so move
the invocation of that logic to HTMLIFrameElement.
2022-03-24 03:35:11 +01:00
Timothy Flynn 5608bc4eaf LibWeb: Remove inheritance of FormAssociatedElement from HTMLElement
HTMLObjectElement will need to be both a FormAssociatedElement and a
BrowsingContextContainer. Currently, both of these classes inherit from
HTMLElement. This can work in C++, but is generally frowned upon, and
doesn't play particularly well with the rest of LibWeb.

Instead, we can essentially revert commit 3bb5c62 to remove HTMLElement
from FormAssociatedElement's hierarchy. This means that objects such as
HTMLObjectElement individually inherit from FormAssociatedElement and
HTMLElement now.

Some caveats are:

* FormAssociatedElement still needs to know when the HTMLElement is
  inserted into and removed from the DOM. This hook is automatically
  injected via a macro now, while still allowing classes like
  HTMLInputElement to also know when the element is inserted.

* Casting from a DOM::Element to a FormAssociatedElement is now a
  sideways cast, rather than directly following an inheritance chain.
  This means static_cast cannot be used here; but we can safely use
  dynamic_cast since the only 2 instances of this already use RTTI to
  verify the cast.
2022-03-24 03:35:11 +01:00
Lenny Maiorani f7f0195fae LibMain: Statically link LibMain
LibMain is dynamically linked in every binary. This results in a
slightly slower load time. In the past people have pegged this at 0.7
ms on some hardware.

This change makes it statically linked and eliminates 0.6 ms of
run-time on my machine. This is tested by running a script which just
executed `/bin/true` in a loop 10,000 times. Before this patch it
reliably executed in ~90,000 ms. After this patch it is ~84,000
ms. This is a speed up of 6,000 ms over 10,000 executions, or 0.6 ms
per execution.
2022-03-24 03:04:57 +01:00
GeekFiftyFive ff8a6d8e59 PixelPaint: Call set_modified on window
Call set_modified on window in order to reflect unsaved
changed in the titlebar's close button
2022-03-24 03:03:50 +01:00
Timothy Flynn 7774c9bb9e LibWeb: Update HTMLObjectElement's children on fallback state changes
This is another event upon which the task to determine an object's
respresentation must be queued:

    * one of the element's ancestor object elements changes to or from
      showing its fallback content

For example, on Acid2, the image for the eyes is nested below an object
that is designed to fail to load. This ensures the eyes will render as
the fallback of the failed parent object.
2022-03-23 21:26:35 +01:00
Timothy Flynn 8f7e642a96 LibWeb: Move HTMLObjectElement spec link to correct method 2022-03-23 21:26:35 +01:00
Timothy Flynn 20eb441cba LibWeb: Evict replaced Resource objects from cache
When a Resource is converted to an ImageResource, evict the original
resource from cache. The original resource's data has been moved, so on
a warm reload of a page, when that resource is loaded from cache, it
would not have any data to actually show.
2022-03-23 21:26:35 +01:00
Sam Atkins 004f69b535 LibWeb: Restore :is() and :where() selector parsing
This was a casualty in a recent merge-conflict resolution. Oops!
2022-03-23 15:46:48 -04:00
Nicholas Cellino 0e51d99322 sql: Do not indent next line when current one is blank
Previously, if a user pressed Enter without typing a command at
the SQL REPL, the next line would be automatically indented. This
change makes it so we check if there were any tokens in the command
before applying the indentation logic.
2022-03-23 15:27:09 -04:00
Andreas Kling e0c7727934 LibWeb: Fill the whole viewport with the correct background color
CSS2 tells us to use the HTML element's background color if not
transparent. Otherwise, the BODY element's background color.
2022-03-23 17:38:00 +01:00
Andreas Kling ca85ac26d4 WebContent: Fill OOPWV with palette base color when there's no content 2022-03-23 17:27:20 +01:00
Andreas Kling fb9ee26c43 LibWeb: Resolve numeric line-heights against element's own font size
For things like "line-height: 2" to work, the font size must be assigned
before resolving the line height. Previously, the line-height was
resolved first, which meant that numeric and other relative units were
resolved against the default font-size instead.
2022-03-23 15:57:05 +01:00
Andreas Kling 5118a4c1e7 LibWeb: Parse CSS "font-variant" as part of "font"
This allows us to parse CSS "font" values that contain e.g "small-caps"
or "normal", as used on Acid3.
2022-03-23 14:54:21 +01:00
Andreas Kling 632928a11e LibWeb: Pass font sizes in pt rather than px to Gfx::FontDatabase
Our font database uses point sizes for fonts, and we were passing it
px sizes. This caused all fonts to be 1.333x larger than they should
be on the web. Of course it wasn't always noticeable with bitmap fonts,
but noticeable everywhere with scalable fonts.
2022-03-23 14:13:15 +01:00
Timothy Flynn bf7b51a569 LibWeb: Implement HTMLObjectElement's data URL according to the spec
There are a long list of conditions under which the HTMLObjectElement is
to queue an element task to load / determine an object's representation.
This handles the case where the data attribute has changed.

Much of the spec for determining the object's representation is not
implemented here. Namely, anything to do with XML documents or browser
plugins are left as FIXMEs.
2022-03-23 13:44:51 +01:00
Timothy Flynn 90829fe880 LibWeb: Allow HTMLObjectElement to convert a Resource to ImageResource
HTMLObjectElement, when implemented according to the spec, does not know
the resource type specified by the 'data' attribute until after it has
actually loaded (i.e. it may be an image, XML document, etc.). Currently
we always use ImageLoader within HTMLObjectElement to load the object,
but will need to use ResourceLoader instead to generically load data.

However, ImageLoader / ImageResource have image-specific functionality
that HTMLObjectElement still needs if the resource turns out to be an
image. This patch will allow (only) HTMLObjectElement to convert the
generic Resource to an ImageResource as needed.
2022-03-23 13:44:51 +01:00
Johannes Laudenberg eb1d7e8076 LibWeb: Make margins in the main dimension work for flex items
The spec at https://www.w3.org/TR/css-flexbox-1/ states that when
calculating specific spaces and sizes inside a flex container, the outer
size of a flex item needs to be taken into account.

This patch adds the margins in the main dimension of a flex item to
these calculations such that their margins are actually painted in a lot
of common cases.

It makes our Github page look marginally better.
2022-03-23 11:59:07 +01:00
Jelle Raaijmakers 5882d891d0 LibGUI: Simplify AbstractZoomPanWidget code
No functional changes, just making things a bit easier to read.
2022-03-23 11:53:34 +01:00
Jelle Raaijmakers b8a53e4a17 Applications: Round layer rect before drawing outline in PixelPaint
This fixes differences in drawing the layer and image outlines.
2022-03-23 11:53:34 +01:00
Jelle Raaijmakers ab19b092ed LibGfx: Implement Rect::to_rounded<U>()
This replaces the usage of `rounded_int_rect`, whose name did not
accurately reflect the rounding operation happening. For example, the
position of the rect was not rounded but floored, and the size was
pulled through `roundf` before casting to `int` which could result in
inadvertent flooring if the resulting floating point could not exactly
represent the rounded value.
2022-03-23 11:53:34 +01:00
Jelle Raaijmakers bec474d99b LibGfx: Calculate source rect once in do_draw_scaled_bitmap 2022-03-23 11:53:34 +01:00
Jelle Raaijmakers f790a69431 LibGfx: Draw last row and column of scaled bitmaps in Painter
There was an off-by-one bug in `Painter::do_draw_scaled_bitmap` where
the last column and row of the source bitmap would be skipped. This was
especially visible in PixelPaint when zooming in and out on smaller
images.

Instead of the top/left of the pixel, we now use the bottom/right side
of the pixel as a threshold to stop drawing.
2022-03-23 11:53:34 +01:00
Andreas Kling fd7a059e09 LibWeb: Make NodeIterator behave like other browser engines
If invoking a NodeFilter ends up deleting a node from the DOM, it's not
enough to only adjust the NodeIterator reference nodes in the
pre-removing steps. We must also adjust the current traversal pointer.

This is not in the spec, but it's how other engines behave, so let's do
the same.

I've encapsulated the Node + before-or-after-flag in a struct called
NodePointer so that we can use the same pre-removing steps for both the
traversal pointer and for the NodeIterator's reference node.

Note that when invoking the NodeFilter, we have to remember the node we
passed to the filter function, so that we can return it if accepted by
the filter.

This gets us another point on Acid3. :^)
2022-03-23 00:22:36 +01:00
Andreas Kling a0b0b29fa1 LibWeb: Minor cleanups in NodeIterator and TreeWalker
- Use TRY() when invoking the NodeFilter
- Say "nullptr" instead of "RefPtr<Node> {}"
2022-03-23 00:19:57 +01:00
Sam Atkins ccee8953d0 LibWeb: Expose SVGEllipseElement attributes to JS 2022-03-22 22:33:17 +01:00
Sam Atkins 1a3d6c68ef LibWeb: Expose SVGCircleElement attributes to JS 2022-03-22 22:33:17 +01:00
Sam Atkins b51ea3a67c LibWeb: Expose SVGLineElement attributes to JS 2022-03-22 22:33:17 +01:00
Liav A b5ef900ccd Kernel: Don't assume paths of TTYs and pseudo terminals anymore
The obsolete ttyname and ptsname syscalls are removed.
LibC doesn't rely on these anymore, and it helps simplifying the Kernel
in many places, so it's an overall an improvement.

In addition to that, /proc/PID/tty node is removed too as it is not
needed anymore by userspace to get the attached TTY of a process, as
/dev/tty (which is already a character device) represents that as well.
2022-03-22 20:26:05 +01:00
Liav A de7566c2c4 LibC: Don't rely on ptsname and ttyname syscalls
Instead, to determine these values (both the pts name and tty name), use
other methods. For determining the new name of the allocated psuedo
terminal, use ioctl on a file descriptor we got after opening /dev/ptmx
with the TIOCGPTN option.
For determining the name of TTY, we enumerate both /dev/pts and /dev
directories to find matching inode number and matching device mode.
2022-03-22 20:26:05 +01:00
Liav A 5ffe2f117c Kernel/TTY: Implement TIOCGPTN ioctl for MasterPTY
This ioctl operation will allow userspace to determine the index number
of a MasterPTY after opening /dev/ptmx and actually getting an internal
file descriptor of MasterPTY.
2022-03-22 20:26:05 +01:00
Liav A e508073168 SystemServer: Create /dev/tty as a character device instead of a symlink
The new device has major number 5, minor number 0, and is represented by
the SelfTTYDevice class in the Kernel.
2022-03-22 20:26:05 +01:00
Andreas Kling 2fb9eb5257 LibWeb: Implement Range.deleteContents()
And here's another point on Acid3. :^)
2022-03-22 20:17:52 +01:00
Andreas Kling e1c71b3f91 LibWeb: Implement Range.cloneContents() 2022-03-22 20:03:09 +01:00
Andreas Kling de6f7f0029 LibWeb: Support CSS floats in inline flow
CSS floats are now emitted by the InlineLevelIterator. When this
happens, IFC coordinates with the parent BFC to float the box to the
side, using the current LineBuilder state for vertical placement.

This makes the "instructions" text on Acid3 render as a single
contiguous flow of inline content.
2022-03-22 19:26:51 +01:00
Andreas Kling fa64a7f6cc LibWeb: Relax "all children must be either inline or block" invariant
This was implemented too rigidly, which made it impossible to place
floats correctly when they occurred in inline flow.

The new invariant is "all in-flow children must be either inline or
block". Out-of-flow children like floating and absolutely positioned
boxes are ignored when deciding when to generate anonymous boxes.
2022-03-22 19:26:51 +01:00
Andreas Kling 74927fd218 LibWeb: Move Layout::Box::is_out_of_flow() to Layout::Node
I want to use this function in inline layout, where we're not just
dealing with boxes.
2022-03-22 19:26:51 +01:00
Linus Groh cd6896d343 LibWeb: Convert URL to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 2219eef250 LibWeb: Convert Text to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 46bb547dd6 LibWeb: Convert ShadowRoot to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh a68d31debd LibWeb: Convert ParentNode to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 8d20fb1e94 LibWeb: Convert NodeOperations to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 3861396fe4 LibWeb: Convert Node to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 07a2c58da0 LibWeb: Convert InnerHTML to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 3cb7c463a7 LibWeb: Convert Element to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh b6f09aaef2 LibWeb: Convert DOMTokenList to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 91d0088a5b LibWeb: Convert DOMImplementation to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh e758bd303f LibWeb: Convert Document to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh ab0a354bb4 LibWeb: Convert ChildNode to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 9ca10c9347 LibWeb: Convert CRC2D to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Timothy Flynn 859a75fd4c LibWeb: Handle input element value setting & getting closer to the spec
We should not set the 'value' attribute when an input element's value is
changed (by the user or programmatically). Instead, we should track the
value internally and mark it with a dirty flag when it is changed.
2022-03-22 16:06:38 +01:00
Sam Atkins 31b24c2b29 LibWeb: Remove now-unused null values from Selector enums
Now that we use a Variant for the SimpleSelector's data, we don't need
to instantiate empty structs or variables for the types that aren't
used, and so we can remove `PseudoElement::None`,
`PsuedoClass::Type::None` and `Attribute::MatchType::None`.

Also, we now always initialize a SimpleSelector with a type, so
`SimpleSelector::Type::Invalid` can go too.
2022-03-22 15:47:36 +01:00
Sam Atkins cbe2eaebab LibWeb: Tidy up CSS::Token::to_debug_string()
The ifs below the switch no longer functioned, so let's move everything
into the switch cases. This also means we can replace the StringBuilder
usage with String::formatted().
2022-03-22 15:47:36 +01:00
Sam Atkins 13e1232d79 LibWeb: Remove separate Token::m_unit field
Dimension tokens don't make use of the m_value string for anything else,
so we can sneak the unit string in there.

- Token goes from 72 to 64 bytes
- StyleComponentValueRule goes from 80 to 72 bytes
2022-03-22 15:47:36 +01:00
Sam Atkins c0d3f1a5e4 LibWeb: Use CSS::Number for CalculatedStyleValue numbers 2022-03-22 15:47:36 +01:00
Sam Atkins fe372cd073 LibWeb: Use CSS::Number for Token numeric values 2022-03-22 15:47:36 +01:00
Sam Atkins e8ab2dab11 LibWeb: Implement a CSS::Number class
We have the same "number and is-integer flag" structure in several
places, so let's put that in a class.
2022-03-22 15:47:36 +01:00
Sam Atkins 0795b9f7bb LibWeb: Use floats instead of doubles for CSS numbers
Using doubles isn't necessary, and they make things slightly bigger and
slower, so let's use floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins 1f5b5d3f99 LibWeb: Use intermediate ints when converting strings to numbers in CSS
These three are all integers - we just repeatedly multiply them by 10
and then add a digit - so using an integer here is both faster and more
accurate. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins 404a7cb63a LibGfx+LibWeb: Use floats not doubles to create HSL colors
There's really no reason to use doubles here, except at the time I
wanted to use doubles everywhere in CSS. I now realize that is
excessive, so everything can be floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins 75ec960495 LibWeb: Initialize PseudoClass/PseudoElement selectors in one go
There was no real benefit to creating the SimpleSelector early and then
modifying it, and doing so made this code harder to follow than it
needs to be.
2022-03-22 15:47:36 +01:00
Sam Atkins c0db19f63c LibWeb: Use a Variant for SimpleSelector's contents
This reduces SimpleSelector's size from 112 bytes to 80 bytes. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins 218a9af6b3 LibWeb: Make StyleComponentValueRule use a Variant
This shrinks its size from 96 bytes to 80. It's now limited by the size
of Token.
2022-03-22 15:47:36 +01:00
Sam Atkins ca1b855d99 LibWeb: Allow percentages in word/letter-spacing properties
This is a change to CSS-TEXT-4, listed here:
https://www.w3.org/TR/2022/WD-css-text-4-20220318/#changes

We don't actually support these properties yet, but it doesn't hurt to
keep them up to date for when they get implemented in the future. :^)
2022-03-22 15:45:46 +01:00
Linus Groh 701d437205 LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY(), pt 2 2022-03-22 13:36:44 +00:00
Linus Groh 70b1f18e58 LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY()
This broke the clang build.
2022-03-22 13:20:06 +00:00
Timothy Flynn c3f9cd6dbd LibWeb: Convert Range to use TRY for error propagation 2022-03-22 12:09:27 +00:00
Timothy Flynn f9cc5d1071 LibWeb: Convert HTMLOptionsCollection to use TRY for error propagation 2022-03-22 12:09:27 +00:00
Timothy Flynn 2d34216628 LibWeb: Make DOM::ExceptionOr compatible with the TRY macro
This will help reduce the quite repetitive pattern of:

    auto result_or_error = dom_node->do_something();
    if (result_or_error.is_exception())
        return result_or_error.exception();
    auto result = result_or_error.release_value();

Similar to LibJS completions, this adds an alias to the error accessors.
This also removes the requirement on release_value() for ValueType to
not be Empty, which we also had to do for TRY compatibility in LibJS.
2022-03-22 12:09:27 +00:00
Linus Groh f36f9c106b LibCrypto: Fix grammar in a couple of comments 2022-03-22 11:26:29 +00:00
Nícolas F. R. A. Prado 2c44c7fc89 KeyboardSettings: Allow changing and applying active keymap
Previously only the list of allowed keymaps could be modified and
applied to the system.

Add a new button to activate the selected keymap from the list. When
applying the changes to the system, also apply the active keymap.
2022-03-22 12:21:21 +01:00
Nícolas F. R. A. Prado a48d7d6adc KeyboardSettings: Rename m_current_applied_keymap
Rename it to m_initial_active_keymap to denote that it's the keymap that
was active when the application started up.
2022-03-22 12:21:21 +01:00
int16 3f391d80c4 SystemMonitor: Recognise wxallowed mount flag 2022-03-22 12:20:19 +01:00
int16 a4d96c159c Mount: Implement wxallowed mount option 2022-03-22 12:20:19 +01:00
Rok Povsic 5bb5967259 Browser: Append .com when pressing CTRL+Enter in the URL text editor
This is the behavior in Firefox / Chrome.
2022-03-22 12:17:48 +01:00
Rok Povsic 7da0d94d03 LibGUI: Add CTRL+Enter callback to TextEditor 2022-03-22 12:17:48 +01:00
Jelle Raaijmakers d195972ec2 Applications: Do not crash if decoded bitmap is null
ImageViewer and PixelPaint would crash when the ImageDecoderClient
returns a frame without a bitmap. This can happen with `.ico` files
with an unsupported BPP, for example.
2022-03-22 12:14:09 +01:00
Nicholas Cellino 1db7c423db disk_benchmark: Port to LibMain 2022-03-22 11:51:32 +01:00
Brian Gianforcaro 0a9e84aff0 readelf: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 575fcc42c3 purge: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro fbceebb717 ping: Utilize TRY + Core::System wrappers 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 08d65e8c38 traceroute: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 6eebd69b70 LibCore: Add Core::System::drop_privileges()
In a few places we intentionally drop privileges to reduce the potential
security surface area of networked program, with the pattern of:

```
if (setgid(getgid()) || setuid(getuid()) {
    return 1;
}
```

We can make this a bit nicer to use by creating a wrapper.
2022-03-22 11:39:20 +01:00
Brian Gianforcaro 7403342387 true: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 544609b40f printf: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro dba23c55dd matroska: Port to LibMain 2022-03-22 11:39:20 +01:00
Jamie Mansfield 9b9d32dfb2 LibWeb: Fix crash when removing event listeners 2022-03-22 02:35:07 +01:00
Timothy Flynn 27eb70cbba LibWeb: Implement HTMLSelectElement.add()
HTMLSelectElement simply defers to its HTMLOptionsCollection.
2022-03-22 02:08:15 +01:00
Timothy Flynn ff9856a214 LibWeb: Implement HTMLOptionsCollection.add() 2022-03-22 02:08:15 +01:00
Timothy Flynn 5133491714 LibWeb: Expose HTMLCollection's root element to its subclasses
For example, HTMLOptionsCollection will need to access its root
HTMLSelectElement.
2022-03-22 02:08:15 +01:00
Simon Wanner dc94879b83 LibWeb: Support transform: translate(...) by percentage 2022-03-22 02:06:21 +01:00
Simon Wanner 4f348f1733 LibGfx: Clip away coordinates outside the source bitmap
This prevents accessing the source pixels out of bounds.
2022-03-22 02:06:21 +01:00
Simon Wanner 145efbe07a LibWeb: Apply the CSS transform-origin property
We don't have transform-box yet, so this applies to the border-box
for now.

This also makes us pass a couple Web Platform Tests as well :^)
For example:
https://wpt.live/css/css-transforms/css3-transform-scale-002.html
2022-03-22 02:06:21 +01:00
Simon Wanner 63055ff5ad LibWeb: Parse the CSS transform-origin property
This is almost a PositionStyleValue, but it's serialized differently,
so let's use a StyleValueList with 2 length-percentage values.
2022-03-22 02:06:21 +01:00
Andreas Kling 8ab25f8d8c LibWeb: Implement Range.surroundContents(newParent)
Here goes another Acid3 point :^)
2022-03-21 23:28:46 +01:00
Karol Kosek 686507a38f LibWeb: Translate table cells by their top left border 2022-03-21 21:55:21 +01:00
Karol Kosek 20730c164c LibWeb: Include table cell border widths when calculating cell rects
Previously, table cells would overlap when they had CSS border or
padding properties defined.
2022-03-21 21:55:21 +01:00
Andreas Kling 68f3feb1d1 LibWeb: Fix two spec transcription mistakes in live range updating
This scores us another point on Acid3. :^)
2022-03-21 21:11:38 +01:00
Timothy Flynn 57296393ed LibWeb: Begin implementing SVGRectElement's SVGAnimatedLength attributes 2022-03-21 21:04:39 +01:00
Timothy Flynn 7a6b4e33ba LibWeb: Implement the SVGAnimatedLength type 2022-03-21 21:04:39 +01:00
Timothy Flynn ebf3829f1c LibWeb: Begin implementing the SVGLength type
There are a few unimplemented features for this type:

1. The value setter should throw a DOMException if it is invoked on an
   SVGLength that was declared readonly in another IDL file.

2. SVG::AttributeParser does not parse unit types when it parses lengths
   so all SVGLength will have an "unknown" unit for now.

3. Due to (2), methods which convert between units are unimplemented.
2022-03-21 21:04:39 +01:00
Andreas Kling 4d49c607f8 LibWeb: Fix spec transcription mistake in Range.extractContents()
The spec text and code didn't match up.

Thanks to Tim for spotting this! :^)
2022-03-21 21:01:47 +01:00
Andreas Kling ac8a8459d0 LibWeb: Don't allow setting Range start/end to document being destroyed 2022-03-21 20:37:49 +01:00
Andreas Kling 3b6323340a LibWeb: Update live ranges on Node insertion and removal
Taking care of some old FIXMEs :^)
2022-03-21 20:26:35 +01:00
Andreas Kling 1254758b00 LibWeb: Update live DOM ranges on Text and CharacterData mutations
Taking care of the FIXMEs I added in earlier patches. :^)
2022-03-21 20:06:59 +01:00
Andreas Kling c74b1b6d65 LibWeb: Implement Range.insertNode(node) 2022-03-21 19:14:50 +01:00
Andreas Kling d2f9f8bd4f LibWeb: Implement Text.splitText(offset)
With FIXMEs about updating live ranges, but still.
2022-03-21 19:14:50 +01:00
Andreas Kling 8bc3f4c186 LibWeb: Fix logic mistakes in Range stringification
We were passing the wrong length argument to substring() when
stringifying a range where start and end are the same text node.

Also, make sure we visit all the contained text nodes when appending
them to the output.

This was caught by an Acid3 subtest.
2022-03-21 19:14:50 +01:00
Andreas Kling 16f4c76da6 LibWeb: Implement Range.extractContents()
Another point on Acid3 coming through! :^)
2022-03-21 18:06:28 +01:00
Andreas Kling 24e25fe3d0 LibWeb: Add CharacterData.replaceData(offset, count, data)
Note that we don't queue mutation records or update live ranges yet,
I've left those as FIXMEs.
2022-03-21 18:05:20 +01:00
Andreas Kling e50c7de1b2 LibWeb: Add CharacterData.substringData(offset, count) 2022-03-21 17:20:42 +01:00
Andreas Kling 394cd77467 LibWeb: Implement stringifier for DOM Range :^) 2022-03-21 16:29:19 +01:00
Andreas Kling c8bdac8736 LibWeb: Implement HTMLTableRowElement.{rowIndex,sectionRowIndex}
Another point on Acid3. :^)
2022-03-21 16:15:33 +01:00
Andreas Kling 1206dd2215 LibWeb: Make parse_html_length() accept floating point numbers
This makes stuff like <img width="12.5"> work. This code is not great,
so I've left a FIXME about improving it.
2022-03-21 15:58:21 +01:00
Andreas Kling 196a3eb239 LibWeb: Ignore invisible boxes and stacking contexts during hit testing 2022-03-21 15:43:37 +01:00
Andreas Kling df8ef03957 LibWeb: Pick up the CSS "visibility" property an honor it when painting 2022-03-21 15:42:57 +01:00
Andreas Kling 01662b2320 LibWeb: Remove now-unused PaintableBox::for_each_child_in_paint_order() 2022-03-21 14:57:00 +01:00
Andreas Kling a779ace6a1 LibWeb: Don't compute fragment absolute rect twice while hit testing 2022-03-21 13:03:33 +01:00
Andreas Kling 996f3228a2 LibWeb: Fix O(n^2) traversal in hit testing
We already walk the entire paint tree within each stacking context in
the main hit testing function (StackingContext::hit_test()), so there's
no need for each individual paintable to walk its own children again.

By not doing that, we remove a source of O(n^2) traversal which made hit
testing on deeply nested web pages unbearably slow.
2022-03-21 13:03:33 +01:00
Andreas Kling f7cfd47b48 LibWeb: Add Paintable::dom_node() convenience accessor 2022-03-21 13:03:33 +01:00
Andreas Kling b64b5fa8bd LibWeb: Add Painting::HitTestResult::dom_node()
This is a convenience accessor to avoid having to say this everywhere:

    result.paintable->layout_node().dom_node()

Instead, you can now do:

    result.dom_node()
2022-03-21 13:03:33 +01:00
Andreas Kling 0ba785894c LibWeb: Make hit testing functions return Optional<HitTestResult>
Using "HitTestResult with null paintable" as a way to signal misses was
unnecessarily confusing. Let's use Optional instead. :^)
2022-03-21 13:03:33 +01:00
Andreas Kling 8c88ee1165 LibWeb: Only invalidate stacking context tree for opacity/z-index change
I came across some websites that change an elements CSS "opacity" in
their :hover selectors. That caused us to relayout on hover, which we'd
like to avoid.

With this patch, we now check if a property only affects the stacking
context tree, and if nothing layout-affecting has changed, we only
invalidate the stacking context tree, causing it to be rebuilt on next
paint or hit test.

This makes :hover { opacity: ... } rules much faster. :^)
2022-03-21 13:03:33 +01:00
Andreas Kling 59afdb959f LibWeb: Build stacking context tree lazily
There's no actual need to build the stacking context tree before
performing layout. Instead, make it lazy and build the tree when it's
actually needed for something.

This avoids a bunch of work in situations where multiple synchronous
layouts are forced (typically by JavaScript) without painting or hit
testing taking place in between.

It also opens up for style invalidations that only target the stacking
context tree.
2022-03-21 13:03:33 +01:00
Hendiadyoin1 89086c337c LibWeb: Fix constness of return type from StyleRule::block()
We want to return a view to a constant object, not a constant view,
which we can implicitly copy to get a mutable reference to the object.

Clang-Tidy helpfully pointed this out.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 2f2efc4775 LibWeb: Use llround in CSS::Token::to_closest_integer
This should be equivalent, and much shorter than a clamp and static_cast
2022-03-21 12:49:00 +01:00
Hendiadyoin1 fff12847d5 LibWeb: Pull out larger parsing parts from Parser::parse_simple_selector
This lowers its cognitive complexity from 271 to under 100.
The new `parse_pseudo_simple_selector` still has a complexity of 114.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 397d8b4aca LibWeb: Use a switch-statement on the delimiter for MatchType selection
... in Parser::parse_simple_selector
2022-03-21 12:49:00 +01:00
Hendiadyoin1 19cca57f8a LibWeb: Condense Delim checks in Parser::parse_simple_selector
This also removes some else-after-returns and adds some const qualifiers
2022-03-21 12:49:00 +01:00
Hendiadyoin1 3a162d2394 LibWeb: Add StyleComponentValueRule::is_token() helper 2022-03-21 12:49:00 +01:00
Hendiadyoin1 3f8347718c LibWeb: Use a u32 for a delim tokens value
The spec says:
> <delim-token> has a value composed of a single code point.

So using StringView is a bit overkill.
This also allows us to use switch statements in the future.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 6119783027 LibWeb: Don't copy Tokens twice on StyleBlockRule initialization 2022-03-21 12:49:00 +01:00
Hendiadyoin1 6e921ae304 LibWeb: Move passed string in MimeType constructor
This was pointed out by Clang-Tidy and should avoid an allocation.
2022-03-21 10:48:17 +01:00
Hendiadyoin1 6a95df2526 LibTextCodec: Don't allocate Strings on encoding normalisation
This ripples down to LibWeb's HTML and XHR decoders, which therefore
become less allocation heavy.
2022-03-21 10:48:17 +01:00
Simon Wanner e154c2c2ca LibWeb: Implement "has element in select scope" per-spec
The HTML Specification is quite tricky in this case.
Usually "have a particular element in <x> scope" mentions
"consisting of the following element types:", but in this case it's
"consisting of all element types except the following:"

Thanks to @AtkinsSJ for spotting this difference
2022-03-21 10:47:46 +01:00
Simon Wanner 1d55437a76 LibWeb: Ignore invalid encodings in Content-Type headers 2022-03-21 10:47:46 +01:00
Simon Wanner 917d06fa30 LibGfx: Clamp coordinates for bilinear blending correctly
Clamp these coordinates based on the src_rect's top/right/bottom/left
instead of assuming src_rect is positioned at 0,0
2022-03-21 01:48:21 +01:00
Andreas Kling 8f1a3f7878 LibWeb: Tweak our User-Agent string
- Switch from "Mozilla/4.0" to "Mozilla/5.0" to match other browsers.
- Remove references to KHTML and Gecko.
- Identify ourselves as "LibWeb+LibJS/1.0 Browser/1.0"

New UA: "Mozilla/5.0 (SerenityOS; x86_64) LibWeb+LibJS/1.0 Browser/1.0"
2022-03-20 23:16:22 +01:00
Brian Gianforcaro 16bee0ba79 Everywhere: Move js/web/wasm tests under /home/anon/Tests 2022-03-20 22:20:59 +01:00
Brian Gianforcaro 67fc81a65a Everywhere: Move cpp-tests under /home/anon/Tests 2022-03-20 22:20:59 +01:00
Andreas Kling d7492927e9 LibWeb: Avoid some layouts in getComputedStyle() property getter
For CSS properties that are known to not affect layout, we can avoid
doing a layout before returning their current resolved value.

It should be enough to only update style for the target element here,
but we don't currently have a mechanism for that.
2022-03-20 22:07:59 +01:00
Brian Gianforcaro 0998074230 LIbVT: Fix copy paste regression I introduced in #13102
I accidentally inverted this behavior in commit 2042d909972

Previously it read:
```cpp
constexpr bool is_untouched() const { return !(flags & Touched); }
```
2022-03-20 21:50:58 +01:00
thankyouverycool b8cc18896f LibGUI+FontEditor: Add context menu for editor actions
GlyphMapWidget now reports context menu requests when secondary
clicking the map. This also adds a new Select All action and updates
the Copy Character action to work on multi-glyph selections. Glyph
navigation actions have been moved to a separate Go menu, as is
common in other apps.
2022-03-20 20:00:25 +01:00
thankyouverycool 42284a1550 FontEditor: Change flip action shortcuts to Ctrl+Shift+{Q,W}
To not interfere with the command palette.
2022-03-20 20:00:25 +01:00
thankyouverycool cdd1bc64f6 FontEditor: Set width on copy only if source glyph is present
Fixes empty glyphs copying as present in fixed-width fonts.
2022-03-20 20:00:25 +01:00
thankyouverycool 212817ea20 FontEditor: Restore selections on undo/redo actions
This makes navigating undo history a lot easier to follow.
Individual glyph alterations now reset selection size if necessary
to save space.
2022-03-20 20:00:25 +01:00
thankyouverycool df443863bd LibGUI: Add set_selection() convenience helper to GlyphMapWidget 2022-03-20 20:00:25 +01:00
thankyouverycool 5c6326ae23 LibGUI: Add automatic scrolling to GlyphMapWidget
Similar to TextEditor, GlyphMapWidget now automatically scrolls
when dragging a selection outside its boundaries.
2022-03-20 20:00:25 +01:00
thankyouverycool a26e71a137 LibGUI: Use system theme when painting GlyphMapWidget focus outline 2022-03-20 20:00:25 +01:00
thankyouverycool cf13cf7225 LibGUI: Reset GlyphMapWidget only if clicking a new active glyph
Fixes an edge case in which mousing down on the active glyph within
a larger selection would reset the selection but fail to update the
glyph map. Now we can grow or shrink the selection by dragging the
active glyph even after an initial selection is made.
2022-03-20 20:00:25 +01:00
thankyouverycool 4f7b37de9c LibGUI: Use nicer API for contrained positions in GlyphMapWidget
Forgot about this little guy. Functionally the same here, but more
robust if scrollbars change.
2022-03-20 20:00:25 +01:00
thankyouverycool 54634fc2df LibGUI: Remove unnecessary MouseEvent calls in GlyphMapWidget
And pass KeyEvents directly to the relevant predecessor.
2022-03-20 20:00:25 +01:00
Simon Wanner dc8ac83f77 Browser: Size the content box in "Box Model" based on its text 2022-03-20 19:57:09 +01:00
Simon Wanner 69fc7009bf LibWeb: Grey out invisible nodes in the DOM inspector
This makes it easier to navigate large DOM trees where
some nodes have display: none
2022-03-20 19:57:09 +01:00
Tim Schumacher a128d4931d Base: Install symlinks instead of aliasing rgrep and egrep 2022-03-20 11:50:47 -07:00
Tim Schumacher 4a5d1db7f6 grep: Recognize mode based on the program name 2022-03-20 11:50:47 -07:00
Andreas Kling 8cc757b92b LibWeb: Always call Layout::Box::did_set_rect()
Since paintables have a default content size of 0x0, we were neglecting
to notify the corresponding layout node about size changes, if the used
content size came out to 0x0.

This fixes an issue where resizing an iframe to 0x0 didn't take effect.
2022-03-20 19:03:43 +01:00
Andreas Kling 07a4d590dd LibWeb: Layout browsing context parent before its children
When updating layout inside a nested browsing context, try first to
perform layout in the parent document (the nested browsing context's
container's document).

This ensures that nested browsing contexts have the right viewport
dimensions in case the parent layout changes them somehow.
2022-03-20 19:03:43 +01:00
Andreas Kling 6ac3bf2982 LibWeb: Don't crash in BrowsingContextContainer::content_document()
Instead of choking on the VERIFY(document), let's just return null if
there's no active document for now. This is incorrect, but sidesteps
a frequent crash that happens on content with iframes.

I've left a FIXME about removing the hack once it's no longer needed.
2022-03-20 19:03:43 +01:00
Andreas Kling d03680a9e7 LibWeb: Always defer callbacks in ResourceClient::set_resource()
Previously, we'd invoke the load/fail callbacks synchronously for
resources that were already loaded and cached.

This patch uses deferred_invoke() in the already-loaded case to ensure
that we always invoke these callbacks in a consistent manner.

This isn't to fix a specific issue, but rather because I kept seeing
these callbacks being invoked synchronously on top of an already-tall
call stack, and it was hard to reason about what was going on.
2022-03-20 19:03:43 +01:00
Sam Atkins d60b3be29a LibWeb: Implement the :focus-within selector
This matches if it has focus, or any nodes inside it do.
2022-03-20 17:35:31 +00:00
Andreas Kling 02497888a6 LibWeb: Ignore linked stylesheets with MIME types other than text/css
This makes the "Acid3" text on ACID3 not show up in red. :^)
2022-03-20 17:20:59 +01:00
Andreas Kling 2b7775118d LibWeb: Clear element.style when the "style" attribute is removed
We were hanging on to element inline style, even after the style
attribute was removed. This made inline style sticky and impossible to
remove. This patch fixes that. :^)
2022-03-20 16:31:40 +01:00
Andreas Kling 485ef276bd LibWeb: Invalidate style & layout inside iframes when they change size 2022-03-20 16:25:54 +01:00
Andreas Kling 618b857457 LibWeb: Evaluate @media CSS rules when updating style
In case we have new @media rules, we need to make sure we've evaluated
them before actually recomputing styles for the document.
2022-03-20 16:19:47 +01:00
Andreas Kling 80ed2ab557 LibWeb: Implement HTMLOptionElement.selected 2022-03-20 16:19:47 +01:00
Andreas Kling a606345576 LibWeb: Implement HTMLSelectElement.selectedIndex 2022-03-20 16:19:47 +01:00
Ali Mohammad Pur 5dc0855489 Spreadsheet: Use the correct top-center alignment when set to Top+Center 2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 292e459901 Spreadsheet: Allow the user to format Identity cells via JS expressions
Also add some hints as to what the format field expects as it would be
very confusing otherwise.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 8919e4b2b6 Spreadsheet: Only update the selection on primary mousedown
Otherwise we'd end up clearing the selected rect before doing anything
with it if the user right-clicks on it.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 0d302516d5 Spreadsheet: Skip over "invalid" saved cell values
These can be generated by saving something that's not serialisable (e.g.
functions), skip over them and let the load logic reevaluate them when
needed.
2022-03-20 13:20:33 +00:00
safarp b0b8d14a2c LibC: Automatically append null terminator in vswprintf 2022-03-20 08:40:36 -04:00
Andreas Kling 96db8d64f6 LibWeb: Include entire border box when painting stacking context layer
For stacking contexts that have opacity between 0 and 1, and also
contexts with a 2D transform, we first paint them into a temporary layer
buffer. Then we blend that buffer with the contents in one go.

Before this patch, we were only drawing the content box of the stacking
context into this layer buffer, which led to padding and borders missing
from elements painted this way.
2022-03-20 13:36:45 +01:00
Andreas Kling 159d4d772a LibWeb: Assign the used top/bottom border widths to inline-block boxes
We were forgetting to update these values, which led to missing top and
bottom borders for elements with display:inline-block.
2022-03-20 13:36:45 +01:00
Andreas Kling bdd42c9b0e LibWeb: Add basic support for :lang() CSS selector
This doesn't have parsing support for multiple languages in the same
selector. Support for language subcodes is not great either. But it
does do the basics.
2022-03-20 13:36:45 +01:00
Andreas Kling 5d672717aa LibWeb: Add a barebones SVGTextContentElement with getNumberOfChars() 2022-03-20 13:36:45 +01:00
sin-ack e212514bbf LookupServer: Return with failure result when lookup fails
This was missed in 4ca0669d1e and the
error condition would still fall through to an ErrorOr unwrapping which
caused a crash.
2022-03-20 12:09:31 +03:30
Ali Mohammad Pur 82a515a748 LibWasm: Increase the arbitrary local value count per type limit
It was arbitrary, it's still arbitrary, but now it's funny too :^)
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur a6c4b6848b LibWasm: Use some template magic to greatly simplify stack validation
This also auto-fixes a few bugs that were present before as we were
manually checking the stack.
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur 18c5b0f1cc LibWasm: Allow Limits max value to be equal to 2^k-1
That value fits in k bits, so we should allow it.
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur a5958b5f45 LibJS: Allow 'expect().fail("some random string")' in test-js
Previously fail() wanted the fail object to be a callable, allow it to
be a string also.
2022-03-20 10:44:32 +03:30
Simon Wanner 1d95745901 LibWeb: Implement the rest of the Adoption Agency Algorithm
This gets us 2 points on html5test.com :^)
- Before: https://html5te.st/4cf57659bc08272e (208)
- After: https://html5te.st/fb8a9259bda1c115 (210)
2022-03-20 02:52:37 +01:00
Florent Castelli e165ae5b60 LibHTTP+LibTLS: Better HTTPS Socket EOF detection
When the server doesn't signal the Content-Length or use a chunked mode,
it may just terminate the connection after sending the data.
The TLS sockets would then get stuck in a state with no data to read and
not reach the disconnected state, making some requests hang.

We know double check the EOF status of HTTP jobs after reading the
payload to resolve requests properly and also mark the TLS sockets as
EOF after processing all the data and the underlying TCP socket reaches
EOF.

Fixes #12866.
2022-03-20 01:01:40 +01:00
Andreas Kling 166cd8e881 Browser: Turn on content filtering by default :^) 2022-03-20 01:01:14 +01:00
Andreas Kling 6b5f0d11ce LibGfx: Fix draw_anti_aliased_line() for steep lines with "OnlyEnds"
Regression from ab794a199b.
2022-03-19 22:32:38 +01:00
Michiel Visser e07ec02470 LibCrypto: Move all elliptic curve private methods into .cpp
All the elliptic curve implementations had a long list of private
methods which were all stored in a single .cpp file. Now we simply use
static methods instead.
2022-03-20 00:51:50 +03:30
Michiel Visser 66d99c83d9 LibCrypto+LibTLS: Add SECP256r1 support to LibTLS
Add the required methods to SECP256r1 to conform to the EllipticCurve
virtual base class. Using this updated version of SECP256r1, support in
LibTLS is implemented.
2022-03-20 00:51:50 +03:30
Michiel Visser c1b041e761 LibCrypto+LibTLS: Generalize the elliptic curve interface
These changes generalize the interface with an elliptic curve
implementation. This allows LibTLS to support elliptic curves generally
without needing the specifics of elliptic curve implementations.

This should allow for easier addition of other elliptic curves.
2022-03-20 00:51:50 +03:30
Tim Schumacher 21bbff0349 grep: Properly update match state when handling files 2022-03-19 22:05:40 +01:00
Tim Schumacher c1004b095e grep: Adapt maximum line size depending on file size
Otherwise, we would never stop trying to fetch new lines if the next
newline is found beyond a range that the (default sized) buffer can
hold.
2022-03-19 22:05:40 +01:00
Andreas Kling ab794a199b LibGfx: Transcribe "Xiaolin Wu's line algorithm" more accurately
This improves the appearance of anti-aliased lines significantly.
2022-03-19 22:04:43 +01:00
Andreas Kling d09e8978c2 LibGfx: Be more aggressive when splitting bezier curves
Significantly reduce the tolerance when splitting bezier curves. This
gives a smoother final appearance at the cost of drawing more lines.
2022-03-19 22:04:43 +01:00
Andreas Kling 0b861e0c9d LibWeb: Make document-level style invalidation fast
Add a flag to DOM::Document that means the whole document needs a style
update. This saves us the trouble of traversing the entire DOM to mark
all nodes as needing a style update.
2022-03-19 22:04:43 +01:00
Andreas Kling f87edd4c14 LibWeb: Don't crash when detached document tries to use system palette
If the current Document is not attached to a Web::Page for whatever
reason, but we're trying to look up a color from the system palette,
let's just fail the lookup instead of crashing the process.
2022-03-19 22:04:43 +01:00
Andreas Kling aa45cdf71d LibWeb: Give StyleComputer a helper for getting the current viewport 2022-03-19 22:04:43 +01:00
Ali Mohammad Pur 3c1815a0d9 pro: Simplify the progress report logic a bit
The previous progress report changed far too fast to be meaningful,
limit the report time to 100ms, and avoid spamming the terminal with
report data that's not even readable.
Also remove some dbgln()'s.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur 6386554cd9 LibProtocol: Don't block indefinitely in stream_into's on_ready_to_read
Blocking there will lead to blocking the entire event loop, so just try
to read until something has been read or we hit EOF, this allows the
event loop to continue to deliver other events while a long download is
happening.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur dff8344336 RequestServer: Keep the EnsureConnection job alive until it finishes
Fixes #12906.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur adff9a96a6 pro: Optionally follow 3xx responses with a Location header
This is not enabled by default, and can be enabled by passing `-l`.
Fixes #12714.
2022-03-19 22:04:35 +01:00
Maciej b172bf4f84 LibCore: Add text/css mime type
Firefox throws out css files with MIME type not being "text/css", so
let's add it to make attached CSS working on WebServer. :^)
2022-03-19 22:03:51 +01:00
Maciej 273b69f947 LibCore: Add some extensions that are text/plain
C++ source/header files, GML, IPC, CMake and various Serenity config
files.
2022-03-19 22:03:51 +01:00
Maciej 933a717f3b LibCore: Make application/octet-stream the default guessed MIME type
This MIME type can be associated with every file, text/plain only with
plaintext files.

This makes browsers (e.g Firefox) properly displaying download progress
when downloading files in WebServer :^)
2022-03-19 22:03:51 +01:00
Maciej c1ca009939 WebServer: Add Content-Length header to HTTP responses
This makes the browser know how much data it should expect.
2022-03-19 22:03:51 +01:00
Itamar fc10bc3cb2 HackStudio: Search for libraries definitions in Userland/
Previously, the ProjectBuilder searched for serenity library definitions
under Userland/Libraries.

However, not all libraries are defined there. For example, LibShell is
under Userland/Shell.
2022-03-19 22:02:44 +01:00
Luke Wilde 096d2bb772 LibJS/Bytecode: Make construct Call throw if callee isn't a constructor 2022-03-19 22:01:52 +01:00
Luke Wilde eac5534ce4 LibJS/Bytecode: Add support for new.target 2022-03-19 22:01:52 +01:00
Karol Kosek fd235d8a06 LibWeb: Don't put a backslash after escape sequences in text-like tokens
Previously, a string token like '\41' would be tokenized to 'A\'. This
could be seen on Wikipedia headlines.
2022-03-19 13:10:00 -07:00
Linus Groh ff3256792d LibJS: Change nanoseconds_to_days() argument from a JS to Crypto BigInt
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0b1346c
2022-03-19 19:28:49 +00:00
Linus Groh 039cb9f189 LibJS: Change nanoseconds_to_days() result from a JS to Crypto BigInt
Similar to the preceding commit(s).
2022-03-19 19:28:49 +00:00
Linus Groh 360c65e92b LibJS: Change balance_duration() nanoseconds from a JS to Crypto BigInt
Similar to the preceding commit.
2022-03-19 19:28:49 +00:00
Linus Groh 48856498f0 LibJS: Change total_duration_nanoseconds() from JS to Crypto BigInts
This removes a bunch of silly wrapping and unwrapping of Crypto
SignedBigInteger values in JS BigInt objects, which isn't even intended
by the spec - it just wants us to take an integer value, not a BigInt
specifically. Nice opportunity to remove a couple of allocations. :^)
2022-03-19 19:28:49 +00:00
Sam Atkins 1ba6974b60 cmp: Implement cmp(1) 2022-03-19 11:01:49 -07:00
Sam Atkins 25c2a76d10 LibMain: Add the ability to configure the exit code on error
Some POSIX utilities are specified to return a specific value on error,
which is not 1. `Main::set_return_code_for_errors()` lets you set it to
that value.
2022-03-19 11:01:49 -07:00
Tim Schumacher 13ef8469da Utilities: Add support for setting permissions to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 9de742e321 Utilities: Add support for multiple sources to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 62f0fa818d LibCore: Add File::ensure_directories() 2022-03-19 10:26:33 -07:00
Tim Schumacher f44cd168b0 Utilities: Add the -c option to install 2022-03-19 10:26:33 -07:00
Andreas Kling cbd343dced LibWeb: Only delay "load" event for script elements that load something
We shouldn't delay the load event for scripts that we're completely
refusing to run anyway. Also, for scripts that have inline text content,
we don't need to delay them either, as they will become ready before
returning from "prepare script".

This makes the "load" event finally fire on lots of websites, including
Wikipedia. :^)
2022-03-19 16:11:36 +01:00
Andreas Kling c1f0d21bbe LibWeb: Rename the LayoutMode enum values and explain them
The old mode names, while mechanically accurate, didn't really reflect
their relationship to the CSS specifications.

This patch renames them as follows:

    Default => Normal
    AllPossibleLineBreaks => MinContent
    OnlyRequiredLineBreaks => MaxContent

There's also now an explainer comment with the LayoutMode enum about the
specific implications of layout in each mode.
2022-03-19 15:46:15 +01:00
Andreas Kling ceb055a75e LibWeb: Don't delay document "load" event for non-loading link elements
If we try loading a link element but it's reject for whatever reason
(broken URL, content filtering, etc.) make sure we don't mark that link
element as delaying the document load event.
2022-03-19 15:04:48 +01:00
Andreas Kling 2c9dfadb21 LibWeb: Don't delay document "load" event for unclosed script tags
We previously had a bug where markup with unclosed script tags caused
the document load event to be delayed indefinitely. Fix this by only
marking script elements as delaying the load event once we encounter
the script end tag.
2022-03-19 15:04:48 +01:00
Sam Atkins 2975d7275d LibWeb: Don't serialize hex-colors as identifiers
ID selectors need to be serialized as identifiers in the spec, but other
hash-values do not. This was causing hex colors that start with a
number, like `#54a3ff`, to serialize as `#\35 4a3ff`, which is silly
and unnecessary.

Selector serialization is done elsewhere, so this case in Token is
probably also unnecessary, but there might be situations I haven't
thought of where serializing an ID does need to happen while it's still
a Token.
2022-03-19 13:22:13 +01:00
Ali Mohammad Pur 8f7021faf7 LibJS: Implement bytecode generation for For-In/Of statements
This also implements the rather interesting behaviour that #12772 relies
on, so this fixes that bug in BC mode (the AST interp remains affected).
2022-03-19 12:51:29 +01:00
Andreas Kling 83afc1154c LibWeb: Fix IFC over-shrinking the available space for line boxes
After accounting for left-side floats, we have to subtract the offset of
the IFC's containing block again, to get the real starting X offset
for the current line.

This was done correctly in leftmost_x_offset_at() but incorrectly in
available_space_for_line(), causing IFC to break lines too early in
cases where the containing block had a non-zero X offset from the BFC
root block.
2022-03-19 12:42:10 +01:00
Andreas Kling 8d5768b103 LibWeb: Don't treat inline-level children of flex items as whitespace
This was causing us to collapse some children of flex items as if they
were useless whitespace text nodes.
2022-03-19 12:42:10 +01:00
Andreas Kling 28b771560a LibWeb: Make SVG <svg> elements behave as CSS replaced elements
This makes SVG-in-HTML behave quite a bit better by following general
replaced layout rules. It also turns <svg> elements into inline-level
boxes instead of block-level boxes.
2022-03-19 12:42:10 +01:00
Andreas Kling 48abbefb99 LibWeb: Make Paintable::hit_test() return nothing
For paintables that don't know how to hit test themselves, let's just
return nothing instead of crashing.
2022-03-19 12:42:10 +01:00
Andreas Kling 3f55271c8e LibWeb: Don't crash when dumping layout tree pre-layout
If we haven't run layout yet, there aren't any paintables attached to
the tree, so we have to null check them.
2022-03-19 12:42:10 +01:00
martinfalisse 11dffbd96f Spreadsheet+LibGUI: Calculate cell position given scroll position
Take into account the current scroll position when calculating the
position of cells. This way when the user scrolls either horizontally
or vertically, the calculations done to find the cell position
will be correct.
2022-03-19 09:31:29 +03:30
martinfalisse 5759b25ca8 Spreadsheet: Handle case when drag-and-drop location is out of bounds
When the drop location of a drag-and-drop operation is not valid, then
don't continue with the drop_event. For example, if the ending location
is the header row or header column, or is outside of the table, then
should not continue.
2022-03-19 09:31:29 +03:30
martinfalisse 9e54815799 Spreadsheet: Implement extend functionality
Implements ability to extend a cell's contents by clicking the bottom
right of the cell and dragging in a linear direction. For now, the
content that is extended is simply a copy of the target cell's
values.
2022-03-19 09:31:29 +03:30
martinfalisse f6ad98b1a1 Spreadsheet: Take into account cell order when copying and cutting
Since copying and cutting uses the cell values in the origin to decide
which values to paste in the destination, it is necessary to do it
in an ordered manner when the origin and destination ranges overlap.
Otherwise you may overwrite values in the origin unintentionally
before having successfully transferred them to the destination.
2022-03-19 09:31:29 +03:30
martinfalisse 2f2a705a8e Spreadsheet: Cut instead of copy when dragging a cell's items
Use cut instead of copy when dragging one or many cells' contents.
This is more intuitive as most other spreadsheet applications
handle the drag in this manner instead of as a copy operation.
2022-03-19 09:31:29 +03:30
martinfalisse 8a7d2c3336 Spreadsheet: Rename variables to better describe their function
Rename some variables relating to the drag-and-cut operations as
well as the select operation so that they are more clear.
2022-03-19 09:31:29 +03:30
martinfalisse e98d0dafa0 Spreadsheet: On cut end select same cells in target location
When finished dragging and cutting, select the cells in the
destination. E.g. if you select 5 cells and drag and paste
them in a new location, select the 5 pasted cells in the
destination.
2022-03-19 09:31:29 +03:30
martinfalisse 10bbb01ed8 Spreadsheet: Set cursor manually so that correct cells are outlined
Due to the fact that in the AbstractView, when multiple cells are
selected, and then another cell is selected within this selection,
the cursor is not updated as the user may be beginning to drag, have
to override this functionality for the Spreadsheet application.

This is because in spreadsheets when multiple cells are selected,
and then you click on one of the cells within the selection,
the selection should be cleared and the targetted cell highlighted.
2022-03-19 09:31:29 +03:30
martinfalisse 1287238430 Spreadsheet: Select the correct cell on click
Due to the margin that is given to be able to select cells for
cutting or extending, have to override the mouse click function
so that the targetted cell is chosen and not the one that may be
beneath the cursor.
2022-03-19 09:31:29 +03:30
martinfalisse 4f0a123b2f Spreadsheet: Display different cursors depending on action
Depending on the cursor location with respect to a selected cell,
display different icons pertaining to the distinct possible actions,
for example dragging and cutting, extending the cell's contents, or
doing a simple selection.
2022-03-19 09:31:29 +03:30
martinfalisse a378e3ccbf Spreadsheet: Add states for cursor hovering
Add states for the cutting and extending icons that are to be shown
depending on where the user's cursor is with respect to the target
cell.
2022-03-19 09:31:29 +03:30
Lenny Maiorani a0367aa43b DevTools+LibJS+LibWeb: Change class_name to use StringView
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 5b7a5b3c01 LibCpp: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 327e9a2187 LibCore: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 66189169f9 LibGfx: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00