Commit graph

9834 commits

Author SHA1 Message Date
Andreas Kling
45da08a1e6 LibWeb: A whole bunch of work towards spec-compliant <script> elements
This is still very unfinished, but there's at least a skeleton of code.
2020-05-24 23:54:22 +02:00
Andreas Kling
3a30180e1e LibWeb: Add HTMLScriptElement to the forwarding header 2020-05-24 23:54:22 +02:00
Andreas Kling
128eaf9295 LibWeb: Add some helpers to the DOM Node class
This patch adds the following things needed by the HTML spec:

- Node::child_text_content()
- Node::is_connected()
- Node::root()
2020-05-24 23:54:22 +02:00
Andreas Kling
6c409310a8 LibWeb: Add a way to opt out of TreeNode::append_child() notifications
This will be used temporarily by the new HTML parser while we're
bringing it up.
2020-05-24 23:54:22 +02:00
Andreas Kling
5d332c1f11 LibWeb: Parse enough to handle a <style> inside a <head> :^) 2020-05-24 23:54:22 +02:00
Andreas Kling
af8a9331b2 LibWeb: Support comments in the "in head" insertion mode 2020-05-24 23:54:22 +02:00
Andreas Kling
20911efd4d LibWeb: More work on the HTML parser and tokenizer
The parser can now switch the state of the tokenizer! Very webby. :^)
2020-05-24 23:54:22 +02:00
Andreas Kling
31db3f21ae LibWeb: Start implementing character token parsing
Now that we've gotten rid of the misguided character buffering in the
tokenizer, it actually spits out character tokens that we have to deal
with in the parser.

This patch implements enough to bring us back to speed with simple.html
2020-05-24 23:54:22 +02:00
Andreas Kling
53d2f4df70 LibWeb: Factor out the "stack of open elements" into its own class
This will allow us to write more expressive parsing code. :^)
2020-05-24 23:54:22 +02:00
Andreas Kling
96cc1138c0 LibWeb: Remove tokenizer's premature character buffering optimization 2020-05-24 23:54:22 +02:00
Linus Groh
92fd140cb2 LibJS: Make Array.prototype.includes() generic 2020-05-24 23:51:14 +02:00
Linus Groh
e78bc2f6fd LibJS: Make Array.prototype.lastIndexOf() generic 2020-05-24 23:51:14 +02:00
Linus Groh
9b9b6a4cff LibJS: Make Array.prototype.indexOf() generic 2020-05-24 23:51:14 +02:00
Sergey Bugaev
174ac5d348 Demos: Add Eyes demo
This is a neat clone of xeyes. It demoes the new ellipse filling functionality,
as well as the existing global mouse cursor tracking functionality :^)
2020-05-24 23:30:12 +02:00
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