Commit graph

10115 commits

Author SHA1 Message Date
Andreas Kling
b0eca4023f LibCrypto: Put some debug spam behind CRYPTO_DEBUG 2020-05-26 23:46:17 +02:00
Andreas Kling
4ec8b9f6ee LibWeb: Use FlyString in FontCache keys 2020-05-26 23:45:48 +02:00
Andreas Kling
82444048de LibWeb: Add cached global attribute name FlyStrings
Instead of creating extremely common FlyStrings like "id" and "class"
on demand every time they are needed, we now have AttributeNames.h,
which provides Web::HTML::AttributeNames::{id,class_}

This avoids a bunch of string allocations during selector matching.
2020-05-26 23:45:43 +02:00
Andreas Kling
5069d380a8 LibWeb: Let Element cache its list of classes
Instead of string splitting every time you call Element::has_class(),
we now split the "class" attribute value when it changes, and cache
the individual classes as FlyStrings in Element::m_classes.

This makes has_class() significantly faster and moves the pain point
of selector matching somewhere else.
2020-05-26 23:07:19 +02:00
Andreas Kling
16accb71a3 AK: Mark some popular String member functions ALWAYS_INLINE
I don't wanna see String::length() in a profile, jeez. :^)
2020-05-26 22:49:06 +02:00
Andreas Kling
7ed80ae96c LibWeb: Make the CSS parser a little more tolerant to invalid CSS
Sometimes people put a '}' where it doesn't belong, or various other
things go wrong. 99% of the time, it's our fault, but either way,
this patch makes us not crash or infinite-loop in some common cases.

The real solution here is to write a proper CSS lexer-parser according
to the language spec, this is just a hack fix to make more sites load
at all.
2020-05-26 22:31:22 +02:00
Linus Groh
72c52466e0 LibWeb: Add more HTML entities
®, ß and all the lowercase and uppercase umlaut characters.
2020-05-26 22:23:09 +02:00
Andreas Kling
f01af62313 LibWeb: Basic support for display:inline-block with width:auto
We now implement the somewhat fuzzy shrink-to-fit algorithm when laying
out inline-block elements with both block and inline children.

Shrink-to-fit works by doing two speculative layouts of the entire
subtree inside the current block, to compute two things:

1. Preferred minimum width: If we made a line break at every chance we
   had, how wide would the widest line be?
2. Preferred width: We break only when explicitly told to (e.g "<br>")
   How wide would the widest line be?

We then shrink the width of the inline-block element to an appropriate
value based on the above, taking the available width in the containing
block into consideration (sans all the box model fluff.)

To make the speculative layouts possible, plumb a LayoutMode enum
throughout the layout system since it needs to be respected in various
places.

Note that this is quite hackish and I'm sure there are smarter ways to
do a lot of this. But it does kinda work! :^)
2020-05-26 22:02:27 +02:00
FalseHonesty
4e8bcda4d1 LibWeb: Add HTML copyright escape 2020-05-26 22:02:17 +02:00
Kevin Meyer
b85ab86c84 LibWeb: Fix step within reconstruct the active elements
In step 4 of the "renstruct the active formatting elements" algorithm it
says:
  Rewind: If there are no entries before entry in the list of active
  formatting elements, then jump to the step labeled create.

