Commit Graph

4520 Commits

Author SHA1 Message Date
Idan Horowitz
ee608f58ee LibJS: Add type range checks to the Date make_day AO
As the specification says "but if this is not possible (because some
argument is out of range), return NaN."
2021-08-19 19:15:00 +01:00
Idan Horowitz
95bc8e4641 LibCore: Make DateTime's members signed
Core::DateTime is essentially a C++ wrapper of the tm struct, so we
should support the same signed range as the underlying tm.
2021-08-19 19:15:00 +01:00
Andrew Kaster
332b29c741 LibTest+Utilities: Print a start message before each test in run-tests
It can sometimes be difficult to tell from the debug.log and test stdout
which test was the last to run before the test runner hangs or exits the
QEMU instance unexpectedly.

Print out a start message before each test is executed, along with a
progress message indicating which test out of how many tests we're about
to run.
2021-08-19 18:42:34 +02:00
Jesse Buhagiar
68d895eb7c LibGL: Don't crash on invalid pname value in glGetFloatv
This brings `glGetFloatv` more inline with the other `glGet`
functions. We should prevent crashing in the driver as much as
possible and instead let the application deal with the generated
GL error.
2021-08-19 17:08:04 +02:00
Linus Groh
0e201fbb42 LibJS: Implement Temporal.PlainDate.prototype.toJSON() 2021-08-19 00:26:09 +01:00
Linus Groh
73d888e9e6 LibJS: Implement Temporal.PlainDate.prototype.toLocaleString() 2021-08-19 00:23:48 +01:00
Linus Groh
402f04c2fc LibJS: Implement Temporal.PlainDate.prototype.toString() 2021-08-19 00:14:17 +02:00
Linus Groh
310192f918 LibJS: Make Temporal's get_option() take a PropertyName directly
Instead of constructing a String and converting that to a PropertyName
on the fly, we can just leverage CommonPropertyNames, add a couple more
and directly pass ready-to-use PropertyNames with pre-allocated Strings.
2021-08-19 00:14:17 +02:00
sin-ack
d8fd4eee9b LibGUI: Move common action definitions to CommonActions.cpp
This makes Action.cpp itself only talk about the Action object, and
makes it easier to navigate.
2021-08-19 00:11:42 +02:00
Linus Groh
092f924cfd LibJS: Reflect naming consistency editorial changes in the Temporal spec
See:

- https://github.com/tc39/proposal-temporal/commit/2aa7dce
- https://github.com/tc39/proposal-temporal/commit/13daa33
- https://github.com/tc39/proposal-temporal/commit/8085873
2021-08-18 23:03:22 +01:00
Stephan Unverwerth
c4de2bb5e5 LibGL: Leave render loop early if color mask empty 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
addbcd42d7 LibGL: Fix triangle winding calculation
Since we operate in screen space where y points down we need to reverse
what is considered clock wise and what is considered counter clockwise.

The rasterizer always expects triangles with a consistent winding order
thus swap 2 vertices if necessary to reverse the winding before passing
the triangle on to the rasterization stage.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
220ac5eb02 LibGL: Fix clipping and interpolate vertex attributes
The previous clipping implementation was problematic especially when
clipping against the near plane. Triangles are now correctly clipped
using homogenous coordinates against all frustum planes.

Texture coordinates and vertex colors are now correctly interpolated.
The earier implementation was just a placeholder.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
39ff1459f8 LibGL: Improve texture sampling performance
GL_NEAREST: Remove unnecessary modulo. UV is always in range due to
wrapping.
GL_LINEAR: Rewrite filter equation to save a few math operations.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
59998ff0b2 LibGL: Return white texel when sampling uninitialized texture 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
894d81c1b8 LibGL: Complete glGetString implementation
GL_VERSION: The spec mandates the following format: x.y or x.y.z
optionally followed by text separated by space.

GL_EXTENSIONS: Return empty string. We do not support any extensions.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
5b9c87a8b5 LibGL: Implement glDepthFunc 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
a97dbd2317 LibGL: Implement glDepthRange 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
3dd9efd35f LibGL: Fix incorrect blend factor setup 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
b38edf994b LibGL: Allow glTexImage2D to create uninitialized textures
When passing a nullptr as the pixel array LibGL now allocates texture
memory but does not initialize the texture contents.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
22905daacb LibGL: Fix interpretation of BGRA byte order
This fixes byte order interpretation in several places.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
e9514cf6c0 LibGL: Fix glVertexPointer argument validation 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
5e27da20f4 LibGL: Fix glTexCoord behaviour
glTexCoord should behave like glColor. It only updates a gl context
variable that contains the current texture coordinates. The vertex is
only actually created once glVertex is called.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
b6373c2aba LibGL+3DFileViewer: Make glRotatef accept degrees, not radians
This is in accordance with the GL spec. Also adjust rotation values in
3DFileViewer to take the new units into account.
2021-08-18 20:30:58 +02:00
Jean-Baptiste Boric
8cc8d72619 LibCore: Implement preserve flag for file/directory copy 2021-08-18 20:30:46 +02:00
Linus Groh
b2badd6333 LibJS: Update some Temporal spec section numbers
These shifted due to the addition of the ParseTemporalRelativeToString
AO in https://github.com/tc39/proposal-temporal/commit/ad06578.
2021-08-18 19:26:08 +01:00
kleines Filmröllchen
195d6d006f LibAudio: Resample FLAC audio data
FlacLoader initialized, but never used its resampler; this is now fixed
and all subframes are resampled before decorrelation occurs. FLAC files
with non-44100-Hz sample rates now play properly.
2021-08-18 18:16:48 +02:00
kleines Filmröllchen
d7ca60b998 LibAudio: Resample with integer ratios instead of floats
Floating-point ratios are inherently imprecise, and can lead to
unpredictable or nondeterministic behavior when resampling and expecting
a certain number of resulting samples. Therefore, the resampler now uses
integer ratios, with almost identical but fully predictable behavior.

This also introduces the reset() function that the FLAC loader will use
in the future.
2021-08-18 18:16:48 +02:00
Daniel Bertalan
bd6dc5ccec Meta+LibC: Don't allow text relocations in SerenityOS libraries
The `-z,text` linker flag causes the linker to reject shared libraries
and PIE executables that have textrels. Our code mostly did not use
these except in one place in LibC, which is changed in this commit.
This makes GNU ld match LLD's behavior, which has this option enabled by
default.

TEXTRELs pose a security risk, as performing these relocations require
executable pages to be written to by the dynamic linker. This can
significantly weaken W^X hardening mitigations.

Note that after this change, TEXTRELs can still be used in ports, as the
dynamic loader code is not changed. There are also uses of it in the
kernel, removing which are outside the scope of this PR. To allow those,
`-z,notext` is added.
2021-08-18 18:01:22 +02:00
Andreas Kling
a401a0f8fe LibWeb: Add fast_is<Layout::InitialContainingBlockBox>
This is used by Layout::Node::containing_block() which is fairly hot.
2021-08-18 11:45:39 +02:00
Andreas Kling
1268b39ba0 LibGfx: Make FastBoxBlurFilter go faster
When entering FastBoxBlurFilter::apply_single_pass(), we VERIFY that the
bitmap format is BGRA8888.

This invariant allows us to use get_pixel<BGRA8888>() instead of the
generic get_pixel() throughout the function. This removes a lot of
branches and makes the filter significantly faster. :^)
2021-08-18 11:35:51 +02:00
Andreas Kling
2432c5264b LibGfx: Remove ancient unused NO_FPU macros 2021-08-18 11:35:51 +02:00
Rob Ryan
34a64ed25b LibGUI+Browser: Add UrlBox class
This allows the address bar to "select all" when initially gaining focus
as Firefox and Chrome do. A future improvement on this would be for the
Widget class to mange and provide focus transition as part of the events
instead of the UrlBox class. Currently focus is updated before the event
is provided to the UrlBox class.
2021-08-18 10:39:13 +02:00
Rob Ryan
fbf824a50f LibGUI: Allow widgets to make themselves non-auto-focusable
This patchs adds a way for widgets exclude themselves from being a focus
candidate in Window::focus_a_widget_if_possible().

This is to allow the URL box to not get auto-focused when the browser
is loaded.
2021-08-18 10:39:13 +02:00
Jean-Baptiste Boric
c972afbea6 LibC: Fix sigsetjmp and siglongjmp 2021-08-18 10:33:48 +02:00
Jean-Baptiste Boric
6165811081 LibC: Expose sig_sysname array 2021-08-18 10:33:48 +02:00
Jean-Baptiste Boric
77bec6b01d LibC: Move SIG_* definitions for sigprocmask into bits/sighow.h 2021-08-18 10:33:48 +02:00
Sam Atkins
b7aba70a28 LibWeb: Fix check for too many 'normal' values in font declaration
I had the values backwards, oops!
2021-08-18 10:32:32 +02:00
Sam Atkins
b64b97ef88 LibWeb: Implement font-fallback
If the font-family property is set to a StyleValueList, we now iterate
through it, looking up each font in turn until one is found.

StyleResolver no longer needs to handle FontFamily specifically, which
is a nice bonus.

Serenity's current dependence on bitmap fonts leads to some weirdness
here - for example, the `if (!found_font)` path can trigger even if a
generic font family like "sans-serif" is used, since our default
sans-serif font might not be available in the desired size or weight.
The `monospace` variable only exists for that reason.

This is not a complete solution, by a long way! Serenity's font support
is still quite basic, so more work needs to be done there before we can
start implementing the spec's font-matching algorithm. But this is still
an improvement. :^)
2021-08-18 10:32:32 +02:00
Sam Atkins
ceece1c75e LibWeb: Handle numeric font-weights
The code was assuming the font-weight would be a Length, apparently
since NumericStyleValue didn't exist at the time. Now, it's always a
numeric value, so treat it as such.

We also replace the hardcoded numbers with references to the FontWeight
enum.

Also, it was always setting the weight to 900, so that has been fixed.
2021-08-18 10:32:32 +02:00
Sam Atkins
3c541452b7 LibWeb: Calculate font-size in NodeWidthStyle::apply_style()
Previously, this made the same "everything is px" assumption as in
`StyleProperties::load_font()`, so I've replaced it with the calculation
from there.
2021-08-18 10:32:32 +02:00
Sam Atkins
8c39fee34d LibWeb: Handle non-px font sizes
The previous code assumed all font sizes were in px, but now we perform
the conversion. There is an existing bug with em sizes returning 0,
which seems to affect other places too - see
`NodeWithStyle::apply_style()`.

This also implements 'larger', 'smaller' and calc() font-sizes.
2021-08-18 10:32:32 +02:00
Sam Atkins
c990340c5a LibGfx: Mark Typeface::get_font() const, because it is const 2021-08-18 10:32:32 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
Timothy Flynn
325eabc770 LibRegex: Ensure the GoBack operation decrements the code unit index
This was missed in commit 27d555bab0.
2021-08-18 09:47:09 +04:30
Timothy Flynn
a9716ad44e LibRegex: In non-Unicode mode, parse \u{4} as a repetition pattern 2021-08-18 09:47:09 +04:30
Jesse Buhagiar
8ad42e6771 LibGL: Implement glGetIntegerv 2021-08-18 00:35:26 +02:00
Jesse Buhagiar
0b67369830 LibGL: Implenent glGetBooleanv 2021-08-18 00:35:26 +02:00
Linus Groh
90f7e01179 LibJS/Tests: Add Temporal.Calendar.from() tests for more object types 2021-08-17 23:06:05 +01:00