mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:37:47 +00:00
Ladybird/WebView: Apply viewport scroll offset to mouse event coordinate
This commit is contained in:
parent
96170a4f24
commit
874e73e0c9
2 changed files with 11 additions and 3 deletions
|
@ -337,7 +337,7 @@ void WebView::mouseMoveEvent(QMouseEvent* event)
|
||||||
Gfx::IntPoint position(event->x(), event->y());
|
Gfx::IntPoint position(event->x(), event->y());
|
||||||
auto buttons = get_buttons_from_qt_event(*event);
|
auto buttons = get_buttons_from_qt_event(*event);
|
||||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||||
m_page_client->page().handle_mousemove(position, buttons, modifiers);
|
m_page_client->page().handle_mousemove(to_content(position), buttons, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::mousePressEvent(QMouseEvent* event)
|
void WebView::mousePressEvent(QMouseEvent* event)
|
||||||
|
@ -345,7 +345,7 @@ void WebView::mousePressEvent(QMouseEvent* event)
|
||||||
Gfx::IntPoint position(event->x(), event->y());
|
Gfx::IntPoint position(event->x(), event->y());
|
||||||
auto button = get_button_from_qt_event(*event);
|
auto button = get_button_from_qt_event(*event);
|
||||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||||
m_page_client->page().handle_mousedown(position, button, modifiers);
|
m_page_client->page().handle_mousedown(to_content(position), button, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::mouseReleaseEvent(QMouseEvent* event)
|
void WebView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
@ -353,7 +353,12 @@ void WebView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
Gfx::IntPoint position(event->x(), event->y());
|
Gfx::IntPoint position(event->x(), event->y());
|
||||||
auto button = get_button_from_qt_event(*event);
|
auto button = get_button_from_qt_event(*event);
|
||||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||||
m_page_client->page().handle_mouseup(position, button, modifiers);
|
m_page_client->page().handle_mouseup(to_content(position), button, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gfx::IntPoint WebView::to_content(Gfx::IntPoint viewport_position) const
|
||||||
|
{
|
||||||
|
return viewport_position.translated(horizontalScrollBar()->value(), verticalScrollBar()->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::paintEvent(QPaintEvent* event)
|
void WebView::paintEvent(QPaintEvent* event)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
#include <LibGfx/Forward.h>
|
||||||
#include <QAbstractScrollArea>
|
#include <QAbstractScrollArea>
|
||||||
|
|
||||||
class HeadlessBrowserPageClient;
|
class HeadlessBrowserPageClient;
|
||||||
|
@ -35,5 +36,7 @@ signals:
|
||||||
void title_changed(QString);
|
void title_changed(QString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||||
|
|
||||||
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue