Commit graph

10020 commits

Author SHA1 Message Date
Sergey Bugaev
8520d3a425 LibGfx: Add Painter::fill_ellipse() 2020-05-24 23:30:12 +02:00
Sergey Bugaev
31359e3ad2 LibJS: Use the new math constants
Instead of evaluating their values at runtime.
2020-05-24 23:30:12 +02:00
Sergey Bugaev
a449a0b977 LibM: Add M_SQRT2 and M_SQRT1_2 2020-05-24 23:30:12 +02:00
Marcin Gasperowicz
99991761fd LibJS: add Array.prototype.reduceRight()
This patch adds `Array.prototype.reduceRight()` method to LibJS Runtime. The implementation is (to my best knowledge) conformant to https://tc39.es/ecma262/#sec-array.prototype.reduceright.

Short test in `LibJS/Tests/Array.prototype-generic-functions.js` demonstrates that the function can be applied to other objects besides `Array`.
2020-05-24 20:58:14 +02:00
Linus Groh
9c8d390682 LibJS: Refactor Accessor
This changes Accessor's m_{getter,setter} from Value to Function* which
seems like a better API to me - a getter/setter must either be a
function or missing, and the creation of an accessor with other values
must be prevented by the parser and Object.defineProperty() anyway.

Also add Accessor::set_{getter,setter}() so we can reuse an already
created accessor when evaluating an ObjectExpression with getter/setter
shorthand syntax.
2020-05-24 18:49:58 +02:00
Andreas Kling
bdc19563ef Browser: Add new icons for the add/remove bookmark toolbar button
Here's a freshly drawn icon without antialiasing so it fits better with
the system visual style. :^)
2020-05-24 18:46:48 +02:00
Daniel Gustafsson
6561987e9f
LibWeb: Fix copy-paste error in HTMLDocumentParser (#2358)
When watching the video of the new HTML parser I noticed a small copy
and paste error. In one of the cases in `handle_after_head` the code
was checking for end tags when it should check for start tags.

I haven't tested this change, just looking at the spec.
2020-05-24 13:48:46 +02:00
Itamar
10bdb6f33b functrace: use Core::ArgsParser 2020-05-24 10:42:21 +02:00
Itamar
bedce69b23 Debugger: Use Core::ArgsParser 2020-05-24 10:42:21 +02:00
Itamar
773ed930cb Debugger: Re-introduce the sdb alias 2020-05-24 10:42:21 +02:00
Itamar
f9d62fd5e5 LibDebug: Make sure to not single step the program twice
After hitting a breakpoint, we single step the program to execute the
instruction we breaked on and re-enable the breakpoint.
We also single step the program when the user of LibDebug returned a
DebugDecision::SingleStep.

Previously, if we hit a breakpoint and then were asked to to a
DebugDecision::SingleStep, we would single step twice.

This bug can actually crash programs, because it might cause us to
skip over a patched INT3 instruction in the second single-step.

Interestingely enough, this bug manifested as functrace crashing
certain programs: after hitting a breakpoint on a CALL instruction,
functrace single steps the program to see where the CALL jumps to
(yes, this can be optimized :D). functrace crashed when a CALL
instruction jumps to another CALL, because it inserts breakpoints on CALL
instructions, and so the INT3 in the 2nd CALL was skipped over, and we
executed garbage :).

This commit fixes this by making sure not to single-step twice.
2020-05-24 10:42:21 +02:00
Itamar
2686957836 LibDebug: Tolerate missing debug information
We previously crashed when programs were missing certain debug information.
2020-05-24 10:42:21 +02:00
Jack Byrne
58480a510f
LibWeb: Improve support for white-space CSS property (#2348)
Add reasonable support for all values of white-space CSS property.

Values of the property are translated into a 3-tuple of rules:

    do_collapse:        whether whitespace is to be collapsed
    do_wrap_lines:      whether to wrap on word boundaries when
                        lines get too long
    do_wrap_breaks:     whether to wrap on linebreaks

The previously separate handling of per-line splitting and per-word
splitting have been unified. The Word structure is now a more
general Chunk, which represents different amounts of text depending
on splitting rules.
2020-05-24 09:49:02 +02:00
Emanuele Torre
3f2158bbfe LibWeb: HtmlTokenizer.cpp: fix ON_WHITESPACE macro
The "audible bell" character ('\a' U+0007) was treated as whitespace
while the "line feed" character ('\n' U+000a) was not.

'\a' is no longer considered whitespace.
'\n' is now considered whitespace.
2020-05-24 09:47:28 +02:00
FalseHonesty
20df82c983 Browser: Set the console's interpreter when a tab's document changes
Previously, once a console was opened for a tab, its interpreter
would never change, leaving it with a stale interpreter. Now, when
the tab's HtmlView loads a new document, the console will receive
that document's interpreter.
2020-05-24 02:20:08 +02:00
FalseHonesty
51e79a2bbc LibWeb: Add hook to HtmlView when a new document is set 2020-05-24 02:20:08 +02:00
FalseHonesty
391237a8e1 Browser: Add JS Console
The JavaScript console can be opened with Control+I, or using
the menu option. The console is currently a text box with JS
syntax highlighting which will send commands to the document's
interpreter. All output is printed to an HTML view in the console.
The output is an HtmlView to easily allow complex output, such
as expandable views for JS Objects in the long run.
2020-05-24 02:20:08 +02:00
FalseHonesty
5e45d68442 LibGUI: Use word breaks to intelligently navigate a TextEditor
Previously, holding Control while using the left/right arrow keys
to navigate through a TextEditor would only be helpful if the document
had spans. Now, if there are no spans, it will navigate to the
next "word break", defined to be the threshold where text changes
from alphanumeric to non-alphanumeric, or vice versa.
2020-05-24 02:15:21 +02:00
FalseHonesty
a3bf8c72f3 LibGUI: Add word break locator methods to TextDocument
TextDocument now has utilities to locate a word break both before
and after any TextPosition.
2020-05-24 02:15:21 +02:00
Magentah
a1fe34bcd8 Keymap: Added keymap file for Japanese keyboard, without IME
configuration keys.
2020-05-24 02:13:22 +02:00
Andreas Kling
e44c87cfff LibWeb: Implement enough HTML parsing to handle a small simple DOM :^)
We can now parse a little DOM like this:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <div></div>
    </body>
</html>

This is pretty slow work, but the incremental progress is satisfying!
2020-05-24 00:49:22 +02:00
Andreas Kling
fd1b31d0ff LibWeb: Start building the tree building part of the new HTML parser
This patch adds a new HTMLDocumentParser class. It keeps a tokenizer
object internally and feeds itself with one token at a time from it.

The names and idioms in this class are expressed as closely to the
actual HTML parsing spec as possible, to make development as easy
and bug free as possible. :^)

This is going to become pretty large, but it's pretty cool!
2020-05-24 00:14:23 +02:00
Andreas Kling
0b61e21873 LibWeb: Add HTMLFormElement to forwarding header 2020-05-24 00:12:27 +02:00
Andreas Kling
a9fba2fb91 LibWeb: Add "name" to DocumentType nodes 2020-05-24 00:12:00 +02:00
Andreas Kling
634ce37663 LibWeb: Make hit-testing work with display: inline-block;
When hit testing encountered a block with inline children, we assumed
that the inline children are nothing but text boxes. An inline-block
box is actually a block child of a block with inline children, so we
have to handle that scenario as well. :^)

Fixes #2353.
2020-05-23 21:08:25 +02:00
Andreas Kling
a01fd7ecc5 LibWeb: Colorize tag names in layout tree dumps + show element IDs
Showing element IDs in layout tree dumps makes it much easier to
compare against the DOM.
2020-05-23 21:08:25 +02:00
Andreas Kling
e45c8b842c LibWeb: Implement a bit more of DOCTYPE tokenization 2020-05-23 21:08:25 +02:00
Bryan Steele
b5c0703e14 Base: Add a really bad, but yummy Slice of Pizza emoji 🍕 2020-05-23 19:49:42 +02:00
Andreas Kling
7be36366be LibWeb: Emit character/comment tokens lazily to accumulate more data
Instead of emitting data-bearing tokens immediately, do it lazily at
the next state change. This allows us to accumulate full bursts of
text in between tags instead of having one token per character. :^)
2020-05-23 18:44:32 +02:00
Andreas Kling
ede44853d1 Userland: Allow passing a specific HTML file to the "ht" test program 2020-05-23 18:44:32 +02:00
Marcin Gasperowicz
f4985ca113 LibJS: Use __APPLE__ instead of __MACH__ for MacOS build
This is regarding PR #234. Sergey pointed out that not every Mach is Darwin.
2020-05-23 18:09:07 +02:00
AnotherTest
679a84d44c LibLine: Default to resetting styles when a cell has no styles set 2020-05-23 17:05:18 +02:00
Andreas Kling
01a085d3a6 LibC: Move ssize_t from <stddef.h> to <sys/types.h>
This should fix the toolchain build, where GCC doesn't use our stddef.h
Also, Dr. POSIX says ssize_t goes in <sys/types.h> anyway. :^)
2020-05-23 17:03:41 +02:00
Marcin Gasperowicz
27c71d2627
LibJS: Add Array.prototype.reduce() (#2334)
This patch adds `Array.prototype.reduce()` method to LibJS Runtime.
The implementation is (to my best knowledge) comformant to ECMA262.

The test `Array.prototype-generic-functions.js` demonstrates that the
function can be applied to other objects besides `Array`.
2020-05-23 16:41:25 +02:00
Linus Groh
00fe7f82c0 LibJS: Treat NaN in Value::to_i32() as zero
Let's treat it as zero like the ECMAScript spec does in toInteger().

That way we can use to_i32() and don't have to care about weird input
input values where a number is expected, i.e.

"foo".charAt() === "f"
"foo".charAt("bar") === "f"
"foo".charAt(0) === "f"
2020-05-23 16:39:17 +02:00
Spencer Dixon
ecb03716d4 Base: Add red heart emoji ❤️ 2020-05-23 16:33:05 +02:00
Andreas Kling
a75c290e51 Kernel: Use TypedMapping for accessing IOAPIC registers 2020-05-23 15:57:48 +02:00
Andreas Kling
e870b936c3 Kernel: Add non-const version of TypedMapping::operator->() 2020-05-23 15:57:19 +02:00
Andreas Kling
59a56a78c0 Kernel: Oops, we need to use map_typed_writable() for write access :^) 2020-05-23 15:50:50 +02:00
Andreas Kling
a04c8d7101 Kernel: Use TypedMappings when looking for APIC information 2020-05-23 15:46:56 +02:00
Marcin Gasperowicz
c21dc21f36
Build: Make Lagom build under macOS (#2341)
Lagom now builds under macOS. Only two minor adjustments were required:

* LibCore TCP/UDP code can't use `SOCK_{NONBLOCK,CLOEXEC}` on macOS,
use ioctl() and fcntl() instead

* LibJS `Heap` code pthread usage ported to MacOS
2020-05-23 15:31:30 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
Andreas Kling
2fe6b3725a Kernel: Use TypedMappings in the very unfinished APIC code 2020-05-23 15:25:43 +02:00
Andreas Kling
1afbd8936a Kernel+LibC: Let's say that off_t is a ssize_t 2020-05-23 15:25:43 +02:00
Andreas Kling
45450c7edc LibWeb: Make BEGIN_STATE and END_STATE include some {{{ and }}}
This makes it a compile error to omit the END_STATE. Also add some more
missing END_STATE's exposed by this (nice!)

Thanks to @predmond for suggesting the multi-pair trick! :^)
2020-05-23 15:25:43 +02:00
Andreas Kling
d63b6287f5 Kernel: Add missing casts when calling AK::min() 2020-05-23 15:25:43 +02:00
Andreas Kling
8fe4512f8e AK: Fix inconsistent signature for dbgputstr() 2020-05-23 15:25:43 +02:00
Andreas Kling
a0d3c03950 LibC: Declare ssize_t in a platform-agnostic way
While the compiler provides __SIZE_TYPE__ for declaring size_t,
there's unfortunately no __SSIZE_TYPE__ for ssize_t.

However, we can trick the preprocessor into doing what we want anyway
by doing "#define unsigned signed" before using __SIZE_TYPE__ again.
2020-05-23 15:25:43 +02:00
Andreas Kling
8ec8304d74 Kernel: Tweak some suspicious casts in InterruptManagement
This code needs a closer looking-into at some point. It doesn't seem
entirely safe to be casting u32's to pointers like it does.
2020-05-23 15:25:43 +02:00
Andreas Kling
7c278eb970 Kernel: Dont't static_assert that size_t is 32-bit :^) 2020-05-23 15:25:43 +02:00