Commit graph

15490 commits

Author SHA1 Message Date
Sam Atkins 75db8b1f86 LibWeb: Spec-comment consume_a_function() 2022-03-30 18:43:07 +02:00
Sam Atkins 512d1df1c4 LibWeb: Spec-comment consume_a_simple_block() 2022-03-30 18:43:07 +02:00
Sam Atkins 5a23965e93 LibWeb: Comment discrepancy from spec in consume_a_declaration()
We're calling this in a way that is incorrect, and so the algorithm's
assumption that the next token is an `<ident-token>` is wrong, and we
have to handle that failing. Ideally we would just stop calling this
incorrectly, but until then, let's actually document what is happening.
2022-03-30 18:43:07 +02:00
Sam Atkins 999cc51512 LibWeb: Spec-comment consume_a_component_value() 2022-03-30 18:43:07 +02:00
Sam Atkins be86d19529 LIbWeb: Spec-comment consume_a_list_of_declarations() 2022-03-30 18:43:07 +02:00
Sam Atkins e72f42bea1 LibWeb: Spec-comment consume_a_qualified_rule() 2022-03-30 18:43:07 +02:00
Sam Atkins fe86718035 LibWeb: Spec-comment consume_an_at_rule() 2022-03-30 18:43:07 +02:00
Sam Atkins d77de5ccec LibWeb: Spec-comment consume_a_list_of_rules() 2022-03-30 18:43:07 +02:00
Sam Atkins a4f8056828 LibWeb: Spec-comment parse_a_comma_separated_list_of_component_values
The code had to change a bit to match. Previously, we appended an empty
sub-list immediately, but now we append it at the end. The difference
is that if there are no tokens, we now correctly return an empty
list-of-lists, instead of a list containing an empty list.
2022-03-30 18:43:07 +02:00
Sam Atkins 6ec92f5527 LibWeb: Spec-comment parse_a_list_of_component_values() 2022-03-30 18:43:07 +02:00
Sam Atkins 34b3c09462 LibWeb: Spec-comment parse_a_component_value() 2022-03-30 18:43:07 +02:00
Sam Atkins bcf4254331 LibWeb: Spec-comment parse_a_list_of_declarations()
The `parse_as_list_of_declarations()` public method is unused and will
not be used by any user code so has been removed.
2022-03-30 18:43:07 +02:00
Sam Atkins 2aac9f9258 LibWeb: Bring parse_a_declaration() to spec and add comments
User code now calls `parse_as_supports_condition()` which actually does
the conversion to a StyleProperty.
2022-03-30 18:43:07 +02:00
Sam Atkins 239c36a19e LibWeb: Spec-comment parse_a_rule()
We now correctly call convert_to_rule() outside of this function.

As before, I've renamed `parse_as_rule()` -> `parse_as_css_rule()` to
match the free function that calls it.
2022-03-30 18:43:07 +02:00
Sam Atkins 12a787ef8a LibWeb: Use parse_a_list_of_rules() for @media and @supports
From the spec:
> "Parse a list of rules" is intended for the content of at-rules such
> as @media. It differs from "Parse a stylesheet" in the handling of
> <CDO-token> and <CDC-token>.
- https://www.w3.org/TR/css-syntax-3/#ref-for-parse-a-list-of-rules
2022-03-30 18:43:07 +02:00
Sam Atkins 7a225a380c LibWeb: Bring parse_a_list_of_rules() to spec
This is not actually used by anything currently, but it should be used
for `@media` and other at-rules.

Removed the public parse_as_list_of_rules() because public functions
should be things that outside classes actually need to use.
2022-03-30 18:43:07 +02:00
Sam Atkins 85d8c652e9 LibWeb: Implement and use "parse a CSS stylesheet" algorithm
`parse_a_stylesheet()` should not do any conversion on its rules. This
change corrects that. There are other places where we get this wrong,
but one thing at a time. :^)
2022-03-30 18:43:07 +02:00
Sam Atkins fc3d51c59e LibWeb: Use an enum class for the "top-level flag" 2022-03-30 18:43:07 +02:00
Sam Atkins 87b125dcb9 LibWeb: Spec-comment parse_a_stylesheet()
Also introduce a `location` parameter when parsing a CSSStyleSheet. This
is not provided by anyone yet.
2022-03-30 18:43:07 +02:00
Sam Atkins 05bd0ca3ee LibWeb: Rename parse_css() -> parse_css_stylesheet() 2022-03-30 18:43:07 +02:00
Elisée Maurer 34db0dab41 LibWeb: Implement Element.toggleAttribute() 2022-03-30 18:30:29 +02:00
Itamar 1ec3847acd HackStudio: Hide FindWidget on escape key press 2022-03-30 11:26:26 -04:00
Timothy Flynn 4fd463dae0 LibJS: Normalize mathematical references to negative zero
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/d4be24e
2022-03-30 14:24:32 +01:00
Timothy Flynn 41df4c6353 LibJS: Modernize InitializeDateTimeFormat and simplify error handling
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/4cf1d2c
2022-03-30 14:24:32 +01:00
Timothy Flynn 066352c9aa LibJS+LibUnicode: Align ECMA-402 "sanctioned" terminology with UTS 35
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/087995c
https://github.com/tc39/ecma402/commit/233d29c

