Commit Graph

18571 Commits

Author SHA1 Message Date
Andreas Kling
97b5230413 LibWeb: Subtract border & padding when using flex line size as item size
The flex line cross size includes the margin boxes of items, so when
we're taking the flex line's cross size to use as an item cross size,
we have to subtract the margin, border padding from both sides.

Previous we only subtracted the cross margins, which led to oversized
items in some cases.
2022-09-18 18:34:42 +02:00
Andreas Kling
7bf3b40867 LibWeb: Remove bogus main space restriction in wrapping flex layouts 2022-09-18 18:34:42 +02:00
Timothy Flynn
887dac0929 LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"
This is a normative change to the Intl NumberFormat V3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/4751da5
2022-09-18 09:45:40 -04:00
Andreas Kling
0ca1b4b123 LibWeb: Don't replace existing Content-Type header in outgoing XHRs
This fixes an issue where Twitter was HTTP 400'ing some of our XHRs.
2022-09-18 12:53:06 +02:00
Andreas Kling
575e3bf37d LibWeb: Check document fully active status in "element cannot navigate"
This resolves a FIXME and brings us closer to spec.
2022-09-18 12:53:06 +02:00
Andreas Kling
e6ef366859 LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
2022-09-18 02:17:29 +02:00
Andreas Kling
3df9861814 LibWeb: Capture self as a WeakPtr in ResourceClient::set_resource()
It's not safe to capture `this` as a raw pointer here, since nothing
is guaranteed to keep the ResourceClient alive (even if the Resource
stays alive.)
2022-09-18 02:15:01 +02:00
Andreas Kling
fa2dd4cbe3 LibWeb: Make Document vend the same HTMLCollections every time 2022-09-18 02:08:01 +02:00
Andreas Kling
1903dff365 LibWeb: Support getting and setting Attr.textContent 2022-09-18 02:08:01 +02:00
Andreas Kling
530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Andreas Kling
3c3ae3a768 LibWeb: Only uppercase qualified names in HTML documents
This takes care of an old FIXME now that we can distinguish between HTML
and non-HTML documents.
2022-09-18 00:53:26 +02:00
Andreas Kling
dc6e625680 LibWeb: Make ParentNode.children vend the same HTMLCollection every time
Instead of creating a new HTMLCollection every time you access
.children, we now follow the spec and vend the same object.

This was annoyingly difficult before, and trivial now that the DOM is
garbage-collected. :^)
2022-09-18 00:42:33 +02:00
Andreas Kling
6b3293a74b LibWeb: Support getElementsByTagName() properly in non-HTML documents 2022-09-18 00:39:42 +02:00
Andreas Kling
bd0648a492 LibWeb: Simplify getElementsByTagName{,NS}() filters
Everything below the collection root is a descendant of the collection
root, so there's no need to check is_descendant_of() :^)
2022-09-18 00:37:24 +02:00
Andreas Kling
e72896e35e LibWeb: Get default fonts via Platform::FontPlugin
Instead of asking Gfx::FontDatabase for the "default font" and the
"default fixed-width font", we now proxy those requests out via
the Platform::FontPlugin. This will allow Ladybird to use other default
fonts as fallback.
2022-09-17 21:27:32 +02:00
Sam Atkins
ebc29842c8 LibWeb: Start implementing the IDL Overload Resolution Algorithm :^)
There are a *lot* of FIXME's here. :yakoverflow:
2022-09-17 21:27:17 +02:00
Sam Atkins
0d2d5ba02c LibIDL: Implement EffectiveOverloadSet
This requires a little explanation. The overload resolution algorithm,
where this is used, repeatedly has steps like this:

> Otherwise: if V is a platform object, and there is an entry in S that
> has one of the following types at position i of its type list,
>  - an interface type that V implements
>  - object
>  - a nullable version of any of the above types
>  - an annotated type whose inner type is one of the above types
>  - a union type, nullable union type, or annotated union type that has
>    one of the above types in its flattened member types
> then remove from S all other entries.

So, the API here tries to match that. We save the matching entry when
checking through them and then use that in `remove_all_other_entries()`.

Removing all those entries when all we actually care about is looking at
that one matching entry feels silly, but sticking to the spec is more
important while things are still half-implemented. :^)
2022-09-17 21:27:17 +02:00
Sam Atkins
8b4cc07a54 LibIDL+WrapperGenerator: Implement Type::is_distinguishable_from()
As part of this, I've moved a couple of methods for checking for
null/undefined from UnionType to Type, and filled in more of their
steps.

This now detects more, and so causes us to hit a `TODO()` which is too
big for me to go after right now, so I've replaced that assertion with
a log message.
2022-09-17 21:27:17 +02:00
Sam Atkins
7c8ef79898 LibIDL+WrapperGenerator: Make it easier to work with IDL::Type classes
Track the kind of Type it is, and use that to provide some convenient
`is_foo()` / `as_foo()` methods. While I was at it, made these all
classes instead of structs and made their data private.
2022-09-17 21:27:17 +02:00
Sam Atkins
c4668053d1 LibIDL+WrapperGenerator: Move IDL code into a library
IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
2022-09-17 21:27:17 +02:00
Jelle Raaijmakers
6c87c98ed0 LibGL: Remove GL::present_context
No need for a static method if all it does is invoke the object method.
2022-09-17 19:38:30 +02:00
Andreas Kling
83c69fa62e LibWeb: Handle JavaScript source code with non-UTF-8 encoding
When fetching scripts in HTMLScriptElement's "prepare a script"
algorithm, we now re-encode the script sources to UTF-8.
2022-09-17 18:53:26 +02:00
Andreas Kling
da451467b1 LibWeb: Implement basic "scroll" events at the document level 2022-09-17 18:53:26 +02:00
Andreas Kling
07c4bf03b5 LibWeb: Add "scripts to execute in order as soon as possible"
Previously, we had accidentally conflated this set with the
similar-but-distinct "scripts to execute as soon as possible".
2022-09-17 18:53:26 +02:00
Andreas Kling
df7e64d103 LibWeb: Handle multiple class names in getElementsByClassName()
The input string is actually a space-separated list of class names,
not a single class name.
2022-09-17 18:53:26 +02:00
Andreas Kling
2371446952 LibWeb: Update layout in HTMLElement.offset{Top,Left}
We can't report layout-dependent metrics without first ensuring that
layout is up-to-date.
2022-09-17 18:53:26 +02:00
Andreas Kling
9e274d9501 LibWeb: Make Document.createElement() lowercase HTML local names
Bring createElement() a little bit closer to spec-compliance.
2022-09-17 18:53:26 +02:00
davidot
03c468fb7d LibJS: Parse date strings like "9/17/2022" 2022-09-17 18:53:14 +02:00
Jelle Raaijmakers
f6dfd77268 LibGL: Prevent segfault due to texture destruction
Destruction of `GL::GLContext` resulted in the destruction of
`GPU::Driver` _before_ the destruction of the allocated textures, which
in turn point to `GPU::Image` objects. Since the destruction of
`GPU::Driver` unloads the shared library, we were trying to invoke
non-existing code.

Fix this by moving `m_driver` up in `GLContext` so that it's last in
line for destruction.
2022-09-17 09:21:52 +00:00
Julian Offenhäuser
77f5f7a6f4 LibPDF: Support parsing page tree nodes that are in object streams
conditionally_parse_page_tree_node used to assume that the xref table
contained a byte offset, even for compressed objects. It now uses the
common facilities for parsing objects, at the expense of some
performance.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
6225c03256 LibPDF: Rename argument for the latin character set enumeration macro
The previous name "V" collided with one of the entries.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
633e1632d0 LibPDF: Allow whitespace other than EOL after an object marker 2022-09-17 10:07:14 +01:00
Julian Offenhäuser
65e83bed53 LibPDF: Disallow parsing indirect values as operands
An operation like 0 0 0 RG would have been confused for [ 0, 0 0 R ] G
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
04cb00dc9a LibPDF: Fix handling of differences array in custom encodings
When looking up differences in the specified encoding, we previously
didn't recognize a lot of characters, namely those that are referred to
by a string in the PDF itself, like "/germandbls".

