mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
dom: remove verbose logging and simplify css logic
This commit is contained in:
@@ -1058,7 +1058,6 @@ pub fn checkVisibility(self: *Element, page: *Page) bool {
|
|||||||
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
const doc_sheets = page.document.getStyleSheets(page) catch null;
|
||||||
if (doc_sheets) |sheets| {
|
if (doc_sheets) |sheets| {
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
if (sheets.length() > 0) log.info(.dom, "css.visibility.check", .{});
|
|
||||||
while (i < sheets.length()) : (i += 1) {
|
while (i < sheets.length()) : (i += 1) {
|
||||||
const sheet = sheets.item(i) orelse continue;
|
const sheet = sheets.item(i) orelse continue;
|
||||||
const rules = sheet.getCssRules(page) catch continue;
|
const rules = sheet.getCssRules(page) catch continue;
|
||||||
@@ -1067,15 +1066,10 @@ pub fn checkVisibility(self: *Element, page: *Page) bool {
|
|||||||
const rule = rules.item(j) orelse continue;
|
const rule = rules.item(j) orelse continue;
|
||||||
if (rule.is(CSSStyleRule)) |style_rule| {
|
if (rule.is(CSSStyleRule)) |style_rule| {
|
||||||
const selector = style_rule.getSelectorText();
|
const selector = style_rule.getSelectorText();
|
||||||
// log.info(.dom, "check_visibility.eval {s}", .{selector});
|
const does_match = el.matches(selector, page) catch false;
|
||||||
const does_match = el.matches(selector, page) catch |err| blk: {
|
|
||||||
log.info(.dom, "check_visibility.err", .{ .err = err });
|
|
||||||
break :blk false;
|
|
||||||
};
|
|
||||||
if (does_match) {
|
if (does_match) {
|
||||||
const style = (style_rule.getStyle(page) catch continue).asCSSStyleDeclaration();
|
const style = (style_rule.getStyle(page) catch continue).asCSSStyleDeclaration();
|
||||||
const display = style.getPropertyValue("display", page);
|
const display = style.getPropertyValue("display", page);
|
||||||
log.info(.dom, "check_visibility.hit", .{});
|
|
||||||
if (std.mem.eql(u8, display, "none")) {
|
if (std.mem.eql(u8, display, "none")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,8 +172,6 @@ pub fn setFloat(self: *CSSStyleDeclaration, value_: ?[]const u8, page: *Page) !v
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getCssText(self: *const CSSStyleDeclaration, page: *Page) ![]const u8 {
|
pub fn getCssText(self: *const CSSStyleDeclaration, page: *Page) ![]const u8 {
|
||||||
if (self._element == null) return "";
|
|
||||||
|
|
||||||
var buf = std.Io.Writer.Allocating.init(page.call_arena);
|
var buf = std.Io.Writer.Allocating.init(page.call_arena);
|
||||||
try self.format(&buf.writer);
|
try self.format(&buf.writer);
|
||||||
return buf.written();
|
return buf.written();
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ pub fn insertRule(self: *CSSStyleSheet, rule: []const u8, index: u32, page: *Pag
|
|||||||
|
|
||||||
const style_rule = try CSSStyleRule.init(page);
|
const style_rule = try CSSStyleRule.init(page);
|
||||||
try style_rule.setSelectorText(parsed_rule.selector, page);
|
try style_rule.setSelectorText(parsed_rule.selector, page);
|
||||||
@import("../../../log.zig").info(.dom, "css.rule.add {s}", .{parsed_rule.selector});
|
|
||||||
|
|
||||||
const style_props = try style_rule.getStyle(page);
|
const style_props = try style_rule.getStyle(page);
|
||||||
const style = style_props.asCSSStyleDeclaration();
|
const style = style_props.asCSSStyleDeclaration();
|
||||||
@@ -91,7 +90,6 @@ pub fn replaceSync(self: *CSSStyleSheet, text: []const u8, page: *Page) !void {
|
|||||||
while (it.next()) |parsed_rule| {
|
while (it.next()) |parsed_rule| {
|
||||||
const style_rule = try CSSStyleRule.init(page);
|
const style_rule = try CSSStyleRule.init(page);
|
||||||
try style_rule.setSelectorText(parsed_rule.selector, page);
|
try style_rule.setSelectorText(parsed_rule.selector, page);
|
||||||
@import("../../../log.zig").info(.dom, "css.rule.add {s}", .{parsed_rule.selector});
|
|
||||||
|
|
||||||
const style_props = try style_rule.getStyle(page);
|
const style_props = try style_rule.getStyle(page);
|
||||||
const style = style_props.asCSSStyleDeclaration();
|
const style = style_props.asCSSStyleDeclaration();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ pub fn item(self: *const StyleSheetList, index: usize) ?*CSSStyleSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(self: *StyleSheetList, sheet: *CSSStyleSheet, page: *Page) !void {
|
pub fn add(self: *StyleSheetList, sheet: *CSSStyleSheet, page: *Page) !void {
|
||||||
@import("../../../log.zig").info(.dom, "css.sheet.add", .{});
|
|
||||||
try self._sheets.append(page.arena, sheet);
|
try self._sheets.append(page.arena, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ pub fn setDisabled(self: *Style, disabled: bool, page: *Page) !void {
|
|||||||
|
|
||||||
const CSSStyleSheet = @import("../../css/CSSStyleSheet.zig");
|
const CSSStyleSheet = @import("../../css/CSSStyleSheet.zig");
|
||||||
pub fn getSheet(self: *Style, page: *Page) !?*CSSStyleSheet {
|
pub fn getSheet(self: *Style, page: *Page) !?*CSSStyleSheet {
|
||||||
@import("../../../../log.zig").info(.dom, "css.style.get_sheet", .{});
|
|
||||||
// Per spec, sheet is null for disconnected elements or non-CSS types.
|
// Per spec, sheet is null for disconnected elements or non-CSS types.
|
||||||
// Valid types: absent (defaults to "text/css"), empty string, or
|
// Valid types: absent (defaults to "text/css"), empty string, or
|
||||||
// case-insensitive match for "text/css".
|
// case-insensitive match for "text/css".
|
||||||
|
|||||||
Reference in New Issue
Block a user