mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
Merge pull request #1493 from lightpanda-io/document_visibility
Add Document.hidden and visibilityState properties
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
testing.expectEqual(undefined, document.getCurrentScript);
|
testing.expectEqual(undefined, document.getCurrentScript);
|
||||||
testing.expectEqual("http://127.0.0.1:9582/src/browser/tests/document/document.html", document.URL);
|
testing.expectEqual("http://127.0.0.1:9582/src/browser/tests/document/document.html", document.URL);
|
||||||
testing.expectEqual(window, document.defaultView);
|
testing.expectEqual(window, document.defaultView);
|
||||||
|
testing.expectEqual(false, document.hidden);
|
||||||
|
testing.expectEqual("visible", document.visibilityState);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script id=headAndbody>
|
<script id=headAndbody>
|
||||||
|
|||||||
@@ -796,6 +796,17 @@ pub fn setAdoptedStyleSheets(self: *Document, sheets: js.Object) !void {
|
|||||||
self._adopted_style_sheets = try sheets.persist();
|
self._adopted_style_sheets = try sheets.persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getHidden(_: *const Document) bool {
|
||||||
|
// it's hidden when, for example, the decive is locked, or user is on a
|
||||||
|
// a different tab.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn getVisibilityState(_: *const Document) []const u8 {
|
||||||
|
// See getHidden above, possible options are "visible" or "hidden"
|
||||||
|
return "visible";
|
||||||
|
}
|
||||||
|
|
||||||
// Validates that nodes can be inserted into a Document, respecting Document constraints:
|
// Validates that nodes can be inserted into a Document, respecting Document constraints:
|
||||||
// - At most one Element child
|
// - At most one Element child
|
||||||
// - At most one DocumentType child
|
// - At most one DocumentType child
|
||||||
@@ -991,6 +1002,8 @@ pub const JsApi = struct {
|
|||||||
pub const lastElementChild = bridge.accessor(Document.getLastElementChild, null, .{});
|
pub const lastElementChild = bridge.accessor(Document.getLastElementChild, null, .{});
|
||||||
pub const childElementCount = bridge.accessor(Document.getChildElementCount, null, .{});
|
pub const childElementCount = bridge.accessor(Document.getChildElementCount, null, .{});
|
||||||
pub const adoptedStyleSheets = bridge.accessor(Document.getAdoptedStyleSheets, Document.setAdoptedStyleSheets, .{});
|
pub const adoptedStyleSheets = bridge.accessor(Document.getAdoptedStyleSheets, Document.setAdoptedStyleSheets, .{});
|
||||||
|
pub const hidden = bridge.accessor(Document.getHidden, null, .{});
|
||||||
|
pub const visibilityState = bridge.accessor(Document.getVisibilityState, null, .{});
|
||||||
|
|
||||||
pub const defaultView = bridge.accessor(struct {
|
pub const defaultView = bridge.accessor(struct {
|
||||||
fn defaultView(_: *const Document, page: *Page) *@import("Window.zig") {
|
fn defaultView(_: *const Document, page: *Page) *@import("Window.zig") {
|
||||||
|
|||||||
Reference in New Issue
Block a user