Prior to this patch, the implementation accorded to the spec only for
the first loop iteration.
2020-05-26 21:52:46 +02:00
AnotherTest
8b3eb4535d LibLine: Use LibC's getline() when the terminal claims no support for escape sequences
We just look at $TERM and refuse to emit any escape sequences if it
doesn't start with "xterm".
This could be made much better, at detecting, and at not caling
getline().
2020-05-26 21:09:59 +02:00
FalseHonesty
e4760e5b42 Browser: Add option in DownloadWidget to open download's in folder
When a download has completed, instead of graying out the cancel
option, replace it with an option to open your download in the file
manager.
2020-05-26 21:09:45 +02:00
Andreas Kling
4a9deddb4a LibWeb: The line-height should not be multiplied by the glyph height
This was causing very tall lines on many websites. We can now see the
section header thingy on google.com (although it's broken into lines
where it should not be..) :^)
2020-05-26 21:09:32 +02:00
Angel
199a6b40b3 LibJS: Add Array.prototype.fill 2020-05-26 20:34:44 +02:00
Emanuele Torre
d1bc1f5783
LibJS: Fix style inconsistencies in AST.h (#2403)
Our current configuration clang-format allows both of these styles:
------------------
    class A : B
        , C {
-----------------
    class A
        : B
        , C {
------------------

I was not able to find a setting of clang-format to only allow the
latter style (or disallow the first style), but let's at least be
consistent with the style within a file.
2020-05-26 19:52:03 +02:00
Paul Redmond
11405c5139
LibJS: Fix incorrect token column values (#2401)
- initializing m_line_column to 1 in the lexer results in incorrect
  column values in tokens on the first line of input.
- not incrementing m_line_column when EOF is reached results in
  an incorrect column value on the last token.
2020-05-26 19:00:30 +02:00
Andreas Kling
7bb69bb9bf LibWeb: Implement immediate execution in HTMLScriptElement preparation
In some cases, Dr. HTML says we should execute the script right away
even if other scripts are running.
2020-05-26 15:55:18 +02:00
Andreas Kling
ecd25ce6c7 LibWeb: Allow HTML tokenizer to emit more than one token
Tokens are now put on a queue when emitted, and we always pop from that
queue when returning from next_token().
2020-05-26 15:50:05 +02:00
Linus Groh
0f2b3cd280 Browser: Show a "source location hint" for syntax errors :^) 2020-05-26 14:36:30 +02:00
Linus Groh
015d65bc6f js: Show a "source location hint" for syntax errors :^) 2020-05-26 14:36:30 +02:00
Linus Groh
2d47b30256 LibJS: Add Error::source_location_hint()
This util function on the Error struct will take the source and then
returns a string like this based on line and column information it has:

foo bar
    ^

Which can be shown in the repl for syntax errors :^)
2020-05-26 14:36:30 +02:00
Linus Groh
bc307f6b1c LibJS: Only log exception throw information on Serenity
This is a bit annoying when running the js REPL as part of the Lagom
build, as it prints the error twice to the same terminal - once from
dbg() and then from printf().

Long term this should probably be removed completely and each program
take care itself of printing stacktraces to an appropriate location.
2020-05-26 14:36:30 +02:00
Sergey Bugaev
602c3fdb3a AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath.

This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
f746bbda17 Base: Document the sigaction promise
Also add a few generic words about pledge().
2020-05-26 14:35:10 +02:00
Sergey Bugaev
4139838a93 Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
cddaeb43d3 Kernel: Introduce "sigaction" pledge
You now have to pledge "sigaction" to change signal handlers/dispositions. This
is to prevent malicious code from messing with assertions (and segmentation
faults), which are normally expected to instantly terminate the process but can
do other things if you change signal disposition for them.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
839ae82d66 LibC: Ensure abort() doesn't return
It's not enough to send ourselves a SIGABRT, as it may be ignored or handled
differently. We really, really want abort() to never return, as that will mess
up the assumptions of the calling code big time. So, if raise(SIGABRT) returns,
kill ourselves with SIGKILL, and if that somehow returns too, call _exit().

An alternative approach, which glibc apparently follows, is to reset SIGABRT
disposition to its default value and then send SIGABRT to yourself a second
time. That would also work, but I believe SIGKILL + _exit() to be a simpler
approach that is less likely to break in extremely weird situations.

Note that this only guarantees that abort() never returns, not that the process
actually gets killed. It's still possible to install a SIGABRT handler that
simply never returns (such as by longjmp'ing out, endlessly looping, or exec'ing
another image). That is a legitimate use case we want to support; at the same
time most software doesn't use that functionality and would benefit from hard
guarantees that abort() terminates the program. The following commit is going to
introduce means for ensuring SIGABRT handler is never reset to something
unexpected.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
ac4a31e057 LibC: Mark _exit() as noreturn
We already do this for exit().
2020-05-26 14:35:10 +02:00
Sergey Bugaev
83c809df5f LibC: Remove endless loop after abort() call
We (rightfully) mark abort() noreturn, so the loop just gets compiled out.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
62283ade91 Userland: Port sleep(1) to Core::ArgsParser 2020-05-26 14:35:10 +02:00
Brian Gianforcaro
27360f1f20 Build: Fix cmake test runner, so it knows when tests fail
The CMake runner looks at the return code if you don't set
the pattern. Since the AK test suite setup doesn't use return
codes, we were missing test failures.
2020-05-26 13:38:20 +02:00
Brian Gianforcaro
71deafe476 AK: Temporarily disable failing relative_paths tests in FileSystemPath suite
It appears this got broken in a3e4dfdf98.
I filed a tracking bug https://github.com/SerenityOS/serenity/issues/2388
2020-05-26 13:38:20 +02:00
Brian Gianforcaro
e5045b62b8 AK: Expand string tests to include ends_with case insensitivity 2020-05-26 13:17:19 +02:00
Brian Gianforcaro
129462cca7 AK: Unify FlyString/StringView::ends_with implementation on StringUtils::ends_with
This creates a unified implementation of ends_with with case sensitivity
across String/StringView/FlyString.
2020-05-26 13:17:19 +02:00
Brian Gianforcaro
332f96e7ca AK: Add case insensitive String::ends_with support
FileSystemPath::has_extension was jumping through hoops and allocating
memory to do a case insensitive comparison needlessly. Extend the
existing String::ends_with method to allow the caller to specify the
case sensitivity required.
2020-05-26 13:17:19 +02:00
Brian Gianforcaro
8e4b858b3f AK: Move String::ends_with implementation to StringUtils
Centralizing so it can be used by other string implementations
2020-05-26 13:17:19 +02:00
Brian Gianforcaro
d98e743568 Meta: Add github link to the man pages from ReadMe.md
Closes #2039
2020-05-26 13:14:37 +02:00
Luke
f9f7cb4583 LibJS: Add Array.prototype.splice
Adds splice to Array.prototype according to the specification:
https://tc39.es/ecma262/#sec-array.prototype.splice
2020-05-26 12:47:11 +02:00
Angel
6137475c39 Kernel: fix assertion on readlink() syscall
The is_error() check on the KResultOr returned when reading the link
target had a stray ! operator which causes link resolution to crash the
kernel with an assertion error.
2020-05-26 12:45:01 +02:00
Andreas Kling
8ff4ebb589 LibWeb: Add Element.getAttribute() and Element.setAttribute() :^) 2020-05-26 12:27:10 +02:00
Andreas Kling
b5788594f9 PixelPaint: Let Layer track whether it's selected or not
This will simplify a lot of code that keeps getting more confusing.
2020-05-26 10:18:03 +02:00
Andreas Kling
18d68c8c94 PixelPaint: Add selection functionality to the LayerListWidget
Now we can get rid of the old table view and with it the LayerModel.
2020-05-26 10:18:03 +02:00
Andreas Kling
e4b11a23b7 PixelPaint: Allow reordering layer by dragging them in LayerListWidget
This is rather cool! :^)
2020-05-26 10:18:03 +02:00
Andreas Kling
dc3de47b03 PixelPaint: Have layers and images send out notifications on changes
We use this to automatically update the thumbnail in LayerListWidget
when you draw into a layer. We also use it to repaint the ImageEditor
when the image changes somehow. :^)
2020-05-26 10:18:03 +02:00
Andreas Kling
de85cd0907 PixelPaint: Start working on a custom layer list widget
Instead of using a TableView to show the layer stack, let's build a new
custom widget for this purpose and give it some neat features!

This patch also introduces an ImageClient interface for Image to notify
interested parties about things happening. The LayerListWidget is the
first ImageClient and listens for "layer added" and "layer removed"
notifications. :^)
2020-05-26 10:18:03 +02:00
FalseHonesty
d2b493b74e Browser: Add output styles to JS source printed in the console
This patch uses the new JS::MarkupGenerator to stylize all of the
source code and runtime values printed in the console's output panel.
This also does away with the Console's global style sheet, as all
styling is handled by the MarkupGenerator and the System Palette.
2020-05-26 10:17:50 +02:00
FalseHonesty
941b028ca3 LibJS: Create JS to HTML markup generator
The new JS::MarkupGenerator class can convert both a JS source string
and a JS Runtime Value into properly formatted HTML using the new
LibWeb System Palette css color values.

It makes more sense for this JS -> HTML process to occur in LibJS
so that it can be used elsewhere, namely Markdown code block syntax
highlighting. It also means the Browser can worry less about LibJS
implementation details.
2020-05-26 10:17:50 +02:00
FalseHonesty
b352a6b59d LibWeb: Implement vendor specific CSS color style for System Palette
Add "-libweb-palette-foo-bar" CSS color properties to allow CSS to
style itself using the currently selected System Theme.
2020-05-26 10:17:50 +02:00
Brian Gianforcaro
6a74af8063 Kernel: Plumb KResult through FileDescription::read_entire_file() implementation.
Allow file system implementation to return meaningful error codes to
callers of the FileDescription::read_entire_file(). This allows both
Process::sys$readlink() and Process::sys$module_load() to return more
detailed errors to the user.
2020-05-26 10:15:40 +02:00
Brian Gianforcaro
c459e4ecb2 Kernel: Clang format file system in prep for changes. 2020-05-26 10:15:40 +02:00