Files
electron/shell
Samuel AttardandClaude a88c70b1b0 refactor: give View, BaseWindow, MessagePortMain and ParentPort their prototypes natively (#53962)
* refactor: give View, BaseWindow, MessagePortMain and ParentPort their prototypes natively

View/WebContentsView/ImageView and BaseWindow/BrowserWindow were plain
constructor templates whose prototype chains (EventEmitter, and the
subclass -> base links) were stitched together afterwards in lib/ with
Object.setPrototypeOf, which is why browser/init.ts had to load
web-contents-view.ts before anything could create a window. MessagePort
and the utility process's ParentPort were wrapped in JS EventEmitter
classes (MessagePortMain, ParentPort) that re-emitted every event and
wrapped/unwrapped ports on the way in and out, in the browser, in
ipc_dispatch and in the utility bundle.

The constructor templates now Inherit() from the EventEmitter template or
their base class's template, app gets its EventEmitter prototype when the
binding creates it, and MessagePort / ParentPort are Constructible
EventEmitters themselves (class names MessagePortMain / ParentPort, not
constructible from JavaScript). lib/browser/api/view.ts,
web-contents-view.ts, views/image-view.ts, message-port-main.ts and
lib/utility/parent-port.ts are deleted along with the port wrapping in
message-channel.ts, utility-process.ts, web-frame-main.ts, ipc-dispatch
and utility/init.ts.

* fix: let process.parentPort.postMessage() be called with no message again

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-18 01:50:24 +00:00
..