mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
Add dummy Element.checkVisibility
`checkVisibility` currently always return true. Also, when the visibility CSS property is checked, always return 'visible'. This allows the playwright click test to pass with a working getComputedStyle. It's also probably more accurate - by default, most elements are probably visible. But it still isn't great. Add named_get to CSSStyleDeclaration (allowing things like `style.display`).
This commit is contained in:
@@ -95,7 +95,16 @@ pub const CSSStyleDeclaration = struct {
|
|||||||
|
|
||||||
// TODO should handle properly shorthand properties and canonical forms
|
// TODO should handle properly shorthand properties and canonical forms
|
||||||
pub fn _getPropertyValue(self: *const CSSStyleDeclaration, name: []const u8) []const u8 {
|
pub fn _getPropertyValue(self: *const CSSStyleDeclaration, name: []const u8) []const u8 {
|
||||||
return if (self.store.get(name)) |prop| prop.value else "";
|
if (self.store.get(name)) |prop| {
|
||||||
|
return prop.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default to everything being visible (unless it's been explicitly set)
|
||||||
|
if (std.mem.eql(u8, name, "visibility")) {
|
||||||
|
return "visible";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _item(self: *const CSSStyleDeclaration, index: usize) []const u8 {
|
pub fn _item(self: *const CSSStyleDeclaration, index: usize) []const u8 {
|
||||||
@@ -127,6 +136,11 @@ pub const CSSStyleDeclaration = struct {
|
|||||||
|
|
||||||
gop.value_ptr.* = .{ .value = owned_value, .priority = is_important };
|
gop.value_ptr.* = .{ .value = owned_value, .priority = is_important };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn named_get(self: *const CSSStyleDeclaration, name: []const u8, _: *bool) []const u8 {
|
||||||
|
std.debug.print("named_get: {s} {s}\n", .{name, self._getPropertyValue(name)});
|
||||||
|
return self._getPropertyValue(name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
@@ -164,6 +178,7 @@ test "CSSOM.CSSStyleDeclaration" {
|
|||||||
.{ "style.setProperty('color', 'green')", "undefined" },
|
.{ "style.setProperty('color', 'green')", "undefined" },
|
||||||
.{ "style.getPropertyValue('color')", "green" },
|
.{ "style.getPropertyValue('color')", "green" },
|
||||||
.{ "style.length", "4" },
|
.{ "style.length", "4" },
|
||||||
|
.{ "style.color", "green"},
|
||||||
|
|
||||||
.{ "style.setProperty('padding', '10px', 'important')", "undefined" },
|
.{ "style.setProperty('padding', '10px', 'important')", "undefined" },
|
||||||
.{ "style.getPropertyValue('padding')", "10px" },
|
.{ "style.getPropertyValue('padding')", "10px" },
|
||||||
@@ -225,4 +240,9 @@ test "CSSOM.CSSStyleDeclaration" {
|
|||||||
.{ "style.setProperty('border-bottom-left-radius', '5px')", "undefined" },
|
.{ "style.setProperty('border-bottom-left-radius', '5px')", "undefined" },
|
||||||
.{ "style.getPropertyValue('border-bottom-left-radius')", "5px" },
|
.{ "style.getPropertyValue('border-bottom-left-radius')", "5px" },
|
||||||
}, .{});
|
}, .{});
|
||||||
|
|
||||||
|
try runner.testCases(&.{
|
||||||
|
.{ "style.visibility", "visible" },
|
||||||
|
.{ "style.getPropertyValue('visibility')", "visible" },
|
||||||
|
}, .{});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,6 +407,18 @@ pub const Element = struct {
|
|||||||
pub fn _scrollIntoViewIfNeeded(_: *parser.Element, center_if_needed: ?bool) void {
|
pub fn _scrollIntoViewIfNeeded(_: *parser.Element, center_if_needed: ?bool) void {
|
||||||
_ = center_if_needed;
|
_ = center_if_needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CheckVisibilityOpts = struct {
|
||||||
|
contentVisibilityAuto: bool,
|
||||||
|
opacityProperty: bool,
|
||||||
|
visibilityProperty: bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn _checkVisibility(self: *parser.Element, opts: ?CheckVisibilityOpts) bool {
|
||||||
|
_ = self;
|
||||||
|
_ = opts;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
|
|||||||
Reference in New Issue
Block a user