CSSRuleList::CSSRuleList(CSSStyleSheet* styleSheet, bool omitCharsetRules) : m_styleSheet(styleSheet) { if (styleSheet && omitCharsetRules) { m_styleSheet = 0; for (unsigned i = 0; i < styleSheet->length(); ++i) { CSSRule* rule = styleSheet->item(i); if (!rule->isCharsetRule()) append(static_cast<CSSRule*>(rule)); } } }
PassRefPtr<CSSRuleList> CSSStyleSheet::rules() { KURL url = finalURL(); Document* document = findDocument(); if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url)) return 0; // IE behavior. RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create(); unsigned ruleCount = length(); for (unsigned i = 0; i < ruleCount; ++i) { CSSRule* rule = item(i); if (rule->isCharsetRule()) continue; nonCharsetRules->rules().append(rule); } return nonCharsetRules.release(); }