Commit graph

9159 commits

Author SHA1 Message Date
Yonatan Goldschmidt
3df3ab4598 Build: Support building in Docker
Add missing installations to instructions, and use genext2fs instead
of mounting.
2020-05-07 10:23:26 +02:00
Andreas Kling
beaec6bd2d Kernel: Memory purging was incorrectly "purging" the shared zero page
This caused us to report one purged page per occurrence of the shared
zero page in a purgeable memory region, despite it being a no-op.

Thanks to Sergey for spotting the bad assertion removal that led to
this being found!
2020-05-07 09:44:41 +02:00
Andreas Kling
6fe83b0ac4 Kernel: Crash the current process on OOM (instead of panicking kernel)
This patch adds PageFaultResponse::OutOfMemory which informs the fault
handler that we were unable to allocate a necessary physical page and
cannot continue.

In response to this, the kernel will crash the current process. Because
we are OOM, we can't symbolicate the crash like we normally would
(since the ELF symbolication code needs to allocate), so we also
communicate to Process::crash() that we're out of memory.

Now we can survive "allocate 300 MB" (only the allocate process dies.)
This is definitely not perfect and can easily end up killing a random
innocent other process who happened to allocate one page at the wrong
time, but it's a *lot* better than panicking on OOM. :^)
2020-05-06 22:28:23 +02:00
Andreas Kling
c633c1c2ea Kernel: Assert on OOM in Region::commit()
This function has a lot of callers that don't bother checking if it
returns successfully or not. We'll need to handle failure in a bunch
of places and then we can remove this assertion.
2020-05-06 22:28:23 +02:00
Andreas Kling
43593455db Kernel: Don't assert on OOM in allocate_user_physical_page()
We now give callers a chance to react to OOM situations.
2020-05-06 22:28:23 +02:00
Andreas Kling
bf7b77e252 AK: Fix Bitmap not finding unset ranges at the end of the map
When we switched the Bitmap code to operating 32 bits at a time,
we neglected to look in the trailing remainder bits after the last
full 32-bit word.

This patch fixes that and adds a couple of tests for Bitmap that I
hacked up while tracking down this bug.

I found this bug when noticing that the kernel would OOM while there
were still some pages left in the physical page allocator.
2020-05-06 22:28:23 +02:00
FalseHonesty
8182a709e3 Browser: Open links in a new tab when middle clicked 2020-05-06 21:59:29 +02:00
FalseHonesty
0e048f3c4c LibWeb: Add hook when a link is middle clicked 2020-05-06 21:59:29 +02:00
Linus Groh
9dbab2d05e Misc: Replace "String(string_view)" with "string_view.to_string()"
StringView::to_string() was added in 917ccb1 but not actually used
anywhere yet.
2020-05-06 19:28:59 +02:00
Matthew Olsson
107ca2e4ba LibJS: Add function call spreading
Adds support for the following syntax:

    myFunction(...x, ...[1, 2, 3], ...o.foo, ...'abcd')
2020-05-06 19:19:02 +02:00
Emanuel Sprung
8fe821fae2 AK: Add to_string() method to StringView
This allows easy creation of a new string from an existing StringView.
Can be used e.g. for output with printf(..., view.to_string().characters())
instead of writing printf(..., String{view}.characters()).
2020-05-06 19:07:22 +02:00
Emanuel Sprung
c7568943d9 AK: Make tests compilable with the serenity target toolchain 2020-05-06 19:07:22 +02:00
Matthew Olsson
838390171c LibJS: Function.length respects default and rest parameters
"[Function.length is] the number of formal parameters. This number
excludes the rest parameter and only includes parameters before
the first one with a default value." - MDN
2020-05-06 17:40:56 +02:00
Linus Groh
2c14714ee0 Browser: Add dedicated "view source" window
Basically a window containing a read-only GUI::TextEditor containing the
source code of the current webpage. No temporary file needed :^)

