mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:57:45 +00:00
LibWeb: Clear the mouse event tracking node when it stops wanting events
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.
This commit is contained in:
parent
8f0b7fa370
commit
806e08425a
2 changed files with 37 additions and 33 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <Kernel/API/KeyCode.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Page/EditEventHandler.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
|
@ -44,6 +45,12 @@ private:
|
|||
CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const;
|
||||
CSSPixelPoint compute_mouse_event_page_offset(CSSPixelPoint event_client_offset) const;
|
||||
|
||||
struct Target {
|
||||
JS::GCPtr<Painting::Paintable> paintable;
|
||||
Optional<int> index_in_node;
|
||||
};
|
||||
Optional<Target> target_for_mouse_position(CSSPixelPoint position);
|
||||
|
||||
Layout::Viewport* layout_root();
|
||||
Layout::Viewport const* layout_root() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue