Commit graph

8888 commits

Author SHA1 Message Date
Andreas Kling
57fe4d19ac LibGUI: Remove unnecessary is_enabled() checks in mouse event handlers
We never deliver mouse events to disabled widgets, so there's no need
to check is_enabled() in these event handlers.
2020-04-29 19:17:40 +02:00
Andreas Kling
cdbc252190 LibGUI: Require a full click on ColorInput's color rect to open picker
Let's not open the ColorPicker on mousedown, that was too jarring.
2020-04-29 19:17:40 +02:00
Linus Groh
8159f45f6e LibJS: Make String.prototype.slice() generic 2020-04-29 19:14:36 +02:00
Linus Groh
cfdb7b8806 LibJS: Make (most) String.prototype functions generic
I.e. they don't require the |this| value to be a string object and
"can be transferred to other kinds of objects for use as a method" as
the spec describes it.
2020-04-29 18:53:21 +02:00
Linus Groh
4bdb6daac5 LibJS: Handle non-string primitive values in Object::to_string() 2020-04-29 18:53:21 +02:00
Linus Groh
2c6e7dbd07 LibJS: Throw error in Object::to_string() if string conversion fails 2020-04-29 18:53:21 +02:00
mattco98
95abcc3722 LibJS: Implement correct object property ordering
This commit introduces a way to get an object's own properties in the
correct order. The "correct order" for JS object properties is first all
array-like index properties (numeric keys) sorted by insertion order,
followed by all string properties sorted by insertion order.

Objects also now print correctly in the repl! Before this commit:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ bar: 2, foo: 1, baz: 3 }

After:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ foo: 1, bar: 2, baz: 3 }
2020-04-29 18:47:03 +02:00
Kesse Jones
58f6f50de4 LibJS: Add String.prototype.slice 2020-04-29 18:35:18 +02:00
Andreas Kling
bf727eb44c DisplaySettings: Arrange buttons in "OK, Cancel, Apply" order 2020-04-29 16:25:02 +02:00
Andreas Kling
e8a044390e DisplaySettings: Don't allow desktop background color with alpha 2020-04-29 16:22:29 +02:00
Andreas Kling
f8069418e1 LibGUI: Transfer "color has alpha channel" state 2020-04-29 16:22:09 +02:00
Andreas Kling
51df4bdbfc DisplaySettings: Rename from DisplayProperties 2020-04-29 15:53:51 +02:00
Andreas Kling
c7107385ee LibGUI: Allow disabling the alpha channel in ColorInput widgets 2020-04-29 15:33:36 +02:00
Andreas Kling
17e76b4760 LibGfx: Add Color::to_string_without_alpha()
This simply returns an "#rrggbb" string and ignores the alpha value.
2020-04-29 15:31:45 +02:00
Andreas Kling
bc305a16ae LibGUI: Allow editing ColorInput widgets as text
You can now enter a specific color as #rrggbb instead of clicking your
way through the color picker.

If you still want the color picker, just click the little color rect in
the widget and we'll bring up a ColorPicker. For a visual cue that this
rect is interactive, we use a hover hand cursor when hovering the rect.
2020-04-29 15:30:01 +02:00
Andreas Kling
033a4aee50 LibGUI: Remove copy-pasted auto-repeat logic from ColorInput
This was copy-pasted from button classes and not useful here.
2020-04-29 14:38:19 +02:00
Andreas Kling
40fe076e10 Base: Tweak default desktop background color slightly 2020-04-29 14:37:10 +02:00
Andreas Kling
aaf35112a4 LibJS: Pass JS::Function around by reference more 2020-04-29 13:43:57 +02:00
Andreas Kling
97382677bd LibWeb: Make EventListener::function() return a reference 2020-04-29 12:46:20 +02:00
Andreas Kling
a38658dc88 LibJS: Don't use Optional<Value> for bound |this| values
Just use a plain Value since it already has an empty state.
2020-04-29 12:41:58 +02:00
Andreas Kling
698652a548 LibJS: Make Value::as_string() return a PrimitiveString reference 2020-04-29 12:35:39 +02:00
Andreas Kling
75f246dde8 LibJS: Make StringObject::primitive_string() return a reference 2020-04-29 12:33:28 +02:00
Andreas Kling
7dadb75e28 WindowServer: Pop up the window menu at bottom left of window icon
When clicking the window icon, we now pop up the window menu at the
bottom left of the icon, no matter where you clicked it.

Right-clicking the title bar still pops up at the event position.
2020-04-29 12:07:40 +02:00
Andreas Kling
f0cde70c18 LibGUI: Simplify submenu construction
The API for adding a submenu to a menu is now:

auto& submenu = menu.add_submenu("Name");
submenu.add_action(my_action);
2020-04-29 11:48:11 +02:00
Andreas Kling
13dcd9a037 WindowServer: Fix build after FBResolution changes 2020-04-29 11:41:34 +02:00
Linus Groh
d4ec38097f LibJS: Return undefined in Array.prototype.{pop,shift} for empty values 2020-04-29 09:38:25 +02:00
Emanuele Torre
a220236cde Browser: Add missing #pragma once in Tab.h 2020-04-29 09:38:11 +02:00
Andreas Kling
385dacce05 Kernel: Fix integer overflow in framebuffer resolution handling
This made it possible to map the E1000 MMIO range into userspace and
mess with the registers.

Thanks to @grigoritchy for finding this!

Fixes #2015.
2020-04-29 09:37:36 +02:00
mattco98
18cfb9218a LibJS: Set Array length attributes to "Configurable | Writable" 2020-04-29 09:02:29 +02:00
Linus Groh
da0ab16f01 LibJS: Don't handle arrays separately in Value::to_number()
Now that Array.prototype.join() is producing the correct results we
can remove the separate code path for arrays in Value::to_number()
and treat them like all other objects - using to_primitive() with
number as the preferred type and then calling to_number() on the
result.

This is how the spec descibes it.

This also means we don't crash anymore when trying to coerce
[<empty>] to a number - it now does the following:

[<empty>] - to string - "" - to number - 0
[<empty>, <empty>] - to string - "," - to number - NaN
2020-04-29 01:30:59 +02:00
Linus Groh
6d6cd64689 LibJS: Skip undefined and null in join_array_with_separator()
This it being used in Array.prototype.{join,toString}() - and now
adhering to the spec: [undefined, null].join() === ","
2020-04-29 01:30:59 +02:00
Andreas Kling
86810a4b02 LibLine: Actually fix build :^) 2020-04-29 00:03:19 +02:00
AnotherTest
a6fcf70e25 LibLine: Properly mark the result of read() as ignored
Unbreaks the build.
2020-04-28 23:48:38 +02:00
AnotherTest
e83300dc27 LibLine: Drop stray input before doing vt_dsr
This patch fixes the issue where some data would be buffered while the
editor is not editing, and vt_dsr would read them, resulting in the
cursor to jump to (1,1)
2020-04-28 23:29:07 +02:00
AnotherTest
9473733d7a LibLine: Handle initialize() internally
This patch makes initialize() transparent to the users, but exposes it
publicly, as the users might need a copy of the default termios (i.e.
Shell)
2020-04-28 23:29:07 +02:00
AnotherTest
7ecf29f206 LibLine: Ignore interrupts unless actively editing
It does not make much sense to receive an interrupt and process it
*much later*.
Also patches Userland/js to only create exceptions while some code is
actually running.
2020-04-28 23:29:07 +02:00
Linus Groh
8b195d1211 TextEditor: Fix typo in comment 2020-04-28 23:12:16 +02:00
Linus Groh
8ad11df89f LibJS: Handle exception in for loop test execution 2020-04-28 23:11:18 +02:00
Andreas Kling
5eaa7ff406 TextEditor: Add live preview when editing markdown :^)
This works by hooking into the change notifications from the TextEditor
widget and parsing the document content as markdown, and generating an
HTML document from it which is displayed using LibWeb.

This will make it a bit easier to write man pages! :^)
2020-04-28 21:46:43 +02:00
Andreas Kling
ea204ef05b LibMarkdown: Drop MD prefixes and move into "Markdown" namespace :^) 2020-04-28 21:04:25 +02:00
mattco98
104969a9f5 LibJS: Add spreading in object literals
Supports spreading strings, arrays, and other objects within object
literals.
2020-04-28 20:37:21 +02:00
Andreas Kling
3cc31ff3f3 Browser: Make Ctrl+L select the location bar again
..by making sure the Tab actions are scoped to the Tab.
2020-04-28 20:36:08 +02:00
Andreas Kling
5b4b72e699 Browser: Don't put favicons as the window icon
It's nicer to always use the browser's own app icon instead. :^)
2020-04-28 20:31:51 +02:00
Andreas Kling
463c2e3768 Kernel: Be a little more defensive when indexing E1000 Rx/Tx buffers 2020-04-28 20:31:51 +02:00
Hüseyin ASLITÜRK
b3bdab8cf7 Application: Fix for reboot on PowerDialog close button click 2020-04-28 20:30:48 +02:00
Linus Groh
3152559422 LibJS: Call Array.prototype.findIndex() callback for empty elements
If the array value at the current index is empty, the callback will
be called with undefined as value.
2020-04-28 20:15:38 +02:00
Linus Groh
823cc7bc1c LibJS: Call Array.prototype.find() callback for empty elements
If the array value at the current index is empty, the callback will
be called with undefined as value.
2020-04-28 20:15:38 +02:00
Linus Groh
ad8abce8a5 LibJS: Let Array.prototype.map() resize new array before loop
Currently we would create an empty array of size 0 and appening results
of the callback function while skipping empty values.

This is incorrect, we should be initializing a full array of the correct
size beforehand and then inserting the results while still skipping
empty values.

Wrong: new Array(5).map(() => {}) // []
Right: new Array(5).map(() => {}) // [<empty> * 5]
2020-04-28 20:15:38 +02:00
Linus Groh
0a0ba64383 LibJS: Handle Object.prototype.hasOwnProperty() with no arg correctly
I.e. the same as hasOwnProperty(undefined) or
hasOwnProperty("undefined") :^)
2020-04-28 20:03:50 +02:00
Andreas Kling
4419685b7e Kernel: Leave VMObject alone on OOM during CoW fault
If we OOM during a CoW fault and fail to allocate a new page for the
writing process, just leave the original VMObject alone so everyone
else can keep using it.
2020-04-28 17:05:14 +02:00