Commit Graph

7754 Commits

Author SHA1 Message Date
Andreas Kling
b196665131 LibWeb: Dispatch "mouseup" event
This is a very naive implementation that doesn't account for where the
mousedown happened.
2020-03-21 17:55:41 +01:00
Andreas Kling
8b18674229 LibJS: Add Math.random() :^) 2020-03-21 17:52:12 +01:00
Andreas Kling
c4c549625f LibWeb: Add HTMLCanvasElement.{width,height} properties 2020-03-21 17:44:01 +01:00
Andreas Kling
f1715bbd5e LibWeb: Make the "document" global a native property
This defers construction of the document wrapper until actually needed.
2020-03-21 14:54:33 +01:00
Andreas Kling
a7d458f76a Base: Tidy up the events.html test page a little bit 2020-03-21 14:53:13 +01:00
Andreas Kling
08b17d70af LibJS+LibWeb: Fix some inconsistencies in NativeFunction callbacks
These should always pass the arguments in a const Vector<JS::Value>&.
2020-03-21 14:43:44 +01:00
Andreas Kling
324b92fd06 LibJS: Virtualize access to an Object's own properties
Object now has virtual get_own_property() and put_own_property() member
functions that can be overridden to provide custom behavior.

We use these virtuals to move Array-specific access behavior to Array.
2020-03-21 14:37:34 +01:00
Andreas Kling
2a7dbac0c5 LibJS: Include the cell size in HeapBlock mmap names
HeapBlocks now show up in SystemMonitor as "LibJS: HeapBlock(32)" :^)
2020-03-21 13:12:16 +01:00
Andreas Kling
00feef8642 LibJS: Some optimizations for ObjectExpression
- move() the property map when constructing ObjectExpression instead of
  making a copy.
- Use key+value iterators to traverse the property map in the execute()
  and dump() functions.
2020-03-21 13:11:51 +01:00
Andreas Kling
6c3afca686 LibJS: Round cell sizes up to a multiple of 16 bytes
This increases HeapBlock utilization significantly (and reduces overall
memory usage.)
2020-03-21 11:49:18 +01:00
Andreas Kling
2106dafd62 LibJS: Delete fully-empty HeapBlocks after garbage collection
We now deallocate GC blocks when they are found to have no live cells
inside them.
2020-03-21 11:46:47 +01:00
0xtechnobabble
bc002f807a LibJS: Parse object expressions 2020-03-21 10:08:58 +01:00
BenJilks
c64b5e73f5
Build: Add FreeBSD support (#1492) 2020-03-21 09:46:30 +01:00
Andreas Kling
bceabd7c4b LibJS: Add ArrayPrototype and implement Array.prototype.push()
This function is ultimately supposed to be generic and allow any |this|
that has a length property, but for now it only works on our own Array
object type.
2020-03-20 21:56:40 +01:00
Andreas Kling
8f7d4f67a4 LibJS: Support reading/writing elements in an Array via Object get/put
I'm not completely thrilled about Object::get() and Object::put() doing
special-case stuff for arrays, and we should probably come up with a
better abstraction for it.

But at least it works for now, which is really nice. :^)
2020-03-20 21:56:40 +01:00
Andreas Kling
a3d2e07446 LibJS: Parse computed MemberExpressions
MemberExpression comes in two flavors:

    computed: a[b]
non-computed: a.b

We can now parse both of the types. :^)
2020-03-20 21:56:40 +01:00
Andreas Kling
86642add2f LibJS: Allow default-constructing a JS::Value (undefined) 2020-03-20 21:56:40 +01:00
Andreas Kling
a82f64d3d6 LibJS: Parse ArrayExpression and start implementing Array objects
Note that property lookup is not functional yet.
2020-03-20 21:56:40 +01:00
myphs
0891f860f7 LibWeb: Add CSS property 'border'
This makes it possible to write shorter CSS. Instead of writing
.foo {
        border-width: 3px;
        border-style: solid;
        border-color: blue;
}
it is now possible to write
.foo {
        border: 3px solid blue;
}
while the order of values is irrelevant.
Currently only the basic values are supported. More values should be
added in the future.