Fixes #1103.
2020-05-06 17:14:51 +02:00
Andreas Kling
eabb7b563a Documentation: Add note about /dev/kvm to BuildInstructions.md 2020-05-06 17:12:49 +02:00
Andreas Kling
025cdfdce8 LibJS: Simplify a Value type check in Object::to_string() 2020-05-06 16:40:08 +02:00
AnotherTest
a82419469f LibWeb: Add canvas.fill
This implements only one of the two forms of this function,
ctx.fill(winding_rule).
Also tweaks the quadratic curve demo to have a nice looking filled
shape.
2020-05-06 14:50:29 +02:00
AnotherTest
f54b41f748 LibGfx: Implement filling paths
There are some imperfections with intersecting edges (because the main
algorithm used is scanline, and that is not geared towards drawing
complex shapes), however, it behaves mostly fine for normal use :^)
2020-05-06 14:50:29 +02:00
Linus Groh
4d20cf57db LibJS: Implement tagged template literals (foobar)
To make processing tagged template literals easier, template literals
will now add one empty StringLiteral before and after each template
expression *if* there's no other string - e.g.:

`${foo}` -> "", foo, ""
`test${foo}${bar}test` -> "test", foo, "", bar, "test"

This also matches the behaviour of many other parsers.
2020-05-06 14:49:53 +02:00
Linus Groh
eea62dd365 LibJS: Add Value::{is, as}_function() 2020-05-06 14:49:53 +02:00
Matthew Olsson
419bce6915 LibJS: Fix syntax error for arrow function non-decl variable assignment
A regression was introduced in dc9b4da where the parser would
incorrectly parse the assignment of arrow functions to (non-declaration)
variables. For example, consider:

    a = () => {}

Because the parser was aware of default parameters, in
try_parse_arrow_function, the equals sign would be interpreted as a
default argument, leading to incorrect parsing of the overall
expression. Also resulted in some funny behavior
(a = () => {} => {} worked just fine!).

The simple fix is to only look for default parameters if the arrow
function is required to have parenthesis.
2020-05-06 12:21:29 +02:00
modmuss50
3142c4a4fd Browser: Add "Copy link" context menu item 2020-05-06 12:14:54 +02:00
Yonatan Goldschmidt
83eb31bb2e Taskbar: Remove checkable property from taskbar buttons
If a button is checkable, its "checked" state is inversed in
Button::click. It's not needed for taskbar buttons - their checked
state is updated in TaskbarWindow::wm_event, based on the
current state of their window.

Fixes: #1878.
2020-05-06 12:14:07 +02:00
Andreas Kling
d6ab9e6790 Browser: Add a basic GUI download feature
We now allow you to download files by right-clicking a link and then
choosing "Download".

All files are currently saved to the standard downloads location that
we get from Core::StandardPaths::downloads_directory().

In the future, we'll probably want to come up with a more restrictive
way of doing the "write to disk" portion of this.
We should also improve the ProtocolServer to allow streaming of data
instead of writing everything in one big go.

At the moment, I'm just pretty happy with this GUI. :^)
2020-05-05 23:58:22 +02:00
Andreas Kling
b778e99c61 LibWeb: Expose the ProtocolClient inside ResourceLoader as an API
This allows others to reuse the existing connection to ProtocolServer
instead of creating a separate one.
2020-05-05 23:57:35 +02:00
Andreas Kling
76dd1e3284 LibCore: Add a standard downloads directory (~/Downloads) 2020-05-05 23:56:57 +02:00
Andreas Kling
ae047649db AK: Add URL::basename() 2020-05-05 23:56:35 +02:00
Andreas Kling
68abc103f7 ProtocolServer: Report success after stopping a download 2020-05-05 23:56:20 +02:00
Andreas Kling
588e18721d Browser: Add a simple context menu for hyperlinks
This only has "Open" and "Open in new tab" for now. :^)
2020-05-05 22:42:50 +02:00
Andreas Kling
f32989a3e7 LibWeb: Add hook when context menu is requested by right-clicking link 2020-05-05 22:42:21 +02:00
Andreas Kling
1061127ca7 LibGfx: Add missing FloatRect function implementations
These are just clones of the Rect equivalents.
2020-05-05 18:53:34 +02:00
Andreas Kling
fc5d0a1bd2 LibJS: Switch objects to unique shape after 100 property additions
At that point, it seems unlikely that the shape is gonna be shared with
other objects, and we avoid getting stuck holding a big bag of shapes.
2020-05-05 18:49:45 +02:00
Andreas Kling
e73ad78ba6 LibWeb: Add support for "display: inline-block"
This display type is implemented using a LayoutBlock that is_inline().
Basically it behaves like a block internally, and its children are laid
out in the normal block layout fashion. Externally however, it behaves
like an atomic inline-level box.

