Bug 495269. Fix our detection of @import rules when cloning sheets. r+sr=dbaron

This commit is contained in:
Boris Zbarsky 2009-05-28 18:16:31 -04:00
parent 05ccc0ab01
commit d2c3684946
5 changed files with 43 additions and 11 deletions

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="data:text/css,@font-face {}';">
<link rel="stylesheet" href="data:text/css,@font-face {}';">
<script>
// Force a unique inner for the second linked sheet
document.styleSheets[1].cssRules[0];
</script>
</head>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
<script>
// Force a unique inner for the second linked sheet
document.styleSheets[1].cssRules[0];
</script>
</head>
</html>

View File

@ -37,3 +37,5 @@ load 473720-1.html
load 473892-1.html
load 473914-1.html
skip load long-url-list-stack-overflow.html # skipped due to being slow (bug 477490)
load 495269-1.html
load 495269-2.html

View File

@ -818,12 +818,13 @@ nsCSSStyleSheet::RebuildChildList(nsICSSRule* aRule, void* aBuilder)
{
PRInt32 type;
aRule->GetType(type);
if (type == nsICSSRule::CHARSET_RULE) {
if (type < nsICSSRule::IMPORT_RULE) {
// Keep going till we get to the import rules.
return PR_TRUE;
}
if (type == nsICSSRule::NAMESPACE_RULE || type == nsICSSRule::MEDIA_RULE ||
type == nsICSSRule::STYLE_RULE) {
if (type != nsICSSRule::IMPORT_RULE) {
// We're past all the import rules; stop the enumeration.
return PR_FALSE;
}

View File

@ -55,16 +55,21 @@ class nsAString;
class nsICSSRule : public nsIStyleRule {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_RULE_IID)
// The constants in this list must maintain the following invariants:
// If a rule of type N must appear before a rule of type M in stylesheets
// then N < M
// Note that nsCSSStyleSheet::RebuildChildList assumes that no other kinds of
// rules can come between two rules of type IMPORT_RULE.
enum {
UNKNOWN_RULE = 0,
STYLE_RULE = 1,
IMPORT_RULE = 2,
MEDIA_RULE = 3,
FONT_FACE_RULE = 4,
PAGE_RULE = 5,
CHARSET_RULE = 6,
NAMESPACE_RULE = 7,
DOCUMENT_RULE = 8
CHARSET_RULE,
IMPORT_RULE,
NAMESPACE_RULE,
STYLE_RULE,
MEDIA_RULE,
FONT_FACE_RULE,
PAGE_RULE,
DOCUMENT_RULE
};
NS_IMETHOD GetType(PRInt32& aType) const = 0;