mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
webapi): reorder css function params and merge pointer events
This commit is contained in:
@@ -94,7 +94,7 @@ fn walk(self: @This(), node: *Node, xpath_buffer: *std.ArrayList(u8), parent_nam
|
|||||||
if (tag == .datalist or tag == .option or tag == .optgroup) return;
|
if (tag == .datalist or tag == .option or tag == .optgroup) return;
|
||||||
|
|
||||||
// Check visibility using the engine's checkVisibility which handles CSS display: none
|
// Check visibility using the engine's checkVisibility which handles CSS display: none
|
||||||
if (!el.checkVisibilityCached(self.page, css_cache)) {
|
if (!el.checkVisibilityCached(css_cache, self.page)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ pub fn classifyInteractivity(
|
|||||||
listener_targets: ListenerTargetMap,
|
listener_targets: ListenerTargetMap,
|
||||||
cache: ?*Element.CssCache,
|
cache: ?*Element.CssCache,
|
||||||
) ?InteractivityType {
|
) ?InteractivityType {
|
||||||
if (el.hasPointerEventsNoneCached(page, cache)) return null;
|
if (el.hasPointerEventsNone(cache, page)) return null;
|
||||||
|
|
||||||
// 1. Native interactive by tag
|
// 1. Native interactive by tag
|
||||||
switch (el.getTag()) {
|
switch (el.getTag()) {
|
||||||
|
|||||||
@@ -1053,7 +1053,7 @@ pub const CssProperties = struct {
|
|||||||
|
|
||||||
pub const CssCache = std.AutoHashMapUnmanaged(*Element, CssProperties);
|
pub const CssCache = std.AutoHashMapUnmanaged(*Element, CssProperties);
|
||||||
|
|
||||||
fn getCssProperties(el: *Element, page: *Page, doc_sheets: ?*StyleSheetList, cache: ?*CssCache) CssProperties {
|
fn getCssProperties(el: *Element, doc_sheets: ?*StyleSheetList, cache: ?*CssCache, page: *Page) CssProperties {
|
||||||
if (cache) |c| {
|
if (cache) |c| {
|
||||||
if (c.get(el)) |props| return props;
|
if (c.get(el)) |props| return props;
|
||||||
}
|
}
|
||||||
@@ -1144,27 +1144,23 @@ fn getCssProperties(el: *Element, page: *Page, doc_sheets: ?*StyleSheetList, cac
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hasPointerEventsNoneCached(self: *Element, page: *Page, cache: ?*CssCache) bool {
|
pub fn hasPointerEventsNone(self: *Element, cache: ?*CssCache, page: *Page) bool {
|
||||||
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
||||||
var current: ?*Element = self;
|
var current: ?*Element = self;
|
||||||
while (current) |el| {
|
while (current) |el| {
|
||||||
const props = el.getCssProperties(page, doc_sheets, cache);
|
const props = el.getCssProperties(doc_sheets, cache, page);
|
||||||
if (props.pointer_events_none) return true;
|
if (props.pointer_events_none) return true;
|
||||||
current = el.parentElement();
|
current = el.parentElement();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hasPointerEventsNone(self: *Element, page: *Page) bool {
|
pub fn checkVisibilityCached(self: *Element, cache: ?*CssCache, page: *Page) bool {
|
||||||
return self.hasPointerEventsNoneCached(page, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn checkVisibilityCached(self: *Element, page: *Page, cache: ?*CssCache) bool {
|
|
||||||
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
||||||
var current: ?*Element = self;
|
var current: ?*Element = self;
|
||||||
|
|
||||||
while (current) |el| {
|
while (current) |el| {
|
||||||
const props = getCssProperties(el, page, doc_sheets, cache);
|
const props = getCssProperties(el, doc_sheets, cache, page);
|
||||||
if (props.display_none or props.visibility_hidden or props.opacity_zero) return false;
|
if (props.display_none or props.visibility_hidden or props.opacity_zero) return false;
|
||||||
current = el.parentElement();
|
current = el.parentElement();
|
||||||
}
|
}
|
||||||
@@ -1173,7 +1169,7 @@ pub fn checkVisibilityCached(self: *Element, page: *Page, cache: ?*CssCache) boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn checkVisibility(self: *Element, page: *Page) bool {
|
pub fn checkVisibility(self: *Element, page: *Page) bool {
|
||||||
return self.checkVisibilityCached(page, null);
|
return self.checkVisibilityCached(null, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getElementDimensions(self: *Element, page: *Page) struct { width: f64, height: f64 } {
|
fn getElementDimensions(self: *Element, page: *Page) struct { width: f64, height: f64 } {
|
||||||
|
|||||||
Reference in New Issue
Block a user