Commit graph

15567 commits

Author SHA1 Message Date
Linus Groh 1e01a85cdf LibJS: Import C++ sources from libjs-test262 :^)
This commit upstreams most of the C++ bits of the LibJS test262 runner
at https://github.com/linusg/libjs-test262/, specifically everything but
the main.cpp file serving as the actual executable.
Since all of these are just regular JS objects, I opted to put them in
LibJS itself, in a new Contrib/ directory like many other projects have
one. Other code that can end up there in the future is the runtime for
esvu, which might even share some functionality with test262's $262
object.

The code has been copied verbatim, and only a small number of changes
have been made:

- Putting everything into the JS::Test262 namespace
- Removing now redundant JS namespace prefixes
- Updating includes to use absolute <LibJS/...> paths
- Updating the SPDX-License-Identifier comments from MIT to BSD-2-Clause

I gained permission to change the license and upstream these changes
from all the major contributors to this code: Ali, Andrew, David, Idan.

The removal of the code from the source repository is here:
https://github.com/linusg/libjs-test262/pull/54

This is only the first step, the goal is to eventually upstream the
actual libjs-test262-runner executable and supporting Python scripts
into SerenityOS as well.
2022-03-29 21:01:08 +01:00
Andreas Kling e7eb6241c2 LibWeb: Ignore list-item marker boxes in height:auto calculation 2022-03-29 21:50:31 +02:00
Andreas Kling 5da7ebb806 LibWeb: Make height:auto for non-BFC-root blocks more correct
Unlike BFC root blocks with height:auto, when the block *isn't* a BFC
root, we don't have to look for the "bottommost" block-level child and
determine the width from that.

Instead, we should just look at the last in-flow block-level child.
This was already indicated in the spec comment next to the code, but
the code itself was wrong.

This makes the body element on Acid3 have the correct height. It also
introduces a small regression on Acid2 that we'll have to track down.
2022-03-29 18:53:27 +02:00
Andreas Kling 18048efce0 LibWeb: Don't round numbers too early when painting backgrounds
Preserve floating point precision and delay rounding until the last
moment when figuring out where to paint background layers. This fixes an
issue on Acid3 where a thin sliver of red was visible because the
background X position was incorrectly rounded by 1px.
2022-03-29 18:53:27 +02:00
Andreas Kling afebc372b9 LibGfx: Use llroundf() in Rect<float>::to_rounded()
No need to drag the values through a float-to-double conversion.
2022-03-29 18:53:27 +02:00
Daniel Glazman 91e1383b85 LibWeb: Implement attribute selector case identifier 2022-03-29 18:53:20 +02:00
Daniel Glazman 049d847230 LibWeb: Clarify attribute selectors when needle is empty 2022-03-29 18:53:20 +02:00
Tim Schumacher aa7b6852ce LibC: Make prctl() a varargs function 2022-03-29 09:10:34 -07:00
Itamar d9d299f884 HackStudio: Add FindWidget
The find widget appears on Ctrl+F.

It uses the GUI::TextEditor search API to search for text, which also
takes care of highlighting the search results.
2022-03-29 17:45:36 +02:00
Itamar de902ab659 TextEditor: Use the search API of GUI::TextEditor
This enables us to remove some code duplication and also makes the
search results highlighted.
2022-03-29 17:45:36 +02:00
Itamar 5f2a0f03a6 LibGUI: Add search API to TextEditor with highlighted results
This adds a search API to TextEditor.

The API that is similar to "find_text" of TextDocument (which is used
internally to do the search).

All search results (as well as the current one) are highlighted with
a "span collection", which is pretty neat :^)
2022-03-29 17:45:36 +02:00
Itamar a12385dc4b LibGUI: Add match_case parameter to TextDocument::find_all() 2022-03-29 17:45:36 +02:00
Itamar ab0b4f46f7 LibGUI: Support multiple layers of TextDocument spans
TextDocument::set_spans() now also takes a "span collection index"
argument.

TextDocument keeps a map between a span collection index and its spans.
It merges the spans from all collections into a single set of spans
whenever set_spans() is called.

This allows us to style a document with multiple layers of spans, where
as previously we only supported a single layer of spans that was set
from the SyntaxHighlighter.
2022-03-29 17:45:36 +02:00
Itamar b75ed992a6 LibGUI: Add operators >,>= to TextPosition 2022-03-29 17:45:36 +02:00
Itamar 1d522e4b4c LibGUI: Add DoClamp option to AbstractSlider::set_value() 2022-03-29 17:45:36 +02:00
Andreas Kling 427beb97b5 LibWeb: Streamline how inline CSS style declarations are constructed
When parsing the "style" attribute on elements, we'd previously ask the
CSS parser for a PropertyOwningCSSStyleDeclaration. Then we'd create a
new ElementCSSInlineStyleDeclaration and transfer the properties from
the first object to the second object.

