Commit graph

29 commits

Author SHA1 Message Date
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
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
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
FalseHonesty
0e048f3c4c LibWeb: Add hook when a link is middle clicked 2020-05-06 21:59:29 +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
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
Linus Groh
94c28552c6 LibWeb: Add basic support for redirects 2020-05-04 00:01:31 +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
Peter Nelson
e159370ccb LibWeb: Handle .gifs as images and use ImageDecoder to decode them 2020-04-25 16:49:09 +02:00
Andreas Kling
2be184f49c LibWeb: Try fetching a favicon when loading a non-file URL in HtmlView
If valid and decodable, the favicon will be provided to clients via the
on_favicon_change hook. :^)
2020-04-24 22:26:53 +02:00
Andreas Kling
5c2bdbf27f Browser+LibWeb: Open link in new tab on Ctrl+Click :^) 2020-04-24 14:43:56 +02:00
Linus Groh
061205b3b3 LibWeb: Pass link target to HtmlView's on_link_click callback 2020-04-24 14:34:11 +02:00
Jack Byrne
f65c55791e LibWeb: Scroll back to the top when a new page is loaded 2020-04-16 14:13:03 +02:00
Andreas Kling
7382b27c22 LibWeb: Add Origin concept (protocol, host, port tuple)
Every Document now has an Origin, found via Document::origin().
It's based on the URL of the document.

This will be used to implement things like the same-origin policy.
2020-04-07 23:01:45 +02:00
Andreas Kling
f8d6d61da5 LibWeb: Fix null dereference in HtmlView::mousedown_event
Running event handlers in response to a mouse event may cause full
layout invalidation, so we can't expect the layout root to be present
right after returning from JS.

Fixes #1629.
2020-04-07 10:26:54 +02:00
Andreas Kling
9b0bfcb8b7 LibWeb: Handle javascript: URLs inside LibWeb :^)
This patch makes it possible to execute JavaScript by clicking on an
anchor element with href="javascript:your_script_here()".
2020-04-04 22:12:37 +02:00
Andreas Kling
9eec63e471 LibWeb: Protect DOM node while preparing to send mouse events
The Help application was hooking HtmlView::on_link_click, which would
get invoked before DOM event dispatch. Since we were holding on to the
clicked node with a Node*, the DOM node was gone after returning from
the on_link_click callback.

Fix this by keeping DOM nodes in RefPtrs in the event management code.
Also move DOM event dispatch before widget hook invocation, to try and
keep things sane on the LibWeb side of things.

Fixes #1605.
2020-04-03 21:34:57 +02:00
Linus Groh
07049f98ec LibWeb: Handle invalid URL in HtmlView::load() 2020-04-03 19:41:25 +02:00
Linus Groh
021d78f8f7 Browser: Add error page
Add a simple HTML error page that gets loaded into the HtmlView when
loading the page fails.

Closes #1210 and #1516
2020-04-01 18:49:48 +02:00
Andreas Kling
660ec504ca LibWeb: Move get_element_by_id() to a NonElementParentNode mixin class
This matches the current version of the DOM spec. And since C++ doesn't
have mixins this is actually a CRTP class.
2020-03-28 09:13:29 +01:00
Andreas Kling
0395b25e3f LibWeb: Put selection-related debug spam behind an #ifdef 2020-03-22 13:03:43 +01:00
Andreas Kling
55c845713a LibWeb: Give MouseEvents the correct offsetX and offsetY values 2020-03-21 18:27:06 +01:00
Andreas Kling
4dde36844b LibWeb: Add a DOM Event class (instead of events being simple strings)
This patch adds the Event base class, along with a MouseEvent subclass.
We now dispatch MouseEvent objects for mousedown, mouseup and mousemove
and these objects have the .offsetX and .offsetY properties.

Both of those properties are hard-coded at the moment. This will be
fixed in the next patch. :^)
2020-03-21 18:17:18 +01:00
Andreas Kling
b196665131 LibWeb: Dispatch "mouseup" event
This is a very naive implementation that doesn't account for where the
mousedown happened.
2020-03-21 17:55:41 +01:00
Andreas Kling
e265058768 LibWeb: Fire "mousedown" and "mousemove" events in the DOM :^) 2020-03-18 17:13:22 +01:00
Andreas Kling
830a57c6b2 LibWeb: Rename directory LibHTML => LibWeb
Let's rename this to LibWeb since it aims to provide more parts of the
web platform than just HTML. :^)
2020-03-07 10:32:51 +01:00
Renamed from Libraries/LibHTML/HtmlView.cpp (Browse further)