Commit Graph

9327 Commits

Author SHA1 Message Date
Andreas Kling
219e3b9235 LibWeb: Make stacking context tree dumps more readable
Include the Layout::Node::debug_description() and the z-index.
2022-03-04 15:52:42 +01:00
Andreas Kling
15ed0ebdc6 LibWeb: Implement hit testing a bit closer to spec
We now perform hit testing in reverse paint order as described in CSS2's
section about the z-index property.
2022-03-04 15:52:42 +01:00
Andreas Kling
0401d7da36 LibWeb: Preserve z-index:auto in CSS::ComputedValues
This is still interesting for debugging purposes, so let's not blindly
convert "auto" to 0. Code later down the line handles "auto" anyway.
2022-03-04 15:52:42 +01:00
Lenny Maiorani
d144da3a62 LibGfx: Refactor Vector[2,3,4] to VectorN with specializations
`Gfx::Vector[2,3,4]` are nearly identical implementations. This code
redundancy does not follow the DRY (Don't Repeat Yourself) principle
leading to possible out-of-sync errors between the classes.

Combining these classes into a class template which can be specialized
for each needed size makes the differences obvious through
`constexpr-if` blocks and `requires` clauses.
2022-03-04 12:56:05 +01:00
Andreas Kling
c2a66b77df LibWeb: Measure intrinsic block width *around* children's border edge
When calculating the intrinsic width of a block-level box, we were
previously measuring the content boxes of children. This meant that
shrink-to-fit sized blocks didn't gain enough width to contain children
with horizontal padding and/or border.
2022-03-04 12:34:26 +01:00
ForLoveOfCats
e8f6a650ad LibGUI: Add mimic_pressed to Button to signify being virtually clicked
A button that is "mimic pressed" is drawn like it is being clicked when
it isn't necessarily actually being pressed. This lets programs which
keyboard based input that mirrors a button to show visual feedback when
a key is pressed.
2022-03-03 22:06:14 +01:00
ForLoveOfCats
1fd16232d3 LibGUI: Use logical and instead of bitwise in Button paint call
This appears to have been a typo. While it does work it's probably
better to be more clear here.
2022-03-03 22:06:14 +01:00
Luke Wilde
b59773de17 LibWeb: Include cookies in form submission
Services expect cookies to be submitted with forms, especially login
screens.

Allows us to sign in to GitHub (including two factor authentication)
and start using it!
2022-03-03 15:08:35 +01:00
Jelle Raaijmakers
6e1333cc71 LibWeb: Prevent crashes with progress element's value and max attributes
If either of these attributes are missing, do not crash in `strtod()`
but return a default value instead.
2022-03-03 14:14:33 +01:00
Andreas Kling
51d3c8bbf7 LibWeb: Forward-declare FormattingState as a struct 2022-03-03 13:56:37 +01:00
Andreas Kling
205208db11 LibWeb: Reduce HashMap thrashing during custom property cascade
Build the final custom property map right away instead of first making
a temporary pointer-only map. We also precompute the final needed
capacity for the map to avoid incremental rehashing.
2022-03-03 13:56:37 +01:00
Andreas Kling
e4fdb40158 LibWeb: Use FlyString for CSS custom property names 2022-03-03 13:56:37 +01:00
Stephan Unverwerth
7a19d0b4f9 LibSoftGPU: Add mipmap selection to sampler class 2022-03-03 13:50:25 +01:00
Stephan Unverwerth
dd900570fd LibSoftGPU: Add log2_approximate() 2022-03-03 13:50:25 +01:00
Stephan Unverwerth
be15cf5457 LibSoftGPU: Add ddx() and ddy() to calculate partial derivatives 2022-03-03 13:50:25 +01:00
Stephan Unverwerth
869393c7a0 LibGL: Fix interpretation of mipmap filtering modes
GL_LINEAR_MIPMAP_NEAREST means choose nearest mipmap level, interpolate
texels linearly.

GL_NEAREST_MIPMAP_LINEAR means choose the two closest mipmap levels,
sample the texels unfiltered and linearly interpolate based on the
fractional value of the mipmap level.

Previously we had this backwards.
2022-03-03 13:50:25 +01:00
Andreas Kling
88aa356606 LibWeb: Update element style when focus state changes
To ensure that :focus rules get included (or excluded), we have to
update style whenever focus moves.
2022-03-03 13:24:03 +01:00
Andreas Kling
ef33a40b99 LibWeb: Remove bogus line box width adjustment
This basically reverts 95715f0c8f, as it
was totally wrong for text-align:center and text-align:right.
2022-03-03 12:57:53 +01:00
Andreas Kling
7dae895704 LibWeb: Align actual baselines, not just bottoms
Until now, we've been treating the bottom of every line box fragment as
its baseline, and just aligning all the bottoms to the bottom of the
line box. That gave decent results in many cases, but was not correct.

This patch starts moving towards actual baseline calculations as
specified by CSS2.

Note that once layout is finished with a line box, we also store the
baseline of the line box in LineBox::m_baseline. This allows us to align
the real baseline of display:inline-block elements with other inline
content on the same line.
2022-03-03 12:57:53 +01:00
Andreas Kling
1d6cf3a43f LibWeb: Consider all children when doing height:auto for normal blocks
Only measuring from the top to the last in-flow block was not giving us
enough height in many cases.
2022-03-03 12:57:53 +01:00
Andreas Kling
ed44f9e290 LibWeb: Small improvements to layout tree dumps
- Say "content-size" instead of just "size" to clarify which size it is
- Show box model metrics by default
2022-03-03 12:57:53 +01:00
MacDue
6c48fd84ad LibGfx: Don't paint the window frame larger for the border-radius
Previously with a border radius you would get a "ghost" window frame
which was not really there, and would not respond to clicks/attempts
to resize.
2022-03-02 21:56:57 +01:00
Michiel Visser
39409438b2 LibWeb: Send Origin on WebSocket connection
Some services using WebSockets require that the request contains the
Origin header, otherwise these services will return a 403 Forbidden
response. WebSocketServer already supports sending the Origin header,
however LibWeb did not send the origin with the IPC request.
2022-03-02 21:38:17 +01:00
thankyouverycool
f3d672d53d LibGUI: Support hierarchical matches in FilterProxyModel
Fixes crash when searching in Help.
Patch by @eggpi
2022-03-02 21:37:58 +01:00
ForLoveOfCats
f350c153e8 LibJS: Implement and test ArrayBuffer.prototype.resize 2022-03-02 20:53:18 +01:00
ForLoveOfCats
b29e19c52a LibJS: Implement and test getters added by resizable ArrayBuffer 2022-03-02 20:53:18 +01:00
ForLoveOfCats
e01ee4e30b LibJS: Construct ArrayBuffer with max byte length when provided 2022-03-02 20:53:18 +01:00
ForLoveOfCats
e8416b603f LibJS: Accept ArrayBuffer constructor options argument
Test262 seems to test the changes in the "Resizable ArrayBuffer and
growable SharedArrayBuffer" proposal. Begin implementing this proposal
by accepting the new options object argument to the ArrayBuffer
constructor.

https://tc39.es/proposal-resizablearraybuffer
https://github.com/tc39/test262/blob/main/test/built-ins/ArrayBuffer/options-maxbytelength-diminuitive.js
2022-03-02 20:53:18 +01:00
Lucas CHOLLET
5d29f64c99 LibCore: Add wrapper for posix_openpt(), grantpt() and unlockpt() 2022-03-02 18:08:05 +01:00
Lucas CHOLLET
ddf9987c39 LibCore+LibC: Add wrapper for setenv
I also added a common interface with StringView compatible parameters:

int serenity_setenv(const char*, ssize_t, const char*, ssize_t, int)

This function is called by both C and C++ API for setenv().
2022-03-02 18:08:05 +01:00
Lucas CHOLLET
b1af1b399e LibCore: Add tcsetpgrp(int, pid_t) wrapper 2022-03-02 18:08:05 +01:00
Lucas CHOLLET
19d5974e3a LibCore: Add killpg() wrapper 2022-03-02 18:08:05 +01:00
Andreas Kling
9888e29c14 LibWeb: Streamline Node::enclosing_link_element() somewhat
No need to verify_cast repeatedly once we've confirmed the type.
2022-03-02 17:40:18 +01:00
Andreas Kling
ad9f3f7ae6 LibWeb: Add fast_is<T> for HTML::HTMLAnchorElement
We were spending 20% of style computation time on the HTML spec on
deciding whether DOM nodes were HTML anchor (a) tags or not.
2022-03-02 17:40:18 +01:00
Andreas Kling
65b38f2623 LibWeb: Don't skip position:relative elements in inline-level layout
InlineLevelIterator was wrongly skipping over all positioned elements,
instead of just the absolutely positioned ones.
2022-03-02 17:40:18 +01:00
Sam Atkins
973f3c3642 LibWeb: Correct handling of negative step values in nth-foo() selectors
This should be 1% on Acid3. :^)

Added the `-5n+3` case to all `nth-of-whatever()` selector test pages,
so we can easily check that it works.
2022-03-02 17:39:57 +01:00
Andreas Kling
1061c863f8 LibWeb: Fix issue where double-quoted doctype system ID was not captured
We were storing double-quoted system ID's in the public ID field.

1% progression on ACID3. :^)
2022-03-02 12:30:15 +01:00
Peter Ross
feb19646df LibC: Increase alignment for malloc() BigAllocationBlocks to 16 bytes
commit 5f3773b715 increased alignment
for ChunckedBlocks, but not for BigAllocationBlocks.

This is required to make SSE instructions work.
2022-03-02 11:40:37 +01:00
Peter Ross
36af2fdc4f LibC: Replace [[gnu::aligned(16)]] with C++ standard alignas(16) 2022-03-02 11:40:37 +01:00
Peter Ross
6c06b70911 LibC: Set PRI[xX]8/PRI[xX]16 macros to x and X
Described in:
  <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/
    inttypes.h.html>

The macros were first added in a7a456002e,
but it is not clear why the PRIx16/32 macros were defined as 'b' & 'w'.
PrintfImplementation was never able to parse these values.
2022-03-02 11:40:37 +01:00
Peter Ross
97cfb9934b LibC: Add TCP_MAXSEG to tcp.h
This is an unimplemented setsockopt. Defining it is sufficient to build
FFmpeg with networking.
2022-03-02 11:40:37 +01:00
Peter Ross
54fa06e85c LibC: Add IN_MULTICAST to in.h 2022-03-02 11:40:37 +01:00
Andreas Kling
bfa7aad0f6 LibWeb: Support (and validate) prefixes in Document.createElementNS()
1% progression on ACID3. :^)
2022-03-02 10:55:16 +01:00
Andreas Kling
4fb67c1621 LibWeb: Fix logic error in Document::validate_qualified_name()
We were mixing up the "name character" and "name start character"
validation checks. Also, we were not checking the first character after
a colon against the "name start character" set.
2022-03-02 10:53:38 +01:00
Andreas Kling
7231c1c895 LibWeb: Fix bogus result from "validate and extract" DOM operation
We were returning a QualifiedName with the localName and namespace
fields swapped.
2022-03-02 10:21:57 +01:00
Andreas Kling
05e9dceba6 LibWeb: Support DOMImplementation.createDocument() doctype parameter
1% progression on ACID3. :^)
2022-03-02 09:18:19 +01:00
Ben Abraham
a9c9c8c076 LibJS: Fix rounding issues in Number.toFixed
toFixed was not rounding properly when trimming a number.
ie: (0.00006).toFixed(4) should be "0.00001" but was returning "0.0000"
2022-03-02 08:34:04 +01:00
Andreas Kling
fa43a4118e LibWeb: Handle height:auto separately for BFC root vs other block boxes
I was wrong in 56df05ae44, there are
situations where floating children should not affect the auto height of
their parent.

It turns out we were using the "height:auto for BFC roots" algorithm for
all height:auto blocks. This patch fixes that by splitting it into two
separate functions, and implementing most of the two different variants.

Note that we don't support vertical margin collapsing here yet.

Thanks to Tim for noticing the error! :^)
2022-03-01 23:26:35 +01:00
Luke Wilde
4fa270d81f LibWeb: Implement <button>'s activation behaviour
This allows us to submit forms from <button> elements and not just
<input type="submit">

This allows Discord to progress past the username registration :^)
2022-03-01 23:19:41 +01:00
Luke Wilde
46c0d0f7ae LibWeb: Associate form elements with a form in parsing and dynamically
This makes it available for all form associated elements and not just
select and input elements. It also makes it more spec compliant,
especially around the form attribute.

The main thing missing is re-associating form elements with a form
attribute when the form attribute changes or an element with an ID
is inserted/removed or has its ID changed.
2022-03-01 23:19:41 +01:00
Luke Wilde
29f9947ff9 LibWeb: Implement HTMLButtonElement.type 2022-03-01 23:19:41 +01:00
Luke Wilde
432d496ed6 LibWeb: Add form associated element categories 2022-03-01 23:19:41 +01:00
Luke Wilde
d2e18175ef LibWeb: Move enabled() to FormAssociatedElement and follow the spec 2022-03-01 23:19:41 +01:00
Luke Wilde
0f660760ed LibWeb: Fix incorrect check in BrowsingContext::is_top_level
A top level browsing context is a browsing context with no parent
browsing context.

However, we considered a top level browsing context to be a browsing
context with no associated browsing context container.
2022-03-01 21:21:42 +00:00
Andreas Kling
56df05ae44 LibWeb: Always include floats when computing height:auto for blocks
I'm not sure why we had two modes for this, but floats should always be
included in the auto height AFAICT.
2022-03-01 19:01:19 +01:00
Andreas Kling
6478b460fb LibWeb: Fix wrong height:auto computation for block with floating child
If an element with height:auto has any floating descendants whose bottom
margin edge is below the element's bottom content edge, then the height
is increased to include those edges.

Before this patch, we were stopping at the bottom *content* edge of
floating descendants.
2022-03-01 19:01:19 +01:00
Alex M
f0f2009170 LibWeb: Add origin property to window object 2022-03-01 13:38:20 +00:00
Andrew Kaster
39f92fa131 LibC: Define offsetof in stddef.h instead of sys/cdefs.h
Just like Dr. POSIX ordered. Move the macro where it belongs, but make
sure it's visible to Userland files compiled with -DKERNEL. Parts of
LibEDID that are compiled into the Kernel use offsetof to parse the
EDID information given to us by hardware.
2022-02-28 20:28:01 -08:00
Andrew Kaster
fcb64311dc LibC: Don't export ALWAYS_INLINE from sys/cdefs.h
POSIX doesn't tell us to export a macro like this, and it's largely
going to never be defined when compiling a serenity-native C++ file,
since AK defines it already.

This does raise a strange issue where some futex-related helpers in
serenity.h are declared with ALWAYS_INLINE. Whether these helpers belong
in a C-visible header as file-static methods is questionable, but let's
work around the issue but adding some preprocessor magic to make sure
these declarations get the behavior they used to have without leaking
macros.
2022-02-28 20:28:01 -08:00
davidot
244adb371f LibJS: Spin the event loop until await has completed
Before this the event loop was spun until the state of the promise was
not pending, however it is possible that a promise has already been
fulfilled/rejected when awaiting it. This could then lead to a crash
below as it would not pump the event loop in such cases.
Although this change is in LibJS, it really only impacts any usage of
LibJS within a EventLoop environment such as LibWeb.

Instead of checking the state of the promise we know check that success
has a value which can only happen if either the fulfilled or rejected
closure set up by await are called.
2022-02-28 23:22:35 +00:00
Linus Groh
4170fcb777 LibWeb: Also apply default button styles to <button>, not just <input> 2022-02-28 23:12:37 +00:00
Lucas CHOLLET
8a9a9fac4d LibC: Add a wrapper for the getrusage syscall 2022-02-28 20:09:37 +01:00
Tobias Christiansen
8461791ce2 LibWeb: Add support for 'view-box' attribute to SVGs
This patch begins the support for the 'view-box' attribute that can be
attached to <svg>'s.
The FormattingContext determines the size of the Element according to
the specified 'width' and 'height' or if they are not given by the
'viewbox' or by the bounding box of the path if nothing is specified.
When we try to paint a SVG Path that belongs to a <svg> that has the
'view-box' and a specified 'height'/'width', all the parts of the path
get scaled/moved accordingly.