This patch teaches the parser to make ElementCSSInlineStyleDeclaration
objects directly.
2022-03-29 16:35:46 +02:00
Andreas Kling 3efa6cedec LibWeb: Remove unused StyleSheetList::m_generation 2022-03-29 16:35:46 +02:00
Andreas Kling 0de488749f LibWeb: Use rounding instead of enclosing_int_rect() when painting
By using enclosing_int_rect(), borders and backgrounds of boxes were
sometimes 1 pixel off, making things slightly larger than they should
be. Fix this by using to_rounded() instead of enclosing_int_rect().

There's definitely more of these type of issues lurking in the code,
and we'll get to them in time.
2022-03-29 16:35:46 +02:00
Ali Mohammad Pur e1cf51b0bd Shell: Add a shell option for autocompleting via the program itself
This feature needs a bit more work, so let's disable it by default.
Note that the shell will still use _complete_foo if it is defined
regardless of this setting.
2022-03-29 15:42:55 +02:00
Tim Schumacher cdca6fc113 LibC: Make wchar size definitions available from stdint.h
POSIX describes WCHAR_MIN and WCHAR_MAX in stdint.h(0P), while
wchar.h(0P) only says "as described in stdint.h".

As there isn't a trivial path of "may make visible", just move it to a
shared header and include it from both files.
2022-03-29 15:19:39 +02:00
Andreas Kling f4ed4b2806 LibWeb: Swallow whitespace when it causes us to break the line
This fixes an issue seen on Acid3 where the instruction text would shift
around when moving from "white-space:pre-wrap" to "white-space:normal".
2022-03-29 13:37:54 +02:00
Idan Horowitz 02e97b3313 LibJS: Bring ForIn body evaluation closer to the specification
This fixes 2 bugs in our current implementation:
 * Properties deleted during iteration were still being iterated
 * Properties with the same name in both the object and it's prototype
   were iterated twice
2022-03-29 14:34:08 +03:00
Idan Horowitz 9cfbbfd8d8 LibJS: Implement the EnumerateObjectProperties AO 2022-03-29 14:34:08 +03:00
Andreas Kling 9711e1b303 LibWeb: Make floating boxes in IFC occupy horizontal margin box
Previously, we only allowed floats to take up its own border box's worth
of horizontal space when laid out inside an IFC.

We should instead consume the full margin box horizonally. This fixes an
issue where a floated box on Acid3 had {width:20px; margin-right:-20px;}
but still consumed 20px of the previously available space, despite being
moved out of the way by its own negative margin.
2022-03-29 12:35:31 +02:00
Andreas Kling 5def3b0150 LibWeb: Use LineBox::height() when determining IFC auto heights
We don't need to loop through all the fragments on the line to work out
how tall it is. Just ask for the height. :^)
2022-03-29 12:25:34 +02:00
Andreas Kling 03008d9c9c LibWeb: Ensure that TextNode::ChunkIterator emits preserved newlines
When doing max-content layout, we were not committing newlines even
though we were supposed to due to white-space:pre*.

This broke the WPT harness due to a VERIFY() in ChunkIterator where we
were assuming the commit would always succeed.

Thanks to Orphis for reporting this! :^)
2022-03-29 03:05:11 +02:00
Andreas Kling a6eb031058 LibWeb: Use correct top content edge when calculating auto block heights
When the spec tells us to measure from the top content edge of a block,
that just means we should measure from Y=0. We don't need to go looking
for a child box with a negative top offset and measure from there.
2022-03-29 02:59:00 +02:00
Matthew Olsson 4e81663b31 LibPDF: Attempt to unecrypt strings and streams 2022-03-29 02:52:57 +02:00
Matthew Olsson 60c3e786be LibPDF: Require Document* in Parser constructor
This makes it a bit easier to avoid calling parser->set_document, an
issue which cost me ~30 minutes to find.
2022-03-29 02:52:57 +02:00
Matthew Olsson a8de9cf541 LibPDF: Keep track of the current object index/generation while Parsing
This information is required to decrypt encrypted strings/streams.
2022-03-29 02:52:57 +02:00
Matthew Olsson 5b316462b2 LibPDF: Add implementation of the Standard security handler
Security handlers manage encryption and decription of PDF files. The
standard security handler uses RC4/MD5 to perform its crypto (AES as
well, but that is not yet implemented).
2022-03-29 02:52:57 +02:00
Matthew Olsson c98bda8ce6 LibPDF: Get rid of PlainText/Encoded StreamObject
This was a small optimization to allow a stream object to simply hold
a reference to the bytes in a PDF document rather than duplicating
them. However, as we move into features such as encryption, this
optimization does more harm than good. This can be revisited in the
future if necessary.
2022-03-29 02:52:57 +02:00
Matthew Olsson 15b7999313 LibPDF: Change CommonNames' enumerator macro parameter name
Apparently "V" is a PDF property. Let's hope "A" isn't!
2022-03-29 02:52:57 +02:00
Matthew Olsson 9a4a3318a9 LibPDF: Store a PDFFont in the Renderer's text state 2022-03-29 02:52:57 +02:00
Matthew Olsson 0624472768 LibPDF: Add initial support for Type1 fonts
This is enough to get a char code -> code point mapping
2022-03-29 02:52:57 +02:00
Matthew Olsson 8441fa2bc4 LibPDF: Add support for builtin and custom Encodings 2022-03-29 02:52:57 +02:00
Andreas Kling 1f9aed2617 LibWeb: Load and use fonts described by @font-face rules :^)
When encountering a @font-face rule, StyleComputer will now fire off
a resource request and download the first source URL specified.

