Commit graph

15398 commits

Author SHA1 Message Date
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