Tab selection in multiprocess Firefox 编辑

In single-process Firefox, when the user switches tabs, this is a synchronous operation. The browser blocks while it loads content into the newly selected tab, then switches to that tab. It indicates that the tab is selected by setting the selected attribute on the XUL tab object. Code (including browser code, extensions, or themes) that wants to change the appearance of the selected tab can use the selected attribute to apply CSS for that tab.

In multiprocess Firefox, tab switching is asynchronous. When the user switches tabs, the chrome process sends a request to the content process to load the page into the newly selected tab. The function in the chrome process then returns immediately, so other code can run. Once the content process is ready, it sends a message back to the chrome process, which then switches tabs in the user interface.

There's also a timer in the chrome process: if the content process has not responded before the timer expires, then the browser switches tabs anyway, and just displays an empty tab containing a spinner, until the content process has finished loading the page. Currently the timer is set to 300 milliseconds.

There are, correspondingly, two attributes used to signal tab selection:

  • The old selected attribute is set synchronously, at the start of the process. It signals that tab selection has started, but at this point the user interface has not yet been updated.
  • A new attribute visuallyselected is now used once the browser has actually updated the user interface, either because the content process is ready or because the timer has expired.

This means that code which wants to style the currently selected tab needs to use the visuallyselected attribute to do so. If it uses the selected attribute, then there will be a momentary disconnect in which the newly selected tab's style is updated, but the browser is still displaying the old tab's content.

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:125 次

字数:2321

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文