Commit Graph

27415 Commits

Author SHA1 Message Date
Brian Gianforcaro
a34ea51ca4 Fire: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
ddfdfc2342 Cube: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
12024aeda9 LibJS: Use ElapsedTimer::start_new(); 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
8476ad2e18 ChessEngine: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
f6d179b304 Shell: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
5df74c99ab Utilities: Use ElapsedTimer::start_new in allocate 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
74ee7cabf2 Utilities: Use ElapsedTimer::start_new() in disk_bechmark 2021-09-12 17:24:44 +00:00
Brian Gianforcaro
a2ee387683 LibCore: Add factory to create and start a new ElapsedTimer
Simplifies one of the main usage patterns of the timer class.
2021-09-12 17:24:44 +00:00
Mustafa Quraish
500a3fb2a7 Core/SecretString: Use memset_s instead of explicit_bzero on MacOS
MacOS doesn't have `explicit_bzero`, so this was causing errors when
compiling LibCore on the host.
2021-09-12 17:11:45 +00:00
Brian Gianforcaro
871ef7a735 AK+LibCore: Standardize on AK_OS_MACOS instead of __APPLE__
We use our custom platform definitions in most places, remove
the few remaining places we weren't using `AK_OS_MACOS`.
2021-09-12 18:31:10 +02:00
Linus Groh
51da5d03da LibWeb: Implement window.matchMedia() 2021-09-12 18:25:45 +02:00
Linus Groh
4155cc7ed5 LibWeb: Start implementing the MediaQueryList interface 2021-09-12 18:25:45 +02:00
Brian Gianforcaro
a61857eb0a Kernel: Use AK::to_underlying in lock rank tracking
AK::to_underlying simplifies the code a bit, instead of having to
manually cast to the underlying type.
2021-09-12 18:24:15 +02:00
Mustafa Quraish
2afa28d297 PixelPaint: Let PickerTool optionally sample all layers
Previously, only the color from the selected layer would be picked.
Now, we allow the user to select if they want to sample the color
from all layers.
2021-09-12 17:48:14 +02:00
Sam Atkins
640a980080 LibWeb: Parse CSS selectors with no space before a combinator
Previously selectors like `.foo>.bar` did not parse, because there is no
whitespace between `.foo` and `>`. Now we correctly parse these. :^)
2021-09-12 17:27:34 +02:00
Mustafa Quraish
bd83edf148 Base: Add ~/.config/PixelPaint.ini sample file
This is just a config file with the default options that PixelPaint
recognizes and reads so far. Adding this in since the options are
not really documented anywhere so at least the user can now know what
options are available.
2021-09-12 17:15:30 +02:00
Mustafa Quraish
70d13ea66b PixelPaint: Write changed settings back to config file
In a previous commit we read default values from a commit file, this
commit now also writes back any changes to those settings made by
the user. Persistent settings always feel good :^)
2021-09-12 17:15:30 +02:00
Mustafa Quraish
677aa7b769 PixelPaint: Use config to get default values for Guides/Rulers/PixelGrid
Someone may not want to have these things enabled by default on every
startup, but toggle them on manually. So instead of having hard-coded
everything to be enabled by default, we now query LibConfig to find
out what the preference is. These values can still always be changed
from the Menus / with shortcuts.

It's not really ideal querying LibConfig twice, but when initializing
the menu we may not have an active editor, so we need to get the
value for both the menu checkbox as well as the internal property.
This shouldn't be too much of a big deal since LibConfig caches the
values anyway :^)
2021-09-12 17:15:30 +02:00
Mustafa Quraish
dd0cc58d6c PixelPaint: Allow panning when right-clicking with MoveTool
The MoveTool now lets you pan if you're dragging with a right click.
Previously, right-clicking did not perform any actions at all, so this
isn't removing any old functionality.
2021-09-12 17:14:57 +02:00
Mustafa Quraish
abefe2391d PixelPaint: Add setter/getter for ImageEditor::m_pan_origin
This allows us to use tools to change the panned position, since
right now this is only accessible internally to the editor.
2021-09-12 17:14:57 +02:00
Brian Gianforcaro
189066d91d LibWeb: Log resource loading success, failure, and duration
When debugging why your website isn't loading in LibWeb the
resource loader is a blind spot as we don't have much logging
except on certain error paths. This can lead to confusing situations
where the browser just appears to hang.

