Commit Graph

201 Commits

Author SHA1 Message Date
Kevin Meyer
d5d732cc87 LibWeb: Fix EVENT_DEBUG dump compilation 2020-07-11 11:34:59 +02:00
Kevin Meyer
5b6920a18a LibWeb: Don't call did_layout in non-main frame documents
Fixes https://github.com/SerenityOS/serenity/issues/2649

Loading a page with iframes could lead to a scenario, where the iframe
document finished layout prior to the main frame beeing laid out
initially. This caused a crash/assertion of the browser.
2020-07-08 23:45:12 +02:00
Kevin Meyer
a5b8cc2d0b LibWeb: Add type for FrameLoader::load
This should enable to destinguish between IFrame, Reload and Navigation
motivated loads in order to call the appropriate hooks.

This change is motivated as loading the IFrame test page causes the
IFrame url to be added to the history and shows up as the current
browser location bar.
2020-07-08 23:45:12 +02:00
Andreas Kling
5975a425bd LibWeb: Turn floated display:inline elements into block-level elements 2020-07-07 17:10:12 +02:00
Andreas Kling
244fe1089c LibWeb: Use LayoutTableRowGroup for display:table-{header,footer}-group 2020-07-05 19:51:49 +02:00
Andreas Kling
b8dc1fc195 LibWeb: Turn <td width> into a CSS width property 2020-06-28 14:30:37 +02:00
Andreas Kling
9e642827fc LibWeb: Don't tolerate unit-less lengths (except 0) in standards mode
"width: 500" is not a valid CSS property in standards mode and should
be ignored.

To plumb the quirks-mode flag into CSS parsing, this patch adds a new
CSS::ParsingContext object that must be passed to the CSS parser.
Currently it only allows you to check the quirks-mode flag. In the
future it will be a good place to put additional information needed
for things like relative URL resolution, etc.

This narrows <div class=parser> on ACID2 to the correct width. :^)
2020-06-28 12:46:40 +02:00
Andreas Kling
8d2194bdbd LibWeb: Make DOM timers cancellable and stop leaking them
This patch adds a Web::Timer object that represents a single timer
registration made with window.setTimeout() or window.setInterval().
All live timers are owned by the DOM Window object.

The timers can be stopped via clearTimeout() or clearInterval().
Note that those API's are actually interchangeable, but we have to
support both.
2020-06-27 20:02:04 +02:00
Andreas Kling
9d8565cf9a LibWeb: Add CanvasRenderingContext2D.rotate()
This is pretty limited since we don't have wholesale mapping through
the context transform, but we have to start somewhere. :^)
2020-06-26 18:27:12 +02:00
Andreas Kling
92d831c25b LibWeb: Implement fragment parsing and use it for Element.innerHTML
This patch implements most of the HTML fragment parsing algorithm and
ports Element::set_inner_html() to it. This was the last remaining user
of the old HTML parser. :^)
2020-06-26 00:53:25 +02:00
Andreas Kling
edf0aacda4 LibWeb: Add Document.getElementsByTagName() 2020-06-26 00:53:25 +02:00
Andreas Kling
440b4ece22 LibWeb: Move border width and color into LayoutStyle
To make this possible, I also had to give each LayoutNode a Document&
so it can resolve document-specific colors correctly. There's probably
ways to avoid having this extra member by resolving colors later, but
this works for now.
2020-06-24 19:43:27 +02:00
Andreas Kling
bc178ee743 LibWeb: Add CSS::Display enum and StyleProperties::display()
The display property is not interesting after we've built the layout
tree, so we don't have to move it into LayoutStyle.
2020-06-24 18:06:21 +02:00
Andreas Kling
5e83a97fa2 LibWeb: Rename LayoutNode::style() => specified_style()
Let's make way for a slightly-more-cooked style() that will eventually
replace the raw specified_style() for layout and paint purposes.
2020-06-24 13:54:31 +02:00
Andreas Kling
78f10942ba LibWeb: Update PageView content size on page relayout
If the layout changes and the page becomes taller or shorter for some
reason, we need to update the PageView's scrollable content size.
2020-06-23 18:02:08 +02:00
Andreas Kling
fc4ed8d444 LibWeb: Make wrapper factory functions take JS::GlobalObject&
Instead of taking the JS::Heap&. This allows us to get rid of some
calls to JS::Interpreter::global_object(). We're getting closer and
closer to multiple global objects. :^)
2020-06-23 16:57:39 +02:00
Andreas Kling
c24f5585b2 LibWeb: Let HTMLScriptElement call Document::run_javascript()
The fewer places we invoke the JS parser the better. Unless we have
some specific reason to parse manually, we can just call Document.
2020-06-23 16:45:01 +02:00
Andreas Kling
3a5af6ef61 LibWeb: Remove hacky old ways of running <script> element contents
Now that we're using the new HTML parser, we don't have to do the weird
"run the script when inserted into the document, uhh, or when the text
content of the script element changes" dance.

