void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; if (ruleMatches(ruleData)) { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); } } }
void RuleSet::addChildRules(const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules, const MediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) { for (unsigned i = 0; i < rules.size(); ++i) { StyleRuleBase* rule = rules[i].get(); if (rule->isStyleRule()) { StyleRule* styleRule = toStyleRule(rule); const CSSSelectorList& selectorList = styleRule->selectorList(); for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { if (selectorList.selectorCrossesTreeScopes(selectorIndex)) { m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { m_shadowDistributedRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); } else { addRule(styleRule, selectorIndex, addRuleFlags); } } } else if (rule->isPageRule()) { addPageRule(toStyleRulePage(rule)); } else if (rule->isMediaRule()) { StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), &m_viewportDependentMediaQueryResults))) addChildRules(mediaRule->childRules(), medium, addRuleFlags); } else if (rule->isFontFaceRule()) { addFontFaceRule(toStyleRuleFontFace(rule)); } else if (rule->isKeyframesRule()) { addKeyframesRule(toStyleRuleKeyframes(rule)); } else if (rule->isViewportRule()) { addViewportRule(toStyleRuleViewport(rule)); } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) { addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags); } } }
void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVector* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (!ruleData.canMatchPseudoElement() && m_pseudoStyleRequest.pseudoId != NOPSEUDO) continue; if (m_selectorFilter && m_selectorFilter->fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; unsigned specificity; if (ruleMatches(ruleData, specificity)) addMatchedRule(ruleData, specificity, matchRequest.treeContextOrdinal, ruleRange); } }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary, CascadeScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) { if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) return; StyleRule* rule = ruleData.rule(); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo, behaviorAtBoundary)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet* properties = rule->properties(); if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) return; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) return; // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == SelectorChecker::CollectingStyleRules) return; // FIXME: Matching should not modify the style directly. if (m_style && dynamicPseudo < FIRST_INTERNAL_PSEUDOID) m_style->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeScope, cascadeOrder); return; } } }
void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* rules, CascadeOrder cascadeOrder, const MatchRequest& matchRequest) { if (!rules) return; SelectorChecker::Init init; init.mode = m_mode; init.isUARule = m_matchingUARules; init.elementStyle = m_style.get(); init.scrollbar = m_pseudoStyleRequest.scrollbar; init.scrollbarPart = m_pseudoStyleRequest.scrollbarPart; SelectorChecker checker(init); SelectorChecker::SelectorCheckingContext context(m_context.element(), SelectorChecker::VisitedMatchEnabled); context.scope = matchRequest.scope; context.pseudoId = m_pseudoStyleRequest.pseudoId; unsigned rejected = 0; unsigned fastRejected = 0; unsigned matched = 0; for (const auto& ruleData : *rules) { if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) { fastRejected++; continue; } // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; StyleRule* rule = ruleData.rule(); // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet& properties = rule->properties(); if (properties.isEmpty() && !m_includeEmptyRules) continue; SelectorChecker::MatchResult result; context.selector = &ruleData.selector(); if (!checker.match(context, result)) { rejected++; continue; } if (m_pseudoStyleRequest.pseudoId != PseudoIdNone && m_pseudoStyleRequest.pseudoId != result.dynamicPseudo) { rejected++; continue; } matched++; didMatchRule(ruleData, result, cascadeOrder, matchRequest); } StyleEngine& styleEngine = m_context.element()->document().styleEngine(); if (!styleEngine.stats()) return; INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesRejected, rejected); INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesFastRejected, fastRejected); INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesMatched, matched); }
void StyleInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* styleSheetContents) { ASSERT(!styleSheetContents->isLoading()); // See if all rules on the sheet are scoped to some specific ids or classes. // Then test if we actually have any of those in the tree at the moment. const Vector<RefPtr<StyleRuleImport> >& importRules = styleSheetContents->importRules(); for (unsigned i = 0; i < importRules.size(); ++i) { if (!importRules[i]->styleSheet()) continue; analyzeStyleSheet(importRules[i]->styleSheet()); if (m_dirtiesAllStyle) return; } const Vector<RefPtr<StyleRuleBase> >& rules = styleSheetContents->childRules(); for (unsigned i = 0; i < rules.size(); i++) { StyleRuleBase* rule = rules[i].get(); if (!rule->isStyleRule()) { // FIXME: Media rules and maybe some others could be allowed. m_dirtiesAllStyle = true; return; } StyleRule* styleRule = static_cast<StyleRule*>(rule); if (!determineSelectorScopes(styleRule->selectorList(), m_idScopes, m_classScopes)) { m_dirtiesAllStyle = true; return; } } }
void ElementRuleCollector::doCollectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; const StyleResolver::State& state = m_state; unsigned size = rules->size(); for (unsigned i = 0; i < size; ++i) { const RuleData& ruleData = rules->at(i); if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); InspectorInstrumentationCookie cookie; if (hasInspectorFrontends) cookie = InspectorInstrumentation::willMatchRule(document(), rule, m_inspectorCSSOMWrappers, document()->styleSheetCollection()); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet* properties = rule->properties(); if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingRules) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) state.style()->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, true); continue; } } if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); } }
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope, bool hasDocumentSecurityOrigin, AddRuleFlags addRuleFlags) { for (unsigned i = 0; i < rules.size(); ++i) { StyleRuleBase* rule = rules[i].get(); if (rule->isStyleRule()) { StyleRule* styleRule = static_cast<StyleRule*>(rule); const CSSSelectorList& selectorList = styleRule->selectorList(); for (size_t selectorIndex = 0; selectorIndex != notFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { if (selectorList.hasShadowDistributedAt(selectorIndex)) { if (isDocumentScope(scope)) continue; resolver->ruleSets().shadowDistributedRules().addRule(styleRule, selectorIndex, const_cast<ContainerNode*>(scope), addRuleFlags); } else addRule(styleRule, selectorIndex, addRuleFlags); } } else if (rule->isPageRule()) addPageRule(static_cast<StyleRulePage*>(rule)); else if (rule->isMediaRule()) { StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule); if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver))) addChildRules(mediaRule->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags); } else if (rule->isFontFaceRule() && resolver) { // Add this font face to our set. // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment. if (!isDocumentScope(scope)) continue; const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFace*>(rule); resolver->fontSelector()->addFontFaceRule(fontFaceRule); resolver->invalidateMatchedPropertiesCache(); } else if (rule->isKeyframesRule() && resolver) { // FIXME (BUG 72462): We don't add @keyframe rules of scoped style sheets for the moment. if (!isDocumentScope(scope)) continue; resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(rule)); } else if (rule->isRegionRule() && resolver) { // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style sheets for the moment. addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecurityOrigin); } else if (rule->isHostRule()) resolver->ensureScopedStyleResolver(scope->shadowHost())->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope); #if ENABLE(CSS_DEVICE_ADAPTATION) else if (rule->isViewportRule() && resolver) { // @viewport should not be scoped. if (!isDocumentScope(scope)) continue; resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(rule)); } #endif else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rule)->conditionIsSupported()) addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags); } }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, CascadeOrder cascadeOrder, const MatchRequest& matchRequest) { StyleRule* rule = ruleData.rule(); if (ruleMatches(ruleData)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet& properties = rule->properties(); if (properties.isEmpty()) return; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeOrder, matchRequest.styleSheetIndex, matchRequest.styleSheet); } }
StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector>>* selectors) { StyleRule* result = 0; if (selectors) { m_allowImportRules = m_allowNamespaceDeclarations = false; RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create(); rule->parserAdoptSelectorVector(*selectors); rule->setProperties(createStylePropertySet()); result = rule.get(); m_parsedRules.append(rule.release()); CSSSelectorParser::recordSelectorStats(m_context, result->selectorList()); } clearProperties(); return result; }
void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, dynamicPseudo)) { // For SharingRules testing, any match is good enough, we don't care what is matched. if (m_mode == SelectorChecker::SharingRules || m_mode == SelectorChecker::StyleInvalidation) { addMatchedRule(&ruleData); break; } // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingRules) continue; if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID && m_style) m_style->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); continue; } } } }
StyleRule HtmlFormatter::ComputeStyleRule(HtmlToken* t) { StyleRule rule; // get style rules ordered by specificity StyleRule* prevRule = FindStyleRule(Tag_Body, nullptr, 0); if (prevRule) rule.Merge(*prevRule); prevRule = FindStyleRule(Tag_Any, nullptr, 0); if (prevRule) rule.Merge(*prevRule); prevRule = FindStyleRule(t->tag, nullptr, 0); if (prevRule) rule.Merge(*prevRule); // TODO: support multiple class names AttrInfo* attr = t->GetAttrByName("class"); if (attr) { prevRule = FindStyleRule(Tag_Any, attr->val, attr->valLen); if (prevRule) rule.Merge(*prevRule); prevRule = FindStyleRule(t->tag, attr->val, attr->valLen); if (prevRule) rule.Merge(*prevRule); } attr = t->GetAttrByName("style"); if (attr) { StyleRule newRule = StyleRule::Parse(attr->val, attr->valLen); rule.Merge(newRule); } return rule; }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) { StyleRule* rule = ruleData.rule(); if (ruleMatches(ruleData, matchRequest.scope, contextFlags)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) return; // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeScope, cascadeOrder, matchRequest.styleSheetIndex, matchRequest.styleSheet); } }
void HtmlFormatter::ParseStyleSheet(const char* data, size_t len) { CssPullParser parser(data, len); while (parser.NextRule()) { StyleRule rule = StyleRule::Parse(&parser); const CssSelector* sel; while ((sel = parser.NextSelector()) != nullptr) { if (Tag_NotFound == sel->tag) continue; StyleRule* prevRule = FindStyleRule(sel->tag, sel->clazz, sel->clazzLen); if (prevRule) { prevRule->Merge(rule); } else { rule.tag = sel->tag; rule.classHash = sel->clazz ? MurmurHash2(sel->clazz, sel->clazzLen) : 0; styleRules.Append(rule); } } } }
void StyleInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* styleSheetContents) { ASSERT(!styleSheetContents->isLoading()); // See if all rules on the sheet are scoped to some specific ids or classes. // Then test if we actually have any of those in the tree at the moment. const Vector<RefPtr<StyleRuleImport> >& importRules = styleSheetContents->importRules(); for (unsigned i = 0; i < importRules.size(); ++i) { if (!importRules[i]->styleSheet()) continue; analyzeStyleSheet(importRules[i]->styleSheet()); if (m_dirtiesAllStyle) return; } if (styleSheetContents->hasSingleOwnerNode()) { Node* ownerNode = styleSheetContents->singleOwnerNode(); if (ownerNode && ownerNode->hasTagName(HTMLNames::styleTag) && toHTMLStyleElement(ownerNode)->isRegisteredAsScoped()) { m_scopingNodes.append(determineScopingNodeForStyleScoped(toHTMLStyleElement(ownerNode), styleSheetContents)); return; } } const Vector<RefPtr<StyleRuleBase> >& rules = styleSheetContents->childRules(); for (unsigned i = 0; i < rules.size(); i++) { StyleRuleBase* rule = rules[i].get(); if (!rule->isStyleRule()) { if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { m_dirtiesAllStyle = true; return; } continue; } StyleRule* styleRule = toStyleRule(rule); if (!determineSelectorScopes(styleRule->selectorList(), m_idScopes, m_classScopes)) { m_dirtiesAllStyle = true; return; } } }
void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* styleSheetContents) { // Updating the style on the shadow DOM for image fallback content can bring us here when imports // are still getting loaded in the main document. Just need to exit early as we will return here // when the imports finish loading. if (styleSheetContents->isLoading()) return; // See if all rules on the sheet are scoped to some specific ids or classes. // Then test if we actually have any of those in the tree at the moment. const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport>>& importRules = styleSheetContents->importRules(); for (unsigned i = 0; i < importRules.size(); ++i) { if (!importRules[i]->styleSheet()) continue; analyzeStyleSheet(importRules[i]->styleSheet()); if (m_dirtiesAllStyle) return; } if (m_treeScope->rootNode().isShadowRoot()) return; const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules = styleSheetContents->childRules(); for (unsigned i = 0; i < rules.size(); i++) { StyleRuleBase* rule = rules[i].get(); if (!rule->isStyleRule()) { if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { m_dirtiesAllStyle = true; return; } continue; } StyleRule* styleRule = toStyleRule(rule); if (!determineSelectorScopes(styleRule->selectorList(), m_idScopes, m_classScopes)) { m_dirtiesAllStyle = true; return; } } }
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const MediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) { for (unsigned i = 0; i < rules.size(); ++i) { StyleRuleBase* rule = rules[i].get(); if (rule->isStyleRule()) { StyleRule* styleRule = toStyleRule(rule); const CSSSelectorList& selectorList = styleRule->selectorList(); for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) addRule(styleRule, selectorIndex, addRuleFlags); } else if (rule->isMediaRule()) { StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), &m_viewportDependentMediaQueryResults))) addChildRules(mediaRule->childRules(), medium, addRuleFlags); } else if (rule->isFontFaceRule()) { addFontFaceRule(toStyleRuleFontFace(rule)); } else if (rule->isKeyframesRule()) { addKeyframesRule(toStyleRuleKeyframes(rule)); } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) { addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags); } } }
StyleRule* StylePersistence::collectRule(QDomElement *element) { QString entity = element->attribute(ATTRIBUTE_ENTITY, "").toLower(); QString name = element->attribute(ATTRIBUTE_NAME, ""); QString op = element->attribute(ATTRIBUTE_OP, "").toUpper(); QString type = element->attribute(ATTRIBUTE_TYPE, "").toLower(); QString value = element->attribute(ATTRIBUTE_VALUE, ""); QString caseSensitive = element->attribute(ATTRIBUTE_CASE, "").toLower(); QString axis = element->attribute(ATTRIBUTE_AXIS, ""); StyleRule *rule = new StyleRule(); if(NULL != rule) { rule->setEntity(entity == RULE_A_ELEMENT); rule->setName(name); rule->setOp(op); rule->setType(type); rule->setValue(value); rule->setCaseSensitive(caseSensitive != "false"); rule->setAxis(axis); } return rule; }//()
StyleRule::StyleRule(const StyleRule& o) : StyleRuleBase(o) , m_properties(o.properties().mutableCopy()) , m_selectorList(o.m_selectorList) { }
StyleRule::StyleRule(const StyleRule& o) : StyleRuleBase(o), m_selectorList(o.m_selectorList.copy()), m_properties(o.properties().mutableCopy()), m_shouldConsiderForMatchingRules(ConsiderIfNonEmpty) {}
void PageSerializer::retrieveResourcesForRule(StyleRule& rule, Document* document) { retrieveResourcesForProperties(&rule.properties(), document); }