@@ -194,57 +194,60 @@ bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button
194
194
node->dispatch_event (UIEvents::MouseEvent::create (UIEvents::EventNames::mouseup, offset.x (), offset.y (), position.x (), position.y ()));
195
195
handled_event = true ;
196
196
197
- // FIXME: This is ad-hoc and incorrect. The reason this exists is
198
- // because we are missing browsing context navigation:
199
- //
200
- // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
201
- //
202
- // Additionally, we currently cannot spawn a new top-level
203
- // browsing context for new tab operations, because the new
204
- // top-level browsing context would be in another process. To
205
- // fix this, there needs to be some way to be able to
206
- // communicate with browsing contexts in remote WebContent
207
- // processes, and then step 8 of this algorithm needs to be
208
- // implemented in BrowsingContext::choose_a_browsing_context:
209
- //
210
- // https://html.spec.whatwg.org/multipage/browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name
211
- if (RefPtr<HTML::HTMLAnchorElement> link = node->enclosing_link_element ()) {
212
- NonnullRefPtr document = *m_browsing_context.active_document ();
213
- auto href = link->href ();
214
- auto url = document->parse_url (href);
215
- dbgln (" Web::EventHandler: Clicking on a link to {}" , url);
216
- if (button == GUI::MouseButton::Primary) {
217
- if (href.starts_with (" javascript:" )) {
218
- document->run_javascript (href.substring_view (11 , href.length () - 11 ));
219
- } else if (!url.fragment ().is_null () && url.equals (document->url (), AK::URL::ExcludeFragment::Yes)) {
220
- m_browsing_context.scroll_to_anchor (url.fragment ());
221
- } else {
222
- if (m_browsing_context.is_top_level ()) {
223
- if (auto * page = m_browsing_context.page ())
224
- page->client ().page_did_click_link (url, link->target (), modifiers);
197
+ bool run_activation_behavior = true ;
198
+ if (node.ptr () == m_mousedown_target && button == GUI::MouseButton::Primary) {
199
+ run_activation_behavior = node->dispatch_event (UIEvents::MouseEvent::create (UIEvents::EventNames::click, offset.x (), offset.y (), position.x (), position.y ()));
200
+ }
201
+
202
+ if (run_activation_behavior) {
203
+ // FIXME: This is ad-hoc and incorrect. The reason this exists is
204
+ // because we are missing browsing context navigation:
205
+ //
206
+ // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
207
+ //
208
+ // Additionally, we currently cannot spawn a new top-level
209
+ // browsing context for new tab operations, because the new
210
+ // top-level browsing context would be in another process. To
211
+ // fix this, there needs to be some way to be able to
212
+ // communicate with browsing contexts in remote WebContent
213
+ // processes, and then step 8 of this algorithm needs to be
214
+ // implemented in BrowsingContext::choose_a_browsing_context:
215
+ //
216
+ // https://html.spec.whatwg.org/multipage/browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name
217
+ if (RefPtr<HTML::HTMLAnchorElement> link = node->enclosing_link_element ()) {
218
+ NonnullRefPtr document = *m_browsing_context.active_document ();
219
+ auto href = link->href ();
220
+ auto url = document->parse_url (href);
221
+ dbgln (" Web::EventHandler: Clicking on a link to {}" , url);
222
+ if (button == GUI::MouseButton::Primary) {
223
+ if (href.starts_with (" javascript:" )) {
224
+ document->run_javascript (href.substring_view (11 , href.length () - 11 ));
225
+ } else if (!url.fragment ().is_null () && url.equals (document->url (), AK::URL::ExcludeFragment::Yes)) {
226
+ m_browsing_context.scroll_to_anchor (url.fragment ());
227
+ } else {
228
+ if (m_browsing_context.is_top_level ()) {
229
+ if (auto * page = m_browsing_context.page ())
230
+ page->client ().page_did_click_link (url, link->target (), modifiers);
231
+ }
225
232
}
233
+ } else if (button == GUI::MouseButton::Middle) {
234
+ if (auto * page = m_browsing_context.page ())
235
+ page->client ().page_did_middle_click_link (url, link->target (), modifiers);
236
+ } else if (button == GUI::MouseButton::Secondary) {
237
+ if (auto * page = m_browsing_context.page ())
238
+ page->client ().page_did_request_link_context_menu (m_browsing_context.to_top_level_position (position), url, link->target (), modifiers);
226
239
}
227
- } else if (button == GUI::MouseButton::Middle) {
228
- if (auto * page = m_browsing_context.page ())
229
- page->client ().page_did_middle_click_link (url, link->target (), modifiers);
230
240
} else if (button == GUI::MouseButton::Secondary) {
231
- if (auto * page = m_browsing_context.page ())
232
- page->client ().page_did_request_link_context_menu (m_browsing_context.to_top_level_position (position), url, link->target (), modifiers);
233
- }
234
- } else if (button == GUI::MouseButton::Secondary) {
235
- if (is<HTML::HTMLImageElement>(*node)) {
236
- auto & image_element = verify_cast<HTML::HTMLImageElement>(*node);
237
- auto image_url = image_element.document ().parse_url (image_element.src ());
238
- if (auto * page = m_browsing_context.page ())
239
- page->client ().page_did_request_image_context_menu (m_browsing_context.to_top_level_position (position), image_url, " " , modifiers, image_element.bitmap ());
240
- } else if (auto * page = m_browsing_context.page ()) {
241
- page->client ().page_did_request_context_menu (m_browsing_context.to_top_level_position (position));
241
+ if (is<HTML::HTMLImageElement>(*node)) {
242
+ auto & image_element = verify_cast<HTML::HTMLImageElement>(*node);
243
+ auto image_url = image_element.document ().parse_url (image_element.src ());
244
+ if (auto * page = m_browsing_context.page ())
245
+ page->client ().page_did_request_image_context_menu (m_browsing_context.to_top_level_position (position), image_url, " " , modifiers, image_element.bitmap ());
246
+ } else if (auto * page = m_browsing_context.page ()) {
247
+ page->client ().page_did_request_context_menu (m_browsing_context.to_top_level_position (position));
248
+ }
242
249
}
243
250
}
244
-
245
- if (node.ptr () == m_mousedown_target && button == GUI::MouseButton::Primary) {
246
- node->dispatch_event (UIEvents::MouseEvent::create (UIEvents::EventNames::click, offset.x (), offset.y (), position.x (), position.y ()));
247
- }
248
251
}
249
252
}
250
253
0 commit comments