Commit Graph

43 Commits

Author SHA1 Message Date
Andrew Kaster
67ceba2e6a LibWeb: Add Exposed attribute and IDL spec links where missing
The intent is to use these to autogenerate prototype declarations for
Window and WorkerGlobalScope classes.

And the spec links are just nice to have :^)
2022-10-09 10:14:57 +02:00
Andreas Kling
e6ef366859 LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
2022-09-18 02:17:29 +02:00
Luke Wilde
6a4934a030 LibWeb: Implement document.domain getter
The document.domain setter is currently stubbed as that is a doozy to
implement, given how much restrictions there are in place to try and
prevent use of it and potential multi-process implications.

This was the only thing preventing us from being able to start
displaying ads delivered via Google Syndication.
2022-09-15 09:46:04 +02:00
MacDue
d4b2eb22e1 LibWeb: Resolve circular IDL imports
These circular imports led to the generator silently failing to
generate the required methods/properties.
2022-07-30 13:20:47 +02:00
Sam Atkins
d4c40e3aad LibWeb: Extract the ParentNode IDL mixin 2022-07-29 17:15:49 +01:00
Sam Atkins
79fdc08de9 LibWeb: Correct typo in Document.idl
Makes me wonder how things were working when Document was never
including GlobalEventHandlers.
2022-07-29 17:15:49 +01:00
Igor Pissolati
e2fa5c0cda LibWeb: Bring Document closer to spec 2022-04-12 19:42:16 +02:00
Idan Horowitz
d25bd2dbd8 LibWeb: Add the GlobalEventHandlers IDL mixin 2022-04-02 12:22:48 +04:30
Idan Horowitz
f45d361f03 LibWeb: Replace ad-hoc EventHandler type with callback function typedef 2022-03-31 01:10:47 +02:00
Andreas Kling
acbdb95b0a LibWeb: Add support for DOM's TreeWalker
This patch adds TreeWalker (created via Document.createTreeWalker())
which allows you to traverse a filtered view of the DOM in all
directions.
2022-03-09 16:43:55 +01:00
Andreas Kling
fabcee016f LibWeb: Add basic support for DOM's NodeIterator and NodeFilter
This patch adds NodeIterator (created via Document.createNodeIterator())
which allows you to iterate through all the nodes in a subtree while
filtering with a provided NodeFilter callback along the way.

This first cut implements the full API, but does not yet handle nodes
being removed from the document while referenced by the iterator. That
will be done in a subsequent patch.
2022-03-09 16:43:00 +01:00
Linus Groh
1422bd45eb LibWeb: Move Window from DOM directory & namespace to HTML
The Window object is part of the HTML spec. :^)
https://html.spec.whatwg.org/multipage/window-object.html
2022-03-08 00:30:30 +01:00
Lorenz Steinert
db789813c9 LibWeb: Add basic support for dynamic markup insertion
This implements basic support for dynamic markup insertion, adding
 * Document::open()
 * Document::write(Vector<String> const&)
 * Document::writeln(Vector<String> const&)
 * Document::close()

The HTMLParser is modified to make it possible to create a
script-created parser which initially only contains a HTMLTokenizer
without any data. Aditionally the HTMLParser::run method gains an
overload which does not modify the Document and does not run
HTMLParser::the_end() so that we can reenter the parser at a later time.
Furthermore all FIXMEs that consern the insertion point are implemented
wich is defined in the HTMLTokenizer. Additionally the following
member-variables of the HTMLParser are now exposed by getter funcions:
 * m_tokenizer
 * m_aborted
 * m_script_nesting_level

The HTMLTokenizer is modified so that it contains an insertion
point which keeps track of where the next input from the Document::write
functions will be inserted. The insertion point is implemented as the
charakter offset into m_decoded_input and a boolean describing if the
insertion point is defined. Functions to update, check and {re}store the
insertion point are also added.
The function HTMLTokenizer::insert_eof is added to tell a script-created
parser that document::close was called and HTMLParser::the_end() should
be called.
Lastly an explicit default constructor is added to HTMLTokenizer to
create a empty HTMLTokenizer into which data can be inserted.
2022-02-21 18:26:43 +01:00
Ali Mohammad Pur
a59800b4a0 LibWeb: Add imports to all IDL files that depend on others 2022-02-16 22:48:32 +03:30
Maciej
ed33ea13ab LibWeb: Add stubs for document.write and document.writeln
ACID3 test page throws exception about document.write. Let's at least
get rid of it by defining these stubs.

