Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popup window logic - use CEF built-in popup management #303

Closed
wants to merge 1 commit into from

Conversation

tishion
Copy link
Member

@tishion tishion commented Aug 26, 2023

  • 重新实现popup browser的逻辑
  • 使用CEF内置的popup 生命周期管理逻辑
  • onBeforePopup 方法提供允许/禁止弹出窗口的拦截时机,可以重载该函数,返回true/false来控制,以及在该方法内设置一些参数
  • onPopupCreated 方法提供自定义已经弹出的popup browser的能力

@tishion tishion requested a review from L-Super August 26, 2023 06:18
@tishion
Copy link
Member Author

tishion commented Aug 26, 2023

macOS和Linux没有测试过

@tishion
Copy link
Member Author

tishion commented Aug 27, 2023

@L-Super review一下

@L-Super
Copy link
Member

L-Super commented Aug 27, 2023

@L-Super review一下

ASAP,我抽时间测试一下Linux 平台

Comment on lines 287 to +289
QCefSettingPrivate::CopyFromCefBrowserSettings(&s, &settings);
bool cancelPopup = q->onBeforePopup(frameId, url, name, d, rc, s, disableJavascript);
QCefSettingPrivate::CopyToCefBrowserSettings(&s, &settings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不理解为什么还要再调用一次CopyToCefBrowserSettings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先把CefSettings转为QCefSetting,然后吧QCefSetting传给用户,用户可能需要修改setting,然后再把用户的修改copy回CefSetting,再传回给CEF

Comment on lines +287 to +301
void
QCefView::onPopupCreated(QWidget* popup, const QString& url, const QString& name)
{
// create a top level window container
QMainWindow* popupWin = new QMainWindow();
popupWin->setAttribute(Qt::WA_DeleteOnClose, true);
popupWin->setWindowTitle(name);
popupWin->resize(popup->size());

// add the popup browser widget into the window
popupWin->setCentralWidget(popup);

// show window
popupWin->show();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段是为了向外提供重写的接口吗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数是提供给用户重载用的,内部的默认实现是创建一个顶层窗口来放置popup,用户可能有其他的实现需求,比如放到别的tab里面。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那实际上应该不需要吧,是否可以通过注释告诉用户可以这样重载使用?

@L-Super
Copy link
Member

L-Super commented Aug 28, 2023

在Windows运行demo时,发现通过Popup Browser By Script按钮创建弹出窗口后,再次点击Popup Browser By Script按钮不管是父窗口还是弹出的窗口,都是无响应。同时对比了旧版本,是都能弹出的。
image

@tishion
Copy link
Member Author

tishion commented Aug 28, 2023

在Windows运行demo时,发现通过Popup Browser By Script按钮创建弹出窗口后,再次点击Popup Browser By Script按钮不管是父窗口还是弹出的窗口,都是无响应。同时对比了旧版本,是都能弹出的。 image

这个是正常的,因为popup的name没有变化,CEF内部其实保持了一个按照name来映射的popup,如果这个name的popup已经存在了,就不会再走popup流程了。

@tishion
Copy link
Member Author

tishion commented Aug 28, 2023

这个实现在Linux NCW模式下还是不行,主要是Linux的UI系统问题。

@L-Super
Copy link
Member

L-Super commented Aug 28, 2023

在Windows运行demo时,发现通过Popup Browser By Script按钮创建弹出窗口后,再次点击Popup Browser By Script按钮不管是父窗口还是弹出的窗口,都是无响应。同时对比了旧版本,是都能弹出的。 image

这个是正常的,因为popup的name没有变化,CEF内部其实保持了一个按照name来映射的popup,如果这个name的popup已经存在了,就不会再走popup流程了。

OK,明白了

@L-Super
Copy link
Member

L-Super commented Aug 28, 2023

这个实现在Linux NCW模式下还是不行,主要是Linux的UI系统问题。

通过Qt还是无法隔离Linux UI的问题吗

@tishion tishion closed this Aug 28, 2023
@tishion tishion deleted the feature/reform-popup-browser branch August 29, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants