Commit Graph

8045 Commits

Author SHA1 Message Date
Andreas Kling
1d468ed6d3 AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtr
We were allowing this dangerous kind of thing:

RefPtr<Base> base;
RefPtr<Derived> derived = base;

This patch changes the {Nonnull,}RefPtr constructors so this is no
longer possible.

To downcast one of these pointers, there is now static_ptr_cast<T>:

RefPtr<Derived> derived = static_ptr_cast<Derived>(base);

Fixing this exposed a ton of cowboy-downcasts in various places,
which we're now forced to fix. :^)
2020-04-05 11:19:00 +02:00
Andreas Kling
058c614110 LibJS: Fix missing paren in modulo-basic.js test 2020-04-05 11:19:00 +02:00
Brian Gianforcaro
240a5b5fd7 LibJS: Add support for Math.ceil() and Math.trunc()
Introduce support for the both of these Math methods.
Math.trunc is implemented in terms of Math.ceil or Math.floor
based on the input value. Added tests as well.
2020-04-05 10:56:23 +02:00
Brendan Coles
4ea71c9571 IRCClient: Add support for raw protocol commands with /RAW 2020-04-05 10:39:36 +02:00
Brian Gianforcaro
b8cef3a2d3 LibJS: Add support for floating point modulous
This change implements floating point mod based on the algorithm
used in LibM's fmod() implementation. To avoid taking a dependency
on LibM from LibJS I reimplemented the formula in LibJS.

I've incuded some of the example MDM test cases as well.
This surfaced and issue handling NaN which I've fixed as well.
2020-04-05 10:38:13 +02:00
Brian Gianforcaro
41bfff1abe LibJS: Correctness fixes for bitwise_or, address FIXME's in test. 2020-04-05 10:37:02 +02:00
AnotherTest
3e8cf79efa Servers: Add a new DHCP client
This adds a DHCPClient...Server that leases IPv4s.
2020-04-05 09:50:48 +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
AnotherTest
7d0bf9b5a9 Kernel+AK: Separate out MACAddress and move it into AK 2020-04-05 09:50:48 +02:00
Brendan Coles
55b25b3c9b IRCClient: Add icons for channel list, channel invite, channel topic 2020-04-05 09:37:19 +02:00
Tibor Nagy
192513ec33 QuickShow: Fix crash on startup
QSWidget::relayout get triggered before setting a bitmap to display
while setting the widget as the main widget of the window.

I've added a null check to the paint event too to make sure the
widget works with no bitmap set.
2020-04-05 09:36:46 +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
Linus Groh
79539378c6 js: Add lines to history 2020-04-05 01:54:38 +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
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