This also adds a missing spec link for the sanctioned units and fixes a
broken spec link for IsSanctionedSingleUnitIdentifier. In LibUnicode,
the NumberFormat generator is updated to use the constexpr helper to
retrieve sanctioned units.
2022-03-30 14:24:32 +01:00
Timothy Flynn 1a76839e8d LibJS: Use consistent ASCII case-transformation and string language
Also update the incorrect spec link for IsWellFormedCurrencyCode.

These are editorial changes in the Intl spec. See:
https://github.com/tc39/ecma402/commit/6939b44
https://github.com/tc39/ecma402/commit/3a775eb
https://github.com/tc39/ecma402/commit/97a7940
https://github.com/tc39/ecma402/commit/129c790
https://github.com/tc39/ecma402/commit/42ec908
https://github.com/tc39/ecma402/commit/ea25c36
2022-03-30 14:24:32 +01:00
Timothy Flynn 72674d7905 LibJS: Set DateTimeFormat's [[HourCycle]] internal slot only once
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/8081868
2022-03-30 14:24:32 +01:00
Timothy Flynn 0975eba724 LibJS: Mark an invocation to RequireObjectCoercible as fallible
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/6939b44
2022-03-30 14:24:32 +01:00
Timothy Flynn 36bff95f15 LibJS: Use the new TransformCase AO for locale-aware case conversions
This is an editorial change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/6939b44
2022-03-30 14:24:32 +01:00
Timothy Flynn f8e7701cf3 LibJS: Disallow calendar display names which contain an underscore
This is a normative change in the Intl spec. See:
https://github.com/tc39/ecma402/commit/2703d06
2022-03-30 14:24:32 +01:00
Timothy Flynn 7c41e6058a LibJS: Explicitly indicate infallible incovations
These are editorial changes in the Intl spec.

See:
https://github.com/tc39/ecma402/commit/6804096
https://github.com/tc39/ecma402/commit/6361167
https://github.com/tc39/ecma402/commit/8718171
https://github.com/tc39/ecma402/commit/fd37cb4
https://github.com/tc39/ecma402/commit/00fcfb0
https://github.com/tc39/ecma402/commit/913f832
2022-03-30 14:24:32 +01:00
Kenneth Myhra 6581cf47ab test: Port to LibMain 2022-03-30 09:53:11 +01:00
safarp 704e1d13f4 AK: Allow printing wide characters using %ls modifier 2022-03-30 11:30:43 +04:30
Idan Horowitz 8abe653009 LibWeb: Make WebSocket::close() arguments optional to match IDL 2022-03-30 08:56:25 +03:00
Kenneth Myhra c843f2e3a5 seq: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 1ee93e0fe7 tty: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra cf154ec0d9 tt: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra ab9a78a305 tr: Utilize TRY more
This converts the local functions to return ErrorOr<T> and utilizes TRY
more.
2022-03-29 21:28:29 -07:00
Kenneth Myhra e548b2cff2 tr: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 8bd7c5b3d5 test_env: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 3df8c9e9de test-unveil: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 0015040ebd LibCore: Add syscall wrapper for access() 2022-03-29 21:28:29 -07:00
Kenneth Myhra f4aef35e6e test-pthread: Port to LibMain and let local functions return ErrorOr<T>
This ports 'test-pthread' to LibMain and converts the local functions of
the program to return ErrorOr<T>.
2022-03-29 21:28:29 -07:00
Kenneth Myhra d69f3aa958 test-fuzz: Allow listing fuzzing targets without specifying input file 2022-03-29 21:28:29 -07:00
Kenneth Myhra 4994718d8d test-fuzz: Port to LibMain
Also use StringView in place of raw C strings and String.
2022-03-29 21:28:29 -07:00
Kenneth Myhra b47a9ab4dc test-bindtodevice: Port to LibMain
This ports 'test-bindtodevice' to LibMain and convert the local 'test'
function to return ErrorOr<T>.
2022-03-29 21:28:29 -07:00
Kenneth Myhra e302fac34b kcov-example: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 234025ee53 telws: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra bb4994d67b run-tests: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra 7d87f0d56d markdown-check: Use Core::ArgsParser 2022-03-29 21:28:29 -07:00
Kenneth Myhra de7d333d43 markdown-check: Port to LibMain 2022-03-29 21:28:29 -07:00
Simon Wanner 6437f5da36 LibWeb: Add basic support for the attr() CSS function
CSS Values and Units Module Level 5 defines attr as:
  `attr(<q-name> <attr-type>?, <declaration-value>?)`