Layout of inline-block boxes happens in three stages:

1. The outer dimensions of the block are computed during the recursive
   normal layout pass. We skip positioning, but lay out children.

2. Later on, during line layout in the *containing block*, the inline
   block now contributes a linebox fragment. When linebox fragments are
   positioned, we learn the final position of the inline block. That's
   when we set the inline block's position.

3. We re-layout the inline block's children once again. This is done to
   make sure they end up in the right position. The layout tree doesn't
   use relative offsets, so after we position the inline block in (2),
   its children will not have its positions updated. Relayout moves
   all children of inline blocks to the right place.

This is a rather naive approach but it does get the basic behavior into
place so we can iterate on it. :^)
2020-05-05 16:18:28 +02:00
Linus Groh
0a1ecbec48 LibMarkdown: Escape HTML entities in text 2020-05-05 16:18:11 +02:00
Linus Groh
fc3d16d664 LibMarkdown: Use escape_html_entities() from AK/String 2020-05-05 16:18:11 +02:00
Andreas Kling
b7339745d0 LibGfx: Add a naive "rgba(r,g,b,a)" color parser
It's not very whitespace tolerant but it works.
2020-05-05 15:50:28 +02:00
Andreas Kling
8a40294f42 LibWeb: Turn some HTML entities into nicer text in the parser 2020-05-05 15:50:28 +02:00
Andreas Kling
6676f2c259 LibWeb: Don't emit a simple selector if nothing was consumed 2020-05-05 15:50:28 +02:00
Andreas Kling
493cbb7956 LibWeb: Fall back to LayoutInline for any unrecognized CSS display
Let's at least try to keep going and see what we can render.
2020-05-05 15:50:28 +02:00
Andreas Kling
d677d23da1 LibWeb: Make the URL encoding function a little less copy-happy 2020-05-05 15:50:28 +02:00
DexesTTP
d1a9afa7cd Help: Clicking on link changes the treeview selection
Fixes #1259
2020-05-05 14:27:51 +02:00
Linus Groh
055e955a1c LibWeb: Recognise :focus pseudo-class
It's still only a dummy as LibWeb doesn't have focused elements yet, but
at least now we don't treat "selector:focus" as just "selector".

This fixes an issue on google.com which was mostly grey - coming from
some menu item focus styles :^)
2020-05-05 13:16:33 +02:00
DexesTTP
f3cff4c677 SystemMonitor: Replace details with message when process isn't accessible
In addition to being less surprising, this sets up some groundwork for #1676
2020-05-05 12:49:18 +02:00
Andreas Kling
5c12f3fef0 js: Tighten up ReplConsoleClient::trace() a little bit
Remove a bunch of unnecessary String copying.
2020-05-05 11:49:14 +02:00
Andreas Kling
e4b9cf9b6c AK: Some FlyString improvements
We're now clever enough to notice when we're constructing a FlyString
from a String that is actually already a FlyString. :^)
2020-05-05 11:26:03 +02:00
AnotherTest
2a29e668bd LibTLS: Try to disambiguate errors in case of failure
Not particularly helpful, but better than nothing.
2020-05-05 11:20:42 +02:00
Shadowfacts
fcd922f7b1 LibWeb: Add basic URL encoder for individual values and param lists 2020-05-05 11:19:38 +02:00
Shadowfacts
7f538ea7eb LibWeb: When creating form action URL, only include value for the submit
that was used to submit the form
2020-05-05 11:19:38 +02:00
Shadowfacts
5c46741be8 LibHTTP: Actually include query parameters when serializing raw request 2020-05-05 11:19:38 +02:00
Shadowfacts
4d5dc5950a LibWeb: Improve <form> submit method handling
The spec defines the only valid methods to be get, post, and dialog.
Post and dialog are currently unhandled and do nothing, any other value
(or no value specified) is defined by the spec to use the get method.
2020-05-05 11:19:38 +02:00