This changes attempts to fix that by adding common success and
failure logging handlers so all resource loading outcomes can
are logged.
2021-09-12 16:39:23 +02:00
Brian Gianforcaro
bca8707e15 LibWeb: Start tracking elapsed time when a resource is loaded 2021-09-12 16:39:23 +02:00
Brian Gianforcaro
1d4be9ca33 LibCore: Enable elapsed time as AK::Time on a ElapsedTimer 2021-09-12 16:39:23 +02:00
Brian Gianforcaro
e92b576cba LibWeb: Include headers HashMap in the LoadRequest::hash() calculation 2021-09-12 16:39:23 +02:00
Brian Gianforcaro
54fe0c8855 AK: Add the ability to hash the contents of a AK::HashMap 2021-09-12 16:39:23 +02:00
Brian Gianforcaro
df04283d61 LibCore: Make Account::authenticate take a SecretString
To encourage users to use the SecretString API, change the API so that
Account::authenticate only accepts a SecretString.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
9e667453c7 LibCore: Make get_password return SecretString instead of String
We shouldn't let secrets sit around in memory, as they could potentially
be retrieved by an attacker, or left in memory during a core dump.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
3bf6902790 LibCore: Add SecretString, a buffer that is zero'd on destruction
We have a few places where we read secrets into memory, and then
do some computation on them. In these cases we should always make
sure we zero the allocations before they are free'd.

The SecureString wrapper provides this abstraction by wrapping a
ByteBuffer and calling explicit_bzero on destruction of the object.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
d158f2ed89 Kernel: Zero initialize SlabAllocator member variables
PVS-Studio flagged these as uninitialized. While there is no bug here,
it is our policy to always initialize members to avoid potential bugs
in the future.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
27a124f7d8 LibCrypto: Use explicit_bzero instead of memset to zero 'secure data'
PVS-Studio flagged this, as memset can be optimized away by the compiler
in some cases. We obviously don't want that to ever happen so make sure
to always use `explicit_bzero(..)` which can't be optimized away.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
3590c55b69 Utilities: Fix incorrect error handling in traceroute
The result will be -1 on error, and the error value will be stored in
errno. PVS-Studio found this because result it saw result < 0 and new
EFAULT is < 0, so this could never be true.
2021-09-12 16:36:52 +02:00
Andreas Kling
7691c7abcb LibWeb: Explicitly zero-initialize WindowObject::m_location_object 2021-09-12 16:32:12 +02:00
Sam Atkins
c66689ea76 LibWeb: Remove unused PropertyID parameter to StyleValue parsing methods
It's no longer used, and awkward to pass around.
2021-09-12 16:30:38 +02:00
Sam Atkins
8e4a4fd4db LibWeb: Remove "takes integer value" concept from parse_css_value()
This was only needed when numeric values had to be wrapped as Lengths,
and now serves no purpose.
2021-09-12 16:30:38 +02:00
Sam Atkins
2a141600a3 LibWeb: Correctly parse numeric and 'auto' z-index values
As with `opacity`, this code expected a Length value, when it is specced
to take a Number or `auto`. Now it's correct. :^)
2021-09-12 16:30:38 +02:00
Sam Atkins
b8c4320ffa LibWeb: Fix CSS opacity parsing
The StyleProperties code for opacity existed before NumericStyleValue
was a thing, and was affected by over-enthusiastic unitless-length
parsing, so it assumed everything was a length. Now it matches the
Color4 spec instead, accepting either a number, or a percentage.

We also get to remove the hack! :^)
2021-09-12 16:30:38 +02:00
Sam Atkins
8dc4f3763d LibWeb: Only apply the unitless-length quirk to needed properties
Previously, we applied the unitless length quirk to all numbers in
quirks mode. Now, we correctly only do so for the set of properties
listed in the quirks-mode spec:
https://quirks.spec.whatwg.org/#quirky-length-value

However, we do not yet prevent this quirk inside CSS expressions (like
`calc()`) as the spec directs.
2021-09-12 16:30:38 +02:00
Sam Atkins
3fa4f55f86 LibWeb: Add current_property_id to CSS ParsingContext
After `parse_css_value(PropertyID, TokenStream)`, we only need to know
the current PropertyID when checking for property-specific quirks, which
will take place in only 2 places, which happen deep down. Making the
current PropertyID part of the context means that those places can check
it easily, without us having to pass it to every one of the parsing
functions, which otherwise do not care.
2021-09-12 16:30:38 +02:00
Sam Atkins
af58bddfc8 LibWeb: Generate CSS::property_has_quirk() function
This lets you query if a given Quirk applies to a given PropertyID.
Currently this applies only to the "Hashless hex color" and "Unitless
length" quirks.
2021-09-12 16:30:38 +02:00
Sam Atkins
9c873fc4dc LibWeb: Add CSS quirks information to Properties.json
Two CSS quirks are specced to only apply to specific properties:

