Commit graph

10104 commits

Author SHA1 Message Date
Andreas Kling
db6cf9b37d LibWeb: Implement the first half of the Adoption Agency Algorithm
The AAA is a somewhat daunting algorithm you have to run for certain
tag when inserted inside the <body> element. The purpose of it is to
resolve issues with mismatched tags.

This patch implements the first half of the AAA. We also move the
"list of active formatting elements" to its own class, since it kept
accumulating little behaviors. "Marker" entries are now signified by
null Element pointers in the list.
2020-05-27 23:22:42 +02:00
Andreas Kling
4c9c6b3a7b LibWeb: Bring up basic external script execution in the new parser
This only works in some narrow cases, but should be enough for our own
welcome.html at least. :^)
2020-05-27 23:02:03 +02:00
Andreas Kling
2cb50f6750 LibWeb+Browser: Add ability to run Browser with the new HTML parser
You can now pass "-n" to the browser to use the new HTML parser.
It's not turned on by default since it's still very immature, but this
is a huge step towards bringing it into maturity. :^)
2020-05-27 21:57:30 +02:00
FalseHonesty
08e2907210 Browser: Add console history to re-send old commands
The console has now enabled history in its input text box. Pretty
nice to not have to retype things all the time :^)
2020-05-27 20:04:52 +02:00
FalseHonesty
139dbfd5b5 LibGUI: Add up & down arrow hooks and input history to TextBox
This patch adds the ability to enable "input history" on a textbox,
allowing to navigate between the history with the arrow keys.

Also removes a custom TextBox subclass from HackStudio that added
the exact same hooks, and moves it to use the now standard ones.
2020-05-27 20:04:52 +02:00
Andreas Kling
893a9ff5b0 LibTextCodec: Improve Latin-1 decoder so it decodes everything
I can now see Swedish letters when opening Google in the browser. :^)
2020-05-27 19:52:18 +02:00
Andreas Kling
35040dd2c4 LibWeb: LayoutMode line_break_policy => LayoutMode layout_mode 2020-05-27 19:52:18 +02:00
Andreas Kling
a8f0e4d56e LibGUI: Defer line reflow during text insertion
Add a deferral counter and defer reflowing the visual lines until the
counter is at zero. Use this to defer reflow when inserting text.

This fixes glacial slowdown while paste large amounts of text.
2020-05-27 19:52:18 +02:00
Andreas Kling
30edd198ec LibGUI: Make TextEditor::select_all() move the cursor to document head
This feels a lot nicer than moving the cursor to the document end.
2020-05-27 19:52:18 +02:00
Linus Groh
99e775cee3 LibJS: Reformat ArrayPrototype.cpp 2020-05-27 19:51:52 +02:00
Andreas Kling
39b5494aeb LibWeb: Implement the "after attribute name" tokenizer state
One little step at a time towards parsing the monster blob of HTML we
get from twitter.com :^)
2020-05-27 18:30:29 +02:00
Andreas Kling
1b0c39ca60 LibWeb: Handle more benign parse errors in the "in body" insertion mode 2020-05-27 18:30:29 +02:00
Andreas Kling
1de29e3f59 LibWeb: Implement the "self closing start tag" tokenizer state 2020-05-27 18:30:29 +02:00
Andreas Kling
a34258b3d7 ProtocolServer: Forget downloads after they are stopped
Stopping means the client no longer cares about the download, so we
should just forget about it in the server.
2020-05-27 18:30:29 +02:00
Andreas Kling
a5ce09f8e3 LibWeb: Implement partial support for numeric character references 2020-05-27 18:30:27 +02:00
Matthew Olsson
dd08c992e8 LibJS: Simplify and normalize publicly-exposed Object functions
Previously, the Object class had many different types of functions for
each action. For example: get_by_index, get(PropertyName),
get(FlyString). This is a bit verbose, so these methods have been
shortened to simply use the PropertyName structure. The methods then
internally call _by_index if necessary. Note that the _by_index
have been made private to enforce this change.

Secondly, a clear distinction has been made between "putting" and
"defining" an object property. "Putting" should mean modifying a
(potentially) already existing property. This is akin to doing "a.b =
'foo'".

This implies two things about put operations:
    - They will search the prototype chain for setters and call them, if
      necessary.
    - If no property exists with a particular key, the put operation
      should create a new property with the default attributes
      (configurable, writable, and enumerable).

In contrast, "defining" a property should completely overwrite any
existing value without calling setters (if that property is
configurable, of course).