This implementation does not contain support for the type argument,
effectively supporting `attr(<q-name>, <declaration-value>?)`
2022-03-30 03:18:14 +02:00
Andreas Kling 6a4247bee9 LibWeb: Use more precise font metrics when doing inline layout
We now position inline-level boxes based on ascent and descent metrics
from the font in use. This makes our basic text layouts look a lot more
like those produced by other browsers. :^)

I've tried to match the terminology used by the CSS Inline Layout spec.

This will regress Acid2 a little bit, and probably various other sites,
but on the whole it's the direction we should be heading, so let's go.
2022-03-30 01:12:44 +02:00
Andreas Kling fae8fde913 LibWeb: Draw inspector overlay label with default font 2022-03-30 00:57:15 +02:00
Andreas Kling 6d260b14b4 LibGfx: Rasterize TTF glyphs using "hhea" metrics instead of "os2"
This matches what other font systems appear to do.
2022-03-30 00:57:15 +02:00
Andreas Kling 9b0d158e69 LibWeb: Only set children-are-not-inline when inserting in-flow child
We were marking block boxes as having non-inline children when inserting
any child box, even if the child was out-of-flow.
2022-03-30 00:57:15 +02:00
Andreas Kling 1c88536298 LibWeb: Use the new Gfx::Painter::draw_text_run() API for drawing text
This avoids a bunch of unnecessary work in Painter which not only took
time, but sometimes also led to alignment issues. draw_text_run() will
draw the text where we tell it, and that's it.
2022-03-30 00:57:15 +02:00
Andreas Kling dd940dfa85 LibWeb: Use font-derived metrics for "line-height:normal"
Instead of multiplying the font-size with 1.4f because reasons, we now
ask the font for its preferred line spacing.
2022-03-30 00:57:15 +02:00
Andreas Kling 56a284713d LibGfx: Add ascent, descent and line gap to FontPixelMetrics
These are the main values we need in LibWeb to perform inline layout.
2022-03-30 00:57:15 +02:00
Andreas Kling 7850628ff1 LibGfx: Add Painter::draw_text_run(), a simplified text painting API
This API does:
    - Take a Utf8View
    - Take the starting point on the baseline as its input coordinate

This API does not:
    - Align the text
    - Wrap the text
    - Elide too-long text into "..."
2022-03-30 00:57:15 +02:00
Andreas Kling e398164f10 LibGfx: Make Font::pixel_metrics() virtual
This makes it easier for BitmapFont and ScaledFont to implement metrics
lookup themselves.
2022-03-30 00:57:15 +02:00
Andreas Kling 344374588b LibGfx: Rename FontMetrics => FontPixelMetrics
Let's make it clear in the type name that this contains pixel metrics.
Also rename Font::metrics() => Font::pixel_metrics().
2022-03-30 00:57:15 +02:00
Andreas Kling 0f6dd8c62b LibGfx: Make Gfx::FontMetrics include the advance of '0' instead of 'M'
CSS actually wants the advance of the ASCII '0' character for its "ch"
units, so let's include that instead of the arbitrarily chosen 'M'.
2022-03-30 00:57:15 +02:00
Andreas Kling 2f7b6af87e LibGfx: Remove code point parameter from Gfx::Font::Metrics
Everyone was asking for the glyph width of 'M' anyway. We can just make
that request implicit and simplify the API.
2022-03-30 00:57:15 +02:00
Andreas Kling b0955fd269 LibWeb: Add fast_is<T>() for some common DOM Node subclasses 2022-03-30 00:52:02 +02:00
Jelle Raaijmakers 02e2f11380 Browser: Make storage inspector columns sortable 2022-03-29 23:51:47 +01:00
Jelle Raaijmakers 62fbf282b1 Browser: Reorder storage inspector columns
Show "domain" and "path" as the first two columns. Since we're showing
all cookies for all domains and all paths, you will probably want to
see the domain and path before the actual cookie name and value.
2022-03-29 23:51:47 +01:00
Linus Groh 68ee193464 LibJS: Check type of ShadowRealm.prototype.importValue() 2nd argument
This is a normative change in the ShadowRealm spec.

See: https://github.com/tc39/proposal-shadowrealm/commit/2b45a15
2022-03-29 23:48:25 +01:00
Linus Groh f1d744e11a LibJS: Fix sign in PlainYearMonth.prototype.subtract()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6cf421b
2022-03-29 23:21:17 +01:00
Linus Groh e4fe60b972 LibJS: Update incorrect spec comment in ToRelativeTemporalObject
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4cb192d
2022-03-29 22:56:03 +01:00
Jelle Raaijmakers cf1baddb67 LibC: Implement getdtablesize() 2022-03-29 22:49:27 +01:00
GeekFiftyFive 8fee285d72 LibHTTP: Append port to Host header if it exists 2022-03-30 00:34:29 +03:00
Andreas Kling 0fd51ae811 LibWeb: Ignore empty anonymous block children in height:auto calculation
This fixes a regression on GitHub from
5da7ebb806.

Thanks to Simon for reporting it! :^)
2022-03-29 22:30:58 +02:00
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