mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
cache document.implementation for object identity
getImplementation() now returns a cached *DOMImplementation pointer per Document, matching the getStyleSheets() pattern. This ensures document.implementation === document.implementation holds true. Flips dom/nodes/Document-implementation.html (1/2 → 2/2).
This commit is contained in:
@@ -52,6 +52,7 @@ _elements_by_id: std.StringHashMapUnmanaged(*Element) = .empty,
|
|||||||
_removed_ids: std.StringHashMapUnmanaged(void) = .empty,
|
_removed_ids: std.StringHashMapUnmanaged(void) = .empty,
|
||||||
_active_element: ?*Element = null,
|
_active_element: ?*Element = null,
|
||||||
_style_sheets: ?*StyleSheetList = null,
|
_style_sheets: ?*StyleSheetList = null,
|
||||||
|
_implementation: ?*DOMImplementation = null,
|
||||||
_write_insertion_point: ?*Node = null,
|
_write_insertion_point: ?*Node = null,
|
||||||
_script_created_parser: ?Parser.Streaming = null,
|
_script_created_parser: ?Parser.Streaming = null,
|
||||||
_adopted_style_sheets: ?js.Object.Global = null,
|
_adopted_style_sheets: ?js.Object.Global = null,
|
||||||
@@ -272,8 +273,11 @@ pub fn querySelectorAll(self: *Document, input: String, page: *Page) !*Selector.
|
|||||||
return Selector.querySelectorAll(self.asNode(), input.str(), page);
|
return Selector.querySelectorAll(self.asNode(), input.str(), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getImplementation(_: *const Document) DOMImplementation {
|
pub fn getImplementation(self: *Document, page: *Page) !*DOMImplementation {
|
||||||
return .{};
|
if (self._implementation) |impl| return impl;
|
||||||
|
const impl = try page._factory.create(DOMImplementation{});
|
||||||
|
self._implementation = impl;
|
||||||
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createDocumentFragment(self: *Document, page: *Page) !*Node.DocumentFragment {
|
pub fn createDocumentFragment(self: *Document, page: *Page) !*Node.DocumentFragment {
|
||||||
@@ -726,6 +730,7 @@ pub fn open(self: *Document, page: *Page) !*Document {
|
|||||||
self._elements_by_id.clearAndFree(page.arena);
|
self._elements_by_id.clearAndFree(page.arena);
|
||||||
self._active_element = null;
|
self._active_element = null;
|
||||||
self._style_sheets = null;
|
self._style_sheets = null;
|
||||||
|
self._implementation = null;
|
||||||
self._ready_state = .loading;
|
self._ready_state = .loading;
|
||||||
|
|
||||||
self._script_created_parser = Parser.Streaming.init(page.arena, doc_node, page);
|
self._script_created_parser = Parser.Streaming.init(page.arena, doc_node, page);
|
||||||
|
|||||||
Reference in New Issue
Block a user