Commit Graph

1939 Commits

Author SHA1 Message Date
Brian Gianforcaro
41bfff1abe LibJS: Correctness fixes for bitwise_or, address FIXME's in test. 2020-04-05 10:37:02 +02:00
AnotherTest
77191d82dc Kernel: Add the SO_BINDTODEVICE socket option
This patch adds a way for a socket to ask to be routed through a
specific interface.
Currently, this option only applies to sending, however, it should also
apply to receiving...somehow :^)
2020-04-05 09:50:48 +02:00
Brian Gianforcaro
4e54d0ff21 LibJS: Add support for arbitrary arguments to Math.max
Address the FIXME in MathObject::max to handle an arbitrary
number of arguments. Also adding a test case to verify the
behavior of Math.max() while I'm here.
2020-04-05 09:28:58 +02:00
Andreas Kling
d84de532f1 LibJS: Add Math.max() 2020-04-05 00:57:00 +02:00
Andreas Kling
ca90f88d4e LibWeb: Add window.setTimeout()
This also leaks the timer just like setInterval() (FIXME).
2020-04-05 00:56:16 +02:00
Andreas Kling
16bd99aa52 LibJS: Add Math.round() 2020-04-05 00:29:01 +02:00
Andreas Kling
afff228308 LibJS: Add Math.floor() 2020-04-05 00:26:56 +02:00
Andreas Kling
3c99c27db4 LibJS: Clean up the anonymous wrapper block in "for" using ScopeGuard
This ensures that we don't forget to pop the wrapper off of the scope
stack when returning early due to an exception or some such. :^)
2020-04-05 00:24:32 +02:00
Andreas Kling
9ebd066ac8 LibJS: Add support for "continue" inside "for" statements :^) 2020-04-05 00:22:42 +02:00
Andreas Kling
e3b92caa6d LibJS: Make "break" actually work inside "switch" 2020-04-05 00:09:48 +02:00
Andreas Kling
9d099835f9 LibWeb: Add CanvasRenderingContext2D scale() and translate() stubs
These don't do anything for now.
2020-04-04 23:54:58 +02:00
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
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
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
Hüseyin ASLITÜRK
177b30629c LibGUI: Add color palette and custom color selection in the ColorPicker 2020-04-04 10:32:44 +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
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
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