mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 15:28:57 +00:00
Intl and IFrame skeleton
This commit is contained in:
@@ -447,6 +447,7 @@ pub const JsApis = flattenTypes(&.{
|
||||
@import("../webapi/Document.zig"),
|
||||
@import("../webapi/HTMLDocument.zig"),
|
||||
@import("../webapi/History.zig"),
|
||||
@import("../webapi/intl/Intl.zig"),
|
||||
@import("../webapi/KeyValueList.zig"),
|
||||
@import("../webapi/DocumentFragment.zig"),
|
||||
@import("../webapi/DocumentType.zig"),
|
||||
@@ -458,6 +459,7 @@ pub const JsApis = flattenTypes(&.{
|
||||
@import("../webapi/Element.zig"),
|
||||
@import("../webapi/element/Attribute.zig"),
|
||||
@import("../webapi/element/Html.zig"),
|
||||
@import("../webapi/element/html/IFrame.zig"),
|
||||
@import("../webapi/element/html/Anchor.zig"),
|
||||
@import("../webapi/element/html/Body.zig"),
|
||||
@import("../webapi/element/html/BR.zig"),
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
testing.expectEqual(null, document.parentNode);
|
||||
testing.expectEqual(undefined, document.getCurrentScript);
|
||||
testing.expectEqual("http://127.0.0.1:9582/src/browser/tests/document/document.html", document.URL);
|
||||
testing.expectEqual(window, document.defaultView);
|
||||
</script>
|
||||
|
||||
<script id=headAndbody>
|
||||
|
||||
@@ -195,6 +195,11 @@ pub const JsApi = struct {
|
||||
pub const querySelectorAll = bridge.function(Document.querySelectorAll, .{ .dom_exception = true });
|
||||
pub const getElementsByTagName = bridge.function(Document.getElementsByTagName, .{});
|
||||
pub const getElementsByClassName = bridge.function(Document.getElementsByClassName, .{});
|
||||
pub const defaultView = bridge.accessor(struct{
|
||||
fn defaultView(_: *const Document, page: *Page) *@import("Window.zig") {
|
||||
return page.window;
|
||||
}
|
||||
}.defaultView, null, .{.cache = "defaultView"});
|
||||
};
|
||||
|
||||
const testing = @import("../../testing.zig");
|
||||
|
||||
@@ -107,6 +107,7 @@ pub fn getTagNameLower(self: *const Element) []const u8 {
|
||||
.head => "head",
|
||||
.html => "html",
|
||||
.hr => "hr",
|
||||
.iframe => "iframe",
|
||||
.img => "img",
|
||||
.input => "input",
|
||||
.li => "li",
|
||||
@@ -148,6 +149,7 @@ pub fn getTagNameSpec(self: *const Element, buf: []u8) []const u8 {
|
||||
.head => "HEAD",
|
||||
.html => "HTML",
|
||||
.hr => "HR",
|
||||
.iframe => "IFRAME",
|
||||
.img => "IMG",
|
||||
.input => "INPUT",
|
||||
.li => "LI",
|
||||
@@ -522,6 +524,7 @@ pub fn getTag(self: *const Element) Tag {
|
||||
.form => .form,
|
||||
.p => .p,
|
||||
.custom => .custom,
|
||||
.iframe => .iframe,
|
||||
.img => .img,
|
||||
.br => .br,
|
||||
.button => .button,
|
||||
@@ -577,6 +580,7 @@ pub const Tag = enum {
|
||||
hr,
|
||||
html,
|
||||
i,
|
||||
iframe,
|
||||
img,
|
||||
input,
|
||||
li,
|
||||
|
||||
@@ -6,6 +6,7 @@ const log = @import("../../log.zig");
|
||||
const Page = @import("../Page.zig");
|
||||
const Console = @import("Console.zig");
|
||||
const History = @import("History.zig");
|
||||
const Intl = @import("intl/Intl.zig");
|
||||
const Navigator = @import("Navigator.zig");
|
||||
const Document = @import("Document.zig");
|
||||
const Location = @import("Location.zig");
|
||||
@@ -52,6 +53,10 @@ pub fn getNavigator(_: *const Window) Navigator {
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn getIntl(_: *const Window) Intl {
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn getLocalStorage(self: *const Window) *storage.Lookup {
|
||||
return &self._storage_bucket.local;
|
||||
}
|
||||
@@ -266,6 +271,7 @@ pub const JsApi = struct {
|
||||
pub const parent = bridge.accessor(Window.getWindow, null, .{ .cache = "parent" });
|
||||
pub const console = bridge.accessor(Window.getConsole, null, .{ .cache = "console" });
|
||||
pub const navigator = bridge.accessor(Window.getNavigator, null, .{ .cache = "navigator" });
|
||||
pub const Intl = bridge.accessor(Window.getIntl, null, .{ .cache = "Intl" });
|
||||
pub const localStorage = bridge.accessor(Window.getLocalStorage, null, .{ .cache = "localStorage" });
|
||||
pub const sessionStorage = bridge.accessor(Window.getSessionStorage, null, .{ .cache = "sessionStorage" });
|
||||
pub const document = bridge.accessor(Window.getDocument, null, .{ .cache = "document" });
|
||||
|
||||
@@ -31,6 +31,7 @@ pub const TextArea = @import("html/TextArea.zig");
|
||||
pub const Paragraph = @import("html/Paragraph.zig");
|
||||
pub const Select = @import("html/Select.zig");
|
||||
pub const Option = @import("html/Option.zig");
|
||||
pub const IFrame = @import("html/IFrame.zig");
|
||||
|
||||
const HtmlElement = @This();
|
||||
|
||||
@@ -51,6 +52,7 @@ pub const Type = union(enum) {
|
||||
html: Html,
|
||||
hr: HR,
|
||||
img: Image,
|
||||
iframe: IFrame,
|
||||
input: *Input,
|
||||
li: LI,
|
||||
link: Link,
|
||||
@@ -89,6 +91,7 @@ pub fn className(self: *const HtmlElement) []const u8 {
|
||||
.p => "[object HtmlParagraphElement]",
|
||||
.custom => "[object CUSTOM-TODO]",
|
||||
.img => "[object HTMLImageElement]",
|
||||
.iframe => "[object HTMLIFrameElement]",
|
||||
.br => "[object HTMLBRElement]",
|
||||
.button => "[object HTMLButtonElement]",
|
||||
.heading => "[object HTMLHeadingElement]",
|
||||
|
||||
24
src/browser/webapi/element/html/IFrame.zig
Normal file
24
src/browser/webapi/element/html/IFrame.zig
Normal file
@@ -0,0 +1,24 @@
|
||||
const js = @import("../../../js/js.zig");
|
||||
const Node = @import("../../Node.zig");
|
||||
const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const IFrame = @This();
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *IFrame) *Element {
|
||||
return self._proto._proto;
|
||||
}
|
||||
pub fn asNode(self: *IFrame) *Node {
|
||||
return self.asElement().asNode();
|
||||
}
|
||||
|
||||
pub const JsApi = struct {
|
||||
pub const bridge = js.Bridge(IFrame);
|
||||
|
||||
pub const Meta = struct {
|
||||
pub const name = "HTMLIFrameElement";
|
||||
pub const prototype_chain = bridge.prototypeChain();
|
||||
pub var class_id: bridge.ClassId = undefined;
|
||||
};
|
||||
};
|
||||
20
src/browser/webapi/intl/Intl.zig
Normal file
20
src/browser/webapi/intl/Intl.zig
Normal file
@@ -0,0 +1,20 @@
|
||||
const std = @import("std");
|
||||
const js = @import("../../js/js.zig");
|
||||
|
||||
const Intl = @This();
|
||||
|
||||
// Skeleton implementation with no actual functionality yet.
|
||||
// This allows `if (Intl)` checks to pass, while property checks
|
||||
// like `if (Intl.Locale)` will return undefined.
|
||||
// We can add actual implementations as we encounter real-world use cases.
|
||||
|
||||
pub const JsApi = struct {
|
||||
pub const bridge = js.Bridge(Intl);
|
||||
|
||||
pub const Meta = struct {
|
||||
pub const name = "Intl";
|
||||
pub var class_id: bridge.ClassId = undefined;
|
||||
pub const prototype_chain = bridge.prototypeChain();
|
||||
pub const empty_with_no_proto = true;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user