We now create a mapping of those characters to the code points they are
referring to, and correctly look them up when needed.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
36828f1385 LibPDF: Don't expect glyph width arrays to contain integers
They might also contain floats, in which case we convert them to int
before use.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
97ed4106e5 LibPDF: Fix text positioning with operator TJ
As per spec, the positioning (or kerning) parameter of this operator
should translate the text matrix before the next showing of text.
Previously, this calculation was slightly wrong and also only applied
after the text was already shown.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
563d91b6c4 LibPDF: Implement loading compressed objects from object streams
Now, whenever the xref table points to a compressed object,
parse_object_with_index will look it up in the corresponding object
stream as if it were a regular object.

With this, our parser gains the bare minimum support for xref streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
f9beff7b5e LibPDF: Initial work on parsing xref streams
Since PDF version 1.5, a document may omit the xref table in favor of
a new kind of xref stream object. This is used to reference so-called
"compressed" objects that are part of an object stream.

With this patch we are able to parse this new kind of xref object, but
we'll have to implement object streams to use them correctly.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
4887aacec7 LibPDF: Move document-specific parsing functionality into its own class
The Parser class is now a generic PDF object parser, of which the new
DocumentParser class derives. DocumentParser now takes over all
functions relating to linearization, pages, xref and trailer handling.

This allows the use of multiple parsers in the same document's
context, which will be needed in order to handle PDF object streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
9f4659cc63 LibPDF: Move consume and match helper functions to the Reader class 2022-09-17 10:07:14 +01:00
Ben Wiederhake
8de7a91571 LibCompress+Tests: Demonstrate and fix faulty metadata length
The test-case is heavily inspired by:
https://github.com/google/brotli/blob/master/tests/testdata/x.compressed.01
Or in words: A metadata meta-block containing `Y` (which should be
ignored), and then the actual data (a single `Z`). The bug used to skip
one metadata byte too few, and thus read garbage.
2022-09-17 04:10:11 +00:00
Ben Wiederhake
fe48fed4fa LibWeb: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
e909231d78 LibWeb: Break inclusion cycle through forward-declaration 2022-09-17 04:00:54 +00:00
Ben Wiederhake
4cd382c621 LibJS: Break another inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
6a4e2efa65 LibJS: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
ff96747e17 LibPDF: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
75673319ad LibDebug: Break inclusion cycle through many forward-declarations 2022-09-17 04:00:54 +00:00
Ben Wiederhake
7c5e30daaa Everywhere: Fix badly-formatted includes 2022-09-17 04:00:54 +00:00
Tommaso Peduzzi
f547b9be7b PixelPaint: Scale layer and preserve aspect ratio
This patch adds the ability to scale a layer and
preserve the aspect ratio.
When the Shift key is pressed, the aspect ratio is preserved.
2022-09-16 22:53:07 +02:00
Tommaso Peduzzi
293ab2cdc9 PixelPaint: Add scaling function to move tool
This patch adds scaling function to the move tool.
When the cursor is over the lower right corner of the layer, it changes.
This is to signify that the layer can be scaled by dragging the mouse.

There is currently no preview of the scaling.
Doing a resize every time the mouse moves leads to unexpected behavior.
2022-09-16 22:53:07 +02:00
Tim Schumacher
ef9b543426 LibC: Remove the LibM interface target 2022-09-16 16:09:19 +00:00
Tim Schumacher
1b25c38b8b Everywhere: Fully remove the separate LibM directory 2022-09-16 16:09:19 +00:00
Tim Schumacher
81d46fa100 LibM: Move the math standard library to LibC 2022-09-16 16:09:19 +00:00
Andrew Kaster
eef989f9ed LibGPU: Don't use relative paths for libsoftgpu in Lagom environments
We can count on the dynamic loader for each platform, and the RPATH of
our build infrastrucuture, to load the lib up automagically.
2022-09-16 15:32:38 +02:00
Andrew Kaster
8ed5ed3ec0 LibGL: Make GL::create_context fallible
Propagate errors in places that are already set up to handle them, like
WebGLRenderingContext and the Tubes demo, and convert other callers
to using MUST.
2022-09-16 15:32:38 +02:00
Timothy Flynn
7e5080ea53 LibGUI: Load emoji icons for EmojiInputDialog through Gfx::Emoji
No difference when cold-loading the emoji icons, but for a warm load,
this provides a per-process cache of the loaded icons.
2022-09-16 15:20:59 +02:00
Timothy Flynn
98f99a9f7e LibGfx: Change Emoji::emoji_for_code_points to accept const code points
Span<u32 const> is the type used when converting a constant Vector<u32>
to a Span.
2022-09-16 15:20:59 +02:00
Timothy Flynn
35b74ebbfc LibGUI: Defer loading emoji icons until their first paint event
The EmojiInputDialog re-uses emoji buttons to help with performance as
filters are applied / removed. The downside of pre-creating the buttons
is that it currently takes upwards of 600ms (on my machine) to load all
emoji icons from disk at once. This will only become worse over time as
more emoji are added.

To alleviate this, defer loading the icons until they are needed for
painting (i.e. come into view).
2022-09-16 15:20:59 +02:00
Andreas Kling
cd7262ee56 LibWeb+LibWebView+WebContent: Add Web::Platform::ImageCodecPlugin
This replaces the previous Web::ImageDecoding::Decoder interface.
While we're doing this, also move the SerenityOS implementation of this
interface from LibWebView to WebContent. That means we no longer have to
link with LibImageDecoderClient in applications that use a web view.
2022-09-16 15:15:50 +02:00
Andreas Kling
412b2313f3 LibWeb: Improve inline flow around floating boxes
This patch combines a number of techniques to make inline content flow
more correctly around floats:

- During inline layout, BFC now lets LineBuilder decide the Y coordinate
  when inserting a new float. LineBuilder has more information about the
  currently accumulated line, and can make better breaking decisions.

- When inserting a float on one side, and the top of the newly inserted
  float is below the bottommost float on the opposite side, we now reset
  the opposite side back to the start of that edge. This improves
  breaking behavior between opposite-side floats.

- After inserting a float during inline layout, we now recalculate the
  available space on the line, but don't adjust X offsets of already
  existing fragments. This is handled by update_last_line() anyway,
  so it was pointless busywork.

- When measuring whether a line can fit at a given Y coordinate, we now
  consider both the top and bottom Y values of the line. This fixes an
  issue where the bottom part of a line would bleed over other content
  (since we had only checked that the top Y coordinate of that line
  would fit.)

There are some pretty brain-dead algorithms in here that we need to make
smarter, but I didn't want to complicate this any further so I've left
FIXMEs about them instead.
2022-09-16 15:15:50 +02:00
Andreas Kling
54e7359243 LibWeb: Repaint the page immediately when using the mouse to select
Otherwise we'd repaint the next time our "caret blink" timer would fire
(or something else caused a repaint). This made selection feel sluggish.
2022-09-16 15:15:50 +02:00
Enver Balalic
11a44ffb69 LibGfx: Recurse TrueType composite glyphs until a simple glyph is found
This fixes a bug in ladybird where it was crashing while rendering
characters like ščćž in the Noto Sans Regular font.

That font renders those characters as a composite where the caret
has numberOfContours = -1. When using the rasterize_impl simple path
for that, it would negatively overflow the offsets.
2022-09-16 14:52:03 +02:00
MacDue
011439d3e3 LibWeb: Paint backdrop-filter effects!
This implements all the filters other than `saturate()`,
`hue-rotate()`, and `drop-shadow()`.

There are still a lot of FIXMEs to handle in the actual implementation
though, particularly around supporting transforms, but this handles
the most common use cases :^)
2022-09-16 10:50:48 +01:00
MacDue
60356c8dde LibGfx: Support getting a bitmap for a region of painter
This will be needed so we can apply filter effects to the backdrop
of an element in LibWeb.

