Commit Graph

10506 Commits

Author SHA1 Message Date
Andreas Kling
784ed004e6 LibWeb: Implement <center> as -libweb-center
To get the expected behavior for <center>, we needed a special text
alignment mode that centers block-level elements (and not just line
box fragments.)
2020-06-13 12:49:20 +02:00
Andreas Kling
6de937a689 LibWeb: Turn <table bgcolor> into CSS background-color
More presentational attribute stuff. HN looking more and more like it's
supposed to. :^)
2020-06-13 12:49:20 +02:00
Andreas Kling
0b4f92e452 LibWeb: Tweak UA style to reset text-align on table elements
I think maybe this is only supposed to happen in quirks mode but I'm
not entirely sure. This makes "<center><table>..." behave as expected.
2020-06-13 12:49:20 +02:00
Matthew Olsson
b155e64b67 LibJS: Add JSON.parse 2020-06-13 12:43:22 +02:00
Matthew Olsson
e8e728454c AK: JsonParser improvements
- Parsing invalid JSON no longer asserts
    Instead of asserting when coming across malformed JSON,
    JsonParser::parse now returns an Optional<JsonValue>.
- Disallow trailing commas in JSON objects and arrays
- No longer parse 'undefined', as that is a purely JS thing
- No longer allow non-whitespace after anything consumed by the initial
  parse() call. Examples of things that were valid and no longer are:
    - undefineddfz
    - {"foo": 1}abcd
    - [1,2,3]4
- JsonObject.for_each_member now iterates in original insertion order
2020-06-13 12:43:22 +02:00
Matthew Olsson
39576b2238 LibJS: Add JSON.stringify 2020-06-13 12:43:22 +02:00
Hüseyin ASLITÜRK
b4577ffcf3 Kernel: KeyboardDevice, remove char mapping logic
Remove char mapping logic and constant character map.
2020-06-13 12:36:30 +02:00
Hüseyin ASLITÜRK
f4d14c42d0 Kernel: Process, replace internal data type to CharacterMapData 2020-06-13 12:36:30 +02:00
Hüseyin ASLITÜRK
f79b410baa LibKeyboard: Move character map from Kernel to LibKeyboard 2020-06-13 12:36:30 +02:00
Hüseyin ASLITÜRK
3ebdb5ea30 Application: KeyboardMapper, make button to like a real key
Change key paint to more like a real key :)
2020-06-13 12:36:30 +02:00
Hüseyin ASLITÜRK
8733da652e Base: Add numpad keys to keymap files 2020-06-13 12:36:30 +02:00
Andreas Kling
384b5f15c9 LibWeb: Sort matched style rules by specificity, document order
If two rules have equal specificity, they should be applied in the
order in which we encountered them.
2020-06-13 00:44:26 +02:00
Andreas Kling
fa5e8be31c LibWeb: Fix broken Specificity::operator== 2020-06-13 00:43:32 +02:00
Andreas Kling
ae3e5e9d37 LibWeb: Include selector pseudo-class in style sheet dumps 2020-06-13 00:43:06 +02:00
Andreas Kling
256898431c LibWeb: Simplify Node::is_link()
No need to check for presence of the href attribute as that is already
checked by enclosing_link_element().
2020-06-13 00:23:32 +02:00
Andreas Kling
483b371a7b LibWeb: Parse and match the :visited pseudo-class (always fails)
If we don't do this, something like "a:visited" is parsed as "a" which
may then take precedence over a previous "a:link" etc.
2020-06-13 00:23:30 +02:00
Andreas Kling
62893a54cc LibWeb: More work on table layout
Table row layout is now split into two phases:

1. Compute all the column widths (even taking colspan into account!)
2. Place all cells at the correct x,y offsets based on column widths.

Both phases visit all rows and all cells.
2020-06-13 00:12:23 +02:00
Andreas Kling
365703e3f3 LibWeb: Allow url("foo") and url('foo') in CSS background-image values
This is very hackish and will be fixed by writing a proper CSS parser.
2020-06-13 00:11:38 +02:00
Andreas Kling
0306ada1ff LibWeb: Add "colspan" to HTML::AttributeNames 2020-06-13 00:11:14 +02:00
Andreas Kling
0061a82be3 LibWeb: Add LayoutTableCell::colspan()
A convenient function for looking up a cell's colspan attribute.
2020-06-13 00:10:52 +02:00
Andreas Kling
196a3986d6 LibWeb: First cut of extremely naive table row layout
This first version simply auto-sizes all table cells and then places
them on a horizontal line.
2020-06-12 23:18:51 +02:00
Andreas Kling
c5a3d99dd5 LibWeb: Turn <table width> into the CSS width property 2020-06-12 22:52:38 +02:00
Andreas Kling
ca41c2e4a0 LibWeb: Turn <td bgcolor> into background-color 2020-06-12 22:47:51 +02:00
Andreas Kling
e9e2226544 LibWeb: Add "bgcolor" to HTML::AttributeNames 2020-06-12 22:47:41 +02:00
Andreas Kling
6f19067c9a LibWeb+Browser: Add a barebones LayoutTreeModel to the inspector window
This allows you to inspect the layout tree, along side the DOM tree.
It will need more functionality to be truly useful, but it's a start.
2020-06-12 22:30:11 +02:00
Andreas Kling
68ae1de463 Browser: Be a little bit smarter about interpretering command line URLs
If the (optional) URL specified on the command line is an existing file
we now resolve its real path before turning into a URL. This makes
relative URLs inside the loaded document work correctly.

