Commit graph

8024 commits

Author SHA1 Message Date
Andreas Kling
2db8716a6f LibJS: Don't return the "last computed value" from Interpreter::run()
Only return whatever a "return" statment told us to return.
The last computed value is now available in Interpreter::last_value()
instead, where the REPL can pick it up.
2020-04-04 23:45:13 +02:00
Andreas Kling
97cd1173fa LibJS: Add String.prototype.indexOf() 2020-04-04 23:44:29 +02:00
Andreas Kling
9e05672f87 LibJS: Math.sqrt.length should be 1 2020-04-04 23:28:38 +02:00
Andreas Kling
a860a3f793 LibJS: Hack the lexer to allow numbers with decimals
This is very hackish and should definitely be improved. :^)
2020-04-04 23:13:48 +02:00
Andreas Kling
3a026a1ede LibJS: Add NumberObject and make to_object() on number values create it 2020-04-04 23:13:13 +02:00
Andreas Kling
d4dfe7e525 LibJS: Add Math.sqrt() 2020-04-04 22:44:48 +02:00
Andreas Kling
d155491122 LibJS: Add basic Array constructor
We only support Array() with 0 or 1 parameters so far.
2020-04-04 22:28:21 +02:00
Andreas Kling
eabdbe0ee9 LibJS: Log when we throw a JavaScript Error
This makes debugging a lot easier since we actually learn that an Error
got thrown.
2020-04-04 22:14:38 +02:00
Andreas Kling
9b0bfcb8b7 LibWeb: Handle javascript: URLs inside LibWeb :^)
This patch makes it possible to execute JavaScript by clicking on an
anchor element with href="javascript:your_script_here()".
2020-04-04 22:12:37 +02:00
Andreas Kling
5e40aa182b LibJS: Support VariableDeclaration with multiple declarators
This patch adds support in the parser and interpreter for this:

    var a = 1, b = 2, c = a + b;

VariableDeclaration is now a sequence of VariableDeclarators. :^)
2020-04-04 21:47:12 +02:00
Andreas Kling
9691286cf0 LibJS: Add Declaration class to the AST
This is just here to make the AST class hierarchy more spec-like.
2020-04-04 21:32:10 +02:00
Andreas Kling
f8393b80e3 LibJS: Add support for do..while statements 2020-04-04 21:29:23 +02:00
Andreas Kling
da0715aba9 LibJS: Rename WhileStatement::predicate() => body()
This name matches other parsers.
2020-04-04 21:22:03 +02:00
Andreas Kling
644ff1bbfd LibJS: Add basic support for modulo (%) in binary expressions 2020-04-04 21:17:34 +02:00
Andreas Kling
9c8363bb5f LibJS: Allow "for" statement without curly braces around body 2020-04-04 21:09:06 +02:00
Andreas Kling
42f47da75d LibWeb: Treat '<' characters as part of the text inside <script>
When we encounter a '<' during HTML parsing, we now look ahead to see
if there is a full </script> coming, otherwise we treat it as text.

This makes it possible to use '<' in inline scripts. :^)
2020-04-04 21:01:58 +02:00
Andreas Kling
fc5067afd2 ProtocolServer+LibProtocol: Reject unhandled URLs instead of asserting
StartDownload requests for unhandled protocols (or invalid URLs) will
now refuse to load instead of asserting. A failure code is sent back
to LibProtocol and Protocol::Client::start_download() returns nullptr.

Fixes #1604.
2020-04-04 20:01:36 +02:00
Andreas Kling
53d0ca2ad8 Kernel: Strip SUID+SGID bits from file when written to or chowned
Fixes #1624.
2020-04-04 19:46:55 +02:00
Andreas Kling
040ba77d44 Userland: Fix null-pointer deref on unknown user/group in chown/chgrp
We can't just blindly dereference the result of getpwnam()/getgrnam()!

Fixes #1625.
2020-04-04 19:29:30 +02:00
Andreas Kling
54cb1e36b6 Kernel: Enforce file system veil on file creation
Fixes #1621.
2020-04-04 16:41:39 +02:00
Linus Groh
2944039d6b LibJS: Add Function() and Function.prototype 2020-04-04 15:58:49 +02:00
Linus Groh
4d931b524d LibJS: Add length property to ScriptFunction 2020-04-04 15:58:49 +02:00
Linus Groh
cd3e2690eb LibJS: Set length property in Object::put_native_function() 2020-04-04 15:58:49 +02:00
Andreas Kling
b3c4514902 LibWeb: Don't call an absent error callback in load_sync()
Make ResourceLoader::load_sync() match load() in checking if the
error_callback is null before actually calling it.

Fixes #1623.
2020-04-04 14:17:39 +02:00
Andreas Kling
26eeaef0a8 LibGUI: Add MenuBar::add_menu(name)
This allows us to construct menus in a more natural way:

    auto& file_menu = menubar->add_menu("File");
    file_menu.add_action(...);

Instead of the old way:

    auto file_menu = GUI::Menu::construct();
    file_menu->add_action(...);
    menubar->add_menu(file_menu);
2020-04-04 12:58:05 +02:00
Andreas Kling
faac43597a LibJS: Add js_string(Interpreter&, String) 2020-04-04 12:58:05 +02:00
AnotherTest
d8e944e899 LibCore: Fix UDPServer up to properly receive data
Prior to this, UDPServer was using listen/accept, which does not make
sense in the context of UDP.
2020-04-04 12:25:33 +02:00
AnotherTest
2ea934bcfd Kernel: Do not reject broadcast UDP packets right away
This patch relaxes how we think about UDP packets being "for us" a bit;
the proper way to handle this would be to also check if the matched
socket has SO_BROADCAST set, but we don't have that :)
2020-04-04 12:23:46 +02:00
Brendan Coles
8780151155 Browser: Add Reload option to app menu with F5 shortcut key 2020-04-04 11:47:03 +02:00
Andreas Kling
2463a285ee LibGUI: Make GUI::TabWidget::add_tab<T>() return a T&
Since the newly constructed sub-widget is owned by the TabWidget,
we can simply return a T& here. :^)
2020-04-04 11:10:07 +02:00
Andreas Kling
37af1d74cc LibGUI: Fix CppLexer assertion on incomplete #include statements
Thanks to @NotKyon for reporting this bug with a solid analysis.

Fixes #1488.
2020-04-04 11:00:14 +02:00
Andreas Kling
a502ba73dc LibJS: Correctly forward declare "Argument" as a struct 2020-04-04 10:46:00 +02:00
Andreas Kling
9430918026 LibGUI: Move ColorPicker's helper classes fully into ColorPicker.cpp
Since these are not used by the outside world, no need to expose them.
2020-04-04 10:38:39 +02:00
M
8399b7bc11
Base: Add la-latin1 keyboard layout (#1597) 2020-04-04 10:34:06 +02:00
Hüseyin ASLITÜRK
177b30629c LibGUI: Add color palette and custom color selection in the ColorPicker 2020-04-04 10:32:44 +02:00
Tibor Nagy
1bf93d504f AK: Break on end of input in JsonParser::consume_quoted_string
Fixes #1599
2020-04-04 10:31:01 +02:00
Linus Groh
a769db6078 js: Return 1 after exception in non-REPL mode 2020-04-04 10:29:42 +02:00
Dov Alperin
fb67bc2f4f Userland/JS: Add the 'save("file")' repl command
Calling save("file") in a repl saves all the typed lines so far
into the specified file. It currently does not have great support for
multilined functions since those get turned into one line.
2020-04-04 00:31:02 +02:00
Andreas Kling
56ca91b9f8 LibWeb: Implement <script src> support for synchronous scripts
Scripts loaded in this way will block the parser until they finish
executing. This means that they see the DOM before the whole document
has been fully parsed. This is all normal, of course.

To make this work, I changed the way we notify DOM nodes about tree
insertion. The inserted_into() callbacks are now incrementally invoked
during parse, as each node is appended to its parent.

To accomodate inline scripts and inline style sheets, we now also have
a children_changed() callback which is invoked on any parent when it
has children added/removed.
2020-04-03 23:06:09 +02:00
Andreas Kling
18d45d1082 LibWeb: Add ResourceLoader::load_sync()
This function creates a nested event loop and runs a load() operation
inside it, returning only once the load has either succeeded or failed.

This will be used to implement blocking loads (ew!)
2020-04-03 22:58:05 +02:00
Andreas Kling
eeec1c1293 LibCore: Don't replay last handled event when leaving nested event loop
The event that triggered the exit from an inner event loop would always
get re-delivered in the outer event loop due to a silly off-by-one
mistake when transferring pending events between loops.
2020-04-03 22:55:48 +02:00
Andreas Kling
9eec63e471 LibWeb: Protect DOM node while preparing to send mouse events
The Help application was hooking HtmlView::on_link_click, which would
get invoked before DOM event dispatch. Since we were holding on to the
clicked node with a Node*, the DOM node was gone after returning from
the on_link_click callback.

Fix this by keeping DOM nodes in RefPtrs in the event management code.
Also move DOM event dispatch before widget hook invocation, to try and
keep things sane on the LibWeb side of things.

Fixes #1605.
2020-04-03 21:34:57 +02:00
Andreas Kling
c2a8bbcb59 Revert "Kernel: Change Ext2FS to be backed by a file instead of a block device"
This reverts commit 6b59311d4b.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:29:03 +02:00
Andreas Kling
9ae3cced76 Revert "Kernel & Userland: Allow to mount image files formatted with Ext2FS"
This reverts commit a60ea79a41.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:57 +02:00
Andreas Kling
28be90120b Revert "SystemMonitor: Replace 'device' JSON field with 'source'"
This reverts commit 592f218151.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:25 +02:00
Andreas Kling
031d242e0e LibGUI: Clear any hovered index when the cursor leaves an AbstractView 2020-04-03 21:14:34 +02:00
Linus Groh
c26bef0e53 LibWeb: Add NavigatorObject to Makefile 2020-04-03 20:04:21 +02:00
Linus Groh
07049f98ec LibWeb: Handle invalid URL in HtmlView::load() 2020-04-03 19:41:25 +02:00
Stephan Unverwerth
520311eb8b LibJS: Add short circuit logical evaluation
When evaluating logical binop expressions, the rhs must not be
evaluated if the lhs leads to the whole expression not being
truthy.
2020-04-03 19:17:52 +02:00
Andreas Kling
a2b0cc8f08 LibWeb: Add "navigator" object and expose navigator.userAgent
A lot of web content looks for this property. We'll probably have to
tweak this as we go, but at least now we have it. :^)
2020-04-03 18:12:20 +02:00