This now also allows getting a crop of a bitmap in a different format
than the source bitmap. This is for if the painter's bitmap does not
have an alpha channel, but you want to ensure the cropped bitmap does.
2022-09-16 10:50:48 +01:00
MacDue
978a70ddcc LibGfx: Add BrightnessFilter, ContrastFilter, and OpacityFilter
These filters are based off the ones defined in:
https://drafts.fxtf.org/filter-effects-1/#supported-filter-functions
2022-09-16 10:50:48 +01:00
MacDue
8f225acf58 LibGfx: Allow applying all color filters with an amount
This amount can be handled in the filter's implementation or if
not it will default to mixing between the new and previous pixel.

This behaviour is used for implementing CSS filters that allow stuff
like grayscale(70%).
2022-09-16 10:50:48 +01:00
MacDue
7bc0c66290 LibWeb+LibGfx: Move premultiplied alpha mixing to color.mixed_with()
This will be needed for mixing filters in LibGfx (and may be
generally useful elsewhere).
2022-09-16 10:50:48 +01:00
MacDue
ec4de1e07d LibWeb: Plumb style/computed values for backdrop-filter 2022-09-16 10:50:48 +01:00
MacDue
d1b99282d8 LibWeb+Meta: Parse the backdrop-filter CSS property
Note: The parsing and style value completely ignores the SVG filters
part of the spec for now... That's a yak for another day :^)
2022-09-16 10:50:48 +01:00
MacDue
980c92e9b5 LibWeb: Add FilterValueListStyleValue
This style value holds a list of CSS filter function calls e.g.

blur(10px) invert() grayscale()

It will be used to implement backdrop-filter, but the same style value
can be used for the image filter property.

(The name is a little awkward but it's referenced to as
filter-value-list in the spec too).
2022-09-16 10:50:48 +01:00
MacDue
776538a6c4 LibWeb: Add operator== to CSS::Number
This will be needed for the .equals() function of the backdrop-filter
style value.
2022-09-16 10:50:48 +01:00
MacDue
84d9a226e6 LibWeb: Add NumberPercentage CSS type
This type is used quite a bit in CSS filters.
2022-09-16 10:50:48 +01:00
MacDue
b219931dfc LibWeb: Pass values by reference in style value operator== functions 2022-09-16 10:50:48 +01:00
Tim Schumacher
88ff01bb17 LibC: Remove _aligned_malloc and _aligned_free
We now have a proper aligned allocation implementation, and the
toolchain patch to make Clang use the intermediary implementation
has already been removed in an earlier iteration.
2022-09-16 05:39:28 +00:00
Tim Schumacher
388dc9cc5f LibJS: Supress an unused bind when wrapping float atomic operations 2022-09-16 05:39:28 +00:00
Tim Schumacher
8763dbcccc Everywhere: Remove a bunch of dead write-only variables
LLVM 15 now warns (and thus errors) about this, and there is really no
point in keeping them.
2022-09-16 05:39:28 +00:00
Ben Wiederhake
79ec6ed03d Shell: Fix 'Command:' output for built-in 'time' command 2022-09-16 05:38:09 +00:00
Andreas Kling
d1dac8695c LibWeb: Don't set initial font+color on both HTML and BODY elements
It's enough to set it on the HTML element. That way, it doesn't get
reset in content that sets its own font on HTML but not on BODY.
2022-09-15 16:16:56 +02:00
Andreas Kling
1dd4e2dc87 LibWeb: Cache lowercased names in SimpleSelector
When matching selectors in HTML documents, we know that all the elements
have lowercase local names already (the parser makes sure of this.)

Style sheets still need to remember the original name strings, in case
we want to match against non-HTML content like XML/SVG. To make the
common HTML case faster, we now cache a lowercase version of the name
with each type/class/id SimpleSelector.

This makes tag type checks O(1) instead of O(n).
2022-09-15 16:16:56 +02:00
Andreas Kling
d9c64ee876 LibWeb: Hoist case sensitivity check out of loop in Element::has_class() 2022-09-15 16:16:56 +02:00
Ben Wiederhake
8deced39a8 LibWeb: Resolve cyclic declaration/definitions involving Length
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/CSS/GridTrackSize.h>
    // That's it, this was enough to cause a compilation error.
2022-09-15 14:45:38 +01:00
Lucas CHOLLET
53eb35caba Calculator: Change internal representation to support perfect division
The purpose of this patch is to support addition, subtraction,
multiplication and division without using conversion to double. To this
end, we use the BigFraction class of LibCrypto. With this solution, we
can store values without any losses and forward rounding as the last
step before displaying.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET
4ab8ad2ed2 LibCrypto: Fix -0 and 0 non-equality
SignedBigInteger::operator==(const UnsignedBigInteger&) was rejecting
all negative value before testing for equality. It now accepts negative
zero and test for a value equality with the UnsignedBigInteger.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET
6a937312b3 LibCrypto: Add BigFraction
This new abstraction allows the user to store rational numbers with
infinite precision.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET
d589898f5b LibCrypto: Add SignedBigInteger::negated_value()
Return the negated value of the current number.
2022-09-15 14:08:21 +01:00
Andreas Kling
a60c5166c6 LibWeb: Don't ignore data: URLs in @font-face src
Since data: URLs don't have a path, we shouldn't be checking for a TTF
or WOFF extension.

Thanks Timon for pointing this out! :^)
2022-09-15 12:45:00 +02:00
Andreas Kling
4910cc1879 LibGfx: Cache vector fonts by family name
Instead of just keeping them in an unsorted Vector, which led to
increasingly noticeable O(n) lookups, we now cache a list of Typefaces
per family name.
2022-09-15 12:45:00 +02:00
sin-ack
a192095594 LibCore: Rewrite Core::Stream::read_all_impl
The previous version relied on manually setting the amount of data to
read for the next chunk and was overall unclear. The new version uses
the Bytes API to vastly improve readability, and fixes a bug where
reading from files where a single read that wasn't of equal size to the
block size would cause the byte buffer to be incorrectly resized causing
corrupted output.
2022-09-15 12:01:16 +02:00
sin-ack
d3979b0bbd LibCore: Add documentation to Stream functions + make parameter clearer
file_size was not very clear about what it was being used for, so I
switched it to say expected_file_size to make it clear that it's just a
heuristic.
2022-09-15 12:01:16 +02:00
Luke Wilde
6a4934a030 LibWeb: Implement document.domain getter
The document.domain setter is currently stubbed as that is a doozy to
implement, given how much restrictions there are in place to try and
prevent use of it and potential multi-process implications.

This was the only thing preventing us from being able to start
displaying ads delivered via Google Syndication.
2022-09-15 09:46:04 +02:00
Timothy Flynn
85e313077a LibJS: Do not invoke Cell::vm in constructors before Cell is constructed
In a subclass of Cell, we cannot use Cell::vm() before the base Cell
object itself is constructed. Use the Realm's VM instead.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
3efe611dbf LibJS: Do not assume that IsArray means the object type is an Array
IsArray returns true if the object is an Array *or* if it is a
ProxyObject whose target is an Array. Therefore, we cannot downcast to
an Array based on IsArray.

Luckily, we don't actually need an Array here; SerializeJSONArray only
needs an Object.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
98a6f962a0 LibJS: Use correct include + object class for Function{Object,Prototype}
Not causing any real issue, just noticed while debugging vptr sanitation
errors.
2022-09-15 09:45:13 +02:00
Andreas Kling
1c0fc75cb6 LibWeb: Fix bogus condition when checking CSS font file extensions
Thanks Idan for pointing this out! :^)
2022-09-15 01:20:35 +02:00
Andreas Kling
6d92c1d231 LibWeb: Be slightly better at @font-face rules with multiple sources
This patch improves @font-face loading when there are multiple src
values in two ways:

- Invalid/empty URLs are ignored
- Fonts with unsupported file extensions are ignored

This makes us load and display the emblem font on modern Reddit,
which is pretty neat! :^)
2022-09-14 21:46:34 +02:00
Andreas Kling
c5a19a4d55 LibWeb: Allow CSS at-rules to have an empty prelude
I don't see any indication in the spec that an empty prelude should be
disallowed. This fixes rules like `@font-face{...}` (note the absence
of whitespace before the `{`.)
2022-09-14 21:37:19 +02:00
Andreas Kling
f64c175960 LibWeb: Invalidate layout whenever a CSS font is loaded
It's not enough to invalidate only the style, we have to do a full
layout invalidation since new fonts might mean new metrics, etc.
2022-09-14 21:24:31 +02:00
Andreas Kling
df49a6ae9b LibWeb: Schedule a layout update in Document::invalidate_layout()
Otherwise, nothing will repaint until someone else decides to trigger
an update.
2022-09-14 21:23:39 +02:00
Andreas Kling
463355d1eb LibWeb: Allow data: URLs with font/ MIME type in @font-face CSS rules 2022-09-14 21:14:16 +02:00
Andreas Kling
34025442ff LibWeb: Account for float's container offsets in BFC root auto height
When calculating the automatic height of a BFC root, we stretch it to
contain the bottommost margin edge of floating boxes.

Before this change, we assumed that floating boxes had coordinates
relative to the BFC root, when they're actually relative to the floating
box's containing block. This may or may not be the BFC root, so we have
to use margin_box_in_ancestor_coordinate_space() to apply offsets from
all boxes in the containing block chain (up to the BFC root).
2022-09-14 20:18:49 +02:00
Jelle Raaijmakers
8ff7c52cf4 LibSoftGPU: Return a const& texel in Image to prevent copying
On every texel access, some floating point instructions involved in
copying 4 floats popped up. Let `Image::texel() const` return a
`FloatVector4 const&` to prevent these operations.

This results in a ~7% FPS increase in GLQuake on my machine.
2022-09-14 17:17:36 +02:00
Jelle Raaijmakers
e9d2f9a95e LibSoftGPU: Use memcpy instead of a loop to blit the color buffer
Looking at `Tubes` before and after this change, comparing the original
loop to the one using `memcpy`, including the time for `memcpy` itself,
resulted in ~15% fewer samples in profiles on my machine.
2022-09-14 17:17:19 +02:00
Jelle Raaijmakers
bfb4e08612 LibGfx: Use memcpy instead of fast_u32_copy for blitting
In some artificial full screen blitting profiling, I've seen `memcpy`
take up about 4% fewer samples each time I measure. It seems like
`fast_u32_copy` is not as fast as it'd like to believe.
2022-09-14 17:17:19 +02:00
Andreas Kling
57ad99ef16 LibWeb: Don't show pointer (hand) cursor over non-linked a elements
This is already handled by the :link and :visited style.
2022-09-14 15:05:10 +02:00
Andreas Kling
35a9a2fbb2 LibWeb: Account for containing block padding when placing abspos boxes
Unlike the other positioning schemes, absolute positioning is relative
to the *padding* edge of the containing block.
2022-09-14 14:43:17 +02:00
Andreas Kling
d27136fcb0 LibWeb: Replace most of our default UA stylesheet with spec rules
The HTML spec provides a set of suitable default CSS rules for our UA
stylesheet, so let's use those instead of inventing our own. :^)

Note that I had to replace "foo-block-start" properties with "foo-top"
since we don't support the block/inline direction based properties yet.
2022-09-14 14:43:17 +02:00
Andreas Kling
4b9c5635b3 LibWeb: Make :link selector behave according to spec
It should match any `a` or `area` element that has an `href` attribute,
not any element *inside* an enclosing linked element.
2022-09-14 14:43:17 +02:00
Andreas Kling
f25203f245 LibWeb: Don't re-resolve "auto" flex item sizes after definitizing them
This is rather subtle and points to our architecture around definite
sizes not being exactly right, but...

At some points during flexbox layout, the spec tells us that the sizes
of certain flex items are considered definite from this point on.
We implement this by marking each item's associated UsedValues as
"has-definite-width/height".

However, this breaks code that tries to resolve computed "auto" sizes
by taking the corresponding size from the containing block. The end
result was that the 1st sizing pass in flexbox would find the right size
for an "auto" sized item, but the 2nd pass would override the correct
size with the containing block's content size in that axis instead.

To work around the issue, FFC now remembers when it "definitizes" an
item, and future attempts to resolve an "auto" computed size for that
value will bypass the computed-auto-is-resolved-against-containing-block
step of the algorithm. It's not perfect, and we'll need to think more
about how to really represent these intermediate states relating to
box sizes being definite..
2022-09-14 14:43:17 +02:00
Andreas Kling
b8aa6a4453 LibWeb: Use PercentageOr<T>::contains_percentage() in CSS layout
By asking if the value *contains* a percentage rather than whether it
*is* one, we cover many more cases where e.g `width: calc(100% - 10px)`
should be "treated as auto" etc.
2022-09-14 14:43:17 +02:00
Andreas Kling
c4050fe675 LibWeb: Treat unimplemented grid-track-size syntax as "auto" for now
Note that there's a FIXME just above the previous case. That applies to
this workaround as well.
2022-09-14 14:43:17 +02:00
Andreas Kling
55ad9591df LibWeb: Add a way to ask if a PercentageOr<T> value contains percentages
Values that contain percentages require special treatment in various
parts of layout. Previously we had no way of peeking into calc() values
to see if their expression contains one or more percentages. That's the
bulk of what we're adding here.
2022-09-14 14:43:17 +02:00
electrikmilk
fdd202259d LibWeb: Add partial serialization for CSSFontFaceRule
This partially adds serialization code for
`CSSFontFaceRule::serialized()` to spec. This is only partially
implemented as some parts of the `@font-face` rule are not implemented
yet.
2022-09-14 10:50:33 +01:00
Brian Gianforcaro
d0a1775369 Everywhere: Fix a variety of typos
Spelling fixes found by `codespell`.
2022-09-14 04:46:49 +00:00
Andreas Kling
63c727a4a3 LibWeb: Don't clip to containing block when painting abspos descendants 2022-09-14 00:09:49 +02:00
Andreas Kling
f941b7aefe LibWeb: Create stacking context for flex/grid items with z-index != auto 2022-09-14 00:09:49 +02:00
Andreas Kling
fb5879fdcc LibWeb: Don't include abspos children in containing block's auto width 2022-09-14 00:09:49 +02:00
martinfalisse
df22f38feb LibWeb: Inform the parent context of the grid's size 2022-09-14 00:09:14 +02:00
martinfalisse
214329b81c LibWeb: Layout grid items after calculation
Now that the positions of each grid item have been calculated, and the
sizes of the individual rows and columns ascertained, can actually
layout the different items.
2022-09-14 00:09:14 +02:00
martinfalisse
58078c1f40 LibWeb: Calculate sizes of Auto grid tracks 2022-09-14 00:09:14 +02:00
martinfalisse
f558fd93b7 LibWeb: Calculate sizes of FlexibleLength grid tracks 2022-09-14 00:09:14 +02:00
martinfalisse
fbe703e2bd LibWeb: Follow spec for calculating intrinsic track sizes 2022-09-14 00:09:14 +02:00
martinfalisse
b7d053421e LibWeb: Calculate sizes of known grid track sizes
Calculate the sizes of grid tracks for which there is a clear size
(length or percentage has been specified).
2022-09-14 00:09:14 +02:00
martinfalisse
6b649b6343 LibWeb: Start sizing grid tracks
The second part of formatting the display grid is calculating the sizes
of the columns and rows.
2022-09-14 00:09:14 +02:00
martinfalisse
902bdc8f15 LibWeb: Position remaining grid items 2022-09-14 00:09:14 +02:00
martinfalisse
707b76ed41 LibWeb: Position grid items with fixed row positions 2022-09-14 00:09:14 +02:00
martinfalisse
f143fefca2 LibWeb: Position grid items with fixed position values 2022-09-14 00:09:14 +02:00
martinfalisse
e0cd63f531 LibWeb: Add array to keep track of grid boxes left to place
This structure will be useful to subtract from after placing different
boxes into the grid.
2022-09-14 00:09:14 +02:00
martinfalisse
a2ecb903af LibWeb: New start at layouting out the grid
According to the spec it's necessary to:
1. Layout the cells in the grid
2. Find the sizes of the rows and columns

Since I had started to do this backwards, and as I expand in future
commits, I take here the opportunity to start with a clean state.

The occupation_grid keeps track of which cells in the grid have been
filled out.
2022-09-14 00:09:14 +02:00
martinfalisse
df88e2bd8e LibWeb: Add spec utility function for GridTrackSize
Often in the spec they talk about intrinsic_track_sizes and this way can
have a clearer way of checking if a GridTrackSize is indeed an
"intrinsic track size".
2022-09-14 00:09:14 +02:00
martinfalisse
9681eb89a6 LibWeb: Add helper function for creating auto GridTrackSizes
Makes it more convenient to create auto GridTrackSizes. I think having
an auto GridTrackSize be defined by an auto Length value kind of
confusing, and this at least helps when creating one.
2022-09-14 00:09:14 +02:00
martinfalisse
ad221164d5 LibWeb: Allow having auto GridTrackPlacements
For grid-row-start, grid-column-end and similar values it is possible to
have auto values (nothing was specified, for example).
2022-09-14 00:09:14 +02:00
martinfalisse
0613972f0c LibWeb: Only set has_span if there is a number following the css value
To follow spec more closely, only set the has_span value if there is a
number immediately following, like "span 2". Otherwise the span value
should be ignored.
2022-09-14 00:09:14 +02:00
martinfalisse
493c6cf0fd LibWeb: Parse flexible length values for GridTrackSizes
Fix a bug as well as implement new functionality by parsing flexible
length values for GridTrackSizes.
2022-09-14 00:09:14 +02:00
martinfalisse
2fa124e8d9 LibWeb: Use float for GridTrackSize length value
Use float instead of int for the GridTrackSize length value as
FlexibleLengths can be "1fr" as well as ".49fr" in grid-track-row
and grid-track-column values.
2022-09-14 00:09:14 +02:00
Hendiadyoin1
1ea90e340c LibWeb: Visit all edge-members in WorkerGlobalScope 2022-09-13 20:55:21 +02:00
Hendiadyoin1
34439a04e8 LibWeb: Add a visit_edges for DOM/Event 2022-09-13 20:55:21 +02:00
Hendiadyoin1
5bd34f115e LibWeb: Add some missing includes 2022-09-13 20:55:21 +02:00
Jelle Raaijmakers
6dcc808994 LibSoftGPU: Reduce subpixel precision from 6 to 4 bits
With 6 bits of precision, the maximum triangle coordinate we can
handle is sqrt(2^31 / (1 << 6)^2) = ~724. Rendering to a target of
800x600 or higher quickly becomes a mess because of integer overflow.

By reducing the subpixel precision to 4 bits, we support coordinates up
to ~2896, which means that we can (try to) render to target sizes like
2560x1440.

This fixes the main menu backdrop for the Half-Life port. It also
introduces more white pixel artifacts in Quake's water / lava
rendering, but this is a level geometry visualization bug (see
`r_novis`).
2022-09-13 20:20:03 +02:00
Jelle Raaijmakers
bac7a12fb9 LibGL: Simplify setting the color mask 2022-09-13 20:20:03 +02:00
Jelle Raaijmakers
8e3b7df408 LibGL: Implement GL_SAMPLES, GL_SAMPLE_BUFFERS context parameters
We do not support multisampling right now, so we return constant values
that indicate this.
2022-09-13 20:20:03 +02:00
Jelle Raaijmakers
62846b4691 LibGL: Implement all glMultiTexCoord*f API methods 2022-09-13 20:20:03 +02:00
Jelle Raaijmakers
eda1ffba73 LibGL: Implement GL_TEXTURE_LOD_BIAS for texture objects 2022-09-13 20:20:03 +02:00
Jelle Raaijmakers
59fc2a4aad LibGL: Implement all glRasterPos2* API methods 2022-09-13 20:20:03 +02:00
Andreas Kling
54e0e85581 LibWeb: Treat percentage width/height as "auto" more consistently in BFC
Since we can't resolve percentage sizes against an indefinitely-sized
containing block, treat the sizes as "auto" in all these cases.
2022-09-13 17:03:31 +02:00
Andreas Kling
71ca857b67 LibWeb: Break lines until we have enough space between floats
Before this change, we'd always insert one line box fragment, even when
a float was taking up too much space on the line, and the fragment
didn't actually fit.

We now perform line breaks until we have enough space between floats.
This fixes many page layouts where we'd previously see small fragments
of inline content outside the right edge of the containing block.
2022-09-13 17:03:31 +02:00
Andreas Kling
c9a7853fef LibWeb: Include all floating descendants in BFC root's automatic height
Before this change, we were only considering floating boxes that were
immediate children of the BFC root.
2022-09-13 17:03:31 +02:00
davidot
1d846e5591 LibWeb: Visit internal fields of Crypto in visit_edges
Not visiting the field holding SubtleCrypto in Crypto caused subtle
crashes all over the Value functions, due to accessing SubtleCrypto
after it was garbage collected (and potentially replaced by a new cell).
This meant that the crashes were only appearing in Value::to_boolean,
Value::typeof, etc. Which then held pointer to things that looked like
Shapes, Environments and other non-Object Cells.

To find the actual cause, all pointer used to construct Values were
checked and if a pointer was none of the allowed types, the backtrace
is logged.

Co-authored-by: Luke Wilde <lukew@serenityos.org>
2022-09-12 20:14:58 -04:00
Ben Wiederhake
0e901f8c68 Shell: Sort CompletionSuggestions for paths lexicographically
This used to be ordered by inode, which can be surprising.
2022-09-12 16:49:48 +01:00
networkException
802cf9bc69 Everywhere: Use my very shiny serenityos.org email :^) 2022-09-12 15:13:12 +01:00
Ali Mohammad Pur
660d2b53b1 LibRegex: Account for eof after \<x> when 'x' leads to legacy behaviour 2022-09-12 16:03:57 +04:30
Ali Mohammad Pur
48442059fc LibRegex: Consume exactly two chars for escaped characters
We were previously consuming an extra char afterwards, which could be
the charclass terminator, leading to possible OOB accesses.
2022-09-12 16:03:57 +04:30
networkException
45aeba15c8 CharacterMap: Allow resizing the unicode block list
Previously we would constrain the unicode block list to a width of 175,
causing it to stick to the splitter when manually resizing.

This patch allows resizing the list properly while retaining the new
width when resizing the window.
2022-09-11 23:25:08 +01:00
Linus Groh
81f1183e28 Tubes: Run clang-format 2022-09-11 23:24:33 +01:00
Jelle Raaijmakers
9dfe50170e Demos: Add Tubes :^) 2022-09-11 22:45:49 +01:00
Jelle Raaijmakers
16ca9ec762 LibGfx: Templatize VectorN::length()
This allows us to get a `float` length from an `IntVector3` without
needing to convert to `FloatVector3` first.
2022-09-11 22:45:49 +01:00
Jelle Raaijmakers
70ea2a2258 LibGL: Implement glNormal3d 2022-09-11 22:45:49 +01:00
Jelle Raaijmakers
1aa1c89afa LibGL+LibGPU+LibSoftGPU: Report texture clamp to edge support 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
087f565700 LibSoftGPU: Divide texture coordinates by Q
Up until now, we have only dealt with games that pass Q = 1 for their
texture coordinates. PrBoom+, however, relies on proper homogenous
texture coordinates for its relatively complex sky rendering, which
means that we should perform this per-fragment division.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
72782d845d LibGL: Ensure texture coordinate Q is set to 1 by default
When using vertex attribute pointers, we default the Q coordinate for
textures to 0 causing issues if the 4th coordinate is not passed in the
vertex data.

Clean up these defaults and make sure that Q is always set to `1.f`.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
af217b0c3a LibGL: Implement GL_(CLIENT_)?ACTIVE_TEXTURE context parameters 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
00d46e5d77 LibGL+LibGPU+LibSoftGPU: Implement matrix stack per texture unit
Each texture unit now has its own texture transformation matrix stack.
Introduce a new texture unit configuration that is synced when changed.
Because we're no longer passing a silly `Vector` when drawing each
primitive, this results in a slightly improved frames per second :^)
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
1540c56e6c LibGL+LibGPU+LibSoftGPU: Implement GL_GENERATE_MIPMAP
We can now generate texture mipmaps on the fly if the client requests
it. This fixes the missing textures in our PrBoom+ port.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
dda5987684 LibGL+LibGPU+LibSoftGPU: Remove concept of layer in favor of depth
Looking at how Khronos defines layers:

  https://www.khronos.org/opengl/wiki/Array_Texture

We both have 3D textures and layers of 2D textures, which can both be
encoded in our existing `Typed3DBuffer` as depth. Since we support
depth already in the GPU API, remove layer everywhere.

Also pass in `Texture2D::LOG2_MAX_TEXTURE_SIZE` as the maximum number
of mipmap levels, so we do not allocate 999 levels on each Image
instantiation.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
44953a4301 LibGL+LibGPU+LibSoftGPU: Implement glCopyTex(Sub)?Image2d
These two methods copy from the frame buffer to (part of) a texture.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
d7f1dc146e LibGL: Calculate maximum log2 of texture size 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
eb81b66b4e LibGL+LibGPU+LibSoftGPU: Rename blit_color_buffer_to
This makes it consistent with our other `blit_from_color_buffer` and
paves the way for a third method that will be introduced in one of the
next commits.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
1d36bfdac1 LibGL+LibSoftGPU: Implement fixed pipeline support for GL_COMBINE
`GL_COMBINE` is basically a fixed function calculator to perform simple
arithmetics on configurable fragment sources. This patch implements a
number of texture env parameters with support for the RGBA internal
format.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
494024b70e LibGL: Verify Texture2D existence
The code currently guarantees that we always have a target texture.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
72b4f95f71 LibGL: Implement glMultiTexCoord2fv(ARB)? APIs 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
789d871892 LibGL: Define GL_NO_ERROR as 0
This conforms to the Khronos enum value listing and prevents a
redefinition warning when compiling with SDL_opengl.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
6d8dd0ee61 LibGL: Remove unused/default includes from GLContext 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
07e94b3ec1 LibGL: Implement GL_CURRENT_COLOR context parameter 2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
759ef82e75 LibSoftGPU: Convert width and height to f32x4 just once
We were passing along a `u32x4` only for it to be converted to `f32x4`
as soon as we'd use it.
2022-09-11 22:37:07 +01:00
Jelle Raaijmakers
b62dba6bbf LibSoftGPU: Remove unused alias truncate_int_range 2022-09-11 22:37:07 +01:00
networkException
9ff6c1e692 LibWeb: Avoid copying viewport rect when converting length to pixels
See https://github.com/SerenityOS/serenity/pull/3433#discussion_r484570948
2022-09-11 22:08:38 +01:00
networkException
2612d23032 LibGUI: Implement rubber band selection in table view
This patch implements rubber band selection in table view while clamping
the rubber band rect to the widget inner rect, matching the behavior of
IconView and ColumnsView.
2022-09-11 21:39:32 +01:00
networkException
e0353c405d LibGUI: Limit column view rubber band rect to widget inner rect
Previously when selecting a column that was partially scrolled out of
view the rubber band rect would extend outside the widget inner rect.

This patch rewrites the implementation to be more readable and clamps
the rubber band rect to the widget inner rect to match the behavior of
IconView.
2022-09-11 21:39:32 +01:00
networkException
e42a9cf957 LibGUI: Properly limit the icon view rubber band rect to the widget
Previously the rubber band rect of IconView was not properly constrained
to the widget inner rect, leaving a one pixel gap on the bottom and
right side. This patch removes the gap by inflating the constraint rect
by one pixel on each axis.
2022-09-11 21:39:32 +01:00
Timothy Flynn
5190f4e605 LibGUI: Support emoji with multiple code points in EmojiInputDialog 2022-09-11 20:33:57 +01:00
Timothy Flynn
31b2d93038 LibGUI+LibVT: Notify widgets of emoji selection with a callback
Currently, LibGUI modifies the Ctrl+Alt+Space key event to instead
represent the emoji that was selected through EmojiInputDialog. This is
limited to a single code point.

For multiple code point emoji support, individual widgets now set a hook
to be notified of the emoji selection with a UTF-8 encoded string. This
replaces the previous set_accepts_emoji_input() method.
2022-09-11 20:33:57 +01:00
Timothy Flynn
8190120f95 LibGUI: Use discovered emoji files as the EmojiInputDialog button icons
Rather than rendering the emoji as text, use the emoji icons themselves.
2022-09-11 20:33:57 +01:00
Timothy Flynn
a2eb42a9c0 LibGUI: Add an emoji category filter for SerenityOS custom emojis
Most of the emoji are 7x10px (or close to that). But some are larger, on
the order of 128x128px. The icon used for the SerenityOS category is one
such large emoji, and must be scaled down to an appropriate size for
rendering.
2022-09-11 20:33:57 +01:00
Timothy Flynn
4cb9472f97 LibGUI: Ensure unknown emoji have a set display order
Currently, we use code point values as a tie break when sorting emoji by
display order. When multiple code point emoji are supported, this will
become a bit awkward. Rather than dealing with varying code point length
while sorting, just set a maximum display order to ensure these are
placed at the end.
2022-09-11 20:33:57 +01:00
Timothy Flynn
b7ef36aa36 LibUnicode: Parse and generate custom emoji added for SerenityOS
Parse emoji from emoji-serenity.txt to allow displaying their names and
grouping them together in the EmojiInputDialog.

This also adds an "Unknown" value to the EmojiGroup enum. This will be
useful for emoji that aren't found in the UCD, or for when UCD downloads
are disabled.
2022-09-11 20:33:57 +01:00
davidot
b6094b7a3d LibTest: Extract some useful functions from TestRunner.h
This allows other test like programs to use these without needing to
link to LibTest.
2022-09-11 20:25:51 +01:00
Liav A
5d0edc7a42 WindowServer: Unveil only subdirectories in /dev directory
Now that each HID device node is located in /dev/input/, and Display
Connector device nodes are in /dev/gpu/, we can simply just unveil those
directories instead of the entire /dev directory.
2022-09-11 19:51:23 +01:00
Liav A
89835558b4 Userland: Move HID input device nodes to /dev/input/{mouse,keyboard}
Because HID devices are not always present in quantities of one per type
it is more elegant and correct to put the representative device nodes in
subdirectories for each HID device type.
2022-09-11 19:51:23 +01:00
networkException
1346a653e4 WidgetGallery: Port file picker to use FileSystemAccessClient
Previously we would unveil the home directory of anon to allow showing
anything in the file picker. This patch removes direct access to the
home directory and instead makes WidgetGallery connect to
FileSystemAccessServer to open a file, making the application more user
agnostic and allowing directories outside /home/anon to be shown.
2022-09-10 20:41:16 +01:00
networkException
08f465a47d LibGUI: Blit brightened icon when try item is hovered 2022-09-10 20:40:05 +01:00
davidot
d4736d17ae LibJS: Allow negative pointers in Value
Also ensure that all a nullptr input gives null object and you don't
accidentally dereference a nullptr.
2022-09-10 00:05:32 +01:00
Jelle Raaijmakers
325263f0e8 LibC: Consume all whitespace in scanf if present in format
We were consuming all whitespace from the format, but not the input
lexer - that was left to the actual format parsing code. It so happened
that we did not account for whitespace with the conversion specifier
'[', causing whitespace to end up in the output variables.

Fix this by always consuming all whitespace and removing the whitespace
logic from the conversion code.
2022-09-09 22:54:25 +01:00
Luke Wilde
875ca2fb68 LibWeb: Set prototype for both TextDecoder and AbortSignal
These were forgotten to be set during the GC heap conversion.
2022-09-09 20:47:43 +02:00
Cr4xy
ac60633694 Keymap: Rename context menu item "Settings" to "Keyboard Settings"
This is a very small change to improve consistency between applet
context menu item names.
2022-09-09 18:59:04 +01:00
networkException
75ac47dbd8 LibWeb: Resolve two document-tree child browsing context count FIXMEs
This patch makes use of helpers implemented for window.length to resolve
two FIXMEs in WindowProxy previously simply assuming no child browsing
contexts :^)
2022-09-09 17:42:30 +01:00
networkException
e377e28fd2 LibWeb: Implement window.length 2022-09-09 17:42:30 +01:00
thankyouverycool
b70e4e9909 Spreadsheet+LibGUI: Set EmojiInputDialog as a CaptureInput modal
This has two advantages: First the picker no longer changes the active
window state of its parent. Visually this is an additional hint that the
dialog is "fragile" and will close on loss of focus. Second, because
it contains a search box, its own input won't be preempted by global
application shortcuts when typing (pending #15129). This is a problem
in apps like PixelPaint which use shortcuts without modifiers.
2022-09-09 11:27:38 -04:00
thankyouverycool
2f6fd56631 LibGUI: Set EmojiInputDialog's FrameShape to "Window" 2022-09-09 11:27:38 -04:00
thankyouverycool
0bcd360266 LibGUI: Add ellipsis to Insert Emoji action
Requires further user input
2022-09-09 11:27:38 -04:00
thankyouverycool
f8e65d24cf LibGUI: Allow blocking CommandPalette/EmojiInput on a per Window basis
Instead of having to negate every focusable widget or textbox, let
windows override all their widgets. These two Dialogs now block
themselves and each other.
2022-09-09 11:27:38 -04:00
Andreas Kling
bfcb4d88cf LibWeb: Treat percentage heights as "auto" if unresolvable
If the containing block has indefinite height, we can't resolve
percentage heights against it. Instead of treating it as 0 by accident,
let's treat it as "auto" on purpose.

This brings back the cheek borders on Acid2.
2022-09-09 15:20:10 +02:00
Andreas Kling
b7d8fbbd70 LibWeb: Update layout in Element.client{Left,Top}
We have to flush any pending layout changes before getting metrics.
2022-09-09 15:20:10 +02:00
Andreas Kling
67b3af8025 LibWeb: Avoid layout in Element.client{Width,Height} if possible
When querying the HTML element (in strict mode) or the BODY element
(in quirks mode), we return the viewport dimensions.

Layout doesn't change the size of the viewport, so we can actually
reorder the steps here and avoid performing layout in some cases.

This removes a bunch of synchronous layouts on pages with reCAPTCHA.
2022-09-09 15:20:10 +02:00
Andreas Kling
3f960781fd LibWeb: Don't collapse vertical margins between floats
Just stack floats at their vertical margin edge instead of letting their
border boxes rub up against each other.
2022-09-09 15:20:10 +02:00
Andreas Kling
524ec95bcd LibWeb: Keep CSS sheets sorted in document tree order
This ensures that style is applied consistently, even if the document
has external CSS resources that don't always arrive in the same order.
2022-09-09 15:20:10 +02:00
faxe1008
d91469ebb1 LibGUI: CommandPalette: Fix key event capture for actions
This patch fixes an issue for applications that contain actions without
a modifier (e.g. PixelPaint). Previously when pressing any key bound to
an action while the CommandPalette was visible the action was forwarded
to the parent instead of the CommandPalette.
2022-09-09 15:15:09 +02:00
demostanis
847577bea2 uniq: Improve POSIX compliance
Adds -d, -c, -i, -f and -s options.
It differs a little bit from other implementations,
but it does the trick and corresponds to POSIX's description
2022-09-09 14:11:52 +01:00
demostanis
1c5f6003d7 LibCore: Add File::open_file_or_standard_stream() 2022-09-09 14:11:52 +01:00
Andrew Kaster
5ab3fcf710 Meta: Update jakt build support for fully bootstrapped compiler
Remove the Corrosion dependency, and use the now-builtin
add_jakt_executable function from the Jakt install rules to build our
example application.

By using find_package(Jakt), we now have to set ENABLE_JAKT manually on
both serenity and Lagom at the same time, so the preferred method to do
this for now is:

    cmake -B Build/superbuild<arch><toolchain> \
          -S Meta/CMake/Superbuild \
          -DENABLE_JAKT=ON \
          -DJAKT_SOURCE_DIR=/path/to/jakt

Where omitting JAKT_SOURCE_DIR will still pull from the main branch of
SerenityOS/jakt. This can be done after runing Meta/serenity.sh run.
2022-09-09 11:23:42 +02:00
thankyouverycool
72ae082ca8 WindowServer: Let Windows handle InputLeft events when blocked
Fixes windows not updating on active input changes after being
blocked
2022-09-08 23:21:54 +01:00
thankyouverycool
51006930da LibGUI: Only react on KeyDown when escaping a Dialog
Both KeyEvents aren't necessary and erroneously close two
Dialogs at once.
2022-09-08 23:21:54 +01:00
thankyouverycool
463aff827e LibGUI+WindowServer: Notify Windows on input preemption
Previously Menus set themselves as active input solely to make
sure CaptureInput modals would close, but this is a functional
half-truth. Menus don't actually use the active input role; they
preempt normal Windows during event handling instead.

Now the active input window is notified on preemption and Menus
can remain outside the active input concept. This lets us make
more granular choices about modal behavior. For now, the only
thing clients care about is menu preemption on popup.

Fixes windows which close on changes to active input closing
on their own context menus.
2022-09-08 23:21:54 +01:00
thankyouverycool
6c35aac617 WindowServer: Add unadjusted position members to Menu
Used to determine Menu relationships by proxy
2022-09-08 23:21:54 +01:00
Timothy Flynn
7c9ad6cc2f LibGUI: Add Unicode emoji group filters to the EmojiInputDialog
This allows users to filter the list of displayed emoji by the group to
which the emoji belong.
2022-09-08 23:12:31 +01:00
Timothy Flynn
273045d40e LibGUI: Display emoji in the EmojiInputDialog in Unicode display order 2022-09-08 23:12:31 +01:00
Timothy Flynn
c2148c7dde LibGUI: Add placeholder text to the emoji picker search box
Co-authored-by: electrikmilk <brandonjordan124@gmail.com>
2022-09-08 23:12:31 +01:00
Timothy Flynn
b61eca0a1e LibUncode: Parse and generate emoji code point data
According to TR #51, the "best definition of the full set [of emojis] is
in the emoji-test.txt file". This defines not only the emoji themselves,
but the order in which they should be displayed, and what "group" of
emojis they belong to.
2022-09-08 23:12:31 +01:00
electrikmilk
fff79379d4 Spreadsheet: Add Insert Emoji action
This adds the Insert Emoji action to Spreadsheet.
2022-09-08 23:08:54 +01:00
electrikmilk
44a5deff40 TextEditor: Add Insert Emoji action
This adds the Insert Emoji action to Text Editor.
2022-09-08 23:08:54 +01:00
electrikmilk
6a09d89329 Base+LibGUI: Add insert emoji common action
This adds a common action to invoke the emoji picker.
2022-09-08 23:08:54 +01:00
Sam Atkins
edc3ed2a0e AK: Allow creating NonnullPtrVectors from an initializer list
This was present in Vector already. Clang-format fixed some const
positions automatically too.

Also removed a now-ambiguous and unnecessary constructor from Shell.
2022-09-08 18:53:08 +02:00
Jelle Raaijmakers
b42feb76a0 LibSoftGPU: Use approximation for maximum depth slope
OpenGL allows GPUs to approximate a triangle's maximum depth slope
which prevents a number computationally expensive instructions. On my
machine, this gives me +6% FPS in Quake III.

We are able to reuse `render_bounds` here since it is the containing
rect of the (X, Y) window coordinates of the triangle, thus its width
and height are the maximum delta X and delta Y, respectively.
2022-09-08 12:07:03 -04:00
Jelle Raaijmakers
08204efe1f LibGL: Set correct color material mode for GL_AMBIENT_AND_DIFFUSE
This was a silly mistake :^)
2022-09-08 12:05:54 -04:00
Andreas Kling
7ba6eb37fc LibWeb: Rename confusing parameter to layout_block_level_box()
It wasn't the content height, but rather the the bottom edge of the
lowest margin box.
2022-09-08 15:03:55 +02:00
Andreas Kling
af73a5d921 LibWeb: Use correct box edge when looking for space between floats 2022-09-08 15:03:55 +02:00
Andreas Kling
8f0a48ef23 LibWeb: Make default CSS font settings match other browsers better
Let's make 16px the default font size instead of 10px. This makes our
layout results match those of other engines in many more cases.

