为什么CSS声明是关于:addons放在userContent而不是userChrome中的,因为命名空间是XUL? [英] Why are CSS declarations for about:addons placed in userContent and not userChrome, given that the namespace is XUL?

查看:206
本文介绍了为什么CSS声明是关于:addons放在userContent而不是userChrome中的,因为命名空间是XUL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么关于 about:addons 的CSS声明必须放在 userContent 中,而不是 userChrome ,因为 about:addons 的命名空间是 XUL



这是关于Firefox的CSS编程。



相关:

chrome 部分包含其他所有内容。这包括界面弹出窗口(例如添加书签对话框),但不包括内容页面弹出窗口。虽然它也包含了窗口周围的边框,但是很多人通常都会想到这一点,包括这部分显示内容:



更多详情



具体来说,只有一个 userChrome.css userContent.css 应用于每个< document> 。在此代码中完成 。代码中的选择取决于属性 document.docShell.itemType 的值。如果该值为0,则使用 userChrome.css ,如果不是(或不存在等),则使用 userContent.css


$ b $ itemType 可以有以下值:


  • typeChrome = 0,
  • typeContent = 1,
  • typeContentWrapper = 2,
  • typeChromeWrapper = 3,
  • typeAll = 2147483647


取决于页面/文件被加载,不仅仅是文件的类型或URL。例如,从 chrome:// URL加载的 .xul 文件可能包含在 typeContent < document> (已应用 userContent.css ),如果从URL栏加载的话。另一方面,同样的 .xul 文件作为< window> 的内容加载到 openDialog ()可能位于 typeChrome 文档中(已应用 userChrome.css )。



包含在文件中的元素的命名空间对于两个文件中的哪一个无关紧要:userChrome.css userContent.css 被使用。如果CSS应用于元素(至少如果它是 typeChrome < document> )。


Why do CSS declarations for about:addons have to be placed in userContent and not userChrome, given that the namespace of about:addons is XUL?

This is regarding CSS programming for Firefox.

Related: What namespace should be defined in Firefox's userContent.css?

解决方案

The short answer to this is that the page about:addons is considered content. Thus, userContent.css is used. The namespace(s) (e.g. HTML, XUL) of the elements used in the <document> don't matter with respect to which of userChrome.css or userContent.css is used (only one or the other is used per <document>).

What does matter is the role for which the <document> is being used. If the <document> is being used for chrome, userChrome.css is used. If it's being used for anything else, it's considered content for which userContent.css is used.

If it's something that's displayed in the content area of Firefox by navigating to the page (e.g. by changing the entry in the URL bar), then it's content, even if it's using XUL elements.

MDN defines "chrome" as:

In a browser, the chrome is any visible aspect of a browser aside from the webpages themselves (e.g., toolbars, menu bar, tabs). This should not to be confused with the Google Chrome browser.

It also provides a link to a blog post, "Browser and GUI Chrome", which provides a similar definition:

Chrome is the visual design elements that give users information about or commands to operate on the screen's content (as opposed to being part of that content). These design elements are provided by the underlying system — whether it be an operating system, a website, or an application — and surround the user's data.

In Firefox, the content portion of the display is:

The chrome portion includes everything else. This includes interface popups (e.g. the add bookmarks dialog), but not content-page popups. While it also includes the borders around the window, many people generally think of it including this portion of the display:

More detail

Specifically, only one of userChrome.css or userContent.css is applied to each <document>. It is done in this code. The choice in the code comes down to what value is of the property document.docShell.itemType. If that value is a 0, then userChrome.css is used, if not (or does not exist, etc.) then userContent.css is used.

The itemType can have the following values:

  • typeChrome = 0,
  • typeContent = 1,
  • typeContentWrapper = 2,
  • typeChromeWrapper = 3,
  • typeAll = 2147483647

Which is assigned depends on how the page/file is loaded, not just the type of file, or the URL. For instance, an .xul file which is loaded from a chrome:// URL may be contained in a typeContent <document> (has userContent.css applied), if it was loaded from the URLbar. On the other hand, the same .xul file which is loaded as the content for a <window> with openDialog() may be in a typeChrome document (has userChrome.css applied).

The namespace of the elements contained in the file used for the doesn't matter to which of the two files, userChrome.css or userContent.css, is used. The namespace does matter for if the CSS applies to the elements (at least if it is a typeChrome <document>).

这篇关于为什么CSS声明是关于:addons放在userContent而不是userChrome中的,因为命名空间是XUL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