Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74b5427

Browse files
authored
fix: nativeView wrapper crash missing when adding child view (electron#43638)
fix: native View wrapper crash missing when adding child view
1 parentdea6a4e commit74b5427

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

‎shell/browser/ui/cocoa/delayed_native_view_host.mm

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515

1616
voidDelayedNativeViewHost::ViewHierarchyChanged(
1717
const views::ViewHierarchyChangedDetails& details) {
18-
// NativeViewHost doesn't expect to have children, so filter the
19-
// ViewHierarchyChanged events before passing them on.
20-
if (details.child ==this) {
21-
NativeViewHost::ViewHierarchyChanged(details);
22-
if (details.is_add &&GetWidget() && !native_view())
23-
Attach(native_view_);
24-
}
18+
NativeViewHost::ViewHierarchyChanged(details);
19+
if (details.is_add &&GetWidget() && !native_view())
20+
Attach(native_view_);
2521
}
2622

2723
boolDelayedNativeViewHost::OnMousePressed(const ui::MouseEvent& ui_event) {

‎spec/api-view-spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ describe('View', () => {
3636
expect(w.contentView.children).to.have.lengthOf(1);
3737
});
3838

39+
it('can be added as a child of another View',async()=>{
40+
constw=newBaseWindow();
41+
constv1=newView();
42+
constv2=newView();
43+
44+
v1.addChildView(v2);
45+
w.contentView.addChildView(v1);
46+
47+
expect(w.contentView.children).to.deep.equal([v1]);
48+
expect(v1.children).to.deep.equal([v2]);
49+
});
50+
3951
it('correctly reorders children',()=>{
4052
w=newBaseWindow({show:false});
4153
constcv=newView();

‎spec/api-web-contents-view-spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ describe('WebContentsView', () => {
135135
expect(w.isFullScreen()).to.be.true('isFullScreen');
136136
});
137137

138+
it('can be added as a child of another View',async()=>{
139+
constw=newBaseWindow();
140+
constv=newView();
141+
constwcv=newWebContentsView();
142+
143+
awaitwcv.webContents.loadURL('data:text/html,<div id="div">This is a simple div.</div>');
144+
145+
v.addChildView(wcv);
146+
w.contentView.addChildView(v);
147+
148+
expect(w.contentView.children).to.deep.equal([v]);
149+
expect(v.children).to.deep.equal([wcv]);
150+
});
151+
138152
describe('visibilityState',()=>{
139153
asyncfunctionhaveVisibilityState(view:WebContentsView,state:string){
140154
constdocVisState=awaitview.webContents.executeJavaScript('document.visibilityState');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp