mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
LibWeb+UI: Rename ChromeInputData to BrowserInputData
This commit is contained in:
parent
47d6747945
commit
e20d7be15f
Notes:
github-actions[bot]
2025-03-15 23:58:47 +00:00
Author: https://github.com/trflynn89
Commit: e20d7be15f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3959
Reviewed-by: https://github.com/awesomekling ✅
5 changed files with 32 additions and 32 deletions
|
@ -10,17 +10,17 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
KeyEvent KeyEvent::clone_without_chrome_data() const
|
KeyEvent KeyEvent::clone_without_browser_data() const
|
||||||
{
|
{
|
||||||
return { type, key, modifiers, code_point, repeat, nullptr };
|
return { type, key, modifiers, code_point, repeat, nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseEvent MouseEvent::clone_without_chrome_data() const
|
MouseEvent MouseEvent::clone_without_browser_data() const
|
||||||
{
|
{
|
||||||
return { type, position, screen_position, button, buttons, modifiers, wheel_delta_x, wheel_delta_y, nullptr };
|
return { type, position, screen_position, button, buttons, modifiers, wheel_delta_x, wheel_delta_y, nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
DragEvent DragEvent::clone_without_chrome_data() const
|
DragEvent DragEvent::clone_without_browser_data() const
|
||||||
{
|
{
|
||||||
return { type, position, screen_position, button, buttons, modifiers, {}, nullptr };
|
return { type, position, screen_position, button, buttons, modifiers, {}, nullptr };
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
struct ChromeInputData {
|
struct BrowserInputData {
|
||||||
virtual ~ChromeInputData() = default;
|
virtual ~BrowserInputData() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KeyEvent {
|
struct KeyEvent {
|
||||||
|
@ -28,7 +28,7 @@ struct KeyEvent {
|
||||||
KeyUp,
|
KeyUp,
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyEvent clone_without_chrome_data() const;
|
KeyEvent clone_without_browser_data() const;
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
UIEvents::KeyCode key { UIEvents::KeyCode::Key_Invalid };
|
UIEvents::KeyCode key { UIEvents::KeyCode::Key_Invalid };
|
||||||
|
@ -36,7 +36,7 @@ struct KeyEvent {
|
||||||
u32 code_point { 0 };
|
u32 code_point { 0 };
|
||||||
bool repeat { false };
|
bool repeat { false };
|
||||||
|
|
||||||
OwnPtr<ChromeInputData> chrome_data;
|
OwnPtr<BrowserInputData> browser_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MouseEvent {
|
struct MouseEvent {
|
||||||
|
@ -48,7 +48,7 @@ struct MouseEvent {
|
||||||
DoubleClick,
|
DoubleClick,
|
||||||
};
|
};
|
||||||
|
|
||||||
MouseEvent clone_without_chrome_data() const;
|
MouseEvent clone_without_browser_data() const;
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
Web::DevicePixelPoint position;
|
Web::DevicePixelPoint position;
|
||||||
|
@ -59,7 +59,7 @@ struct MouseEvent {
|
||||||
int wheel_delta_x { 0 };
|
int wheel_delta_x { 0 };
|
||||||
int wheel_delta_y { 0 };
|
int wheel_delta_y { 0 };
|
||||||
|
|
||||||
OwnPtr<ChromeInputData> chrome_data;
|
OwnPtr<BrowserInputData> browser_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DragEvent {
|
struct DragEvent {
|
||||||
|
@ -70,7 +70,7 @@ struct DragEvent {
|
||||||
Drop,
|
Drop,
|
||||||
};
|
};
|
||||||
|
|
||||||
DragEvent clone_without_chrome_data() const;
|
DragEvent clone_without_browser_data() const;
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
Web::DevicePixelPoint position;
|
Web::DevicePixelPoint position;
|
||||||
|
@ -80,7 +80,7 @@ struct DragEvent {
|
||||||
UIEvents::KeyModifier modifiers { UIEvents::KeyModifier::Mod_None };
|
UIEvents::KeyModifier modifiers { UIEvents::KeyModifier::Mod_None };
|
||||||
Vector<HTML::SelectedFile> files;
|
Vector<HTML::SelectedFile> files;
|
||||||
|
|
||||||
OwnPtr<ChromeInputData> chrome_data;
|
OwnPtr<BrowserInputData> browser_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
using InputEvent = Variant<KeyEvent, MouseEvent, DragEvent>;
|
using InputEvent = Variant<KeyEvent, MouseEvent, DragEvent>;
|
||||||
|
|
|
@ -203,13 +203,13 @@ void ViewImplementation::enqueue_input_event(Web::InputEvent event)
|
||||||
|
|
||||||
m_pending_input_events.tail().visit(
|
m_pending_input_events.tail().visit(
|
||||||
[this](Web::KeyEvent const& event) {
|
[this](Web::KeyEvent const& event) {
|
||||||
client().async_key_event(m_client_state.page_index, event.clone_without_chrome_data());
|
client().async_key_event(m_client_state.page_index, event.clone_without_browser_data());
|
||||||
},
|
},
|
||||||
[this](Web::MouseEvent const& event) {
|
[this](Web::MouseEvent const& event) {
|
||||||
client().async_mouse_event(m_client_state.page_index, event.clone_without_chrome_data());
|
client().async_mouse_event(m_client_state.page_index, event.clone_without_browser_data());
|
||||||
},
|
},
|
||||||
[this](Web::DragEvent& event) {
|
[this](Web::DragEvent& event) {
|
||||||
auto cloned_event = event.clone_without_chrome_data();
|
auto cloned_event = event.clone_without_browser_data();
|
||||||
cloned_event.files = move(event.files);
|
cloned_event.files = move(event.files);
|
||||||
|
|
||||||
client().async_drag_event(m_client_state.page_index, cloned_event);
|
client().async_drag_event(m_client_state.page_index, cloned_event);
|
||||||
|
|
|
@ -75,7 +75,7 @@ Web::MouseEvent ns_event_to_mouse_event(Web::MouseEvent::Type type, NSEvent* eve
|
||||||
return { type, device_position, device_screen_position, button, button, modifiers, wheel_delta_x, wheel_delta_y, nullptr };
|
return { type, device_position, device_screen_position, button, button, modifiers, wheel_delta_x, wheel_delta_y, nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DragData : public Web::ChromeInputData {
|
struct DragData : public Web::BrowserInputData {
|
||||||
explicit DragData(Vector<URL::URL> urls)
|
explicit DragData(Vector<URL::URL> urls)
|
||||||
: urls(move(urls))
|
: urls(move(urls))
|
||||||
{
|
{
|
||||||
|
@ -96,7 +96,7 @@ Web::DragEvent ns_event_to_drag_event(Web::DragEvent::Type type, id<NSDraggingIn
|
||||||
auto modifiers = ns_modifiers_to_key_modifiers([NSEvent modifierFlags], button);
|
auto modifiers = ns_modifiers_to_key_modifiers([NSEvent modifierFlags], button);
|
||||||
|
|
||||||
Vector<Web::HTML::SelectedFile> files;
|
Vector<Web::HTML::SelectedFile> files;
|
||||||
OwnPtr<DragData> chrome_data;
|
OwnPtr<DragData> browser_data;
|
||||||
|
|
||||||
auto for_each_file = [&](auto callback) {
|
auto for_each_file = [&](auto callback) {
|
||||||
NSArray* file_list = [[event draggingPasteboard] readObjectsForClasses:@[ [NSURL class] ]
|
NSArray* file_list = [[event draggingPasteboard] readObjectsForClasses:@[ [NSURL class] ]
|
||||||
|
@ -123,16 +123,16 @@ Web::DragEvent ns_event_to_drag_event(Web::DragEvent::Type type, id<NSDraggingIn
|
||||||
urls.append(move(url));
|
urls.append(move(url));
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome_data = make<DragData>(move(urls));
|
browser_data = make<DragData>(move(urls));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { type, device_position, device_screen_position, button, button, modifiers, move(files), move(chrome_data) };
|
return { type, device_position, device_screen_position, button, button, modifiers, move(files), move(browser_data) };
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<URL::URL> drag_event_url_list(Web::DragEvent const& event)
|
Vector<URL::URL> drag_event_url_list(Web::DragEvent const& event)
|
||||||
{
|
{
|
||||||
auto& chrome_data = as<DragData>(*event.chrome_data);
|
auto& browser_data = as<DragData>(*event.browser_data);
|
||||||
return move(chrome_data.urls);
|
return move(browser_data.urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSEvent* create_context_menu_mouse_event(NSView* view, Gfx::IntPoint position)
|
NSEvent* create_context_menu_mouse_event(NSView* view, Gfx::IntPoint position)
|
||||||
|
@ -269,7 +269,7 @@ static Web::UIEvents::KeyCode ns_key_code_to_key_code(unsigned short key_code, W
|
||||||
return Web::UIEvents::KeyCode::Key_Invalid;
|
return Web::UIEvents::KeyCode::Key_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeyData : public Web::ChromeInputData {
|
class KeyData : public Web::BrowserInputData {
|
||||||
public:
|
public:
|
||||||
explicit KeyData(NSEvent* event)
|
explicit KeyData(NSEvent* event)
|
||||||
: m_event(CFBridgingRetain(event))
|
: m_event(CFBridgingRetain(event))
|
||||||
|
@ -322,8 +322,8 @@ Web::KeyEvent ns_event_to_key_event(Web::KeyEvent::Type type, NSEvent* event)
|
||||||
|
|
||||||
NSEvent* key_event_to_ns_event(Web::KeyEvent const& event)
|
NSEvent* key_event_to_ns_event(Web::KeyEvent const& event)
|
||||||
{
|
{
|
||||||
auto& chrome_data = as<KeyData>(*event.chrome_data);
|
auto& browser_data = as<KeyData>(*event.browser_data);
|
||||||
return chrome_data.take_event();
|
return browser_data.take_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -801,7 +801,7 @@ void WebContentView::enqueue_native_event(Web::MouseEvent::Type type, QSinglePoi
|
||||||
enqueue_input_event(Web::MouseEvent { type, position, screen_position.to_type<Web::DevicePixels>(), button, buttons, modifiers, wheel_delta_x, wheel_delta_y, nullptr });
|
enqueue_input_event(Web::MouseEvent { type, position, screen_position.to_type<Web::DevicePixels>(), button, buttons, modifiers, wheel_delta_x, wheel_delta_y, nullptr });
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DragData : Web::ChromeInputData {
|
struct DragData : Web::BrowserInputData {
|
||||||
explicit DragData(QDropEvent const& event)
|
explicit DragData(QDropEvent const& event)
|
||||||
: urls(event.mimeData()->urls())
|
: urls(event.mimeData()->urls())
|
||||||
{
|
{
|
||||||
|
@ -822,7 +822,7 @@ void WebContentView::enqueue_native_event(Web::DragEvent::Type type, QDropEvent
|
||||||
auto modifiers = get_modifiers_from_qt_keyboard_modifiers(event.modifiers());
|
auto modifiers = get_modifiers_from_qt_keyboard_modifiers(event.modifiers());
|
||||||
|
|
||||||
Vector<Web::HTML::SelectedFile> files;
|
Vector<Web::HTML::SelectedFile> files;
|
||||||
OwnPtr<DragData> chrome_data;
|
OwnPtr<DragData> browser_data;
|
||||||
|
|
||||||
if (type == Web::DragEvent::Type::DragStart) {
|
if (type == Web::DragEvent::Type::DragStart) {
|
||||||
VERIFY(event.mimeData()->hasUrls());
|
VERIFY(event.mimeData()->hasUrls());
|
||||||
|
@ -836,10 +836,10 @@ void WebContentView::enqueue_native_event(Web::DragEvent::Type type, QDropEvent
|
||||||
files.append(file.release_value());
|
files.append(file.release_value());
|
||||||
}
|
}
|
||||||
} else if (type == Web::DragEvent::Type::Drop) {
|
} else if (type == Web::DragEvent::Type::Drop) {
|
||||||
chrome_data = make<DragData>(event);
|
browser_data = make<DragData>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
enqueue_input_event(Web::DragEvent { type, position, screen_position.to_type<Web::DevicePixels>(), button, buttons, modifiers, AK::move(files), AK::move(chrome_data) });
|
enqueue_input_event(Web::DragEvent { type, position, screen_position.to_type<Web::DevicePixels>(), button, buttons, modifiers, AK::move(files), AK::move(browser_data) });
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentView::finish_handling_drag_event(Web::DragEvent const& event)
|
void WebContentView::finish_handling_drag_event(Web::DragEvent const& event)
|
||||||
|
@ -847,11 +847,11 @@ void WebContentView::finish_handling_drag_event(Web::DragEvent const& event)
|
||||||
if (event.type != Web::DragEvent::Type::Drop)
|
if (event.type != Web::DragEvent::Type::Drop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto const& chrome_data = as<DragData>(*event.chrome_data);
|
auto const& browser_data = as<DragData>(*event.browser_data);
|
||||||
emit urls_dropped(chrome_data.urls);
|
emit urls_dropped(browser_data.urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct KeyData : Web::ChromeInputData {
|
struct KeyData : Web::BrowserInputData {
|
||||||
explicit KeyData(QKeyEvent const& event)
|
explicit KeyData(QKeyEvent const& event)
|
||||||
: event(adopt_own(*event.clone()))
|
: event(adopt_own(*event.clone()))
|
||||||
{
|
{
|
||||||
|
@ -887,8 +887,8 @@ void WebContentView::enqueue_native_event(Web::KeyEvent::Type type, QKeyEvent co
|
||||||
|
|
||||||
void WebContentView::finish_handling_key_event(Web::KeyEvent const& key_event)
|
void WebContentView::finish_handling_key_event(Web::KeyEvent const& key_event)
|
||||||
{
|
{
|
||||||
auto& chrome_data = as<KeyData>(*key_event.chrome_data);
|
auto& browser_data = as<KeyData>(*key_event.browser_data);
|
||||||
auto& event = *chrome_data.event;
|
auto& event = *browser_data.event;
|
||||||
|
|
||||||
switch (key_event.type) {
|
switch (key_event.type) {
|
||||||
case Web::KeyEvent::Type::KeyDown:
|
case Web::KeyEvent::Type::KeyDown:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue