We need to give pages the opportunity to intercept keydown events and
potentially stop them from propagating. Otherwise, for example, pressing
an arrow key in an <input> element is not observable via script.
The return value of fire_keyboard_event is meant to indicate whether the
event should continue propagating (true) or halt (false). This exactly
matches the return value of dispatch_event, so by negating the result,
we are propagating events we shouldn't, and not propagating events we
should.
We currently fire the change event on <input> elements when they lose
focus. The spec allows for us to also fire the event when changes are
"committed", so long as such an action makes sense for the input type.
This patch detects when the return key is entered in an <input> element
and uses that as the commit action for text-related types. If no change
has occurred since the last commit, no change event is fired.
Before this change `navigate()` was always invoked twice when a link
is clicked:
- From `activation_behavior` callback of `HTMLAnchorElement` during
event dispatch.
- Directly from `handle_mouseup`.
The old name was pretty confusing, since it had nothing to do with the
common "id" content attribute.
This makes way for using id() to return the "id" attribute instead. :^)
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>
Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
The existing implementation has some pre-existing issues where it is
incorrectly assumes that byte offsets are given through the IDL instead
of UTF-16 code units. While making these changes, leave some FIXMEs for
that.
Stop worrying about tiny OOMs. Work towards #20449.
While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
This invariant is enforced by the fact that `NonnullGCPtr` can only be
constructed from references.
This commit fixes an instance where we compared a pointer to null after
we have already dereferenced it.
This makes event handler to try to find scrollable paintable in the
chain of containing blocks of hit box. This is very naive and will
have to be improved in the future.
Click event logic should start as false, and after checking if the
mousedown and subsequent mouseup have been on the same element, and if
the node dispatches events it can become true.
This fixes the issue that clicking anywhere on the page, then dragging
the mouse on top of a link or button, then releasing triggers the link.
This is also happening when selecting text, if the selection stops over
a link, the page navigates.
The data we want to send out of the WebContent process is identical for
audio and video elements. Rather than just duplicating all of this for
audio, generalize the names used for this IPC for all media elements.
This also encapsulates that data into a struct. This makes adding new
fields to be sent much easier (such as an upcoming field for muting the
element).
This now allows websites such as Discord, YouTube and your favourite
"Right Click" xkcd comic to open a custom context menu when you right
click. You can bypass this by holding shift, just like Firefox.
This just sets up the IPC to notify the browser process of context menu
requests on video elements. The IPC contains a few pieces of information
about the state of the video element.
This can occur if a mouse click on a mouse event tracking node causes a
page navigation. As the old document is torn down, the event handler may
have a stale reference to the tracking node. If a subsequent mouse event
occurs on that node, we would crash trying to access the node's styled
properties that are no longer valid.
To fix this, when we are deciding what node to send the event to, and we
have a mouse event tracking node, check if that node still wants the
event. If not, clear the tracking node.
The "browsing context container" concept in the HTML spec has been
replaced with "navigable container". Renaming this is the first step of
many towards implementing the new world.
Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
This ports MouseEvent, UIEvent, WheelEvent, and Event to new String.
They all had a dependency to T::create() in
WebDriverConnection::fire_an_event() and therefore had to be ported in
the same commit.
The name "initial containing block" was wrong for this, as it doesn't
correspond to the HTML element, and that's specifically what it's
supposed to do! :^)