I added document.writeln too because it is similar.
2022-02-15 16:23:06 -05:00
Andreas Kling
545ec334f0 LibWeb: Add Document.hasFocus() stub
This always returns true for now. A proper implementation needs to check
if the document is in the focused widget within an active window.
2022-02-03 22:35:13 +01:00
Luke Wilde
d1bc9358c1 LibWeb: Implement ParentNode.replaceChildren 2022-01-31 15:25:36 +01:00
Luke Wilde
34dfdc3f37 LibWeb: Implement ParentNode.append 2022-01-31 15:25:36 +01:00
Luke Wilde
d5c96c3ccf LibWeb: Implement ParentNode.prepend
`convert_nodes_to_single_node` is inside its own file so ChildNode can
include and use it without having to include other headers such as
DOM/Node.h. This is to prevent circular includes.
2022-01-31 15:25:36 +01:00
Luke Wilde
2f7fb1fe63 LibWeb: Convert ParentNode.querySelectorAll to NodeList 2021-10-03 00:18:52 +02:00
Andreas Kling
975a71de45 LibWeb: Implement the Document.activeElement attribute
We were already tracking the active element in DOM::Document, so all we
had to do here was add the attribute to Document.idl :^)
2021-09-27 16:52:22 +02:00
Andreas Kling
e26e85a3d2 LibWeb: Support Document.hidden and Document.visibilityState
These just act as if the document is always visible for now.
2021-09-27 16:52:22 +02:00
Luke Wilde
27dfd0170e LibWeb: Implement Document.importNode 2021-09-26 18:59:19 +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
Luke Wilde
e4d97add3d LibWeb: Implement ParentNode.children
Required by Web Platform Tests for the innerHTML/outerHTML tests.
2021-09-14 02:09:18 +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
Andreas Kling
5c905acf1d LibWeb: Add naive support for the Document.referrer attribute
It always returns the empty string for now.
2021-09-11 14:10:11 +02:00
Luke
7f6baf8b17 LibWeb: Add Document.{images,embeds,plugins,links,forms,scripts} 2021-05-04 23:40:43 +01:00
Andreas Kling
b74bf31a53 LibWeb: Implement document.anchors
This returns an HTMLCollection of all <a> elements in the document that
have a "name" attribute.
2021-04-22 22:14:55 +02:00
Andreas Kling
43d16fa5b6 LibWeb: Implement document.applets
This is a legacy interface that returns an always-empty HTMLCollection.
2021-04-22 22:11:42 +02:00
Andreas Kling
e4df1b223f LibWeb: Implement a slow but functional HTMLCollection :^)
HTMLCollection is an awkward legacy interface from the DOM spec.

It provides a live view of a DOM subtree, with some kind of filtering
that determines which elements are part of the collection.

We now return HTMLCollection objects from these APIs:

- getElementsByClassName()
- getElementsByName()
- getElementsByTagName()

This initial implementation does not do any kind of caching, since that
is quite a tricky problem, and there will be plenty of time for tricky
problems later on when the engine is more mature.
2021-04-22 21:21:46 +02:00
Luke
83d2c3f2f5 LibWeb: Move element_child_count to ParentNode and add its IDL attribute
I initially had it in Node just because, but then saw it was part of
ParentNode in the spec.
2021-04-11 18:32:42 +02:00
Linus Groh
d8d16dea95 LibWeb: Add a basic implementation of Document.createEvent()
This is a legacy function providing a way of constructing events without
using their constructors exposed on the global object.
We don't have many of the events it supports yet, nor can we throw a
DOMException from it, so that's two FIXMEs for later.
2021-04-10 21:00:04 +02:00
Luke
5beacf08a2 LibWeb: Make the node mutation algorithms more spec compliant
The mutation algorithms now more closely follow the spec and
fixes some assertion failures in tests such as Acid3 and Dromaeo.

The main thing that is missing right now is passing exceptions to the
bindings layer. This is because of issue #6075. I spent a while trying
to work it out and got so frustrated I just left it as a FIXME. Besides
that, the algorithms bail at the appropriate points.

This also makes the adopting steps in the document more spec compliant
as it's needed by the insertion algorithm. While I was at it, I added
the adoptNode IDL binding.

This adds a bunch of ancestor/descendant checks to TreeNode as well.
I moved the "remove_all_children" function to Node as it needs to use
the full remove algorithm instead of simply removing it from
the child list.
2021-04-06 21:42:00 +02:00
Andreas Kling
36ea9fbd9e LibWeb: Stub out Document.cookie
We don't get/set anything, but at least scripts that access document
cookies can now progress further. :^)
2021-03-15 21:20:33 +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
9194a97cbe LibWeb: Add Document.createRange()
Also tidy up DOM::Range a little bit while we're here, and unify the
way we create them to use a delegating constructors.
2021-02-21 23:48:01 +01:00
Andreas Kling
15cfde7233 LibWeb: Expose the Window object as Document.defaultView
This should really be a WindowProxy? but since we don't have anything
representing that concept yet, let's just expose the Window object
directly so document.defaultView.foo works. :^)
2021-02-21 21:32:16 +01:00
Linus Groh
0f1da7d40c LibWeb: Add constructor to Document IDL interface 2021-02-17 23:45:07 +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
Luke
3f5532d43e LibWeb: Flesh out prepare_script and execute_script
This fills in a bunch of the FIXMEs that was in prepare_script.

execute_script is almost finished, it's just missing the module side.

As an aside, let's not assert when inserting a script element with
innerHTML.
2021-01-29 08:49:50 +01:00
Luke
449c6c5604 LibWeb: Add simple implementation of Document.createElementNS 2021-01-28 22:18:46 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00