Commit graph

9477 commits

Author SHA1 Message Date
Matthew Olsson b5f1df57ed LibJS: Add raw strings to tagged template literals
When calling a function with a tagged template, the first array that is
passed in now contains a "raw" property with the raw, escaped strings.
2020-05-07 23:05:55 +02:00
Nick Tiberi 9d0c6a32bd Browser: Show line numbers when viewing page source 2020-05-07 22:59:40 +02:00
Ben Wiederhake 124cbea347 WindowServer: Fix 'Maximize' Button
When a window is maximized by clicking the 'maximize' button in the window frame,
the WindowFrame *is* invalidated and repainted properly. However, the internal
state of the WindowServer::Button does not get updated until the next mouse
movement. This means that the 'maximize' button is erroneously highlighted until
the mouse moves again. This is very visible.

Ideally, a patch should compute the actual new m_hovered. However, this requires
knowledge of the new rect, or calling something on the Button after the new rect
has been determined. Until someone can figure out a good way around this,
setting m_hovered to false is a solution that 'usually' works.

Note that this does *not* work when after maximizing/restoring, the maximize
button falls exactly under the mouse again. The button functions properly, but
is erroneously not highlighted.

At least a *missing* highlight is less noticable than a highlight too many.
2020-05-07 22:15:16 +02:00
Ben Wiederhake cc67671d95 WindowServer: Don't block child-windows of modal windows
ComboBox creates a regular (non-modal) window; I believe this is fine.
A Dialog (modal window) can contain a ComboBox; I believe this is fine.
A non-modal child window of a modal window (e.g. a ComboBox pop-out within
a Dialog) wasn't clickable, and was blocked in the WindowManager.
I want to change this behavior.

This edge case occurs when trying to select a month in the "Calendar"
Application.
2020-05-07 22:15:16 +02:00
Linus Groh c1a6841cb2 Base: Add "`" to GB keymap 2020-05-07 22:13:46 +02:00
DexesTTP b478c5f86c LibGUI: Properly draw the background of the selected TreeView line
In the TreeView, the background of the selected line (or any background,
really) was only drawn until the frame's width. When the text was larger
than the frame's width, this caused the end of the text to be displayed
without background, making it unreadable if it was white (which is the
default text color for selected lines).

To compute the background width, we have a choice between :
- The inner frame width (the current behaviour which causes the issue)
- The total width of all columns (which causes the background to end
  early if the columns don't cover the full width)

The new algorithm uses the biggest of the above values, which gives us
exactly what we want in all cases :^)

Fixes #2134
2020-05-07 22:13:25 +02:00
Linus Groh 8d01fd9863 HackStudio: Apply INI syntax highlighter when opening a .ini file 2020-05-07 22:04:56 +02:00
Linus Groh 7571e9e460 LibGUI: Rename SyntaxLanguage::{Javascript -> JavaScript} 2020-05-07 22:04:56 +02:00
Linus Groh 520d464865 HackStudio: Rename ProjectType::{Javascript -> JavaScript} 2020-05-07 22:04:56 +02:00
Linus Groh 85b69e54e4 Browser: Escape percent sign in download progress format string
Otherwise the following is printed:

printf_internal: Unimplemented format specifier   (fmt: 0% of %s)
2020-05-07 16:01:03 +02:00
Andreas Kling 444b6c8407 LibCrypto: Cache the "trimmed length" of UnsignedBigIntegers
This avoids repeated traversals of the underlying words and gives a
30% speed-up on "test-crypto -t pk" :^)
2020-05-07 12:23:09 +02:00
Linus Groh 57f68ac5d7 LibX86: Rename build0FSlash() to build_0f_slash()
As spotted by @heavyk this was missed in 57b2b96.
2020-05-07 12:22:36 +02:00
pierre 662e47e140 MouseDemo: A more visual approach for MouseEvents :^) 2020-05-07 12:21:52 +02:00
Emanuele Torre 21712ed0a3 Meta: We don't need to ignore run-tests in lint-shell-scripts.sh 2020-05-07 12:20:41 +02:00
Emanuele Torre 6bbd0a18a1 LibJS: Fix shellcheck warnings in Tests/run-tests 2020-05-07 12:20:41 +02:00
Maciej Sobaczewski 8989300851
Browser: Assume http:// when no protocol is provided in the location bar (#2142) 2020-05-07 11:57:53 +02:00
AnotherTest af1ce6c33d LibTLS: Verify server certificate expiry date 2020-05-07 10:23:58 +02:00
AnotherTest d051fffe25 LibCore: Add a primitive comparison function to DateTime
This should go away when we get the ability to parse strings to
DateTime's.
2020-05-07 10:23:58 +02:00
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