Instead, we just follow the spec, and scripts run the way they should.
2020-06-23 16:45:01 +02:00
Andreas Kling
9ef5d46277 LibWeb: Use ImageLoader::has_image() in HTMLObjectElement
This makes ACID2 load the eyes image again. :^)
2020-06-23 14:28:45 +02:00
Andreas Kling
10255bc5c6 LibWeb+Browser: Decode non-animated images out-of-process :^)
We now use the ImageDecoder service in LibWeb for everything except
GIF images (we'll have to deal with them later, ofc.)

This has a little bit of overhead but we should be able to optimize
it until it becomes negligible.
2020-06-22 21:47:01 +02:00
Andreas Kling
9ce25bbf1d LibWeb: Generate CanvasRenderingContext2D bindings from IDL :^)
We're still missing optional argument support, so this implementation
doesn't support fill(), only fill(fill_rule).

Still it's really nice to get rid of so much hand-written wrapper code.
2020-06-22 19:07:25 +02:00
Andreas Kling
213e2793bd LibWeb: Add Node.insertBefore(Node node, Node? child) 2020-06-21 17:42:00 +02:00
Andreas Kling
e1bd815a6a LibWeb: Generate Event and MouseEvent bindings from IDL :^)
We still have to hand-write a function to turn an Event& into a wrapper
but this is still a hue improvement. Eventually we'll find a way to
auto-generate that function as well.
2020-06-21 16:12:28 +02:00
Andreas Kling
dd29ff884f LibWeb: Generate ImageData bindings from IDL :^) 2020-06-21 15:57:10 +02:00
Andreas Kling
b959d06ace LibWeb: Generate HTMLCanvasElement bindings from IDL :^) 2020-06-21 15:37:13 +02:00
Andreas Kling
119dd2c541 LibWeb: Generate HTMLImageElement bindings from IDL :^) 2020-06-21 15:26:09 +02:00
Andreas Kling
1914f52371 LibWeb: Add HTMLElement wrapper
Expose the "title" attribute just to expose something. :^)
2020-06-21 14:39:15 +02:00
Andreas Kling
244b243d22 LibWeb: Add EventTarget.removeEventListener() 2020-06-21 12:37:34 +02:00
Andreas Kling
d724a12732 LibWeb: Generate EventTarget bindings from IDL :^) 2020-06-21 12:31:42 +02:00
Andreas Kling
a014b2930e LibWeb: Add Element.tagName and Element.className 2020-06-21 12:01:13 +02:00
Andreas Kling
a64033e581 LibWeb: Generate Element bindings from IDL :^)
Had to do a bunch more hacking on WrapperGenerator to support this.
We now support attribute setters as well.
2020-06-21 11:39:32 +02:00
stelar7
5eb39a5f61 LibWeb: Update parser with more insertion modes :^)
Implements handling of InHeadNoScript, InSelectInTable, InTemplate,
InFrameset, AfterFrameset, and AfterAfterFrameset.
2020-06-21 10:13:31 +02:00
Maciej Sobaczewski
a4fbc78f25 LibWeb: Respect display:none on <input> elements 2020-06-21 09:59:06 +02:00
Andreas Kling
bc4fa7a3c9 LibWeb: Expose Node.appendChild() to the web
This is a very barebones implementation of appendChild() that doesn't
take any of the idiosyncratic DOM behaviors into account yet.