Three more value specific parse functions were added:
parse_line_width, parse_color, and parse_line_style

Additionally a few test cases were added to borders.html.
2020-03-20 21:40:55 +01:00
Elisée Maurer
12e8efd74e
LibWeb: Fix HTMLCanvasElement::preferred_height() default value (#1490)
The correct height is 150px rather than 300px.
2020-03-20 15:19:38 +01:00
Andreas Kling
12b8cd8c10 js: Make printing of the last result optional 2020-03-20 14:52:27 +01:00
Andreas Kling
0bc6bcc2ed js: Ignore the first line of input if it starts with "#!"
This allows us to create executable programs in JavaScript :^)
2020-03-20 14:49:17 +01:00
Andreas Kling
3823d13e21 copy: Use StringBuilder::join() 2020-03-20 14:41:23 +01:00
Andreas Kling
5db8940c9e LibJS: Use StringBuilder::join() 2020-03-20 14:41:23 +01:00
Andreas Kling
4eef3e5a09 AK: Add StringBuilder::join() for joining collections with a separator
This patch adds a generic StringBuilder::join(separator, collection):

    Vector<String> strings = { "well", "hello", "friends" };
    StringBuilder builder;
    builder.join("+ ", strings);
    builder.to_string(); // "well + hello + friends"
2020-03-20 14:41:23 +01:00
Andreas Kling
218f082226 LibJS: Print a newline in each console.log() 2020-03-20 14:41:23 +01:00
Andreas Kling
2176a3dd18 Documentation: Tweak document about smart pointers a bit
Add notes about assigning between FooPtr / NonnullFooPtr.
2020-03-20 14:41:02 +01:00
Andreas Kling
03ec57b271 LibWeb: Make hit testing better for blocks with inline children
If we don't hit one of the inline children, we should still report that
we've hit the block itself.
2020-03-20 12:41:31 +01:00
Tibor Nagy
9e6e731a78 LibGUI: Remove G prefix from macros 2020-03-19 23:17:34 +01:00
rhin123
073ac3a22f Calendar: Add license header 2020-03-19 22:54:30 +01:00
rhin123
a0bc6a8f37 Base: Add Calendar.af 2020-03-19 22:54:30 +01:00
rhin123
8bc412c80b Calendar: Add a 16x16 app icon 2020-03-19 22:54:30 +01:00
rhin123
19e1cd9fb8 Calendar: Corrected spacing for widgets and rectangles 2020-03-19 22:54:30 +01:00
Tibor Nagy
fc71b73c37 Applications: Remove G prefixes from comments 2020-03-19 22:52:44 +01:00
Tibor Nagy
120e8028f6 WidgetGallery: Remove G prefixes from components 2020-03-19 22:52:44 +01:00
Tibor Nagy
9570efa698 LibGUI: Remove friend classes of TextDocumentLine
They were unused. Also GTextEditor doesn't exist anymore and GCC
was silently ignoring this declaration.
2020-03-19 22:52:44 +01:00
Tibor Nagy
30964ba7d0 LibGUI: Remove remaining G prefixes 2020-03-19 22:52:44 +01:00
Tibor Nagy
809490dcb6 Solitaire: Use dark green for empty stack outlines
Looks nicer than using dark gray. Derived from the background color.
2020-03-19 22:52:18 +01:00
Tibor Nagy
e0c16d1b43 Ports: Unbreak vttest build by updating package version 2020-03-19 22:52:01 +01:00
Andreas Kling
a37c29e353 LibWeb: Add <canvas> element and start fleshing out CRC2D
This patch adds HTMLCanvasElement along with a LayoutCanvas object.
The DOM and layout parts are very similar to <img> elements.

The <canvas> element holds a Gfx::Bitmap which is sized according to
the "width" and "height" attributes on the element.

Calling .getContext("2d") on a <canvas> element gives you a context
object that draws into the underlying Gfx::Bitmap of the <canvas>.
The context weakly points to the <canvas> which allows it to outlive
the canvas element if needed.

