Commit Graph

38 Commits

Author SHA1 Message Date
Andreas Kling
b092353e4d LibWeb: Add basic support for HTMLInputElement.form
HTMLInputElement now inherits from FormAssociatedElement, which will
be a common base for the handful of elements that need to track their
owner form (and register with it for the form.elements collection.)

At the moment, the owner form is assigned during DOM insertion/removal
of an HTMLInputElement. I didn't implement any of the legacy behaviors
defined by the HTML parsing spec yet.
2021-04-20 12:05:56 +02:00
Timothy Flynn
3cc5286565 LibWeb: Helper for creating load requests with a Cookie header
Instead of all interested parties needing to write out the code to get
the cookie value for a load request, add a static helper to do it in
one location.
2021-04-15 09:46:49 +02:00
Timothy Flynn
c2d38abe6f Browser+LibWeb: Move cookie parser into LibWeb
This moves the cookie parsing steps out of CookieJar into their own file
inside LibWeb. It makes sense for the cookie structures to be in LibWeb
for a couple reasons:

1. There are some steps in the spec that will need to partially happen
   from LibWeb, such as the HttpOnly attribute.
2. Parsing the cookie string will be safer if it happens in the OOP tab
   rather than the main Browser process. Then if the parser blows up due
   to a malformed cookie, only that tab will be affected.
3. Cookies in general are a Web concept not specific to a browser.
2021-04-14 16:07:46 +02:00
Luke
9e338a2be2 LibWeb: Add ProcessingInstruction node
Not particuarly useful right now, but is used in
ensure_pre_insertion_validity.

I'm not totally sure on the constructor arguments.
2021-04-06 21:42:00 +02:00
Timothy Flynn
d8106dda73 LibWeb: Add "Label" to be the layout node for HTMLLabelElement
The HTML <label> element is special in that it may be associated with
some other <input> element. When the label element is clicked, the input
element should be activated.

To achieve this, a LableableNode base class is introduced to provide an
interface for "labelable" elements to handle mouse events on their
associated labels. This not only allows clicking the label to activate
the input, but dragging the mouse from the label to the input (and vice-
versa) while the mouse is clicked will also active the label.

As of this commit, this infrastructure is not hooked up to any elements.
2021-04-04 16:13:25 +02:00
Linus Groh
340e1f4b28 LibWeb: Implement the Screen interface
https://drafts.csswg.org/cssom-view/#the-screen-interface
2021-04-04 00:37:54 +02:00
Timothy Flynn
b50de19cd3 LibWeb: Add support for HTML input type=radio 2021-04-03 15:39:46 +02:00
Andreas Kling
dcfc357860 LibWeb: Add a FrameHostElement for frame/iframe common functionality
A FrameHostElement is an HTML element (<frame> or <iframe>) that may
have a content frame that participates in the frame tree.

This basically just moves code from <iframe> to a separate base class
so we can share it with <frame> once we implement <frame>.
2021-04-03 11:57:32 +02:00
Andreas Kling
036b5c2804 LibWeb: Import new CSS parser
It's not finished or hooked up to anything yet, but let's get it into
the tree so we can continue working on it.

Original work by @stelar7.
2021-03-22 18:40:08 +01:00
Luke
31f7296934 LibWeb: Add legacy Image factory function 2021-03-21 09:37:25 +01:00
Andreas Kling
4559faf8d8 LibWeb: Support named CSS properties on CSSStyleDeclaration wrapper
Use the new CustomGet/CustomPut wrapper mechansim to intercept gets and
puts on CSSStyleDeclaration objects. This allows content to get and set
individual CSS properties from JavaScript. :^)
2021-03-15 21:20:33 +01:00
Andreas Kling
33e3f0c71f LibWeb: Expose barebones CSSStyleDeclaration to JavaScript
You can now access an element's inline style via Element.style.
The interface is not very capable yet though. :^)
2021-03-13 22:41:32 +01:00
Andreas Kling
0759f54bd3 LibWeb: Rename StyleDeclaration => CSSStyleDeclaration to match CSSOM 2021-03-13 22:41:32 +01:00
Andreas Kling
ad152bfa59 LibWeb: Add a whole bunch of rule classes for the new CSS parser
Original work by @stelar7.
2021-03-09 17:36:21 +01:00
Andreas Kling
16cde3f14a LibWeb: Rename CSSParser => DeprecatedCSSParser 2021-03-09 17:35:57 +01:00
Andreas Kling
078f0a5c67 LibWeb: Add specification-based CSS tokenizer
Original work by @stelar7 for #2628.
2021-03-09 17:35:38 +01:00
Andreas Kling
a9830d9a55 LibWeb: Start exposing CSS style sheets to JavaScript :^)
This patch adds bindings for the following objects:

- StyleSheet
- StyleSheetList
- CSSStyleSheet

You can get to a document's style sheets via Document.styleSheets
and iterate through them using StyleSheetList's item() and length().