Also interpret all other specified URLs the same way we would if you
had typed them into the location bar.
2020-06-12 21:29:27 +02:00
Andreas Kling
d54ace5f04 LibCore: Add Core::File::real_path_for()
A slightly convenient wrapper around realpath(3).
2020-06-12 21:29:01 +02:00
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
sppmacd
15f4043a7a AudioServer: removed AS prefix from class and file names
And moved everything to AudioServer namespace
2020-06-12 20:42:22 +02:00
Andreas Kling
c91981eba8 LibWeb: Handle negative values when collapsing vertical margins
In the presence of negative margins, we subtract the largest negative
margin from max(0, largest positive margin).
2020-06-12 18:47:18 +02:00
Andreas Kling
21b1f1653d LibWeb: Implement very basic margin collapsing
We now collapse a block's top margin with the previous sibling's
bottom margin so that the larger margin wins.
2020-06-12 18:47:18 +02:00
Kevin Meyer
88673f3f85 LibIPC: Use create_single_shot to construct timer 2020-06-12 18:29:55 +02:00
Sergey Bugaev
f1566ed4c6 AK: Remove useless casts 2020-06-12 16:08:45 +02:00
Sergey Bugaev
3ff651323c AK: Ensure RefCounted types are never copied or moved
Before this, it has been possible to assign a RefCounted object to another
RefCounted object. Hilariosly (or sadly), that copied the refcount among
the other fields, meaning the target value ended up with a wrong refcount.

Ensure this never happens by disallowing copies and moves for RefCounted types.
2020-06-12 16:08:45 +02:00
Sergey Bugaev
0ff3c1c34d AK: Assert refcount doesn't overflow
We don't really have a good way to prevent this kind of overflow,
but let's at least immediately panic in this case.
2020-06-12 16:08:45 +02:00
Sergey Bugaev
c80e657dda AK: Switch RefCounted to atomic refcounting
This fixes all sorts of race conditions, primarily in the kernel, where till
now it's been possible to obtain either double free or use-after-free by
exploiting refcounting races.
2020-06-12 16:08:45 +02:00
Sergey Bugaev
583108004c AK: Use unsigned int for refcount
And while fixing all the tests that look at ref_count(),
sneak in a fix for the test suite name.
2020-06-12 16:08:45 +02:00
Sergey Bugaev
0466810638 AK: Ensure we never use OwnPtr<> with RefCounted types 2020-06-12 16:08:45 +02:00
Sergey Bugaev
62d1ac63e8 MenuApplets: Fix using OwnPtr<> with RefCounted types 2020-06-12 16:08:45 +02:00
Sergey Bugaev
eb3700c565 Calendar: Fix using OwnPtr<> with RefCounted types 2020-06-12 16:08:45 +02:00
Sergey Bugaev
5624f8d8ee AK: ALWAYS_INLINE most Atomic<T> methods 2020-06-12 16:08:45 +02:00
Sergey Bugaev
4d65466f02 AK: Fix missing ptrdiff_t in non-Serenity builds
We have to include <stddef.h> to get its definition.
2020-06-12 16:08:45 +02:00
Andreas Kling
08f29be87a LibWeb: Remove absolutely positioned elements from the normal flow
Skip over absolutely positioned children when laying out the inline
children of a block. This takes them out of the flow and allows them
to be positioned correctly relative to the (absolute) containing block.
2020-06-12 15:27:52 +02:00
Andreas Kling
f3ea8d49a9 LibWeb: Remove absolute positioning logic from LayoutReplaced
Absolutely positioned elements are placed by their containing block.
Instead of trying to compute its own position, LayoutReplaced will
now simply add itself as an absolutely positioned descendant of its
containing block.
2020-06-12 15:24:33 +02:00
Andreas Kling
137f6d44ec LibWeb: Add basic support for position:fixed
Fixed position elements have the ICB as their containing block.
The magic of fixed positioning is implemented at the rendering stage,
where we temporarily translate painting by the current scroll offset.

Note that "absolutely positioned" includes both position:absolute
and position:fixed.
2020-06-12 14:20:07 +02:00
Andreas Kling
bd33bfd120 LibWeb: Whine about unrecognized CSS properties in debug log 2020-06-12 14:15:55 +02:00
Andreas Kling
9cbef10bdd LibWeb: Rename BoxModelMetrics::full_margin() => margin_box()
This matches the other member names (padding_box() and border_box().)
2020-06-12 13:44:11 +02:00
Andreas Kling
260427f0ad LibWeb: Some improvements to absolute positioning
Absolutely positioned blocks now register themselves with their
containing block (and note that the containing block of an absolutely
positioned box is the nearest non-statically positioned block ancestor
or the ICB as fallback.)

Containing blocks then drive the layout of their tracked absolutely
positioned descendants as a separate layout pass.

This is very far from perfect but the general direction seems good.
2020-06-12 13:43:46 +02:00
Andreas Kling
ff2c949d70 LibWeb: Include class names in layout tree dumps
This makes it a lot easier to see which layout node is which DOM node.
2020-06-12 13:23:07 +02:00
Andreas Kling
6f1b5fc0ab LibIPC: Actually use the new Core::Timer::restart() I just added
Thanks @brynet for noticing. :^)
2020-06-12 09:13:27 +02:00