Commit graph

9372 commits

Author SHA1 Message Date
Sam Atkins
e0a727bc76 LibWeb: Remove type checking from set_property_expanding_shorthands()
Now that the Parser checks that StyleValues are valid, we don't need to
do the checks here, since any value here is guaranteed to be acceptable.
2021-09-23 17:47:40 +02:00
Sam Atkins
f574f538d2 LibWeb: Use property_accepts_value() for parsing text-decoration 2021-09-23 17:47:40 +02:00
Sam Atkins
4bc9b9eaaa LibWeb: Use property_accepts_value() for overflow parsing 2021-09-23 17:47:40 +02:00
Sam Atkins
85254ada94 LibWeb: Fix auto conversion to identifier
Calling `is_identifier()` here was wrong, since it just means you can
get an Identifier from it. This meant that an `auto` LengthStyleValue
would return true, then it would get `static_cast` to the wrong class,
and return a garbage value.

Basically, I really need to tidy up the API for StyleValue, so it's
clear whether `is_foo()` means the object is a `FooStyleValue`, or it
can just return a `foo` value.
2021-09-23 17:47:40 +02:00
Sam Atkins
b08094bccc LibWeb: Use property_accepts_value() for list style parsing 2021-09-23 17:47:40 +02:00
Sam Atkins
dcf70ab821 LibWeb: Use property_accepts_value() for font parsing 2021-09-23 17:47:40 +02:00
Sam Atkins
b927972da7 LibWeb: Add range-checking to property_accepts_value()
For `number` and `integer` types, you can add a range afterwards to add
a range check, using similar syntax to that used in the CSS specs. For
example:

```json
"font-weight": {
  ...
  "valid-types": [
    "number [1,1000]"
  ],
  ...
}
```

This limits any numbers to the range `1 <= n <= 1000`.
2021-09-23 17:47:40 +02:00
Sam Atkins
e262596ee1 LibWeb: Use property_accepts_value() for parsing flexbox properties 2021-09-23 17:47:40 +02:00
Sam Atkins
37e69fb286 LibWeb: Use property_accepts_value() when parsing borders 2021-09-23 17:47:40 +02:00
Sam Atkins
5213760e4b LibWeb: Use property_accepts_value() for background parsing
We also get rid of `is_background_{image,repeat}()` since they're no
longer needed. :^)
2021-09-23 17:47:40 +02:00
Sam Atkins
35eb8b0dc2 LibWeb: Add better debug logging for CSS parsing errors
Hidden behind `CSS_PARSER_DEBUG`, so I won't drive everyone else crazy.
:^)
2021-09-23 17:47:40 +02:00
Sam Atkins
5d6a4c5fc2 LibWeb: Check parsed CSS values with property_accepts_value()
This brings us a few nice benefits:

- We only generate a `StyleValueList` for properties that accept
  multiple values.
- We reject declarations that have too many values.
- We check the type of each value that is parsed, to make sure it's
  acceptable to the property.

Probably there are some regressions here, since this is

Later, we can also replace many of the `is_foo()` functions and lambas
inside the Parser with more calls to `property_accepts_value()`. Also we
can remove some checks when resolving styles, since only valid types of
values will get to that point. But one step at a time. :^)
2021-09-23 17:47:40 +02:00
Sam Atkins
633ede5c6c LibWeb: Add valid-value information to Properties.json 2021-09-23 17:47:40 +02:00
Sam Atkins
57168150aa LibWeb: Add several CSS identifiers to the list
These ones are needed by the value-checking system, coming next.
2021-09-23 17:47:40 +02:00
Sam Atkins
603f611ceb LibWeb: Sort StyleValue enums alphabetically
I was finding it impossible to find them.
2021-09-23 17:47:40 +02:00
Sam Atkins
4a1dbb4f36 LibWeb: Move color identifier checking to StyleValue::is_color()
This allows us to perform this check outside of the CSS Parser.
2021-09-23 17:47:40 +02:00
Sam Atkins
e40ea819d9 LibWeb: Prevent special-case CSS property parsing fallback
We don't want a property like `background` to fall back to parsing as a
single value or StyleValueList if `parse_background_style_value()`
fails. We just want it to fail.
2021-09-23 17:47:40 +02:00
Karol Kosek
620e4fd0d2 WebContent: Pass an empty bitmap object if the pointer is null
Prior this commit we were always dereferencing the image bitmap pointer,
even if it was null, which resulted in a crash when trying to open
the context menu when an image wasn't loaded.

Closes: #10178
2021-09-22 22:10:11 +02:00
Tobias Christiansen
a501a02851 LibWeb: Ignore negative margins for calculating height in a BFC
Negative margins are a headache anyways, and allowing them to be
negative lead to weird behavior.
This patch avoids vasty wrong height-calculations by limiting the
allowed margins to positive numbers when evaluating the height of a
block.
2021-09-22 22:06:52 +02:00
thankyouverycool
bbaebdcd00 FontEditor: Keep selected glyph in view on resize 2021-09-22 21:35:42 +02:00
thankyouverycool
efe44451ca FontEditor: Make update_{statusbar,preview} member functions
For use outside constructor. Renames demo to preview to make
the UI and code comport.
2021-09-22 21:35:42 +02:00
thankyouverycool
3159e548a5 LibGUI: Calculate unclamped_scrubber_size() as float
Large enough content ranges produced unclamped scrubbers sized zero,
effectively clamped by their integer type. This led to zero sized
page_increments and scrubbers which didn't budge on gutter events.
This fixes broken gutters in FontEditor and TextEditor for large
files.
2021-09-22 21:35:42 +02:00
thankyouverycool
e8f3fda3cf FontEditor: Remove reprobe_font()
This was used to update GlyphMapWidget on Type changes and is
no longer needed since removal of Type enumeration in bb592ae.
2021-09-22 21:35:42 +02:00
thankyouverycool
144d32d537 FontEditor: Sanitize RTL and control glyphs in Clipboard metadata
Fixes display issues in ClipboardHistory.
2021-09-22 21:35:42 +02:00
thankyouverycool
0a4640e892 FontEditor: Put glyph width changes on the undo stack
And select the restored glyph on undo/redo.
2021-09-22 21:35:42 +02:00
thankyouverycool
1ae4caca4b FontEditor: Set width to zero when deleting a glyph
Previously, Delete left a glyph's width maximized.
2021-09-22 21:35:42 +02:00
thankyouverycool
ca6cb6cec3 FontEditor: Simplify initialization by disabling widget callbacks
Reduces some complexity dealing with callback effects and fixes
redundant calls to update_title and erroneously set glyph widths.
2021-09-22 21:35:42 +02:00
thankyouverycool
92fffc3abc LibGUI: Rename CallOnChange => AllowCallback and implement elsewhere
This is a helpful option to prevent unwanted side effects, distinguish
between user and programmatic input, etc. Sliders and SpinBoxes were
implementing it idiosyncratically, so let's generalize the API and
give Buttons and TextEditors the same ability.
2021-09-22 21:35:42 +02:00
Luke Wilde
d47e431d54 LibWeb: Add getElementsByTagNameNS and add support for * in non-NS
This also moves getElementsByTagName to ParentNode to remove the code
duplication between Document and Element. This additionally fixes a bug
where getElementsByTagName did not check if the element was a
descendant, meaning it would also include the context element if the
condition matched.
2021-09-22 20:33:06 +02:00
Sam Atkins
5c7dca3526 LibWeb: Stop rejecting valid values for several CSS properties
In StyleResolver, we were rejecting single values for properties that
take 1-4: `border-color`, `border-style`, and `border-width`. Now, we
handle them correctly. I also added support for `calc()` and `var()` to
`padding` and `margin`.

This fixes the orange border on Acid2, which now correctly appears
black. :^)
2021-09-22 20:32:35 +02:00
Andreas Kling
635ab6db0b LibWeb: Expose the GlobalEventHandlers mixin on the Window object
We now expose all the `onfoo` event handler attributes on the window
object. This makes `window.onload = ...` actually work. :^)
2021-09-22 16:40:24 +02:00
Andreas Kling
fb2f7c7b9c LibWeb: Remove unnecessary WindowObject.h include in DOMException.h 2021-09-22 15:37:50 +02:00
Andreas Kling
1884e2caf1 LibWeb: Add DOM::ExceptionOr<T> to forwarding header 2021-09-22 15:37:21 +02:00
Andreas Kling
fccf0a466b LibWeb: Log resource load success before invoking success callback
The success callback may trigger JavaScript execution, causing resource
load times to appear much longer than they actually are. :^)
2021-09-22 14:35:13 +02:00
Andreas Kling
784ab75d2d LibCoredump: Don't copy uncompressed coredumps into a ByteBuffer
This was completely unnecessary and accounted for 6% of the total time
spent when loading a WebContent coredump into CrashReporter.
2021-09-22 00:40:07 +02:00
Idan Horowitz
1da8faebf5 LibJS: Convert perform_eval to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
e24d4c346d LibJS: Add VM::throw_completion helper for throwing custom Strings 2021-09-21 23:28:38 +03:00
Idan Horowitz
f302b114f3 LibJS: Convert get_substitution to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
69430855e0 LibJS: Remove non-specification compliant exception check 2021-09-21 23:28:38 +03:00
Idan Horowitz
e90e4ac1e2 LibJS: Convert length_of_array_like to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
02a88c5063 LibJS: Convert make_super_property_reference to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Andreas Kling
9d7fe39640 CrashReporter: Show coredump loading progress in the Taskbar :^) 2021-09-21 20:52:29 +02:00
Andreas Kling
f6f9599899 CrashReporter+LibCoredump: Show progress window while loading coredump
Some coredumps take a long time to symbolicate, so let's show a simple
window with a progress bar while they are loading.

I'm not super happy with the factoring of this feature, but it's an
absolutely kickass feature that makes crashing feel 100% more responsive
than before, since you now get GUI feedback almost immediately after a
crash occurs. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling
4f224b15ed CrashDaemon+CrashReporter: Streamline crash reporting a little bit
Before this patch, this is what would happen after something crashed:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon compresses the new coredump (gzip)
3. CrashDaemon parses the uncompressed coredump and prints a backtrace
4. CrashDaemon launches CrashReporter
5. CrashReporter parses the uncompressed coredump (again)
6. CrashReporter unlinks the uncompressed coredump
7. CrashReporter displays a GUI

This was taking quite a long time when dealing with large programs
crashing (like Browser's WebContent processes.)

The new flow:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon mmap()'s the (uncompressed) coredump
3. CrashDaemon launches CrashReporter
4. CrashDaemon goes to sleep for 3 seconds (hack alert!)
5. CrashReporter parses the (uncompressed) coredump
6. CrashReporter unlinks the (uncompressed) coredump
7. CrashReporter displays a GUI
8. CrashDaemon wakes up (after step 4)
9. CrashDaemon compresses the coredump (gzip)

TL;DR: we no longer parse the coredumps twice, and we also prioritize
launching the CrashReporter GUI immediately when a new coredump shows
up, instead of compressing and parsing it in CrashDaemon first.

The net effect of this is that you get a backtrace on screen much
sooner. That's pretty nice. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling
38b0200151 LibCoredump: Make Backtrace getters return const references 2021-09-21 20:52:29 +02:00
Idan Horowitz
e12a707ca1 checksum: Stop reusing the same Core::File for multiple files
Since we were just repeatedly calling `->open()` on the same Core::File
no one was clearing it's internal buffer, which means hashing multiple
files in one go would result in different hashes than hashing each file
separately.
2021-09-21 20:36:19 +03:00
Linus Groh
d792869799 LibJS: Update spec comment to convert mathematical to number value
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d2ae357
2021-09-21 19:13:22 +02:00
Andreas Kling
ca45d34055 LibWeb: Don't add shorthand CSS properties to cascaded values
We already expand shorthands in the cascade, so there's no need to
preserve them in the output.

This patch reorganizes the CSS::PropertyID enum values so that we can
easily iterate over all shorthand or longhand properties.
2021-09-21 16:54:28 +02:00
Sam Atkins
e07cf6f41b LibWeb: Paint bitmaps with rounded_int_rect(), not enclosing_int_rect()
This fixes the issue where an `<img>` set to its native size would
sometimes still appear blurry, because it had a fractional position,
causing `enclosing_int_rect()` to expand by 1px.
2021-09-21 16:53:46 +02:00
Sam Atkins
0b7eefd4e5 LibGfx: Add rounded_int_rect() function for Rects
We were seeing a problem in LibWeb, where layout elements would be 1px
larger than they should be, due to layout positions using float values,
and then converting using `enclosing_int_rect()`. `rounded_int_rect()`
replaces that use, by maintaining the original rect's size.
2021-09-21 16:53:46 +02:00