- The hashless hex color quirk
  https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
- The unitless length quirk
  https://quirks.spec.whatwg.org/#the-unitless-length-quirk

These are now represented in `Properties.json` like so:
```json
"property-name-here": {
    "quirks": [
        "hashless-hex-color",
        "unitless-length"
    ]
}
```

Every property that either of those two quirks applies to is included in
`Properties.json` and now has their quirks listed. :^)
2021-09-12 16:30:38 +02:00
Karol Kosek
c0709c4447 Playground: Ask to save file contents on quit action
Prior this change, activating the action instantly closed the program.
2021-09-12 16:30:25 +02:00
Tobias Christiansen
acf3e230b0 PixelPaint: Fix zooming to cursor
This patch fixes the behavior of zooming. Now the cursor stays over the
same spot in the image when zooming.
2021-09-12 16:30:09 +02:00
Sam Atkins
8ddce2faaf LibWeb: Don't assert if reconsuming on an empty TokenStream
This fixes #9978.

When a TokenStream is empty, reading its `current_token()` still returns
a token (for EOF) so it makes sense to allow users to
`reconsume_current_input_token()` that token, so they do not have to
handle that themselves. Instead of VERIFY()ing, we can just no-op when
reconsuming token 0.
2021-09-12 16:11:48 +02:00
Andreas Kling
f58f58fb77 LibWeb: Fix out-of-order DOM tree dumps
There were a few calls to the standalone version of dump_tree() inside
the recursive version of dump_tree(), which led to the output getting
jumbled out of order.
2021-09-12 16:07:35 +02:00
Luke Wilde
678dd2d180 LibWeb: Expose the location object via Document.location
Both Window.location and Document.location use the same instance of the
Location object. Some sites use it via Window, some via Document.
2021-09-12 16:07:24 +02:00
Luke Wilde
ee5bac0891 LibWeb: Implement some custom JS internal overrides for Location
As required by the spec. Note that this isn't the full suite of
overrides.
2021-09-12 16:07:24 +02:00
Linus Groh
7991077284 LibWeb: Implement window.event as a [Replaceable] property
This is the result of debugging React DOM, which would throw a TypeError
when assigning to window.event in strict mode and then not complete
rendering - here:
https://github.com/facebook/react/blob/cae6350/packages/shared/invokeGuardedCallbackImpl.js#L134

With this change, the following minimal React example now works!

    <div id="app"></div>
    <script src="react.development.js"></script>
    <script src="react-dom.development.js"></script>
    <script>
        ReactDOM.render(
            React.createElement("h1", null, "Hello World"),
            document.getElementById("app")
        );
    </script>
2021-09-12 15:53:48 +02:00
Linus Groh
a05c998e69 LibWeb: Add A JS setter macro for [Replaceable] IDL properties
The [Replaceable] attribute "indicates that setting the corresponding
property on the platform object will result in an own property with the
same name being created on the object which has the value being
assigned. This property will shadow the accessor property corresponding
to the attribute, which exists on the interface prototype object."
(https://heycam.github.io/webidl/#Replaceable)

The spec doesn't tell how exactly this is supposed to be done, but other
engines just have a setter as well that just redefines the property
as a data descriptor when called, and returns undefined.
It's bound to the property name and requires an object of the correct
type, so I mirrored these constraints here. Storing the setter and
calling it multiple times will therefore just work.

Implementing this in the wrapper generator is left as an exercise for
the reader, this is going to be used in WindowObject, which isn't
generated from IDL yet.
2021-09-12 15:53:48 +02:00
Linus Groh
c5bd382524 LibJS: Leave NativeFunction's Realm unset if VM has no Interpreter
There's currently a fallback at the call site where the Realm is needed
(due to a slightly incorrect implementation of [[Call]] / [[Construct]])
so this is better than crashing (in LibWeb, currently).
2021-09-12 15:18:25 +02:00
Linus Groh
7b92889e6b LibJS: Change Interpreter::create_with_existing_{global_object => realm}
We need both a GlobalObject and Realm now, but can get the former from
the latter (once initialized).
This also fixes JS execution in LibWeb, as we failed to set the Realm of
the newly created Interpreter in this function.
2021-09-12 15:18:25 +02:00