Also make the h1-h6 element styles use relative (em) font sizes, also
matching other browsers.
2022-09-08 12:43:49 +02:00
Andreas Kling
3dc82d2fa5 LibGfx: Add API for loading more directories into Gfx::FontDatabase
Also make the font discovery algorithm search subdirectories as well.
This will be used by Ladybird to discover more fonts on non-Serenity
systems. :^)
2022-09-08 12:30:25 +02:00
Andreas Kling
5c2e3d1637 LibWeb+WebContent: Add abstraction layer for generic font families
Instead of hard-coding the names of system fonts to use for the CSS
generic fonts (like "sans-serif", "monospace", etc.) we now call out
to a Platform::FontPlugin and ask for the generic names.
2022-09-08 11:57:03 +02:00
Andreas Kling
26544f559c LibWeb: Make anonymous wrapper blocks actually have "display: block"
We didn't set their display at all before, and since CSS display is not
inherited, anonymous block wrappers were actually "display: inline", but
it kinda worked anyway because we positioned blocks based on their C++
class (BlockContainer) rather than their CSS display value.

Now that we position based on CSS display value, this broke positioning
of anonymous wrapper blocks, and this fixes that.
2022-09-08 11:54:13 +02:00
thankyouverycool
0b0c4fc1e8 WindowServer: Set rendered cache dirty on maximization event
Fixes restore/maximize icon not updating when the cursor overlaps
window frame on restoration.
2022-09-08 10:17:27 +01:00
thankyouverycool
35e557c657 Browser+LibGUI+WindowServer: Open Button menus uniformly
Instead of letting buttons determine the relative position
of their menus, a workaround only used by Statusbar segments,
open them all uniformly for a nice, consistent UI.

Passing a rect to popup() now routes to open_button_menu(), an
analog to open_menubar_menu(), which adjusts the menu's popup
position in the same way. Fixes button menus obscuring the buttons
which spawn them and jutting out at odd corners depending on screen
position.
2022-09-08 10:17:27 +01:00
thankyouverycool
0fc1925cd7 LibGUI: Simulate a click on arrow key events for AbstractButtons
in exclusive, checkable groups. Instead of merely setting the
button checked, call click() so buttons with registered actions
can activate. Fixes ActionGroups like FileManager's view type
checkables not activating when cycled with the keyboard.
2022-09-08 10:17:27 +01:00
thankyouverycool
ab29f8976d Taskbar: Set TaskbarButton checkable 2022-09-08 10:17:27 +01:00
thankyouverycool
12ee92004d LibGUI+Taskbar: Don't immediately repaint checkable Buttons
Unlike regular buttons, unchecked checkables don't need to repaint
on MouseUp to feel responsive when clicking rapidly. In fact, this
can lead to a flickering effect when a bogus unchecked state gets
painted again before the button's checked one.
2022-09-08 10:17:27 +01:00
electrikmilk
6675865582 Browser: Add context menu icons
This adds two new icons for browser context menu items "Close Other
Tabs" and "Download".

This adds existing icons where they were missing in context menu items.
2022-09-08 10:02:37 +01:00
Andreas Kling
9e39f51fd3 LibWeb: Position blocks after previous block-level box, ignoring type
Before this change, block-level boxes were laid out vertically by
placing them after the nearest previous BlockContainer sibling. This
only worked if the preceding block-level box happened to be a
BlockContainer.

This fixes an issue where the screenshot on netsurf-browser.org was not
being laid out properly (it was `img { display: block }` which creates
a block-level ImageBox, and ImageBox is not a BlockContainer but a
ReplacedBox, so the following block-level box was skipping over the
ImageBox and being placed next to whatever was before the ImageBox..)
2022-09-08 01:42:25 +02:00
Andreas Kling
7b0dd98103 LibJS+LibWeb: Spin event loop via VM::CustomData abstraction
Instead of calling Core::EventLoop directly, LibJS now has a virtual
function on VM::CustomData for customizing this behavior.

We use this in LibWeb to plumb the spin request through to the
PlatformEventPlugin.
2022-09-08 00:13:39 +02:00
Andreas Kling
9567e211e7 LibWeb+WebContent: Add abstraction layer for event loop and timers
Instead of using Core::EventLoop and Core::Timer directly, LibWeb now
goes through a Web::Platform abstraction layer instead.

This will allow us to plug in Qt's event loop (and QTimer) over in
Ladybird, to avoid having to deal with multiple event loops.
2022-09-07 20:30:31 +02:00
Andreas Kling
9018b58875 LibWeb: Only schedule ImageStyleValue resource load once
load_any_resources() may get called multiple times during layout, but
once we've started a resource load, we don't need to do it again.
2022-09-07 17:47:33 +02:00
Andreas Kling
faf9746244 LibWeb: Cache width of "alt" text in ImageBox
We were constantly measuring and re-measuring the "alt" attribute text
of ImageBox layout nodes, even when the alt text didn't change. By
caching this, we avoid a *lot* of repeated text measurement work.
2022-09-07 17:47:33 +02:00
Andreas Kling
514fa83708 LibWeb: Improve float: right behavior
- Use the border box of the floated element when testing if something
  needs to flow around it.
- Take the floated element's containing block size into account (instead
  of the BFC root) when calculating available space on a line where a
  right-side float intrudes.
2022-09-07 17:47:33 +02:00
Andreas Kling
a42506c8b9 LibWeb: Fix three accidental float truncations
We were doing this:

    max(0, some_floating_point_value)

This returns an `int` result based on the type of `0`, oops!
2022-09-07 17:47:33 +02:00
Timothy Flynn
21a89b65fc LibGUI: Set a tooltip on the emojis' buttons to their code point names 2022-09-07 14:34:02 +01:00
Timothy Flynn
eeb7b153a2 LibGUI: Add a search box to filter EmojiInputDialog by code point names 2022-09-07 14:34:02 +01:00
Timothy Flynn
a885406511 LibGUI: Disable EmojiInputDialog updates while re-displaying emoji
To prevent lag when the displayed code points are redrawn in support of
a search box, disable updates while re-adding the emoji buttons.
2022-09-07 14:34:02 +01:00
Timothy Flynn
1c32823dd8 LibGUI: Create the emoji buttons only once for EmojiInputDialog
To prevent lag when the displayed code points are redrawn in support of
a search box, only create the GUI::Button objects for the emoji a single
time. Re-use those buttons when adding them to the dialog.
2022-09-07 14:34:02 +01:00
Timothy Flynn
a511dec5ca LibGUI: Move code to display emoji buttons to a helper function
For a search box to be added, this code will need to be re-invoked as
the search query updates.
2022-09-07 14:34:02 +01:00
Timothy Flynn
3aaaacdb3a LibGUI: Wrap the EmojiInputDialog in a scrollable container
This will prevent the dialog from growing endlessly as emoji are added.
2022-09-07 14:34:02 +01:00
Timothy Flynn
11d29bc2ea LibGUI: Convert EmojiInputDialog to GML
This will allow easily adding components such as a search box. Also,
increase the number of emoji per row. This does not fix the issue where
too many emoji will cause the dialog to grow limitlessly, but it looks a
bit more reasonable now with the number of emoji that we have.
2022-09-07 14:34:02 +01:00
Jelle Raaijmakers
15a9fca461 LibGfx: Correctly shift pixels during bilinear blend
Our bilinear scaling logic worked well for upscaling, but during
downscaling the bitmap was often shifted one pixel to the bottom right.

This is a common problem, described here in more detail:

  https://bartwronski.com/2021/02/15/bilinear-down-upsampling-pixel-grids-and-that-half-pixel-offset/

Fix it by calculating coordinate shift values that align the pixel's
boundaries between the source and target pixels before selecting the
source pixels to interpolate.
2022-09-06 18:00:50 +01:00
networkException
178164808c Calendar: Limit the starting day input range to the selected month
Previously we allowed entering any day value greater than one. With this
patch the maximum input value is dynamic based on the selected month and
year.
2022-09-06 17:37:44 +01:00