Commit graph

13789 commits

Author SHA1 Message Date
Andreas Kling
f68ed6d25b LibWeb: Make DOM Nodes keep their Document alive
In addition to being reference-counted, all nodes that are part of a
document must also keep the document alive.

This is achieved by adding a second ref-count to the Document object
and incrementing/decrementing it whenever a node is created/destroyed
in that document.

This brings us much closer to a proper DOM lifetime model, although
the JS bindings still need more work.
2020-10-11 21:52:59 +02:00
Andreas Kling
99acbbe86b LibWeb: Remove unused Document::fixup()
This was some naive fixup mechanism we used before implementing a spec
compliant HTML parser.
2020-10-11 21:24:14 +02:00
Andreas Kling
ac8fe3d062 Kernel: Remove FIXME about unsurfaced error and log something
If something goes wrong when trying to write out a perfcore file during
process finalization, there's nowhere to report an error to, other than
the debug log. So write it to the debug log.
2020-10-10 23:47:53 +02:00
Kesse Jones
31791945ab FileManager: Added menu to show dotfiles in directory context menu 2020-10-10 23:29:18 +02:00
Matthew Olsson
455ce0b9c3 LibWeb: Create LayoutNodes for each SVG element
This brings the SVG API closer to the rest of LibWeb
2020-10-10 23:28:41 +02:00
Matthew Olsson
f2055bb509 LibWeb: Add a basic SVGContext object, add to PaintContext
This will be used to transmit any svg-relevant data between svg nodes.
This is prep for moving a lot of the SVG logic into Layout nodes.
2020-10-10 23:28:41 +02:00
Matthew Olsson
0b3b6310ec LibWeb: Add {before,after}_children_paint() methods
This allows layout nodes to do some setup before their children paint,
and cleanup after their children paint. This will be used for SVG
components, where their attributes (like stroke width, fill color, etc)
need to be correctly propogated to layout nodes down the line.
2020-10-10 23:28:41 +02:00
Matthew Olsson
236eeb6fb1 LibGfx: Add ability to get a bounding box from a Path 2020-10-10 23:28:41 +02:00
Luke
4155de2572 LibWeb: Cache the default font if we fail to find the specified font
This is a hack to stop chewing CPU on sites that use a font we don't
have and have a lot of text or changes text often.

Examples are the Serenity 2nd birthday page and the JS specification.
2020-10-10 23:25:19 +02:00
Linus Groh
a5bf6cfff9 LibJS: Don't change offset when reconfiguring property in unique shape
When changing the attributes of an existing property of an object with
unique shape we must not change the PropertyMetadata offset.
Doing so without resizing the underlying storage vector caused an OOB
write crash.

Fixes #3735.
2020-10-10 23:25:00 +02:00
Linus Groh
fcd263f17b FileManager: Fix file creation error message
s/String::format/String::formatted/ - the error message was not being
formatted properly.
2020-10-10 00:53:09 +02:00
Linus Groh
2d84c0c184 HackStudio: Fix running JavaScript files
s/String::format/String::formatted/ - the command was not being
formatted properly.
2020-10-10 00:53:09 +02:00
Linus Groh
e7c53bee16 Spreadsheet: Fix rendering of documentation examples
s/String::format/String::formatted/ - the Markdown source was not being
formatted properly.
2020-10-10 00:53:09 +02:00
Andreas Kling
6f74eaed42 LibWeb: Don't collapse blocks into the previous sibling's padding
We were forgetting to account for the padding-bottom of the previous
relevant sibling when placing blocks vertically.
2020-10-09 21:27:34 +02:00
Andreas Kling
0aa74074dd LibWeb: Ignore non-URL values for background-image for now 2020-10-09 21:27:01 +02:00
asynts
7c4fb2b804 HackStudio: Use new format functions. 2020-10-09 20:52:17 +02:00
asynts
3b601cd4bd LibGfx: Add formatter for Rect. 2020-10-09 20:52:17 +02:00
asynts
cf6980848b AK: Add formatter for LexcialPath. 2020-10-09 20:52:17 +02:00
asynts
7ae530fbc7 AK+Format: Remove new_dbg(dbg) and raw_dbg.
We are adding the process name as prefix and a newline as suffix to any
message written to debug. Thus, the following doesn't make any sense:

    for (u8 byte : bytes)
        dbg("{:02x} ", byte);
    dbgln();

Which function call would put the prefix? This doesn't make any sense,
thus these functions must go.

The example above could be converted to:

    StringBuilder builder;
    for (u8 byte : bytes)
        builder.appendff("{:02x} ", byte);
    dbgln("{}", builder.build());
2020-10-09 20:52:17 +02:00
Nico Weber
f3b4fbf01f LibWeb: In the HTML tokenizer, pretty up ON_WHITESPACE a tiny bit
No behavior change.
2020-10-09 17:40:19 +02:00
Lenny Maiorani
151b8b5984 Endian: constexpr constructors and conversion operators
Problem:
- Constructors and conversion operators are not `constexpr`,
  but they can be.
- `constexpr` is needed here so that other classes can add `constexpr`
  evaluation.

Solution:
- Add the `constexpr` keyword to the constructors and
  conversion operators.
- Add `static_assert` tests which ensure the capability works.
2020-10-08 23:28:54 +02:00
Matthew Olsson
e8da5f99b1 LibJS: break or continue with nonexistent label is a syntax error 2020-10-08 23:27:16 +02:00
Matthew Olsson
67f2301150 AK: Make StringView hashable 2020-10-08 23:27:16 +02:00
Matthew Olsson
6e05685ad4 LibJS: Fix return statements not working properly in loops
Previously, when a loop detected an unwind of type ScopeType::Function
(which means a return statement was executed inside of the loop), it
would just return undefined. This set the VM's last_value to undefined,
when it should have been the returned value. This patch makes all loop
statements return the appropriate value in the above case.
2020-10-08 23:23:55 +02:00
Matthew Olsson
d980073122 LibJS: Handle unwinding in while and do-while statements
For some reason, this was never added. So something like "while (true)
{ return }" would loop infinitely.
2020-10-08 23:23:55 +02:00
Nico Weber
397e5766ff LibGUI: Make arrow-left/right with selection move cursor to edge of selection
This matches behavior on Linux, macOS, Windows, and it makes it possible
to hit ctrl-L arrow-right ctrl-backspace to edit the last component of
an URL in browser, or of the current path in File Manager.

Also make it so that ctrl-left/right does a word movement that starts
at the edge of the selection. This matches Linux and macOS, but not
Windows (which instead does a word movement relative to the cursor,
not the selection edge).
2020-10-08 23:22:30 +02:00
Andreas Kling
95077f9a5d LibWeb: Apply the CSS background-image property to elements
Previously we'd only pick up background-image when it was part of the
background shorthand.

CSS property application remains hackish, lots of room for improvement
in this area. :^)
2020-10-08 23:21:39 +02:00
Andreas Kling
18b6c47178 LibGUI: Set initial AbstractButton background/foreground color roles
Widgets should respect the background/foreground roles in a way that
makes sense for the widget.
2020-10-08 23:21:39 +02:00
Andreas Kling
48647cc3ed Demos: Stop using Widget::foreground_color() 2020-10-08 23:21:39 +02:00
Linus Groh
e6709e3834 LibWeb: Handle theme change event in OutOfProcessWebView 2020-10-08 23:20:52 +02:00
Linus Groh
870dd44ba9 Help: Replace InProcessWebView with OutOfProcessWebView 2020-10-08 23:20:52 +02:00
Linus Groh
95a6019ff0 LibWeb: Add OutOfProcessWebView::load_empty_document()
This is cheating a little bit as we don't set the document to a nullptr
as in InProcessWebView, but the observable outcome is the same. :^)
2020-10-08 23:20:52 +02:00
Linus Groh
b797de3adf HackStudio: Replace InProcessWebView with OutOfProcessWebView 2020-10-08 23:20:52 +02:00
Linus Groh
f0ba536095 html: Replace InProcessWebView with OutOfProcessWebView 2020-10-08 23:20:52 +02:00
Linus Groh
4ef3a55900 html: Create URL from filename, if any
This makes it possible for the WebView to resolve relative paths in
documents loaded from a file.
2020-10-08 23:20:52 +02:00
Linus Groh
f6af2d747e TextEditor: Replace InProcessWebView with OutOfProcessWebView 2020-10-08 23:20:52 +02:00
Linus Groh
9f3789cdc7 LibWeb: Register the OutOfProcessWebView widget 2020-10-08 23:20:52 +02:00
Linus Groh
e40135fefd LibWeb: Add OutOfProcessWebView::load_html() 2020-10-08 23:20:52 +02:00
Linus Groh
216ccaf805 LibWeb: Handle PageClient::page_did_change_title() in Frame::set_document() 2020-10-08 23:20:52 +02:00
Linus Groh
a2a603d38a LibWeb: Add FrameLoader::load_html()
This moves responsibility for parsing and loading the document
from InProcessWebView to FrameLoader, so can be re-used easily.
2020-10-08 23:20:52 +02:00
Matthew Olsson
e49ea1b520 LibJS: Disallow 'continue' & 'break' outside of their respective scopes
'continue' is no longer allowed outside of a loop, and an unlabeled
'break' is not longer allowed outside of a loop or switch statement.
Labeled 'break' statements are still allowed everywhere, even if the
label does not exist.
2020-10-08 10:20:49 +02:00
Tibor Nagy
b85af075b7 Build: Emit paths in macros and debug sections relative to repo root
To avoid including paths from the build environment in the binaries.
A step towards having reproducible builds.
2020-10-08 10:04:02 +02:00
Matthew Olsson
9a82c22a85 LibJS: Disallow 'return' outside of a function 2020-10-08 10:03:21 +02:00
Linus Groh
5feb7e8d28 LibJS: Use PropertyName::from_value() in MemberExpression::computed_property_name()
No need for duplicating this logic.
2020-10-08 10:02:47 +02:00
Linus Groh
bc78e4b7da LibJS: Fix PropertyName::from_value() for negative and non-int numbers
It was converting *any* number to an i32 index, which obviously is not
correct for negative ints, doubles, infinity and nan.

Fixes #3712.
2020-10-08 10:02:47 +02:00
Lenny Maiorani
44d4423229 TCP: Remove unnecessarily defined constructor and destructor
Problem: Defining the destructor violates the "rule of 0" and prevents
the copy/move constructor/assignment operators from being provided by
the compiler.

Solution: Change the constructor and destructor to be the default
compiler-provided definition.
2020-10-08 10:01:10 +02:00
Nico Weber
9d27644b7d DHCPClient: Remove unused UPDSocket.h include 2020-10-08 10:00:39 +02:00
Nico Weber
8a01be4849 Kernel: Add some CPU feature flags related to TSC
In case we want to rely more on TSC in time keeping in the future, idk

This adds:

- RDTSCP, for when the RDTSCP instruction is available

- CONSTANT_TSC, for when the TSC has a constant frequency, invariant
  under things like the CPU boosting its frequency.

- NONSTOP_TSC, for when the TSC doesn't pause when the CPU enters
  sleep states.

AMD cpus and newer intel cpus set the INVSTC bit (bit 8 in edx of
extended cpuid 0x8000000008), which implies both CONSTANT_TSC and
NONSTOP_TSC. Some older intel processors have CONSTANT_TSC but not
NONSTOP_TSC; this is set based on cpu model checks.

There isn't a ton of documentation on this, so this follows Linux
terminology and http://blog.tinola.com/?e=54

CONSTANT_TSC:
39b3a79105

NONSTOP_TSC:
40fb17152c

qemu disables invtsc (bit 8 in edx of extended cpuid 0x8000000008)
by default even if the host cpu supports it. It can be enabled by
running with `SERENITY_QEMU_CPU=host,migratable=off` set.
2020-10-08 10:00:39 +02:00
asynts
1d96d5eea4 AK: Use new format functions. 2020-10-08 09:59:55 +02:00
asynts
560c52989c Demos: Use new format functions. 2020-10-08 09:59:55 +02:00