Commit graph

3218 commits

Author SHA1 Message Date
Andreas Kling
5f9d80d8bc LibWeb: Add basic support for CSS percentages
Many properties can now have percentage values that get resolved in
layout. The reference value (what is this a percentage *of*?) differs
per property, so I've added a helper where you provide a reference
value as an added parameter to the existing length_or_fallback().
2020-05-11 23:07:30 +02:00
Linus Groh
5142acd13e LibWeb: Add very basic handling of "font-family" font stacks 2020-05-11 10:48:54 +02:00
Linus Groh
673527d314 LibWeb: Ignore parsed pseudo-element selectors & empty complex selectors
Currently we don't deal with them, so they shouldn't return a
SimpleSelector - that'd be a false positive.

Also don't produce a ComplexSelector if no SimpleSelector was parsed.

This fixes a couple of rendering issues on awesomekling.github.io:
link colours, footer size, content max-width (and possibly more!)
2020-05-11 10:48:54 +02:00
Linus Groh
a427821dd1 LibWeb: Don't paint borders with width <= 0px
Previously we would only check if the border width property is empty and
skip drawing in that case, and enforcing a minimum width of 1px
otherwise - but "border: 0;" should not paint a border :^)
2020-05-11 10:48:54 +02:00
Linus Groh
8edf2bbcbd LibWeb: Set nav, main, article, aside, section to "display: block"
This makes the blog posts on awesomekling.github.io show up :^)
2020-05-11 10:48:54 +02:00
Linus Groh
51707b6c68 LibWeb: Draw the inspected node rect last in LayoutBox::render() 2020-05-11 10:48:54 +02:00
Andreas Kling
d612ca1fcc LibWeb: Render content based on MIME type provided by server (or guess)
We now look at the Content-Type HTTP header when deciding how to render
some loaded content. If there is no Content-Type header (which will
always be the case when loading local files, for example), we make a
guess based on the URL filename.
2020-05-10 22:32:12 +02:00
Andreas Kling
20f50f9133 LibProtocol: Pass response headers in a case insensitive HashMap
HTTP headers are case-insensitive, so just add CaseInsensitiveTraits
to the HashMap and we're good to go! :^)
2020-05-10 22:32:12 +02:00
Andreas Kling
fc26aefe81 LibWeb: Add a hook for when an URL is dropped on an HtmlView
Embedders of HtmlView can now react to this by hooking on_url_drop.
2020-05-10 22:32:12 +02:00
Andreas Kling
f1708b3832 LibWeb: Teach HtmlView how to render Markdown files :^) 2020-05-10 22:32:12 +02:00
Andreas Kling
97adcde36e LibWeb: Teach HtmlView how to open a .txt file
When encountering a text file, we now put it in a wrapper document with
the file contents in a <pre> tag. This works really nicely :^)
2020-05-10 22:32:12 +02:00
Andreas Kling
0e60e7aef0 LibWeb: Add Document create_element() and create_text_node() helpers 2020-05-10 22:32:12 +02:00
Andreas Kling
9d7ab13b32 LibWeb: Add Text to the forwarding header 2020-05-10 22:32:12 +02:00
Linus Groh
4c1a765076 LibWeb: Add basic support for "border-style: {dotted,dashed}" 2020-05-10 19:41:00 +02:00
Linus Groh
59d00e5df6 LibGfx: Replace 'bool dotted' with a LineStyle::{Solid,Dotted} enum
Just a bool is insufficient as we'll have to support dashed lines as well.
2020-05-10 13:34:59 +02:00
Andreas Kling
fe0de26277 LibWeb+Browser: Support about: URL protocol so "about:blank" works :^)
For now, we simply load an empty resource from any about: URL.
2020-05-10 11:14:30 +02:00
Linus Groh
54c4cd8a66 Meta: Delete empty .cpp files 2020-05-09 23:45:16 +02:00
AnotherTest
ce36071447 LibWeb: Implicitly close all subpaths when canvas.fill() is called 2020-05-09 23:25:39 +02:00
Peter Nelson
b8f5b81019 LibWeb: Add support for animated images to HTMLImageElement
Uses a Core::Timer (similar to HTMLBlinkElement) to transition between
frames of an animated image. Also keeps track of the number of animation
loops.
2020-05-09 12:01:59 +02:00
Linus Groh
f8c7ab55f8 LibWeb: Implement "text-transform: {upper,lower}case" 2020-05-08 23:04:54 +02:00
Andreas Kling
6e9c57fcc3 LibWeb: Generate a new list item marker on every layout
This is a workaround for the silly issue where some content would move
one pixel upward on every layout. The block layout code was finding
the list item marker and doing regular inline layout on it. We were not
prepared to handle this, which caused it to move in a silly way.

