Commit graph

37 commits

Author SHA1 Message Date
Luke
9950270808 LibWeb: Add HTML::EventNames and UIEvents::EventNames 2020-11-22 18:20:56 +01:00
Andreas Kling
5aeab9878e LibWeb: Rename LayoutNode classes and move them into Layout namespace
Bring the names of various boxes closer to spec language. This should
hopefully make things easier to understand and hack on. :^)

Some notable changes:

- LayoutNode -> Layout::Node
- LayoutBox -> Layout::Box
- LayoutBlock -> Layout::BlockBox
- LayoutReplaced -> Layout::ReplacedBox
- LayoutDocument -> Layout::InitialContainingBlockBox
- LayoutText -> Layout::TextNode
- LayoutInline -> Layout::InlineNode

Note that this is not strictly a "box tree" as we also hang inline/text
nodes in the same tree, and they don't generate boxes. (Instead, they
contribute line box fragments to their containing block!)
2020-11-22 15:56:27 +01:00
Andreas Kling
f358f2255f LibWeb: Rename LayoutNode::node() => LayoutNode::dom_node() 2020-11-22 14:46:36 +01:00
Andreas Kling
10b534849d LibWeb: Remove ancient HTML_DEBUG debug logging 2020-11-19 23:10:21 +01:00
Andreas Kling
81add73955 LibWeb: Make Frame point weakly to Page
This patch makes Page weakable and allows page-less frames to exist.

Page is single-owner, and Frame is multiple-owner, so it's not sound
for Frame to assume its containing Page will stick around for its own
entire lifetime.

Fixes #3976.
2020-11-12 18:29:55 +01:00
Tom
75f61fe3d9 AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safe
This makes most operations thread safe, especially so that they
can safely be used in the Kernel. This includes obtaining a strong
reference from a weak reference, which now requires an explicit
call to WeakPtr::strong_ref(). Another major change is that
Weakable::make_weak_ref() may require the explicit target type.
Previously we used reinterpret_cast in WeakPtr, assuming that it
can be properly converted. But WeakPtr does not necessarily have
the knowledge to be able to do this. Instead, we now ask the class
itself to deliver a WeakPtr to the type that we want.

Also, WeakLink is no longer specific to a target type. The reason
for this is that we want to be able to safely convert e.g. WeakPtr<T>
to WeakPtr<U>, and before this we just reinterpret_cast the internal
WeakLink<T> to WeakLink<U>, which is a bold assumption that it would
actually produce the correct code. Instead, WeakLink now operates
on just a raw pointer and we only make those constructors/operators
available if we can verify that it can be safely cast.

In order to guarantee thread safety, we now use the least significant
bit in the pointer for locking purposes. This also means that only
properly aligned pointers can be used.
2020-11-10 19:11:52 +01:00
Andreas Kling
c67b45aa1f LibWeb: Forget frame selection when changing documents
The old selection is obviously not relevant in the new document.
2020-10-22 23:23:57 +02:00
Linus Groh
e40135fefd LibWeb: Add OutOfProcessWebView::load_html() 2020-10-08 23:20:52 +02:00
Linus Groh
216ccaf805 LibWeb: Handle PageClient::page_did_change_title() in Frame::set_document() 2020-10-08 23:20:52 +02:00
Andreas Kling
51dbea3a0e LibWeb: Use RefPtrs more in getElementById() and getElementsByName()
Passing around Vector<Element*> is not a great idea long-term.
2020-10-07 12:47:17 +02:00
Andreas Kling
91b49dd9d0 LibWeb: Add a PageClient callback for image context menu requests
When the user right-clicks on an image, you might want to show a
special context menu, separate from the regular link context menu.

This patch only implements enough of the functionality to get this
working in a single-process context.
2020-10-02 19:02:47 +02:00
Andreas Kling
2946a684ef ProtocolServer+LibWeb: Support more detailed HTTP requests
This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
2020-09-28 11:55:26 +02:00
Ben Wiederhake
08f9bc26a6 Meta+LibHTTP through LibWeb: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Andreas Kling
86a4eaca38 LibWeb: Rename HTMLIFrameElement::hosted_frame() => content_frame()
This matches the standard API names contentWindow and contentDocument.
2020-09-22 20:10:20 +02:00
Andreas Kling
94c55d9e37 LibWeb: Two mouse event handling fixes
- After letting a LayoutNode handle a mouseup, re-do the hit test
  since things may have changed.
- Make sure we always update the document's hovered node.
2020-09-12 17:55:19 +02:00
Andreas Kling
d9e39cb82d LibWeb: Support window.alert() in multi-process context
Alerts are now delegated to the embedding GUI process.
2020-09-12 14:49:29 +02:00
Andreas Kling
d6889ecf35 LibWeb: Allow layout nodes to receive and track mouse events
To implement form controls internally in LibWeb (necessary for multi
process forms), we'll need the ability to handle events since we can't
rely on LibGUI widgets anymore.

