Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ora/Core/BrowserEngine/Scripts/OraBrowserScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,19 @@ enum OraBrowserScripts {
post('linkHover', url || "");
}

function currentAnchor(node) {
return node && node.closest ? node.closest('a[href]') : null;
}

function onMouseOver(event) {
const anchor = event.target.closest && event.target.closest('a[href]');
const anchor = currentAnchor(event.target);
postHover(anchor ? anchor.href : '');
}
Comment on lines 100 to 103

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 onMouseOver still posts redundant bridge messages within the same anchor

onMouseOut now correctly suppresses posts when the anchor stays the same, but onMouseOver unconditionally posts for every child element transition. Moving the cursor across <a href="/foo"><img/><span>text</span></a> produces a mouseover on <img> and then on <span>, both resolving to the same anchor and both issuing a postHover("/foo"). Each call reaches the native side, assigns hoveredLinkURL to an equal string, and triggers objectWillChange — the visual flicker is gone (thanks to the onMouseOut fix), but the redundant IPC can be eliminated by tracking the last-posted anchor reference in JS and early-returning when it hasn't changed.


function onMouseOut(event) {
const related = event.relatedTarget;
if (!related || !event.currentTarget.contains(related)) {
postHover("");
}
const from = currentAnchor(event.target);
const to = currentAnchor(event.relatedTarget);
if (from !== to) postHover(to ? to.href : '');
}

document.addEventListener('mouseover', onMouseOver, true);
Expand Down
1 change: 1 addition & 0 deletions ora/Features/Browser/Views/BrowserWebContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct BrowserWebContentView: View {
LinkPreview(text: hovered)
}
}
.animation(.easeOut(duration: 0.12), value: tab.hoveredLinkURL)
} else {
ZStack {
Rectangle().fill(theme.background)
Expand Down
Loading