There probably are many edge cases and bugs still to be found, but this
is a nice start. :^)
2022-02-28 16:49:24 +01:00
Tobias Christiansen
4f1df48bd9 LibWeb: Make SVGSVGElement's view_box() const 2022-02-28 16:49:24 +01:00
Vrins
a8cfb34551 LibWeb: Allow <input type="button/submit/reset"> to be styled
Previously we used a native ui button to draw the buttons.
These buttons can however not be styled with css.
To allow these to be styled with css, we create a button with
the UA stylesheet that resembles the system ui button.
2022-02-28 15:46:06 +00:00
Andreas Kling
c8f6a20c02 LibWeb: Remove unused variable in required_box_type_transformation() 2022-02-28 15:14:32 +01:00
Andreas Kling
f8aa0c144f LibWeb: Store box's containing line box fragment in FormattingState
Layout should not change any properties of a box until the moment a
FormattingState is committed.
2022-02-28 14:17:44 +01:00
Andreas Kling
aa72ebf7aa LibWeb: Use copy-on-write to make cloning a FormattingState much cheaper
Instead of making a full copy of every NodeState when cloning a
FormattingState, we make NodeState ref-counted and implement a basic
copy-on-write mechanism.

FormattingState::get_mutable() now makes a deep copy of the NodeState
when first accessed *if* it is shared with other FormattingStates.
2022-02-28 14:17:44 +01:00
Andreas Kling
0a533da22f LibWeb: Don't crash on content with SVG elements outside of <svg>
We'll have to do something more proper to support this scenario
eventually, but for now let's at least not crash just because somebody
put an SVG <path> inside an HTML element.
2022-02-28 14:17:44 +01:00
Andreas Kling
ed089586ea LibWeb: Move some of PaintContext out of line 2022-02-28 14:17:44 +01:00
Andreas Kling
ee50a4e060 LibWeb: Don't blockify or inlinify boxes with already-correct type
If something is already a block on the outside, we don't want to
overwrite its inside display type.
2022-02-28 14:17:44 +01:00
Andreas Kling
c9ab9e2c64 LibWeb: Blockify children of parents with display:grid or display:flex 2022-02-28 14:17:44 +01:00
Andreas Kling
20caea2f86 LibWeb: Split CSS box type transformations into a helper function
Let's have one function that determines the type of transformation
needed, and another to actually perform the transformation.

This makes it much easier to read, and we don't have to duplicate the
logic for doing the transformation.
2022-02-28 14:17:44 +01:00
Andreas Kling
cd5c17d88e LibWeb: Improve Layout::Box has-definite-size? computation
We now consider a layout box as having definite size in these cases:

- The size is a <length>.
- The size is a <percentage> and the containing block has definite size.

This is not complete, but a bit more accurate than what we had before.
2022-02-28 14:17:44 +01:00
Andreas Kling
c6cf240f9a LibWeb: Store bottom edge location with each LineBox
Previously we were computing the bottom edge of a line box by finding
the bottommost fragment on the line.

That method didn't give correct results for line boxes with no fragments
(which is exactly what you get when inserting a bunch of <br> elements.)

To cover all situations, we now keep track of the bottommost edge in the
LineBox object itself.
2022-02-28 14:17:44 +01:00
Andreas Kling
4b6295e667 LibWeb: For height:auto blocks, measure from top of *top* line box
We were incorrectly checking for negative top edges in the *last* line
box only.
2022-02-28 14:17:44 +01:00
Andreas Kling
19954dfdf8 LibWeb: Add FormattingState::clone()
This makes a deep copy of a FormattingState.
2022-02-28 14:17:44 +01:00
Andreas Kling
1d05823810 LibWeb: Store Layout::Box overflow data in Optional instead of OwnPtr 2022-02-28 14:17:44 +01:00
Andreas Kling
916bbf5910 LibWeb: Use Vector<LineBoxFragment> instead of NonnullOwnPtrVector
This removes one step of indirection, but more importantly, makes it
easy to copy these objects. :^)
2022-02-28 14:17:44 +01:00
Andreas Kling
16a47165ee LibWeb: Use coordinate instead of WeakPtr for box->fragment connection
Using WeakPtr to remember which LineBoxFragment owns which Box was
imposing some annoying constraints on the layout code. Importantly, it
was forcing us to heap-allocate fragments, which makes it much harder to
clone a FormattingState.

This patch replaces the WeakPtr with a coordinate system instead.
Fragments are referred to by their line box index + fragment index
within the line box.
2022-02-28 14:17:44 +01:00
Andreas Kling
726edd2d3b LibWeb: Pass state to create_independent_formatting_context_if_needed()
Instead of using the current m_state implicitly, make this function take
a FormattingState&. This will allow us to use it for throwaway layouts.
2022-02-28 14:17:44 +01:00
Lucas CHOLLET
1172fd682a TextEditor: Support multiline highlighting for trailing space
The last commit fixes a bug, but also exposes the fact that trailing
space highlighting isn't really supported on multiple lines. This patch
correct the wrong behavior by adding an offset to adjust rectangle's
position.
2022-02-28 14:00:27 +01:00
Lucas CHOLLET
9c2e89e8b8 TextEditor: Fix highlighting bug in wrapping mode
Before this patch the highlighted rectangle wasn't placed on the right
spot. Now the red highlighting is correctly placed at the end of the
line. This was due to a function called with a wrong argument.
2022-02-28 14:00:27 +01:00
kleines Filmröllchen
e7d84da3da LibDSP: Allow ProcessorRangeParameter to specify if it's a log value
This doesn't affect the parameter's own behavior but is part of the
parameter meta-data, just as the name. If a parameter is logarithmic,
UI elements should represent it with an interface that scales
logarithmically.
2022-02-28 13:59:31 +01:00
Lenny Maiorani
b455363ce7 LibCore: Add rmdir system call wrapper 2022-02-28 13:57:26 +01:00
MacDue
8b2025d8fc LibVT: Fix crash from integer overflow in text wrapping
Fixes #12786
2022-02-28 10:29:48 +01:00
Itamar
7fa7c7d63c LanguageServers/Cpp: Make find declaration of enums work 2022-02-27 21:42:05 +01:00
Itamar
abc420b15a LibCpp: Set end position for the return type node of FunctionType nodes
Previously we didn't set the end position for the return type node of
function FunctionType nodes.

This caused a VERIFY failure crash when dumping an AST that contains
such nodes.
2022-02-27 21:42:05 +01:00
Idan Horowitz
feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
thankyouverycool
5fedb742da LibGUI: Set Editors to wrap at words when MultiLine
And default to NoWrap when they are type SingleLine.
2022-02-26 22:54:25 +01:00
Nícolas F. R. A. Prado
9e81c2dc83 LibLine: Update inline search cursor after kill_line (^U) command
After the kill_line (^U) command was used, searching backwards in the
history would still filter based on the text previous to the deletion.