A LayoutNode can now override wants_mouse_events() and if it returns
true, it will now receive mousedown, mousemove and mouseup events. :^)
2020-09-11 18:42:43 +02:00
Andreas Kling
0f9be82826 LibGfx: Move StandardCursor enum to LibGfx
This enum existed both in LibGUI and WindowServer which was silly and
error-prone.
2020-09-10 19:25:13 +02:00
Rewi Haar
521e730df1 LibWeb: Calculate selection based on glyph centers
Previously you had to drag all the way to the end of a glyph to select
it; now you just need to drag past the center.  Also fixes #2959.
2020-08-26 08:44:31 +02:00
Andreas Kling
684fa0f99b LibWeb: Make selection state recomputation implicit
Add a LayoutDocument API for modifying the selection and make clients
call that so we can recompute selection states automatically.
2020-08-21 17:57:24 +02:00
Andreas Kling
d47f77169f LibWeb: Remember the selection state of each LayoutNode
Instead of computing it on the fly while painting each layout node,
they now remember their selection state. This avoids a whole bunch
of tree traversal while painting with anything selected.
2020-08-21 17:57:24 +02:00
Andreas Kling
56c3748dcc LibWeb: Rename PageView => InProcessWebView 2020-08-17 18:05:35 +02:00
AnicJov
ac4897d613 LibWeb: Change cursor to IBeam when hovering text
This is what most browsers do, hopefully it isn't too silly :^)
2020-08-17 13:07:18 +02:00
Andreas Kling
01022eb5d6 LibWeb: Allow focusing individual (focusable) elements with Tab key
You can now cycle through focusable elements (currently only hyperlinks
are focusable) with the Tab key.

The focus outline is rendered in a new FocusOutline paint phase.
2020-08-15 00:05:45 +02:00
Andreas Kling
9bdd8ec3f3 LibWeb: Don't paint a text cursor in unfocused frames 2020-08-14 12:15:11 +02:00
Andreas Kling
be76abfdb3 LibWeb: Send keydown events to the focused frame 2020-08-14 12:15:11 +02:00
Andreas Kling
6b4a7d1ee3 LibWeb: Add "focused frame" concept, one focused Frame per Page
Focus currently only moves when doing a mousedown in a frame.
2020-08-14 12:15:11 +02:00
Andreas Kling
1c7faa8965 LibWeb: Move text selection serialization from PageView to Frame
This logic doesn't depend on anything at the widget layer, so it can
move down to the frame layer.
2020-08-06 19:59:24 +02:00
Nico Weber
ce95628b7f Unicode: Try s/codepoint/code_point/g again
This time, without trailing 's'. Ran:

    git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
2020-08-05 22:33:42 +02:00
Nico Weber
19ac1f6368 Revert "Unicode: s/codepoint/code_point/g"
This reverts commit ea9ac3155d.
It replaced "codepoint" with "code_points", not "code_point".
2020-08-05 22:33:42 +02:00
Andreas Kling
e2b4fef6c7 LibWeb: Specialize hit testing for text cursor purposes
The text cursor follows slightly different "intuitive" rules than the
regular hit testing. Clicking past the right edge of a text box should
still "hit" the text box, and place the cursor at its end, for example.

We solve this by adding a HitTestType enum that is passed to hit_test()
and determines whether past-the-edge candidates are considered.
2020-08-05 16:57:51 +02:00
Andreas Kling
ea9ac3155d Unicode: s/codepoint/code_point/g
Unicode calls them "code points" so let's follow their style.
2020-08-03 19:06:41 +02:00
Andreas Kling
07e13e9868 LibWeb: Only allow editing of elements with contenteditable="true"
We now respect the contenteditable HTML attribute and only let you
edit content inside explicitly editable elements.
2020-08-02 17:34:50 +02:00
Andreas Kling
8b16c61ff8 LibWeb: Add very basic backspace support to content editing 2020-08-02 17:34:50 +02:00
Andreas Kling
bc299754f6 LibWeb: Allow inserting text at the cursor by typing characters :^)
This works everywhere right now, but it's obviously not going to stay
that way forever. :^)

Note that this does not advance the cursor correctly for whitespace
since the cursor is DOM-based and doesn't take whitespace collapsing
into account yet.
2020-08-02 17:34:50 +02:00
Andreas Kling
2c679d0c8b LibWeb: Add a blinking text cursor :^)
Each Web::Frame now has a cursor that sits at a DOM::Position. It will
blink and look like a nice regular text cursor.

It doesn't really do anything yet, but it will eventually.
2020-08-02 17:34:50 +02:00
Andreas Kling
ef711f501e LibWeb: Move the Page/Frame/EventHandler classes into Page/ 2020-07-28 19:28:29 +02:00