Thus, all of the many JS objects have had any "put" calls changed to
"define_property" calls. Additionally, "put_native_function" and
"put_native_property" have had their "put" replaced with "define".

Finally, "put_own_property" has been made private, as all necessary
functionality should be exposed with the put and define_property
methods.
2020-05-27 13:17:35 +02:00
Andreas Kling
59a32f29b0 test-crypto: Tweaks to make this build properly in Lagom 2020-05-27 12:39:58 +02:00
Andreas Kling
5f9de61bf2 Lagom: Build LibCrypto, LibTLS and test-crypto :^) 2020-05-27 12:28:39 +02:00
Andreas Kling
c1dd67e792 LibCrypto+LibTLS: Use AK/Random.h
This makes it possible to build both of these on Linux.
2020-05-27 12:28:17 +02:00
Andreas Kling
9a113b0229 AK: Add a simple randomness API
This can be used in code that builds on non-Serenity platforms.
2020-05-27 12:25:46 +02:00
Nick Vella
e53fa97cfb LibGUI, About: Implement system-wide W2k-esque About dialog
The new About dialog reads version information from /res/version.ini,
which is generated at build time.
2020-05-27 11:44:19 +02:00
Emanuele Torre
0d5b43552d Meta: Update C++ standard to C++20 in CONTRIBUTING.md
We are compiling with `-std=c++2a` and we are using some C++20 features,
e.g. in Kernel/VM/Region.h
    bool m_shared : 1 { false };
    bool m_user_accessible : 1 { false };
    bool m_cacheable : 1 { false };
    bool m_stack : 1 { false };
    bool m_mmap : 1 { false };
2020-05-27 11:22:14 +02:00
Sergey Bugaev
ae21b8ee56 Base: Replace TTYServer with text mode Shell
Now that we have SystemServer that can (re)spawn the Shell, we don't need a
separate server just for that.

The two shells (on tty0 and tty1) are configured to only be started when booting
in text mode. This means you can now simply say boot_mode=text on the kernel
command line, and SystemServer will set up the system and spawn a comfy root
shell for you :^)
2020-05-27 11:19:38 +02:00
Sergey Bugaev
856e4853f4 SystemServer: Add BootModes and Environment service options
SystemServer will now look at the boot mode, as specified on the kernel command
line, and only launch the services configured for that boot mode.
2020-05-27 11:19:38 +02:00
Sergey Bugaev
df128821b2 Kernel: Introduce "boot_mode" and "init" cmdline options
Together, they replace the old text_debug option.

* boot_mode should be either "graphical" (the default) or "text". We could
  potentially support other values here in the future.
* init specifies which userspace process the kernel should spawn to bootstrap
  userspace. By default, this is SystemServer, but you can specify e.g.
  init=/bin/Shell to run system diagnostics.
2020-05-27 11:19:38 +02:00
Sergey Bugaev
f11270e7ce Kernel: Port VirtualConsole to LibVT :^)
Unfortunately this drops the feature of preserving VGA buffer contents.

Resolves https://github.com/SerenityOS/serenity/issues/2399
2020-05-27 11:19:38 +02:00
Sergey Bugaev
620697d924 LibVT: Move most of key press handling logic into VT::Terminal
This will let us share it between the userspace (TerminalWidget) and the Kernel.
2020-05-27 11:19:38 +02:00
Sergey Bugaev
fce49b3e32 LibGUI: Change GUI::KeyEvent::key() type to KeyCode
...instead of a plain int. Yay for some type safety.
2020-05-27 11:19:38 +02:00
AnotherTest
abfcd7b1b8 Shell: Save the history when quitting via the exit builtin 2020-05-27 11:13:02 +02:00
AnotherTest
ce61cad933 Shell: Never assign equal job ids to two different jobs
Since the last job need not have an ID of size()-1, we need to find the
max job id and give that+1 out
2020-05-27 11:13:02 +02:00
AnotherTest
790915da54 LibWeb: Provide some properties to inspectors of ResourceLoader 2020-05-27 11:13:02 +02:00
AnotherTest
d582c03233 Shell: Provide some information to inspectors 2020-05-27 11:13:02 +02:00
AnotherTest
e75f7ddb1b LibLine: Send over some properties when being inspected 2020-05-27 11:13:02 +02:00
AnotherTest
d5e9213683 Shell: Avoid messing with sigaction while waiting for a child 2020-05-27 11:13:02 +02:00
AnotherTest
70a213a6ec LibLine: Use Core::EventLoop for outer read loop
This commit changes LibLine's internal structure to work in an event
loop, and as a result, also switches it to being a Core::Object.
2020-05-27 11:13:02 +02:00
Luke
8e6df3949d LibTLS: Add more TLS 1.2 error descriptions
Adds more TLS 1.2 error descriptions according to the specification:
https://tools.ietf.org/html/rfc5246#section-7.2.2

This changes the DecryptionFailed description, as the specification
says that this alert should NEVER be sent by a compliant server.
2020-05-27 11:11:56 +02:00
TheDumpap
c700a30ce8 LibWeb: Handle additional parser inputs in "initial" and "before html". 2020-05-27 11:10:54 +02:00
Emanuele Torre
8d8c33833f LibWeb: s_initialized should be static in the AttributeNames initialiser 2020-05-27 09:57:38 +02:00
Andreas Kling
5049e41223 LibTLS: Put lots of debug spam behind TLS_DEBUG 2020-05-26 23:46:28 +02:00
Andreas Kling
b0eca4023f LibCrypto: Put some debug spam behind CRYPTO_DEBUG 2020-05-26 23:46:17 +02:00
Andreas Kling
4ec8b9f6ee LibWeb: Use FlyString in FontCache keys 2020-05-26 23:45:48 +02:00
Andreas Kling
82444048de LibWeb: Add cached global attribute name FlyStrings
Instead of creating extremely common FlyStrings like "id" and "class"
on demand every time they are needed, we now have AttributeNames.h,
which provides Web::HTML::AttributeNames::{id,class_}

This avoids a bunch of string allocations during selector matching.
2020-05-26 23:45:43 +02:00
Andreas Kling
5069d380a8 LibWeb: Let Element cache its list of classes
Instead of string splitting every time you call Element::has_class(),
we now split the "class" attribute value when it changes, and cache
the individual classes as FlyStrings in Element::m_classes.

This makes has_class() significantly faster and moves the pain point
of selector matching somewhere else.
2020-05-26 23:07:19 +02:00
Andreas Kling
16accb71a3 AK: Mark some popular String member functions ALWAYS_INLINE
I don't wanna see String::length() in a profile, jeez. :^)
2020-05-26 22:49:06 +02:00
Andreas Kling
7ed80ae96c LibWeb: Make the CSS parser a little more tolerant to invalid CSS
Sometimes people put a '}' where it doesn't belong, or various other
things go wrong. 99% of the time, it's our fault, but either way,
this patch makes us not crash or infinite-loop in some common cases.

The real solution here is to write a proper CSS lexer-parser according
to the language spec, this is just a hack fix to make more sites load
at all.
2020-05-26 22:31:22 +02:00
Linus Groh
72c52466e0 LibWeb: Add more HTML entities
®, ß and all the lowercase and uppercase umlaut characters.
2020-05-26 22:23:09 +02:00
Andreas Kling
f01af62313 LibWeb: Basic support for display:inline-block with width:auto
We now implement the somewhat fuzzy shrink-to-fit algorithm when laying
out inline-block elements with both block and inline children.

Shrink-to-fit works by doing two speculative layouts of the entire
subtree inside the current block, to compute two things:

1. Preferred minimum width: If we made a line break at every chance we
   had, how wide would the widest line be?
2. Preferred width: We break only when explicitly told to (e.g "<br>")
   How wide would the widest line be?

We then shrink the width of the inline-block element to an appropriate
value based on the above, taking the available width in the containing
block into consideration (sans all the box model fluff.)

To make the speculative layouts possible, plumb a LayoutMode enum
throughout the layout system since it needs to be respected in various
places.

Note that this is quite hackish and I'm sure there are smarter ways to
do a lot of this. But it does kinda work! :^)
2020-05-26 22:02:27 +02:00
FalseHonesty
4e8bcda4d1 LibWeb: Add HTML copyright escape 2020-05-26 22:02:17 +02:00
Kevin Meyer
b85ab86c84 LibWeb: Fix step within reconstruct the active elements
In step 4 of the "renstruct the active formatting elements" algorithm it
says:
  Rewind: If there are no entries before entry in the list of active
  formatting elements, then jump to the step labeled create.

Prior to this patch, the implementation accorded to the spec only for
the first loop iteration.
2020-05-26 21:52:46 +02:00
AnotherTest
8b3eb4535d LibLine: Use LibC's getline() when the terminal claims no support for escape sequences
We just look at $TERM and refuse to emit any escape sequences if it
doesn't start with "xterm".
This could be made much better, at detecting, and at not caling
getline().
2020-05-26 21:09:59 +02:00