This is really quite cool. :^)
2020-03-19 19:07:56 +01:00
Andreas Kling
73d28a0551 LibJS: Prefer FunctionDeclaration if a statement begins with "function" 2020-03-19 18:07:07 +01:00
Andreas Kling
1a10470c1d LibJS: Implement basic object property assignment
This is pretty naive, we just walk up the prototype chain and call any
NativeProperty setter that we find. If we don't find one, we put/set
the value as an own property of the object itself.
2020-03-19 17:44:06 +01:00
Liav A
7268499c76 LibCore: Use monotonic time when handling timers 2020-03-19 15:48:00 +01:00
Liav A
b536547c52 Process: Use monotonic time for timeouts 2020-03-19 15:48:00 +01:00
Liav A
b4c92c24ee Scheduler: Use monotonic time for blocking threads 2020-03-19 15:48:00 +01:00
Liav A
b2585b3577 Userland: Add functionality of changing system date in date utility 2020-03-19 15:48:00 +01:00
Liav A
64c73d0739 LibC: Add new syscall to allow changing the system date 2020-03-19 15:48:00 +01:00
Liav A
4484513b45 Kernel: Add new syscall to allow changing the system date 2020-03-19 15:48:00 +01:00
Liav A
4fcc10c6c3 Kernel: Delete unnecessary files 2020-03-19 15:48:00 +01:00
Liav A
9db291d885 Kernel: Introduce the new Time management subsystem
This new subsystem includes better abstractions of how time will be
handled in the OS. We take advantage of the existing RTC timer to aid
in keeping time synchronized. This is standing in contrast to how we
handled time-keeping in the kernel, where the PIT was responsible for
that function in addition to update the scheduler about ticks.
With that new advantage, we can easily change the ticking dynamically
and still keep the time synchronized.

In the process context, we no longer use a fixed declaration of
TICKS_PER_SECOND, but we call the TimeManagement singleton class to
provide us the right value. This allows us to use dynamic ticking in
the future, a feature known as tickless kernel.

The scheduler no longer does by himself the calculation of real time
(Unix time), and just calls the TimeManagment singleton class to provide
the value.

Also, we can use 2 new boot arguments:
- the "time" boot argument accpets either the value "modern", or
  "legacy". If "modern" is specified, the time management subsystem will
  try to setup HPET. Otherwise, for "legacy" value, the time subsystem
  will revert to use the PIT & RTC, leaving HPET disabled.
  If this boot argument is not specified, the default pattern is to try
  to setup HPET.
- the "hpet" boot argumet accepts either the value "periodic" or
  "nonperiodic". If "periodic" is specified, the HPET will scan for
  periodic timers, and will assert if none are found. If only one is
  found, that timer will be assigned for the time-keeping task. If more
  than one is found, both time-keeping task & scheduler-ticking task
  will be assigned to periodic timers.
  If this boot argument is not specified, the default pattern is to try
  to scan for HPET periodic timers. This boot argument has no effect if
  HPET is disabled.

In hardware context, PIT & RealTimeClock classes are merely inheriting
from the HardwareTimer class, and they allow to use the old i8254 (PIT)
and RTC devices, managing them via IO ports. By default, the RTC will be
programmed to a frequency of 1024Hz. The PIT will be programmed to a
frequency close to 1000Hz.

About HPET, depending if we need to scan for periodic timers or not,
we try to set a frequency close to 1000Hz for the time-keeping timer
and scheduler-ticking timer. Also, if possible, we try to enable the
Legacy replacement feature of the HPET. This feature if exists,
instructs the chipset to disconnect both i8254 (PIT) and RTC.
This behavior is observable on QEMU, and was verified against the source
code:
ce967e2f33

The HPETComparator class is inheriting from HardwareTimer class, and is
responsible for an individual HPET comparator, which is essentially a
timer. Therefore, it needs to call the singleton HPET class to perform
HPET-related operations.

The new abstraction of Hardware timers brings an opportunity of more new
features in the foreseeable future. For example, we can change the
callback function of each hardware timer, thus it makes it possible to
swap missions between hardware timers, or to allow to use a hardware
timer for other temporary missions (e.g. calibrating the LAPIC timer,
measuring the CPU frequency, etc).
2020-03-19 15:48:00 +01:00