Update the inline search cursor like already done in other internal
functions, so the text used for search is the current one.
2022-02-27 00:14:10 +03:30
Lenny Maiorani
4e6898c5cc LibMain: Update header includes 2022-02-26 17:49:58 +00:00
Lenny Maiorani
6bd880c404 LibCrypto: Simplify and move CRC32 table to cpp file
CRC32 table is generated at compile-time and put into a static
variable in the header file. This can be moved to be a function
instead of a class, be moved to the `.cpp` file` and generated as an
array instead of a class which only implements `operator[]`.
2022-02-26 17:49:47 +00:00
kleines Filmröllchen
50dc9a7be7 LibAudio: Add an array conversion transitional API to Buffer
Of course, Buffer is going to be removed very soon, but much of the
WavLoader behavior still depends on it. Therefore, this intermediary
API will allow adopting the Loader infrastructure without digging too
deep into the WavLoader legacy code. That's for later :^)
2022-02-26 17:57:55 +01:00
kleines Filmröllchen
63d9ec8e94 LibAudio: Allow resampling from any array-like type 2022-02-26 17:57:55 +01:00
kleines Filmröllchen
5d01db3493 LibAudio: Split Buffer.{h, cpp} into three files
The Buffer files had contained both the ResampleHelper and the
sample format utilities. Because the Buffer class (and its file) is
going to be deleted soon, this commit separates those two things into
their own files.
2022-02-26 17:57:55 +01:00
Andreas Kling
262488ea33 LibWeb: Validate the qualified name in createDocumentType()
1% progression on ACID3. :^)
2022-02-26 17:26:37 +01:00
Andreas Kling
f855cbac92 LibWeb: Add simple ad-hoc version of window.postMessage()
This allows us to use the wpt.live copy of the ACID3 test, which is kept
updated, unlike the acidtests.org version.
2022-02-26 17:21:40 +01:00
Andreas Kling
fc5e414596 LibWeb: Reorganize window.parent so it looks a bit more like the spec 2022-02-26 16:03:06 +01:00
Arne Elster
7223b593cb LibAudio: Add basic MP3 Decoder
This is a basic MPEG-1 layer 3 audio decoder. It supports all
sample rates and stereo modes except for freeformat.
2022-02-26 16:01:26 +01:00
Arne Elster
6a64aabce8 LibDSP: Add IMDCT
This implements a generic IMDCT to be used by the MP3 decoder.
2022-02-26 16:01:26 +01:00
Arne Elster
82afbd6593 LibAudio: Add decoding tables for MPEG-1 layer 3 audio
All data is taken straight from ISO/IEC 11172-3. These are tables
necessary for decoding MP3.
2022-02-26 16:01:26 +01:00
Arne Elster
a4ba781f23 LibAudio: Add huffman tables for MPEG-1 layer 3 audio
The data is taken straight from the ISO/IEC 11172-3 standard. For
decoding efficiency the tables are transformed into trees at compile
time using a constexpr approach. That way no runtime initialization is
necessary and decoding can be faster than searching through tables.
2022-02-26 16:01:26 +01:00
Sam Atkins
a57128467a LibWeb: Implement :nth-of-type and :nth-last-of-type selectors :^) 2022-02-26 15:30:24 +01:00
Luke Wilde
ad5fb1fd7e LibWeb: Implement Range.comparePoint 2022-02-26 12:53:32 +01:00
Luke Wilde
62b76e0658 LibWeb: Implement Range.isPointInRange 2022-02-26 12:53:32 +01:00
Luke Wilde
386ee5ab17 LibWeb: Implement Range.intersectsNode 2022-02-26 12:53:32 +01:00
Luke Wilde
4c08757ff9 LibWeb: Add Range.detach 2022-02-26 12:53:32 +01:00
Luke Wilde
8a755726ad LibWeb: Implement Range.selectNodeContents 2022-02-26 12:53:32 +01:00
Luke Wilde
2b2dbdc74f LibWeb: Implement Range.collapse 2022-02-26 12:53:32 +01:00
Luke Wilde
dfdc2ddb9e LibWeb: Implement Range.selectNode 2022-02-26 12:53:32 +01:00
Luke Wilde
a26f1b2ff9 LibWeb: Implement Range.compareBoundaryPoints 2022-02-26 12:53:32 +01:00
Luke Wilde
d73fb7e10f LibWeb: Implement Range.set{Start,End}{Before,After} 2022-02-26 12:53:32 +01:00
Luke Wilde
46ce50f74e LibWeb: Make Range.setStart and Range.setEnd spec compliant
These functions are way more involved than simply setting their
respective boundary points :^)
2022-02-26 12:53:32 +01:00
Luke Wilde
af3c866898 LibWeb: Make TreeNode::child_count return size_t instead of int
The primary benefit of this is that it's unsigned, as you can't have a
negative amount of children. Plus, all the users of child_count expect
it to be size_t.
2022-02-26 12:53:32 +01:00
Luke Wilde
3d44118595 LibWeb: Implement StaticRange 2022-02-26 12:53:32 +01:00
Luke Wilde
a2acda5669 LibWeb: Abstract Range's members into AbstractRange
Range's member variables are stored in AbstractRange as per the spec,
as they are also shared with StaticRange.
2022-02-26 12:53:32 +01:00
Luke Wilde
ed76b4238c LibWeb: Implement the legacy Audio factory function
This creates an Audio element with preload="auto" and the given src
attribute.

Required by Cookie Clicker.
2022-02-26 12:18:56 +01:00
Andreas Kling
79ea30bc96 LibWeb: Add HTMLTableSectionElement.rows and HTMLTableRowElement.cells
1% progression on ACID3. :^)
2022-02-26 12:18:39 +01:00
Andreas Kling
647576ec13 LibWeb: Fix LibWeb build with Clang
Clang doesn't like unused lambda captures.
2022-02-26 12:18:39 +01:00
Andreas Kling
fe67fe3791 LibWeb: Check for valid names in Document.createElement() & friends
We now validate that the provided tag names are valid XML tag names,
and otherwise throw an "invalid character" DOM exception.

2% progression on ACID3. :^)
2022-02-26 10:03:07 +01:00
Andreas Kling
8daf603f46 LibWeb: Paint full bitmap font glyphs, even if there's overlap
Since we now honor the CSS font-size values when deciding line box
metrics, we sometimes find ourselves needing to paint text with a bitmap
font into a box that isn't large enough for the glyphs.

As it turns out, it looks a bit better if we just grow the paint rect to
fit the glyphs (instead of painting chopped-off glyphs.) So let's just
do that for now.
2022-02-26 09:32:52 +01:00
Andreas Kling
00146005bb LibWeb: Very basic support for CSS vertical-align: <length>
If vertical-align is a length value, we lift each line box fragment that
far from the baseline of the line box.

This is rather messy, and we'll have to improve factoring as we add
support for more alignment types.
2022-02-26 09:30:17 +01:00
Andreas Kling
c8892f64f5 LibWeb: Make InlineLevelIterator not enter into inline-block boxes
The purpose of "entering" a box is to collect box model metrics that
apply to content fragments within the box. However, inline-blocks are
special, in that their inner content does not directly participate in
the inline formatting context outside it.
2022-02-26 09:27:20 +01:00
Andreas Kling
3ca26c7a7a LibWeb: Fix InlineLevelIterator not exiting box model metric nodes
We were neglecting to pop nodes from the box model stack. The metrics
were already being zeroed out when used, but let's not grow the stack
needlessly.
2022-02-26 09:25:24 +01:00
Andreas Kling
797f51e122 LibWeb: Add border box top/bottom metrics to line box fragments
This will allow us to support more kinds of vertical alignment.
2022-02-26 09:24:40 +01:00
Andreas Kling
8b369bf7bd LibWeb: Remove unused LineBox::ends_with_forced_line_break() 2022-02-26 08:33:45 +01:00
Andreas Kling
784dbdef8e LibWeb: Make DOM inspector overlay rects a little nicer
Instead of just the outline, fill them with some semi-transparent color.
Also add tag name, ID, classes and coordinates to the little tooltip.
Finally, use the border box instead of the context box for metrics,
same as other browsers.
2022-02-26 08:25:46 +01:00
Andreas Kling
c59ab7cc8b LibWeb: Make StyleValue absolutization non-destructive
Instead of awkwardly visiting and mutating lengths inside StyleValues,
we now simply create a new StyleValue instead.

This fixes an issue where inherited relative lengths could get
absolutized using a parent as reference, and then not having the correct
values when used in a child context.
2022-02-26 01:35:25 +01:00
Andreas Kling
1cdbd377e7 LibWeb: Add vertical-align to ComputedValues 2022-02-26 01:35:06 +01:00
Andreas Kling
c9f4759329 LibWeb: Use CSS font-size when computing text fragment content height 2022-02-26 01:10:43 +01:00
Itamar
72ba072768 LibDesktop: Rename LaunchServerConnection=>ConnectionToLaunchServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
2f61d32f99 LibGUI: Rename ClipboardServerConnection=>ConnectionToClipboardServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
2bc8e32af0 LibGUI: Rename NotificationServerConnection
Rename NotificationServerConnection=>ConnectionToNotificationServer.

This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
935d023967 Userland: Rename WindowServerConnection=>ConnectionToWindowServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
af132fdbd1 Userland: Rename WindowManagerServerConnection
Rename WindowManagerServerConnection=>ConnectionToWindowManagerServer.

This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
d88da82e28 Userland: Rename IPC::ServerConnection=>IPC::ConnectionToServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
3a71748e5d Userland: Rename IPC ClientConnection => ConnectionFromClient
This was done with CLion's automatic rename feature and with:
find . -name ClientConnection.h
    | rename 's/ClientConnection\.h/ConnectionFromClient.h/'

find . -name ClientConnection.cpp
    | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
2022-02-25 22:35:12 +01:00
Andreas Kling
efac862570 LibWeb: Parse <style> element text content when inserted into document
1% progression on ACID3. :^)
2022-02-25 22:05:42 +01:00
Andreas Kling
fb11741f20 LibWeb: Use the prefix passed to Document.createElementNS()
1% progression on ACID3. :^)
2022-02-25 21:29:12 +01:00
Andreas Kling
fa17776a51 LibWeb: Support HTMLFormElement.elements and HTMLFormElement.length
Note that we implement .elements as a HTMLCollection for now, instead of
the correct HTMLFormControlsCollection subclass. This covers most
use-cases already.

1% progression on ACID3. :^)
2022-02-25 21:19:06 +01:00
Andreas Kling
fbee0490a3 LibWeb: Improve HTMLElement.click()
This API now follows the spec a bit more closely, with regards to the
event being dispatched. There are still FIXME's but this is already an
improvement.

2% progression on ACID3. :^)
2022-02-25 20:45:19 +01:00
Andreas Kling
c25d653c31 LibWeb: Implement Range.commonAncestorContainer 2022-02-25 20:45:03 +01:00
Andreas Kling
aec0e54f73 LibWeb: Expose Range.collapsed to JavaScript 2022-02-25 20:20:31 +01:00
Andreas Kling
17f34488f6 LibWeb: Implement HTMLImageElement.width and HTMLImageElement.height 2022-02-25 19:38:31 +01:00
Andreas Kling
b023308f5c LibWeb: Notify parent when DOM::CharacterData content changes
This makes <style> elements reparse the CSS when their text child is
programmatically changed.
2022-02-25 19:38:31 +01:00
Andreas Kling
d0ab546d7a LibWeb: Implement UIEvent.initUIEvent()
1% progression on ACID3. :^)
2022-02-25 19:38:31 +01:00
Andreas Kling
093e66afc0 LibWeb: Make document.createEvent("UIEvent") actually create a UIEvent
There were two things preventing this from working right:

- UIEvents::UIEvent::create() was actually just DOM::Event::create()
- We didn't return the right JavaScript wrapper type for UIEvent
2022-02-25 19:38:31 +01:00
Andreas Kling
31508b2788 LibWeb: Make CSS :empty selector match empty text nodes as well
Previously we were only matching elements with *no* text children.
With this patch, we now also allow any number of empty text children to
be present as well.

1% progression on ACID3. :^)
2022-02-25 19:38:31 +01:00
Andreas Kling
29144f9238 LibWeb: Allow all ASCII whitespace chars between element class names
1% progression on ACID3. :^)
2022-02-25 19:38:31 +01:00
Andreas Kling
7ed6549c8b LibWeb: Fix off-by-one in calculation of available space for line boxes
The rightmost edge of the available space ends exactly at the leftmost
right-side floating box, not one pixel away from it.
2022-02-25 19:38:31 +01:00
Andreas Kling
a5c2ab69ec LibWeb: Look for nearest available size when using bitmap fonts
Use the new Gfx::Font::AllowInexactSizeMatch parameter when doing CSS
font lookups. This fixes a long-standing issue where text with e.g text
with "font-size:12px" would be larger than "font-size:13px" since there
was an exact match for 12, but none for 13 (so we'd fall back to 10).
2022-02-25 19:38:31 +01:00
Andreas Kling
4dd9e2df78 LibGfx: Add Font::AllowInexactSizeMatch parameter to font lookup
This allows bitmap font lookup to return the best matching size instead
of failing completely. The previous behavior (exact matches only)
remains the default.
2022-02-25 19:38:31 +01:00
Andreas Kling
95715f0c8f LibWeb: Fix rounding errors in calculation of final line box width
Instead of re-measuring the distance between the left and right edges of
a line box, we now simply adjust the final width based on how much the
rightmost fragment moved during the alignment process.
2022-02-25 19:38:31 +01:00
thankyouverycool
f457e43885 Assistant+CommandPalette: Use FrameShape::Window for main widgets 2022-02-25 19:38:23 +01:00
thankyouverycool
bb4963a697 LibGfx+LibGUI: Add FrameShape::Window
This shape is for use by the main widget of a frameless window
that still wishes to have proper borders but no title.

Raised Containers were used previously for this pattern but did not
always represent perspective and shadow correctly depending on thread
highlighting and the immediate background color. Containers are
really meant to be used inside other widgets where the background
color can be controlled.
2022-02-25 19:38:23 +01:00
thankyouverycool
7a7e57ced0 LibGfx+LibGUI: Remove {Horizontal,Vertical}Line FrameShapes
These were added 3 years ago but never used. Their intended purpose
was probably superceded by the Separator widget.
2022-02-25 19:38:23 +01:00
Sam Atkins
f3cda3c830 LibWeb: Add a rule-cache for PseudoElements
This works a little differently from the other caches - ALL rules
containing a pseudo-element are in this bucket. This lets us only look
at this bucket when finding styles for a pseudo-element, and ignore it
if we're not.
2022-02-25 19:35:34 +01:00
Sam Atkins
817cd13d59 LibWeb: Implement the ::marker pseudo-element
This matches the marker boxes of list-items.
2022-02-25 19:35:34 +01:00
Sam Atkins
5113128bc9 LibWeb: Paint InlineNode overlay in correct phase, skip pseudo-elements
We were painting this in the Foreground phase by mistake. Also, the
`inspected_node() == dom_node()` check returns true for pseudo-elements
(both values are nullptr) so I've added an extra check there. As noted,
once pseudo-elements are inspectable we will need to revisit this.
2022-02-25 19:35:34 +01:00
Sam Atkins
b76ee0e30d LibWeb: Account for all simple-selectors when calculating specificity
This fixes the Acid2 blue nose when hovering. :^)
2022-02-25 19:35:34 +01:00
Sam Atkins
ab2c47542d LibWeb: Create layout nodes for ::before and ::after pseudo-elements :^)
For now, we only handle their `content` being text, but it's a start!
2022-02-25 19:35:34 +01:00
Sam Atkins
1de0ca3286 LibWeb: Compute value for content property 2022-02-25 19:35:34 +01:00
Sam Atkins
7eb7396f8b LibWeb: Match styles for pseudo-elements
Since each selector can only have zero or one pseudo-element, we match
against it as a separate step, before matching the rest of the
selector. This should be faster, but mostly I did this because I could
not figure out how else to stop selectors without a pseudo-element from
matching the pseudo-element, eg so `.foo` styles don't affect
`.foo::before`.
2022-02-25 19:35:34 +01:00
Sam Atkins
caef4ec157 LibWeb: Move PseudoElement enum up a level
This in preparation for changing how we store these, plus it's unwieldy
having to type CSS::Selector::SimpleSelector::PseudoElement.
2022-02-25 19:35:34 +01:00
Sam Atkins
5390e05851 LibWeb: Extract code for creating a Layout::Node based on display type
We need to run the same logic for creating the ::before and ::after
pseudo-elements, so this saves us from duplicating the code.
2022-02-25 19:35:34 +01:00
Sam Atkins
7bb721bea2 LibWeb: Make display: foo box constructors take the Element by pointer
This means we can instantiate them for pseudo-elements, which don't have
an associated Element. They all pass it to their parent as a
`Layout::Node*` and handle a lack of `layout_node()` already so this
won't affect any functionality.
2022-02-25 19:35:34 +01:00
Sam Atkins
adaab23149 LibWeb: Parse the content property
For now, we only understand `none`, `normal`, `<image>` and `<string>`.
The various other functions and identifiers can be added later.

We can *almost* use a StyleValueList for this, except it's divided into
two parts - the content, and the optional "alt text". So, I've added a
new StyleValue for it.
2022-02-25 19:35:34 +01:00
Jan Grau
6992a07afc LibGUI+WindowServer: Add new WMEvent Super+Digit
This adds a keyboard event for Super+0 to Super+9. Later to be consumed
in the taskbar.

Currently only this keyboard sequence is supported:
  - Super key down
  - Digit key down

But not this:
  - Super key down
  - Digit key down
  - Digit key up
  - Digit key down
2022-02-24 18:57:20 +00:00
Andreas Kling
001b08dec9 LibGUI: Put TextEditor widgets in "Wrap at Words" mode by default 2022-02-24 19:40:26 +01:00
thankyouverycool
988c6fea19 LibGUI: Prefer to pop-up Tray Button menus from the top right
Fixes menus obscuring SegmentWidgets in status bars.
2022-02-24 19:09:41 +01:00
thankyouverycool
94b74937d8 LibGUI+LibSyntax: Stringify Highlighter::Language
This patch adds a Highlighter::Language -> string helper and a
callback for Highlighter changes.
2022-02-24 19:09:41 +01:00
thankyouverycool
3aa95dd4d5 LibGUI+Apps: Convert Statusbar Labels to Segments
Segments inherit from Button and let us add clickable widgets
to status bars. This patch also adds proportional, fixed and
autosized modes for segments and lets the status bar consume
all non-clickable segments for override text.
2022-02-24 19:09:41 +01:00
thankyouverycool
e113e3ccaa LibGfx: Return early when painting FrameShape::NoFrames 2022-02-24 19:09:41 +01:00
Timothy Flynn
21bd3a21bd LibWeb: Append only one line feed character in Document.writeln
There were a couple issues here:

1. The line feed should only be appended once, rather than one per
   string.
2. The new_strings list of strings was unused (we were creating the new
   list, then passing the old list to Document.write).
2022-02-24 18:12:19 +01:00
thankyouverycool
d94db1900e LibGUI+LibGfx: Defer to fonts when setting Editor line height
Fonts now provide their preferred line height based on maximum
height and requested line gap. TTFs provide a preferred line gap
from table metrics while BitmapFonts are hardcoded at the previous
default for now.
2022-02-24 18:09:22 +01:00
thankyouverycool
07910c12e3 LibGUI: Ensure ruler grows properly when using proportional fonts
Ruler needs to take into account spacing between glyphs for
proportional fonts as line count increases. This also replaces
the less accurate 'x' width estimate for widest character with
a '4'
2022-02-24 18:09:22 +01:00
Sam Atkins
09262e3b77 LibWeb: Actually query the orientation
I made a typo and was checking for "hover" twice.
2022-02-24 08:04:25 +01:00
Sam Atkins
114a7b357b LibWeb: Implement @media(overflow-inline)
I guess I got confused by this before, but it's actually the same as
overflow-block.
2022-02-24 08:04:25 +01:00
Sam Atkins
fd2ef43cb4 LibWeb: Implement <resolution> as a media feature type
This is the only dimension type besides `<length>` that is used in any
media queries in levels 4 or 5 right now. Others can be included
if/when they're needed.
2022-02-24 08:04:25 +01:00
Sam Atkins
5c8ea81d21 LibWeb: Parse Angle/Frequency/Resolution/Time types 2022-02-24 08:04:25 +01:00
Sam Atkins
f76a541819 LibWeb: Move length-unit-from-string code into Length
This means the units are defined in a single place instead of two.

Also removed the verify that we didn't produce a bogus % dimension token
in the Tokenizer, since this has never happened and the parser is not a
tokenizer test suite. :^)
2022-02-24 08:04:25 +01:00
Sam Atkins
608bfac2a9 LibWeb: Implement CSS Time class
This corresponds to `<time>` in the grammar.
2022-02-24 08:04:25 +01:00
Sam Atkins
0465abcfec LibWeb: Implement CSS Resolution class
This corresponds to `<resolution>` in the grammar.
2022-02-24 08:04:25 +01:00
Sam Atkins
bd79c303f6 LibWeb: Implement CSS Frequency class
This corresponds to `<frequency>` in the grammar.
2022-02-24 08:04:25 +01:00
Sam Atkins
355d1936f2 LibWeb: Implement CSS Angle class
This corresponds to `<angle>` in the grammar.
2022-02-24 08:04:25 +01:00
Sam Atkins
a07fed4e53 LibWeb: Account for Calculated in Length methods
We were ignoring this in a couple of places.
2022-02-24 08:04:25 +01:00
Sam Atkins
64f112c4ea LibWeb: Alphabetize LibWeb CMakeLists.txt 2022-02-24 08:04:25 +01:00
Linus Groh
2c1252b92e LibGUI/EmojiInputDialog: Skip multi code point emojis for now
These will require some tweaking here and elsewhere in LibGUI, to handle
both rendering of the emojis as single glyphs consistently, and faking
key events with multiple code points after selecting one.
2022-02-23 21:53:30 +00:00
Linus Groh
8b790c4ff8 LibGUI/EmojiInputDialog: Automatically calculate the dialog size
This was getting way too crowded again. Let's just fix the FIXME. :^)
2022-02-23 21:53:30 +00:00
Linus Groh
c5c026890e LibGfx: Add basic variation selector and regional indicator support :^)
I'm sure there's a spec for this somewhere, but this is a first working
approximation.

Closes #3315.
2022-02-23 21:53:30 +00:00
Linus Groh
cab032f1ee LibGfx+LibGUI: Support multi code point emojis in text painting :^)
This necessitates switching from passing a single code point to the
callback to passing a non-const Utf8CodePointIterator instead.

Note that the text selection mechanisms in LibGUI and LibWeb don't
handle this properly yet; they still assume that each code point
renders as one glyph. Similarly, width calculations for text widths
don't either, so a single such an emoji will require space for more
than one glyph.

It also doesn't work in LibVT's TerminalWidget, where each code point
is handled and rendered separately, so LibGfx never gets a chance to
check if subsequent code points could result in a combined emoji.
2022-02-23 21:53:30 +00:00
Linus Groh
e1eb882b1c LibGfx: Add Emoji::emoji_for_code_point_iterator(Utf8CodePointIterator&)
In the common case of text rendering rather than getting the emoji
bitmap for a fixed number of code points, we don't know how many code
points make one emoji. As far as I can tell, the longest ones are up to
ten code points, so we try to consume all of them and do a lookup during
each iteration, and return the emoji for the longest chain of code
points. Quite basic and definitely room for improvement, but it works!
2022-02-23 21:53:30 +00:00
Linus Groh
514f3e9c74 LibGfx: Add Emoji::emoji_for_code_points(Span<u32> const&)
Not all emojis are just one code point, so the existing API is not
sufficient: Emoji::emoji_for_code_point(u32).
The file name for such emojis is simply each U+XXXX separated by an
underscore.
2022-02-23 21:53:30 +00:00
thankyouverycool
653f01616c LibGUI+Apps: Adjust Splitter spacings
Different thread highlights between widgets lead to different
visual weights between splitters, even when they have the same
width or height. This means some splitters look best at odd
sizes while others even. This sets the default spacing to the
most commonly used, depending on orientation, and adjusts
spacing for a few apps based on the new paint rect.

The most consistent look across apps requires some manual
tweaking occassionally. Knurlheads, use your discretion!
2022-02-23 18:56:22 +02:00
thankyouverycool
fe864af0dc LibGUI+Apps: Prevent Splitter children from being unresizable
Splitters could be resized in such an order that all their remaining
children were fixed size, leading to unfillable gaps on resize events.

HackStudio and TextEditor already had logic to handle this edge case,
so this patch factors it into a general solution for all Splitters.
At least one widget is now guaranteed to be resizeable after a child
is removed.
2022-02-23 18:56:22 +02:00
thankyouverycool
c3ce562240 LibGUI+Apps: Let Splitters select which resizee to set fixed
This gives Splitters more versatility when the right resizee is
intended to remain fixed or be toggled on and off.
2022-02-23 18:56:22 +02:00
thankyouverycool
495fd1d2c4 LibGUI: Adjust grabbable rect between Splitter widgets
Previously, the rect began on the edge of the first widget instead of
immediately after, causing an overpaint visible on hover.
2022-02-23 18:56:22 +02:00
Michiel Visser
898be38517 LibTLS: Add signature verification for DHE and ECDHE key exchange
This will verify that the signature of the ephemeral key used in the
DHE and ECDHE key exchanges is actually generated by the server.

This verification is done using the first certificate provided by the
server, however the validity of this certificate is not checked here.
Instead this code expects the validity to be checked earlier by
`TLSv12::handle_certificate`.
2022-02-23 13:20:28 +03:30
Michiel Visser
be138474c5 LibCrypto: Add EMSA-PKCS1-V1_5 encoder and verification
This add an implementation for the EMSA-PKCS1-V1_5-ENCODE function from
RFC8017 section 9.2. The verification of this encoding is implemented by
simply encoding the message to be verified, and then comparing the two
encoded string.

The digest info for the different hash function is from RFC8017 section
9.2 notes 1. These byte sequences are actually ASN.1 encoded data,
however these are always constant for a specific hash function and can
be treated as opaque byte sequences.
2022-02-23 13:20:28 +03:30
Michiel Visser
edee8ab32a LibTLS: ECDHE switch from FeatureNotSupported to NotUnderstood error
NotUnderstood will generate a TLS alert with an InternalError instead of
crashing the RequestServer.
2022-02-23 13:20:28 +03:30
Michiel Visser
ab84aa6fb2 LibTLS: Add OutOfMemory error that will send an InternalError alert 2022-02-23 13:20:28 +03:30
Itamar
610b380515 Libraries/LibCpp: Add parser test for out-of-line function definitions 2022-02-23 00:48:44 +00:00
Itamar
7b42abccf2 LibCpp: Allow qualified names in AST Declaration nodes
Previously, the names of declarations where stored as a simple
StringView.

Because of that, we couldn't parse out-of-line function definitions,
which have qualified names.
For example, we couldn't parse the following snippet:

```
void MyClass::foo(){}
```

To fix this, we now store the name of a declaration with a
ASTNode::Name node, which represents a qualified named.
2022-02-23 00:48:44 +00:00
Jelle Raaijmakers
d905de6a7a LibGL: Set correct matrices in glFrustum and glOrtho
We were erroneously setting the projection matrix when `GL_MODELVIEW`
was supplied.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
5cf967e4f2 LibGL: Improve glFrustum precision and error handling
Do not convert to float too early. Additionally, handle some error
cases for the input parameters.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
d92047c74d LibGL: Clamp color in glClearColor to 0..1 2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
44a3d5c101 LibGL: Implement glClearDepthf and store as float
Our API still specifies it as a double, but internally we communicate a
float to the rasterizer. Additionally, clamp the value to 0..1 as
described in the spec.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
36a732e98e LibGL: Ignore stack on projection and model view matrix retrieval
Our implementation keeps the top-most item on the matrix stacks in a
member variable, so we can always use that instead of considering the
actual stack.

Additionally, the current matrix mode should not influence retrieving
the projection or model view matrix.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
c3273e9492 LibSoftGPU: Clean up some conditionals in Device
No functional changes.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
f28047de73 LibSoftGPU: Round rasterization position to nearest integer
This fixes the issue where e.g. `299.97` would be cast to an integer
value of `299`, whereas the pixel's center would lie at `299.5` and
would then erroneously be excluded.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
8c9fa50c61 LibSoftGPU: Apply regular cartesian coordinate system
Currently, LibSoftGPU is still OpenGL-minded in that it uses a
coordinate system with the origin of `(0, 0)` at the lower-left of
textures, buffers and window coordinates. Because we are blitting to a
`Gfx::Bitmap` that has the origin at the top-left, we need to flip the
Y-coordinates somewhere in the rasterization logic.

We used to do this during conversion of NDC-coordinates to window
coordinates. This resulted in some incorrect behavior when
rasterization did not pass through the vertex transformation logic,
e.g. when calling `glDrawPixels`.

This changes the coordinate system to OpenGL's throughout, only to blit
the final color buffer upside down to the target bitmap. This fixes
drawing to the depth buffer directly resulting in upside down images.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
3832656464 LibGL: East-const two methods in Texture2D
No functional changes.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
7004b20656 LibGL+LibSoftGPU: Use more expressive is_power_of_two 2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
971b39ae4f LibSoftGPU: Rename rgba to bgra to reflect actual value 2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
506a857c3e LibGL: Use clamp<float> for depth range
We get `double`s as input, so convert them to `float` first.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
db0616c67a LibSoftGPU: Generalize pixel buffers and standardize on BGRA8888
Between the OpenGL client and server, a lot of data type and color
conversion needs to happen. We are performing these conversions both in
`LibSoftGPU` and `LibGL`, which is not ideal. Additionally, some
concepts like the color, depth and stencil buffers should share their
logic but have separate implementations.

This is the first step towards generalizing our `LibSoftGPU` frame
buffer: a generalized `Typed3DBuffer` is introduced for arbitrary 3D
value storage and retrieval, and `Typed2DBuffer` wraps around it to
provide in an easy-to-use 2D pixel buffer. The color, depth and stencil
buffers are replaced by `Typed2DBuffer` and are now managed by the new
`FrameBuffer` class.

The `Image` class now uses multiple `Typed3DBuffer`s for layers and
mipmap levels. Additionally, the textures are now always stored as
BGRA8888, only converting between formats when reading or writing
pixels.

Ideally this refactor should have no functional changes, but some
graphical glitches in Grim Fandango seem to be fixed and most OpenGL
ports get an FPS boost on my machine. :^)
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
72ec2c21f4 LibGL: Remove superfluous AK::dbgln alias 2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
6318522339 LibSoftGPU: Remove Device::wait_for_all_threads()
This function was added as a FIXME but was then arbitrarily invoked in
the rest of `Device`. We are better off removing this FIXME for now and
reevaluate introducing multithreading later on, so the code is not
littered with useless empty function calls.
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
4d53a87355 LibSoftGPU: Remove unused AK/Function.h include 2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
a5ad702387 LibSoftGPU: Use fabsf instead of fabs for float
Let's not do a `float -> double -> float` roundtrip. :^)
2022-02-22 23:48:59 +00:00
Jelle Raaijmakers
011f6542db LibGL: Allow all primitives in glBegin()
We check for primitive support in `glEnd()`, so we do not need to
preemptively reject the mode in `glBegin()`. This allows `glBegin()` to
be invoked with `GL_POINTS`, for example.
2022-02-22 23:48:59 +00:00
Ali Mohammad Pur
bed129a69f LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour tests
As there's a somewhat active development going on, let's keep the
expected behaviour under tests to make sure nothing blows up :^)
2022-02-23 03:17:12 +03:30
Ali Mohammad Pur
0fe97cdfe4 LibJS: Print the expected and received value on expect.toEqual() failure
'ExpectationError' is hardly an actionable error message.
2022-02-23 03:17:12 +03:30
Andreas Kling
b45ed48ca7 LibWeb: Support CSSStyleDeclaration.cssFloat
Unlike all the other CSS properties, 'float' is special, and can only be
accessed via 'cssFloat' on CSSStyleDeclaration. So this patch adds
support for that. 1 point on ACID3! :^)
2022-02-21 22:27:56 +01:00
Andreas Kling
19b5033dc4 LibWeb: Implement Node.removeChild() in terms of "pre-remove"
This is what the spec wants us to do.
2022-02-21 22:21:59 +01:00
Andreas Kling
8b2499b112 LibWeb: Make document.write() work while document is parsing
This necessitated making HTMLParser ref-counted, and having it register
itself with Document when created. That makes it possible for scripts to
add new input at the current parser insertion point.

There is now a reference cycle between Document and HTMLParser. This
cycle is explicitly broken by calling Document::detach_parser() at the
end of HTMLParser::run().

This is a huge progression on ACID3, from 31% to 49%! :^)
2022-02-21 22:00:28 +01:00
Andreas Kling
bb1f26c149 LibWeb: Use correct coordinate space when measuring space between floats
When calculating how much space is available for inline content between
left and right floated elements, we have to use coordinates in the
containing block's coordinate space, since that's what floats use.

This fixes an issue where text would sometimes overlap floats.
2022-02-21 20:42:34 +01:00
Andreas Kling
8c2a4a2a3d LibWeb: Calculate edge of containing block correctly when floating right 2022-02-21 20:42:34 +01:00
Andreas Kling
f21a0bf437 LibWeb: Don't shift right-floated boxes too much to the left
We were subtracting the content width of right-floated boxes from their
X position for no reason. Removing this makes floats snuggle up to each
other on the right side. :^)
2022-02-21 20:42:34 +01:00
Andreas Kling
5a770f2eff LibWeb: Fix floating boxes getting stacked on top of each other
This was caused by the freestanding margin_box_rect() using 0 for the
content height instead of the actual content height.
2022-02-21 19:38:50 +01:00
Andreas Kling
89d0cb0ce2 LibWeb: Compute table cell height after doing its inside layout 2022-02-21 18:35:12 +01:00
Andreas Kling
db5bf6e64c LibWeb: Rename FormattingState::ensure() -> get_mutable()
This makes it much more obvious what the difference between get() and
get_mutable() is.
2022-02-21 18:35:12 +01:00
Andreas Kling
0f15d1f947 LibWeb: Add hack to avoid crashing on !child_display.is_flow_inside()
When encountering a box that claims to have block-level children, but
its CSS display type isn't actually "flow" inside, we would previously
crash due to a VERIFY() failure.

However, many sites choke on this due to freestanding table-related
boxes like those created by "table-row" and "table-row-group".
We're supposed to fix those up by wrapping them in a full set of table
boxes during layout tree construction, but that algorithm obviously
isn't working correctly in all cases. So let's work around the crashes
for now, allowing many more sites to load (even if visually incorrect.)

This is a rather monstrous hack, and we should get rid of it as soon as
it's not needed anymore.
2022-02-21 18:35:12 +01:00
Andreas Kling
c61747fb2a LibWeb: Respect font-size specified by CSS in "em" length calculations
"5em" means 5*font-size, but by forcing "em" to mean the presentation
size of the bitmap font actually used, we broke a bunch of layouts that
depended on a correct interpretation of "em".

This means that "em" units will no longer be relative to the exact
size of the bitmap font in use, but I think that's a compromise we'll
have to make, since accurate layouts are more important.

This yields a visual progression on both ACID2 and ACID3. :^)
2022-02-21 18:35:12 +01:00
Andreas Kling
2615728d6b LibWeb: Store overflow data in the FormattingState 2022-02-21 18:35:12 +01:00
Andreas Kling
92266d2247 LibWeb: Create list-item markers during layout tree construction
Previously, these were added during layout. This didn't fit into the new
world where layout doesn't mutate the tree incrementally, so this patch
adds logic to Layout::TreeBuilder for adding a marker to each list-item
box after its children have been constructed.
2022-02-21 18:35:12 +01:00
Andreas Kling
c9700e100e LibWeb: Start making our layout system "transactional"
This patch adds a map of Layout::Node to FormattingState::NodeState.
Instead of updating layout nodes incrementally as layout progresses
through the formatting contexts, all updates are now written to the
corresponding NodeState instead.

At the end of layout, FormattingState::commit() is called, which
transfers all the values from the NodeState objects to the Node.

This will soon allow us to perform completely non-destructive layouts
which don't affect the tree.

Note that there are many imperfections here, and still many places
where we assign to the NodeState, but later read directly from the Node
instead. I'm just committing at this stage to make subsequent diffs
easier to understand.
2022-02-21 18:35:12 +01:00
Andreas Kling
561612f219 LibWeb: Add Layout::FormattingState
The purpose of this new object will be to keep track of various states
during an ongoing layout.

Until now, we've been updating layout tree nodes as we go during layout,
which adds an invisible layer of implicit serialization to the whole
layout system.

My idea with FormattingState is that running layout will produce a
result entirely contained within the FormattingState object. At the end
of layout, it can then be applied to the layout tree, or simply queried
for some metrics we were trying to determine.

When doing subtree layouts to determine intrinsic sizes, we will
eventually be able to clone the current FormattingState, and run the
subtree layout in isolation, opening up opportunities for parallelism.

This first patch doesn't go very far though, it merely adds the object
as a skeleton class, and makes sure the root BFC has one. :^)
2022-02-21 18:35:12 +01:00
Andreas Kling
9c05639d35 LibWeb: Assign correct viewport dimensions when making style for ICB
The ICB (initial containing block) gets its style from StyleComputer's
create_document_style(). It's basically a generic style for the root of
the layout tree.

With this patch, we now assign the width and height of the viewport rect
as two CSS "px" lengths to the "width" and "height" properties of the
ICB style. (Previously they were just defaulting to "auto" and we
assigned override dimensions during layout.)

This fixes an issue where position:absolute elements with relative width
and/or height were not dimensioned correctly, since the values were
relative to the width and/or height of the ICB style.
2022-02-21 18:35:12 +01:00
Lorenz Steinert
db789813c9 LibWeb: Add basic support for dynamic markup insertion
This implements basic support for dynamic markup insertion, adding
 * Document::open()
 * Document::write(Vector<String> const&)
 * Document::writeln(Vector<String> const&)
 * Document::close()

The HTMLParser is modified to make it possible to create a
script-created parser which initially only contains a HTMLTokenizer
without any data. Aditionally the HTMLParser::run method gains an
overload which does not modify the Document and does not run
HTMLParser::the_end() so that we can reenter the parser at a later time.
Furthermore all FIXMEs that consern the insertion point are implemented
wich is defined in the HTMLTokenizer. Additionally the following
member-variables of the HTMLParser are now exposed by getter funcions:
 * m_tokenizer
 * m_aborted
 * m_script_nesting_level

The HTMLTokenizer is modified so that it contains an insertion
point which keeps track of where the next input from the Document::write
functions will be inserted. The insertion point is implemented as the
charakter offset into m_decoded_input and a boolean describing if the
insertion point is defined. Functions to update, check and {re}store the
insertion point are also added.
The function HTMLTokenizer::insert_eof is added to tell a script-created
parser that document::close was called and HTMLParser::the_end() should
be called.
Lastly an explicit default constructor is added to HTMLTokenizer to
create a empty HTMLTokenizer into which data can be inserted.
2022-02-21 18:26:43 +01:00
Timothy Flynn
96459e4b3a LibJS: Define the Intl.Collator's compare function name to be empty 2022-02-21 16:30:19 +00:00
Simon Danner
f7dbcb652a LibWeb: SVG parse signed numbers in eliptical arc 2022-02-21 16:32:24 +01:00
Marco Cutecchia
dbfe385879 LibGUI: Add 'remove_all_actions' method to 'Menu' 2022-02-21 16:31:56 +01:00
Adam Hodgen
b6eaefa87d LibWeb: Fix 'Comment end state' in HTML Tokenizer
Also, update the expected hash in the LibWeb TestHTMLTokenizer
regression test.

This is due to the "This comment has a few too many dashes." comment
token being updated.
2022-02-21 16:31:45 +01:00
Adam Hodgen
d73bb2633c LibWeb: Implement tokenization newline preprocessing
Newline normalization will replace \r and \r\n with \n.

The spec specifically states
> Before the tokenization stage, the input stream must be preprocessed
> by normalizing newlines.
wheras this is implemented the processing during the tokenization
itself.

This should still exhibit the same behaviour, while keeping the
tokenization logic in the same place.
2022-02-21 16:31:45 +01:00
Adam Hodgen
c6fcdd0f93 LibWeb: Fix off by one error in HTML Tokenizer
In 'NamedCharacterReference' we attempt to lookup the code point by a
identifier, eg apos; becomes '

This is done by passing the entire rest of the document to the
`HTML::code_points_from_entity` function.

However, before this change we didn't sent the final character which
meant if the document ended in a named character reference the lookup
would fail.
2022-02-21 16:31:45 +01:00
Adam Hodgen
c6dd8a1f66 LibWeb: Implement Node.nodeValue DOM attribute 2022-02-21 16:31:45 +01:00
Idan Horowitz
7ae2debf6e LibJS: Re-implement String.localeCompare using the StringCompare AO
This follows the ECMA402 spec and means String.prototype.localeCompare
will automatically become actually locale aware once StringCompare is
actually implemented based on UTS #10.
2022-02-20 22:05:59 -05:00
Idan Horowitz
6558f4ae6b LibJS: Implement get Intl.Collator.prototype.compare 2022-02-20 22:05:59 -05:00