That's it in terms of functionality at this point, but still neat. :^)
2021-03-08 11:50:36 +01:00
Andreas Kling
fefb05f6f3 LibWeb: Split CSS::StyleSheet into StyleSheet and CSSStyleSheet
This is a little convoluted but matches the CSSOM specification.
2021-03-07 17:45:15 +01:00
Andreas Kling
0af4762662 LibWeb: Rename StyleRule => CSSStyleRule
This matches the CSSOM specification.
2021-03-07 17:45:15 +01:00
Sviatoslav Peleshko
183ebaee91 LibWeb: Add actual document loading for the CSS (at)import rule 2021-02-28 10:27:32 +01:00
Sviatoslav Peleshko
54617e1a91 LibWeb: Added simple parsing for (at)import rules
For now, the parsing is very crude, and parses only the document url.
The meta queries for the import are ignored.
2021-02-28 10:27:32 +01:00
Sviatoslav Peleshko
04d67d0239 LibWeb: Create base class CSSRule for all CSS rules
This is a foundation for handling other ("at") CSS rules.
2021-02-28 10:27:32 +01:00
Linus Groh
ada71dc71b LibWeb: Add DOM::DOMException class and bindings 2021-02-20 00:09:11 +01:00
Andreas Kling
5e91e61900 LibWeb: Remove WidgetBox layout node
The approach of attaching sub-widgets to the web view widget was only
ever going to work in single-process mode, and that's not what we're
about anymore, so let's just get rid of WidgetBox so we don't have the
dead-end architecture hanging over us.

The next step here is to re-implement <input type=text> using LibWeb
primitives.
2021-02-10 09:13:30 +01:00
Andreas Kling
a59b1825ce LibWeb: Basic implementation of global event handlers :^)
Document and HTMLElement now inherit from HTML::GlobalEventHandlers
which allows them to support "onfoo" event handler attributes.

These are assignable both via IDL attributes and content attributes.

Event listeners constructed this way get a special "attribute" flag
on them so we know which one to replace if you reassign them.
This also allows them to coexist with EventTarget.addEventListener().

This is all a bit sloppy, but it works decently for a first cut.
The Window object should also inherit GlobalEventHandlers, but since
we don't generate it from IDL, I haven't taken that step here.

Also this would be a lot nicer if we supported IDL mixins.
2021-02-03 23:03:05 +01:00
Andreas Kling
342b787d1c LibWeb: Move main thread JavaScript VM to its own file
Instead of being a weird little global function in DOM/Document.cpp,
you can now get the main thread JS VM via Bindings::main_thread_vm().
2021-02-03 10:45:39 +01:00
Luke
0a1226344a LibWeb: Add XHREventTarget and have XHR inherit from it 2021-01-23 22:29:21 +01:00
Luke
4f2e154dbe LibWeb: Flesh out existing XHR methods a bit more
This makes open, send and setRequestHeader a bit more spec compliant and
adds a bunch of FIXMEs for unimplemented parts.
2021-01-23 22:29:21 +01:00
Andreas Kling
cfa2fb2eb3 LibWeb: Generate JS bindings for Range from IDL :^) 2021-01-23 17:59:42 +01:00
Andreas Kling
8363b3ae99 LibWeb: Generate JS bindings for XMLHttpRequest from IDL :^)
Remove the hand-written XHR bindings in favor of generated ones.
2021-01-23 15:06:09 +01:00
Andreas Kling
5b91362d4e LibWeb: Move XMLHttpRequest to separate XHR directory
In keeping with the one-directory-per-web-spec layout, let's move XHR
into its own clubhouse.
2021-01-23 11:51:36 +01:00
Emanuele Torre
68c8b52612 Build: Use cmake's make_directory utility instead of env(1) and mkdir(1)
..in CMake files.

Also, the `-S`s were unnecessary here since "mkdir" doesn't have any
spaces and these are not shebangs.
2021-01-22 22:14:42 +01:00
Jonathan Turner
0bf5669ba3
Meta: Get building on NixOS (#5005) 2021-01-22 17:44:05 +01:00
Andreas Kling
fd7920fa8f LibWeb: Add a very naive Layout::FlexFormattingContext :^)
This is very dumb and only lays out its child boxes on a horizontal
line with their shrink-to-fit widths.

You have to start somewhere! :^)
2021-01-18 20:20:13 +01:00
Andreas Kling
9e45594dc8 LibWeb: Stub out the PerformanceTiming object from Navigation Timing
Just have all the timing functions return 0 for now.

We can now run the Shynet JS on https://linus.dev/ although the XHR
is rejected by our same-origin policy.
2021-01-18 15:11:20 +01:00
Andreas Kling
252a98042d LibWeb: Generate constructor and prototype classes for IDL interfaces
This patch adds a FooPrototype and FooConstructor class for each IDL
interface we generate JS bindings for.

These classes are very primitive and don't do everything they should
yet, but we have to start somewhere. :^)

Work towards #4789
2021-01-18 12:18:29 +01:00
Andreas Kling
0db6835e73 LibWeb: Move HTML::SubmitEvent functions out of line 2021-01-18 12:18:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00