Once downloaded, we try to parse it as a TrueType font file, and if it
works, it's added to a cache in StyleComputer. This effectively makes
fonts per-document since every document has its own StyleComputer.

This is very unoptimized and could definitely use some caching, etc.
But it does work on Acid3. :^)
2022-03-29 02:14:20 +02:00
Karol Kosek b006a60366 LibTextCodec: Pass code points instead of bytes on UTF-8 string process
Previously we were passing raw UTF-8 bytes as code points, which caused
CSS content properties to display incorrect characters.

This makes bullet separators in Wikipedia templates display correctly.
2022-03-29 01:01:32 +02:00
Simon Wanner 7e4793df63 LibWeb: Size table cells using a combination of min- and max-widths
This gets us a bit closer to the recommended algorithms in CSS 2.2 and
CSS Table Module 3.

A couple of table heavy websites (e.g. news.ycombinator.com,
html5test.com, etc.) now look quite okay. :^)
2022-03-29 00:39:57 +02:00
Simon Wanner bc4974648c LibWeb: Add HTMLTableCellElement::rowSpan 2022-03-29 00:39:57 +02:00
Simon Wanner b7b647e9cd LibWeb: Add HTMLTableCellElement::colSpan 2022-03-29 00:39:57 +02:00
Simon Wanner b92cc3670b LibWeb: Only size width: auto table-cells by min-content 2022-03-29 00:39:57 +02:00
Ali Mohammad Pur 5a0123fd2f LibWeb: Load X(HT)ML documents and transform them into HTML DOM 2022-03-28 23:11:48 +02:00
Ali Mohammad Pur c1649e3372 LibWeb: Define HTML::perform_a_microtask_checkpoint()
This was declared and not defined.
2022-03-28 23:11:48 +02:00
Ali Mohammad Pur 67357fe984 LibXML: Add a fairly basic XML parser
Currently this can parse XML and resolve external resources/references,
and read a DTD (but not apply or verify its rules).
That's good enough for _most_ XHTML documents as the HTML 5 spec
enforces its own rules about document well-formedness, and does not make
use of XML DTDs (aside from a list of predefined entities).

An accompanying `xml` utility is provided that can read and dump XML
documents, and can also run the XML conformance test suite.
2022-03-28 23:11:48 +02:00
Hendiadyoin1 50b6e74d33 LibIPC: Add IPCErrorOr Type alias 2022-03-28 23:08:08 +02:00
Sam Atkins 6672c19c93 LibWeb: Parse @font-face rules
This is very limited for now, only caring about `font-family` and `src`.
2022-03-28 22:25:25 +02:00
Sam Atkins 804b8c85e8 LibWeb: Implement initial CSSFontFaceRule and FontFace classes
For now, this is the bare minimum that's needed: font-family and src.
2022-03-28 22:25:25 +02:00
Sam Atkins 1dcde57922 LibWeb: Bring "parse a list of declarations" closer to spec
The work to create a PropertyOwningCSSStyleDeclaration is now moved to
convert_to_style_declaration() instead.
2022-03-28 22:25:25 +02:00
Sam Atkins da1a819858 LibWeb: Rename parse_css_declaration() -> parse_css_style_attribute() 2022-03-28 22:25:25 +02:00
Ali Mohammad Pur bcbe258619 LibCore: Set the correct invariant length for consecutive short options
When completing `ls -l` to add another short option, the invariant
length should be zero as we are not replacing anything with our
suggestion.
Also skip the initial dash if there already is one.
Fixes #13301.
2022-03-28 20:02:49 +02:00
Karol Kosek d665492e35 Spreadsheet: Don't remove on_change tab function after loading a file
Forgot to remove that in c0c9825f67, as
this function was no longer declared and used... Until the previous
commit.

This meant that pressing the F2 key after opening a file no longer
matched the current tab.
2022-03-28 22:28:40 +04:30
Karol Kosek 07b369b7d9 Spreadsheet: Create rename action using the GUI::CommonActions helper
Besides from reusing more parts from the code, this allows us to call
the action using the F2 key. That is also the reason why we have
to reassign `m_tab_context_menu_sheet_view` on tab change.
2022-03-28 22:28:40 +04:30
Karol Kosek 3b352e46d6 Spreadsheet: Reuse save and rename actions
These parts of code were identical to their action counterparts.
2022-03-28 22:28:40 +04:30
Daniel Bertalan b23edd418c LibC: Fix inttypes.h macros for x86-64 and extend them
On x86-64, `int64_t` is defined to be `long` (not `long long`) , so for
printing, the "l" format specifier has to be used instead of i686's
"ll".

A couple of these macros weren't updated when the x86-64 target was
added, so using them produced warnings like this:

> warning: format specifies type 'long long' but the argument has type
> 'int64_t' (aka 'long') [-Wformat]
>
>       "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
>       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

This commit changes the macros to be correct for both architectures, and
reorders them to be consistent and adds a couple missing ones for the
sake of completeness.
2022-03-28 22:24:05 +04:30
Tim Schumacher 4917a610ab LibC: Partially implement __fpending 2022-03-28 10:38:02 -07:00
Simon Wanner 304dbb0242 LibWeb: Set a cell's content width based on the column(s) it's in 2022-03-28 15:25:25 +02:00
Simon Wanner 6dbd00970d LibWeb: Calculate a cell's width using min-content 2022-03-28 15:25:25 +02:00
Simon Wanner e5a779aecf LibWeb: Apply the layout_mode argument in BFC::compute_width 2022-03-28 15:25:25 +02:00
Simon Wanner 9b3229da17 LibWeb: Distribute the width of a table cell spanning multiple columns 2022-03-28 15:25:25 +02:00
Simon Wanner 4fe154bd6a LibWeb: Expand the last cell in a row to the right edge 2022-03-28 15:25:25 +02:00
Simon Wanner 5f265eebf5 LibWeb: Apply a table row's height to all cells 2022-03-28 15:25:25 +02:00
Luke Wilde bd809b7787 LibJS: Add more delete operator tests 2022-03-28 14:05:33 +02:00
Luke Wilde 7cc53b7ef1 LibJS/Bytecode: Implement the delete unary expression
`delete` has to operate directly on Reference Records, so this
introduces a new set of operations called DeleteByValue, DeleteVariable
and DeleteById. They operate similarly to their Get counterparts,
except they end in creating a (temporary) Reference and calling delete_
on it.
2022-03-28 14:05:33 +02:00
Luke Wilde 589c3771e9 LibJS: Only store MemberExpression object when loading a computed prop
When calling emit_load_from_reference with a MemberExpression, it is
only necessary to store the result of evaluating MemberExpression's
object when performing computed property lookup.

This allows us to skip unnecessary stores for identifier lookup.
For example, this would generate 3 unnecessary stores:
```
> Temporal.PlainDateTime.prototype.add
JS::Bytecode::Executable (REPL)
1:
[   0] GetVariable 0 (Temporal)
[  28] Store $2
[  30] GetById 1 (PlainDateTime)
[  40] Store $3
[  48] GetById 2 (prototype)
[  58] Store $4
[  60] GetById 3 (add)
```

With this, it generates:
```
> Temporal.PlainDateTime.prototype.add
JS::Bytecode::Executable (REPL)
1:
[   0] GetVariable 0 (Temporal)
[  28] GetById 1 (PlainDateTime)
[  38] GetById 2 (prototype)
[  48] GetById 3 (add)
```
2022-03-28 14:05:33 +02:00
Luke Wilde 88901182b8 LibJS: Generate update Jump in for/in/of only if block is not terminated
The body of for/in/of can contain an unconditional block terminator
(e.g. return, throw), so we have to check for that before generating
the Jump to the loop update block.
2022-03-28 14:05:33 +02:00
Luke Wilde 741745baab LibJS/Bytecode: Update NewArray stringifier to print a register range
NewArray now only contains two elements maximum in `m_elements` to
indicate the range of registers to create the array from.

However, `m_element_count` still contains how many registers are in the
range and the stringifier was not updated to account for this. Thus, if
the range contained more than 2 registers, it would do a read OOB on
`m_elements`.

This makes it now just print the first and second entries in
`m_elements` in the format of `[<reg>-<reg>]`.
2022-03-28 14:05:33 +02:00
Brian Gianforcaro 83e96569ed LibAudio: Make sure we initialize ResampleHelper member variables
Found by Static Analysis: Sonar Cloud
2022-03-27 16:43:05 -07:00
Brian Gianforcaro ecc0459f76 LibC: Fix potential double free in ttyname_r_for_directory
If we break out of the loop before we attempt to allocate again,
then we double free the memory pointed to by `name_path`.

Found by Static Analysis: Sonar Cloud
2022-03-27 16:43:05 -07:00
Brian Gianforcaro 4674577d80 Everywhere: Rename CommandResult stdout, stderr members to output, error
The names stdout / stderr are bound to conflict with existing
declarations when compiling against other LibC's. The build on OpenBSD
is broken for this reason at the moment.

Lets rename the members to more generic names to resolve the situation.
2022-03-27 16:41:39 -07:00
Andreas Kling 3ac9ea369d LibWeb: Don't choke on ICB with inline children
Let's relax our assumption about what kind of children the ICB has.
This is preparation for loading XHTML documents.
2022-03-27 23:38:27 +02:00
Andreas Kling 4575ab558b LibWeb: Make whitespace collapsing stateless
Previously, the whitespace collapsing code had a parameter telling it
whether the previous text node ended in whitespace. This was not
actually necessary, so let's get rid of it.
2022-03-27 21:56:21 +02:00
Linus Groh 192f4b0258 LibWeb: Ensure lazy WindowObject creation when activating event handler 2022-03-27 20:14:25 +01:00
Andreas Kling f9e8f02451 LibWeb: Don't crash in IFC if very first chunk is collapsible whitespace 2022-03-27 21:06:02 +02:00
Ali Mohammad Pur b732edf61c LibLine: Avoid pointless size_t <-> ssize_t cast
Just a small cleanup.
2022-03-27 21:05:44 +02:00
Ali Mohammad Pur f6afb70b07 LibLine: Handle read events serially
Previously LibLine accepted read callbacks while it was in the process
of reading input, this wasn't an issue as no async code was being
executed up until the Shell autocompletion came along.
Simply defer input processing while processing input to avoid causing
problems.
Fixes #13280.
2022-03-27 21:05:44 +02:00
Ali Mohammad Pur 5e541aaebd Shell: Keep the stdio and rpath pledges for execute_process()
If the command fails, we'd like to still be capable of printing out
diagnostics, so restore stdio and rpath.
Fixes #13281.
2022-03-27 21:05:44 +02:00
Linus Groh 46ad69cd1e LookupServer: Fix confusing copy/paste error in debug message 2022-03-27 18:39:47 +01:00
Jelle Raaijmakers 8a3242cb83 LibGL+LibSoftGPU+LibGfx: Reimplement normal transformation
We now support generating top-left submatrices from a `Gfx::Matrix`
and we move the normal transformation calculation into
`SoftGPU::Device`. No functional changes.
2022-03-27 09:19:43 -07:00
Jelle Raaijmakers 74de8e4224 LibGL: Always normalize vertex attribute data
We were normalizing data read from vertex attribute pointers based on
their usage, but there is nothing written about this behavior in the
spec or in man pages.

When we implement `glVertexAttribPointer` however, the user can
optionally enable normalization per vertex attribute pointer. This
refactors the `VertexAttribPointer` to have a `normalize` field so we
can support that future implementation.
2022-03-27 09:19:43 -07:00
Jelle Raaijmakers bc5e5afc7b LibSoftGPU+LibGfx: Transform and normalize normals before lighting
We were transforming the vertices' normals twice (bug 1) and
normalizing them after lighting (bug 2). In the lighting code, we were
then diverting from the spec to deal with the normal situation, which
is now no longer needed.

This fixes the lighting of Tux in Tux Racer.
2022-03-27 09:19:43 -07:00
Jelle Raaijmakers 23476dac64 LibSoftGPU: Clean up Material initial value style 2022-03-27 09:19:43 -07:00
Jelle Raaijmakers 284a629ab4 LibGL+LibSoftGPU: Implement more of GL_LIGHT_MODEL_COLOR_CONTROL
This gets rid of a place where OpenGL was leaking into LibSoftGPU.
2022-03-27 09:19:43 -07:00
Jelle Raaijmakers 4b6b9f272f LibGL: Use correct GLbyte range in glColor4b
We were only setting half the color intensity that we should have set.
2022-03-27 09:19:43 -07:00
Jelle Raaijmakers ae88c642c6 LibSoftGPU: Test for 1.f equality in determining the scale factor
We are still not doing the right thing here, but using `<=` instead of
`<` at least gets rid of artifacts in Grim Fandango.
2022-03-27 09:19:43 -07:00
Andreas Kling 27c68624b6 LibWeb: Resolve top/bottom inset properties for position:relative
This patch reimplements inset property resolution based on the new
CSS Positioned Layout specification. Nothing should change for
left/right insets, but we gain support for top/bottom. :^)
2022-03-27 18:16:09 +02:00
Andreas Kling fa71401bec LibWeb: Rename ComputedValues::offset() => inset() 2022-03-27 18:16:08 +02:00
Andreas Kling d77dfc6b48 LibWeb: Rename FormattingContext::compute_position() => compute_inset()
This function computes the used inset properties, not the position of a
box per se, so let's call it something more accurate.
2022-03-27 18:16:08 +02:00
Andreas Kling c49c036c84 LibWeb: Stop allowing position:relative to affect layout
Relatively positioned boxes should not affect the *layout* of their
siblings. So instead of applying relative inset as a layout-time
translation on the box, we now perform the adjustment at the paintable
level instead.

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

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

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

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

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

This is going to take a bunch of work to get right.
2022-03-27 03:01:09 +02:00
Andreas Kling 2b2915656d LibGfx: Remove bogus baseline adjustment in Painter's draw_text_line()
This didn't achieve anything other than a slight vertical misalignment
for scalable fonts.
2022-03-27 01:14:56 +01:00
Andreas Kling b0208f38f6 LibWeb: Use Gfx::Font::pixel_size() when we want pixel metrics
This gives us consistent results with both bitmap and scalable fonts.
2022-03-27 01:14:56 +01:00
Andreas Kling 65629d26fe LibGfx: Use Font::pixel_size() instead of glyph_height() when painting
This gives us correct height metrics for both bitmap and scalable fonts.
2022-03-27 01:14:56 +01:00
Andreas Kling ff951c89fe LibGfx: Add Font::pixel_size() and Font::point_size()
We've gotten ourselves into a bit of a mess by mixing pixel and point
sizes in multiple places. Step one towards getting out of this mess
is adding explicit accessors for the unit you're trying to fetch.

The core of the issue comes from bitmap fonts storing integer pixel
sizes and scaled (TTF) fonts storing float point sizes.
2022-03-27 01:14:56 +01:00
Andreas Kling d5bba91a16 LibWeb: Don't round font sizes when looking them up
We previously had a rounding error which sometimes led to asking LibGfx
for fonts with slightly wrong sizes.
2022-03-27 01:14:56 +01:00
Andreas Kling ee883372f6 LibGfx: Make FontDatabase lookups take font (point) sizes as float
This will allow web content to ask for fractional sizes, which becomes
important when converting between px/pt.
2022-03-27 01:14:56 +01:00
circl eeeaf410fb WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held
items using the scroll wheel. In order to implement this, they
previously would have to either add a hard-coded division by 4, or look
up your mouse settings to adjust correctly.

This commit adds an MouseEvent.wheel_raw_delta_x() and
MouseEvent.wheel_raw_delta_y().
2022-03-27 01:11:27 +01:00
Lenny Maiorani 148f8169a4 LibWeb: Use date constants
Make the code DRY (Don't Repeat Yourself) by using the `AK`-provided
month name constants instead of copying them.
2022-03-27 00:45:12 +01:00
Andreas Kling 83a2aa1832 LibWeb: Include negative margins in height:auto computation for BFC root
...but never allow the resulting height to become negative. This solves
an issue seen on Acid3 where elements with negative vertical margins
expanded the size of their height:auto container instead of shrinking
it, which is the correct behavior. This now works :^)
2022-03-26 22:51:10 +01:00
Andreas Kling 0d9c28add9 LibWeb: Don't collapse horizontal margins between floating boxes
CSS 2.2 says "Horizontal margins never collapse."

So instead of collapsing them, we now add them together, which makes
negative margins between floating boxes work beautifully.
2022-03-26 22:12:21 +01:00
Andreas Kling 80f1749196 Browser: Make the main browser window a little bit bigger by default 2022-03-26 20:49:42 +01:00
Andreas Kling 516fbad408 LibWeb: Remove debug spam about not executing empty script elements 2022-03-26 20:35:49 +01:00
Andreas Kling d8be441978 LibWeb: Fix typo in SVGSVGElement::apply_presentational_hints()
Regressed in 7df62c64b7.

Thanks to Dex for spotting this! :^)
2022-03-26 20:10:36 +01:00
Andreas Kling fa99259412 LibWeb: Simplify text chunk iteration a little bit
Instead of TextNode::ChunkIterator having two bool members to remember
things across calls to next(), this patch reorganizes the loop in next()
so that preserved newline/whitespace chunks are emitted right away
instead of in an awkward deferred way.
2022-03-26 20:04:56 +01:00
Andreas Kling dd6a0dd0f7 LibWeb: Remove unused declarations from Layout::TextNode 2022-03-26 20:04:56 +01:00
Andreas Kling aefe1727fc LibWeb: Make text newlines in "pre" mode emit a ForcedBreak item
Instead of emitting a Text item with the "should_force_break" flag set
to true, newlines in newline-preserving text content now timply turn
into ForcedBreak items. This makes the <pre> element work again.
2022-03-26 20:04:56 +01:00
Andreas Kling d32630e17b LibWeb: Don't append collapsible whitespace to start of new line
After performing a required line break, and the next text chunk is
all collapsible whitespace, simply discard the whitespace.
2022-03-26 20:04:56 +01:00
Linus Groh de53eb825a LibWeb: Make HTML{Button,Select,TextArea}Element focusable
From the HTML spec:

    Modulo platform conventions, it is suggested that the following
    elements should be considered as focusable areas and be sequentially
    focusable:

      ...
    - button elements
    - select elements
    - textarea elements
      ...

Also add a spec link to the existing HTMLAnchorElement::is_focusable().

Note that this still doesn't allow triggering keyboard-focused buttons,
checkboxes, or radio buttons - we don't seem to run the expected
activation behavior for any of them.
2022-03-26 19:42:58 +01:00
Linus Groh 80506a161f LibWeb: Make any HTMLInputElement with type != hidden focusable
From the HTML spec:

    Modulo platform conventions, it is suggested that the following
    elements should be considered as focusable areas and be sequentially
    focusable:

      ...
    - input elements whose type attribute are not in the Hidden state
      ...
2022-03-26 19:42:58 +01:00
Linus Groh 4923e4d406 LibWeb: Make HTMLInputElement::TypeAttributeState an enum class 2022-03-26 19:42:58 +01:00
Kenneth Myhra 122778b9ac tee: Port to LibMain and move to SerenityOS code patterns
This patch ports the utility 'tee' to LibMain and converts a larger part
of its code to our SerenityOS patterns.
2022-03-26 18:39:58 +00:00
Simon Danner 90fc28152b Chess: On pgn import avoid losing piece promotion info
Fixes #13268
2022-03-26 18:30:12 +00:00
Simon Danner 1888e60015 Spreadsheet: Update Undo / Redo button state 2022-03-26 18:29:21 +00:00
MacDue 593aa9aff1 Demos/LibGfxScaleDemo: Use BGRA8888 bitmap in canvas
Previously BGRx8888 was used, which produces artifacts with the new
antialiased window frames with border radii, which require alpha
blending whilst painting.
2022-03-26 18:24:11 +00:00
MacDue 3c0e17f29f LibGfx: Support scaling in AntiAliasingPainter::draw_circle()
Previously the painter would crash if scaling was enabled.
2022-03-26 18:24:11 +00:00
Sam Atkins 6edea1d59f LibWeb: Assign limits to CSS properties that cannot be negative
I believe this is all of them, but I may have missed some.

Several properties technically do not allow negative numbers but the
description says to accept these as valid, and then clamp them
afterwards to the desired range. As such, we don't reject them during
parsing.
2022-03-26 18:15:08 +01:00
Ali Mohammad Pur f12d81ddf5 Shell: Limit the access of processes spawned for autocompletion
This commit limits the autocomplete processes to effectively have
readonly access to the fs, and only enough pledges to get the dynamic
loader working.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur da12acfa78 LibCore: Allow marking options as 'hidden' in ArgsParser
This removes them from the main invocation example in --help, as well as
hides them from autocomplete results (we were previously special-casing
"help" and "version").
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur ef5523231c Shell+LibCore: Provide argument help strings as display trivia 2022-03-26 21:34:56 +04:30
Ali Mohammad Pur d995be428a LibLine: Add a display trivia field to suggestions
These strings will be shown next to the completions as an optional hint
or description.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur 9453e0e6d2 Shell: Add an ArgsParser-based argument parser builtin
Afterall, why _shouldn't_ Shell functions have nice interfaces?
also helps with autocompletion :^)
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur 7e4cc187d9 Shell: Implement program-aware autocompletion
A program can either respond to `--complete -- some args to complete`
directly, or add a `_complete_<program name>` invokable (i.e. shell
function, or just a plain binary in PATH) that completes the given
command and lists the completions on stdout.
Should such a completion fail or yield no results, we'll fall back to
the previous completion algorithm.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur fc4d36ccd0 LibCore: Make ArgsParser perform some completion if passed --complete
This makes it possible to autocomplete flags and options via the Shell.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur e6bd1f8807 Shell: Add the 'join' and 'filter_glob' immediate functions
'split' was missing its other half, and to avoid globbing the
filesystem, let's keep the globbing to shell-internal state.
2022-03-26 21:34:56 +04:30
Ali Mohammad Pur 4a331c73f8 ls: Remove leading dashes from ArgsParser argument name
Otherwise the full argument would be "----ignore-backups", which is most
certainly not correct :^)
2022-03-26 21:34:56 +04:30
Andreas Kling fda25f9505 LibWeb: Move HTML dimension value parsing from CSS to HTML namespace
These are part of HTML, not CSS, so let's not confuse things.
2022-03-26 17:31:01 +01:00
Andreas Kling 434970f022 LibWeb: Remove the totally ad-hoc parse_html_length()
All clients of this API have been migrated to HTML dimension value
parsing instead.
2022-03-26 17:31:01 +01:00
Andreas Kling 7df62c64b7 LibWeb: Treat width/height on <svg> element as HTML dimension values
This might not be entirely correct, but neither was using the completely
ad-hoc parse_html_length(), and this is the last user of that API so
let's move off of it.
2022-03-26 17:31:01 +01:00
Andreas Kling e96b3315ad LibWeb: Treat width/height on td/th elements as non-zero dimension value 2022-03-26 17:31:01 +01:00
Andreas Kling 71e89fe134 LibWeb: Treat width/height on table elements as non-zero dimension value 2022-03-26 17:31:01 +01:00
Andreas Kling 28c929e85c LibWeb: Add parser for the HTML "non-zero dimensions value" microsyntax 2022-03-26 17:31:01 +01:00
Andreas Kling fe908e7db2 LibWeb: Rename "offset" in box model metrics to "inset"
The CSS Positioned Layout spec refers to the top/left/bottom/right
properties as "inset" properties, so let's use the same terminology.
2022-03-26 17:31:01 +01:00
Andreas Kling 54c3053bc3 LibWeb: Preserve paint state when painting stacking contexts indirectly
For layers that require indirect painting (due to opacity, transform,
etc.) we create a nested PaintContext. Until now, that PaintContext
was created fresh without transferring all the state from the parent
PaintContext.
2022-03-26 17:31:01 +01:00
Andreas Kling 2a8c6361aa LibWeb: Support navigator.javaEnabled() (always false)
This removes exception spam about javaEnabled() on apple.com.
2022-03-26 17:31:01 +01:00
Andreas Kling 0e806f58fe LibWeb: Support the hspace and vspace attributes on img elements
These map HTML dimension values to CSS margin values.
2022-03-26 17:31:01 +01:00
Andreas Kling c92d28b4ea LibWeb: Treat img width/height attributes as HTML dimension values 2022-03-26 17:31:01 +01:00
Andreas Kling 075bdfdef8 LibWeb: Add a parser for the HTML "dimension value" microsyntax 2022-03-26 17:31:01 +01:00
Andreas Kling 2e6f5fddef LibWeb: Transfer flex item box model metrics to paintable
Until now, flex items has 0/0/0 margin/border/padding values.
2022-03-26 17:31:01 +01:00
Karol Kosek 44bfca369a LibWeb: Resolve style values from the element inline style
This will set the background color in the project header on GitHub! :^)
2022-03-26 17:30:49 +01:00
Karol Kosek 0934573deb LibWeb: Set CSS custom properties from the element inline style 2022-03-26 17:30:49 +01:00
sin-ack aaa954f900 LibWeb: Bring handling of anchor elements closer to spec
This commit moves the regular handling of links to the anchor elements'
activation behavior, and implements a few auxiliary algorithms as
defined by the HTML specification.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Some caveats are:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The new invariant is "all in-flow children must be either inline or
block". Out-of-flow children like floating and absolutely positioned
boxes are ignored when deciding when to generate anonymous boxes.
2022-03-22 19:26:51 +01:00
Andreas Kling 74927fd218 LibWeb: Move Layout::Box::is_out_of_flow() to Layout::Node
I want to use this function in inline layout, where we're not just
dealing with boxes.
2022-03-22 19:26:51 +01:00
Linus Groh cd6896d343 LibWeb: Convert URL to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 2219eef250 LibWeb: Convert Text to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 46bb547dd6 LibWeb: Convert ShadowRoot to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh a68d31debd LibWeb: Convert ParentNode to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 8d20fb1e94 LibWeb: Convert NodeOperations to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 3861396fe4 LibWeb: Convert Node to use TRY for error propagation 2022-03-22 18:05:25 +00:00