For now, just regenerate markers on every layout to work around the
issue. In the future we should figure out a nice way to layout markers.
2020-05-08 22:40:20 +02:00
Andreas Kling
cf3b58fbe8 Services: Renamed from Servers
It didn't feel right to have a "DHCPClient" in a "Servers" directory.
Rename this to Services to better reflect the type of programs we'll
be putting in there.
2020-05-08 21:57:44 +02:00
FalseHonesty
0e048f3c4c LibWeb: Add hook when a link is middle clicked 2020-05-06 21:59:29 +02:00
AnotherTest
a82419469f LibWeb: Add canvas.fill
This implements only one of the two forms of this function,
ctx.fill(winding_rule).
Also tweaks the quadratic curve demo to have a nice looking filled
shape.
2020-05-06 14:50:29 +02:00
Andreas Kling
b778e99c61 LibWeb: Expose the ProtocolClient inside ResourceLoader as an API
This allows others to reuse the existing connection to ProtocolServer
instead of creating a separate one.
2020-05-05 23:57:35 +02:00
Andreas Kling
f32989a3e7 LibWeb: Add hook when context menu is requested by right-clicking link 2020-05-05 22:42:21 +02:00
Andreas Kling
e73ad78ba6 LibWeb: Add support for "display: inline-block"
This display type is implemented using a LayoutBlock that is_inline().
Basically it behaves like a block internally, and its children are laid
out in the normal block layout fashion. Externally however, it behaves
like an atomic inline-level box.

Layout of inline-block boxes happens in three stages:

1. The outer dimensions of the block are computed during the recursive
   normal layout pass. We skip positioning, but lay out children.

2. Later on, during line layout in the *containing block*, the inline
   block now contributes a linebox fragment. When linebox fragments are
   positioned, we learn the final position of the inline block. That's
   when we set the inline block's position.

3. We re-layout the inline block's children once again. This is done to
   make sure they end up in the right position. The layout tree doesn't
   use relative offsets, so after we position the inline block in (2),
   its children will not have its positions updated. Relayout moves
   all children of inline blocks to the right place.

This is a rather naive approach but it does get the basic behavior into
place so we can iterate on it. :^)
2020-05-05 16:18:28 +02:00
Andreas Kling
8a40294f42 LibWeb: Turn some HTML entities into nicer text in the parser 2020-05-05 15:50:28 +02:00
Andreas Kling
6676f2c259 LibWeb: Don't emit a simple selector if nothing was consumed 2020-05-05 15:50:28 +02:00
Andreas Kling
493cbb7956 LibWeb: Fall back to LayoutInline for any unrecognized CSS display
Let's at least try to keep going and see what we can render.
2020-05-05 15:50:28 +02:00
Andreas Kling
d677d23da1 LibWeb: Make the URL encoding function a little less copy-happy 2020-05-05 15:50:28 +02:00
Linus Groh
055e955a1c LibWeb: Recognise :focus pseudo-class
It's still only a dummy as LibWeb doesn't have focused elements yet, but
at least now we don't treat "selector:focus" as just "selector".

This fixes an issue on google.com which was mostly grey - coming from
some menu item focus styles :^)
2020-05-05 13:16:33 +02:00
Shadowfacts
fcd922f7b1 LibWeb: Add basic URL encoder for individual values and param lists 2020-05-05 11:19:38 +02:00
Shadowfacts
7f538ea7eb LibWeb: When creating form action URL, only include value for the submit
that was used to submit the form
2020-05-05 11:19:38 +02:00
Shadowfacts
4d5dc5950a LibWeb: Improve <form> submit method handling
The spec defines the only valid methods to be get, post, and dialog.
Post and dialog are currently unhandled and do nothing, any other value
(or no value specified) is defined by the spec to use the get method.
2020-05-05 11:19:38 +02:00
AnotherTest
0a55679de4 LibWeb: Add canvas.quadraticCurveTo()
Also adds a test, and removes debug spam ™️
2020-05-05 09:21:07 +02:00
Andreas Kling
9df71afdb3 LibWeb: Respect the <input size> attribute a bit more :^)
We now use the size attribute to determine the width of a text input.
2020-05-04 22:43:00 +02:00
Andreas Kling
0d2beddc74 LibWeb: Plumb the full HtmlView viewport rect down into the engine
Previously we would use the "content rect" as the viewport rect, which
could sometimes be smaller than the actual viewport rect as the content
size was based on the box geometry of the root layout node.

This fixes an issue on google.com where we would not render the main
logo image since it was "outside" the viewport. The root layout size
is currently very wrong on google.com but that's a separate issue. :^)
2020-05-04 22:35:29 +02:00
Andreas Kling
d3de2b7de5 LibWeb: Don't assert when trying to rebuild a single-node layout tree
This merely postpones dealing with partial layout tree rebuilds for a
while longer.
2020-05-04 22:34:14 +02:00
Andreas Kling
6886c6efa6 LibWeb: Don't generate a layout node for <input type="hidden"> 2020-05-04 22:33:49 +02:00
Linus Groh
94c28552c6 LibWeb: Add basic support for redirects 2020-05-04 00:01:31 +02:00
Andreas Kling
e09b83c60c LibTextCodec: Start fleshing out a simple text codec library
We're starting with a very basic decoding API and only ISO-8859-1 and
UTF-8 decoding (and UTF-8 decoding is really a no-op since String is
expected to be UTF-8.)
2020-05-03 23:01:58 +02:00
Andreas Kling
f3676ebef5 LibWeb: Handle iso-8859-1 web content a little bit better
We now look at the HTTP response headers for a Content-Type header and
try to parse it if present to find the text encoding.

If the text encoding is iso-8859-1, we turn all non-ASCII characters
into question marks. This makes Swedish Google load on my machine! :^)
2020-05-03 23:01:58 +02:00
Andreas Kling
eb6e35a1be ProtocolServer: Pass HTTP response headers to the client
We now store the response headers in a download object on the protocol
server side and pass it to the client when finishing up a download.

Response headers are passed as an IPC::Dictionary. :^)
2020-05-03 23:01:58 +02:00
Linus Groh
99be27b4a1 LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
AnotherTest
7670e5ccf0 LibCore+LibHTTP: Move out the HTTP handler and add HTTPS 2020-05-02 12:24:10 +02:00
Andreas Kling
aaf35112a4 LibJS: Pass JS::Function around by reference more 2020-04-29 13:43:57 +02:00
Andreas Kling
97382677bd LibWeb: Make EventListener::function() return a reference 2020-04-29 12:46:20 +02:00
mattco98
23ec578a01 LibJS: Implement correct attributes for (almost) all properties
Added the ability to include a u8 attributes parameter with all of the
various put methods in the Object class. They can be omitted, in which
case it defaults to "Writable | Enumerable | Configurable", just like
before this commit.

All of the attribute values for each property were gathered from
SpiderMonkey in the Firefox console. Some properties (e.g. all of the
canvas element properties) have undefined property descriptors... not
quite sure what that means. Those were left as the default specified
above.
2020-04-28 09:29:50 +02:00
Andreas Kling
e3232eb25b LibWeb: Support loading data: URLs transparently via ResourceLoader
This is pretty darn cool! :^)
2020-04-26 22:57:00 +02:00