Skip to content

Commit 2885cec

Browse files
committed
document use of i32
1 parent ed31a45 commit 2885cec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/browser/html/document.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,21 @@ pub const HTMLDocument = struct {
233233
// Since LightPanda requires the client to know what they are clicking on we do not return the underlying element at this moment
234234
// This can currenty only happen if the first pixel is clicked without having rendered any element. This will change when css properties are supported.
235235
// This returns an ElementUnion instead of a *Parser.Element in case the element somehow hasn't passed through the js runtime yet.
236+
// While x and y should be f32, here we take i32 since that's what our
237+
// "renderer" uses. By specifying i32 here, rather than f32 and doing the
238+
// conversion ourself, we rely on v8's type conversion which is both more
239+
// flexible (e.g. handles NaN) and will be more consistent with a browser.
236240
pub fn _elementFromPoint(_: *parser.DocumentHTML, x: i32, y: i32, page: *Page) !?ElementUnion {
237241
const element = page.renderer.getElementAtPosition(x, y) orelse return null;
238242
// TODO if pointer-events set to none the underlying element should be returned (parser.documentGetDocumentElement(self.document);?)
239243
return try Element.toInterface(element);
240244
}
241245

242246
// Returns an array of all elements at the specified coordinates (relative to the viewport). The elements are ordered from the topmost to the bottommost box of the viewport.
247+
// While x and y should be f32, here we take i32 since that's what our
248+
// "renderer" uses. By specifying i32 here, rather than f32 and doing the
249+
// conversion ourself, we rely on v8's type conversion which is both more
250+
// flexible (e.g. handles NaN) and will be more consistent with a browser.
243251
pub fn _elementsFromPoint(_: *parser.DocumentHTML, x: i32, y: i32, page: *Page) ![]ElementUnion {
244252
const element = page.renderer.getElementAtPosition(x, y) orelse return &.{};
245253
// TODO if pointer-events set to none the underlying element should be returned (parser.documentGetDocumentElement(self.document);?)

0 commit comments

Comments
 (0)