Also teach the wrapper generator how to turn an Interpreter argument
into a Node&.
2020-06-21 01:01:50 +02:00
Andreas Kling
faff557400 LibWeb: Expose Document.body to the web
Also, make it return a HTMLElement since Document.body should actually
return the frameset element in a frame-based document.
2020-06-21 01:00:30 +02:00
Andreas Kling
319ef8aa86 LibWeb: Expose Document.createElement() to the web 2020-06-21 00:58:55 +02:00
Andreas Kling
94cf1f08ec LibWeb: Add Node.parentNode and Node.parentElement to DOM API :^) 2020-06-21 00:58:55 +02:00
Andreas Kling
1ffffa0053 LibWeb: Start generating JS wrappers from (simplified) WebIDL :^)
This patch introduces a hackish but functional IDL parser and uses it
to generate the JS bindings for Node and Document.

We'll see how far this simple parser takes us. The important thing
right now is generating code, not being a perfect IDL parser. :^)
2020-06-21 00:58:55 +02:00
Andreas Kling
cc5cba90db LibWeb: Give the DOM Window object a (weak) pointer to its JS wrapper 2020-06-20 17:50:48 +02:00
Andreas Kling
6242e029ed LibWeb: Make Element::tag_name() return a const FlyString&
The more generic virtual variant is renamed to node_name() and now only
Element has tag_name(). This removes a huge amount of String ctor/dtor
churn in selector matching.
2020-06-16 19:09:14 +02:00
Andreas Kling
9bb4020195 LibWeb: Don't load stylesheets with rel="alternate"
We're not supposed to load these by default. Alternate stylesheets can
be offered in a menu or something, if the user is interested.
2020-06-15 20:31:18 +02:00
Andreas Kling
17d26b92f8 LibWeb: Just ignore <script> elements that failed to load the script
We're never gonna be able to run them if we can't load them so just
let it go.
2020-06-15 18:37:48 +02:00
Andreas Kling
84f8c91a6f LibWeb: Use the URL encoder from AK instead of rolling a custom one 2020-06-15 17:56:00 +02:00
Andreas Kling
d883607e8f LibWeb: Force a full relayout if an element's CSS display changes
Not doing this was causing the wrong kind of LayoutNode to stay around
even though we had the final "display" value.
2020-06-15 17:56:00 +02:00
Andreas Kling
73c9f7ebf4 LibWeb: Move "visible in viewport" state tracking to ImageLoader
This should technically apply to any LayoutImage, so let's just move
it to ImageLoader.
2020-06-14 19:32:23 +02:00
Andreas Kling
c45615128b LibWeb: Move bitmap animation from HTMLImageElement to ImageLoader
Since ImageLoader manages the image decoder anyway, let it manage
animation as well.
2020-06-14 19:26:25 +02:00
Andreas Kling
ec39f419e5 LibWeb: Remove some unused functions from HTMLImageElement 2020-06-14 19:05:36 +02:00
Andreas Kling
a93fb7299f LibWeb: Don't choke when trying to render a document-less <iframe>
Just paint it like an empty box if there's no document in the frame.
2020-06-14 15:32:38 +02:00
Andreas Kling
3cc0c477db LibWeb: Add basic <object> element support
This patch implements a simple <object> element with fallback content.
If the URL from the data attribute fails to load (including 404),
we render the DOM tree inside the <object> as fallback content.

This works by generating a different layout tree for the <object>
depending on the state and success of the data load. Since we cannot
currently do incremental layout tree updates, we have to force a
complete layout tree rebuild when the resource load finishes/fails.
2020-06-13 22:24:49 +02:00
Andreas Kling
95d70addd8 LibWeb: Split out image loading logic from HTMLImageElement
Since more DOM nodes are going to want to load images (<object>, ...)
this patch splits out the image loading logic into an ImageLoader class
and then HTMLImageElement simply has an ImageLoader.

LayoutImage is then given a const ImageLoader& at construction and can
then provide layout and rendering for many kinds of DOM nodes.
2020-06-13 22:22:54 +02:00