Commit Graph

210 Commits

Author SHA1 Message Date
Matthew Olsson
22f0953fe2 LibWeb: Begin SVG element support
This commit starts adding a basic SVG element. Currently, svg elements
have support for the width and height properties, as well as the stroke,
stroke-width, and fill properties. The only child element supported
is the path element, as most other graphical elements are just shorthand
for paths.
2020-07-26 14:53:43 +02:00
Andreas Kling
d1fdc1a2cf LibWeb: Use [Reflect] for Element.id and Element.className :^) 2020-07-24 13:25:42 +02:00
Andreas Kling
cb35a8ea83 LibWeb: Add HTMLElement.lang (and make HTMLElement.title reflecting) 2020-07-24 13:16:11 +02:00
Andreas Kling
ea451cea6a LibWeb: Add HTMLImageElement.src and HTMLImageElement.alt
These are reflecting attributes! :^)
2020-07-24 13:12:14 +02:00
Andreas Kling
3cb50a4714 LibWeb: Rename Element::tag_name() => local_name()
To prepare for fully qualified tag names, let's call this local_name.
Note that we still keep an Element::tag_name() around since that's what
the JS bindings end up calling into for the Element.tagName property.
2020-07-23 18:18:13 +02:00
Andreas Kling
a3feb46ad7 LibWeb: Parse "width" and "height" presentation attributes on <img>
These are HTML lengths that map to CSS width and height respectively.
2020-07-22 01:16:27 +02:00
Andreas Kling
5a7e57457e LibWeb: Add a dedicated function for parsing HTML length values
Presentation attribute lengths (width, height, etc.) can always be
unit-less (e.g "400") so going via the normal CSS parsing path only
works when the document is in quirks mode.

Add a separate parse_html_length() that always allows unit-less values.
2020-07-22 01:13:18 +02:00
Luke
19d6884529 LibWeb: Implement quirks mode detection
This allows us to determine which mode to render the page in.

Exposes "doctype" and "compatMode" on Document.
Exposes "name", "publicId" and "systemId" on DocumentType.
2020-07-21 01:08:32 +02:00
Tom
27bd2eab22 LibWeb: Require parent window argument for MessageBox
Since the vast majority of message boxes should be modal, require
the parent window to be passed in, which can be nullptr for the
rare case that they don't. By it being the first argument, the
default arguments also don't need to be explicitly stated in most
cases, and it encourages passing in a parent window handle.

Fix up several message boxes that should have been modal.
2020-07-16 16:10:21 +02:00
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