Esempio n. 1
0
PassRefPtrWillBeRawPtr<StyleRuleBase> StyleRuleBase::copy() const
{
    switch (type()) {
    case Style:
        return toStyleRule(this)->copy();
    case Page:
        return toStyleRulePage(this)->copy();
    case FontFace:
        return toStyleRuleFontFace(this)->copy();
    case Media:
        return toStyleRuleMedia(this)->copy();
    case Supports:
        return toStyleRuleSupports(this)->copy();
    case Import:
        // FIXME: Copy import rules.
        ASSERT_NOT_REACHED();
        return nullptr;
    case Keyframes:
        return toStyleRuleKeyframes(this)->copy();
    case Viewport:
        return toStyleRuleViewport(this)->copy();
    case Filter:
        return toStyleRuleFilter(this)->copy();
    case Unknown:
    case Charset:
    case Keyframe:
        ASSERT_NOT_REACHED();
        return nullptr;
    }
    ASSERT_NOT_REACHED();
    return nullptr;
}
Esempio n. 2
0
StyleRuleBase* StyleRuleBase::copy() const {
  switch (type()) {
    case Style:
      return toStyleRule(this)->copy();
    case Page:
      return toStyleRulePage(this)->copy();
    case FontFace:
      return toStyleRuleFontFace(this)->copy();
    case Media:
      return toStyleRuleMedia(this)->copy();
    case Supports:
      return toStyleRuleSupports(this)->copy();
    case Import:
      // FIXME: Copy import rules.
      NOTREACHED();
      return nullptr;
    case Keyframes:
      return toStyleRuleKeyframes(this)->copy();
    case Viewport:
      return toStyleRuleViewport(this)->copy();
    case Namespace:
      return toStyleRuleNamespace(this)->copy();
    case Charset:
    case Keyframe:
      ASSERT_NOT_REACHED();
      return nullptr;
  }
  ASSERT_NOT_REACHED();
  return nullptr;
}
Esempio n. 3
0
PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const
{
    RefPtrWillBeRawPtr<CSSRule> rule;
    StyleRuleBase* self = const_cast<StyleRuleBase*>(this);
    switch (type()) {
    case Style:
        rule = CSSStyleRule::create(toStyleRule(self), parentSheet);
        break;
    case Page:
        rule = CSSPageRule::create(toStyleRulePage(self), parentSheet);
        break;
    case FontFace:
        rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet);
        break;
    case Media:
        rule = CSSMediaRule::create(toStyleRuleMedia(self), parentSheet);
        break;
    case Supports:
        rule = CSSSupportsRule::create(toStyleRuleSupports(self), parentSheet);
        break;
    case Import:
        rule = CSSImportRule::create(toStyleRuleImport(self), parentSheet);
        break;
    case Keyframes:
        rule = CSSKeyframesRule::create(toStyleRuleKeyframes(self), parentSheet);
        break;
    case Viewport:
        rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet);
        break;
    case Filter:
        rule = CSSFilterRule::create(toStyleRuleFilter(self), parentSheet);
        break;
    case Unknown:
    case Charset:
    case Keyframe:
        ASSERT_NOT_REACHED();
        return nullptr;
    }
    if (parentRule)
        rule->setParentRule(parentRule);
    return rule.release();
}
Esempio n. 4
0
CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet,
                                           CSSRule* parentRule) const {
  CSSRule* rule = nullptr;
  StyleRuleBase* self = const_cast<StyleRuleBase*>(this);
  switch (type()) {
    case Style:
      rule = CSSStyleRule::create(toStyleRule(self), parentSheet);
      break;
    case Page:
      rule = CSSPageRule::create(toStyleRulePage(self), parentSheet);
      break;
    case FontFace:
      rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet);
      break;
    case Media:
      rule = CSSMediaRule::create(toStyleRuleMedia(self), parentSheet);
      break;
    case Supports:
      rule = CSSSupportsRule::create(toStyleRuleSupports(self), parentSheet);
      break;
    case Import:
      rule = CSSImportRule::create(toStyleRuleImport(self), parentSheet);
      break;
    case Keyframes:
      rule = CSSKeyframesRule::create(toStyleRuleKeyframes(self), parentSheet);
      break;
    case Namespace:
      rule = CSSNamespaceRule::create(toStyleRuleNamespace(self), parentSheet);
      break;
    case Viewport:
      rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet);
      break;
    case Keyframe:
    case Charset:
      ASSERT_NOT_REACHED();
      return nullptr;
  }
  if (parentRule)
    rule->setParentRule(parentRule);
  return rule;
}
Esempio n. 5
0
void StyleRuleBase::finalizeGarbageCollectedObject()
{
    switch (type()) {
    case Charset:
        toStyleRuleCharset(this)->~StyleRuleCharset();
        return;
    case Style:
        toStyleRule(this)->~StyleRule();
        return;
    case Page:
        toStyleRulePage(this)->~StyleRulePage();
        return;
    case FontFace:
        toStyleRuleFontFace(this)->~StyleRuleFontFace();
        return;
    case Media:
        toStyleRuleMedia(this)->~StyleRuleMedia();
        return;
    case Supports:
        toStyleRuleSupports(this)->~StyleRuleSupports();
        return;
    case Import:
        toStyleRuleImport(this)->~StyleRuleImport();
        return;
    case Keyframes:
        toStyleRuleKeyframes(this)->~StyleRuleKeyframes();
        return;
    case Keyframe:
        toStyleRuleKeyframe(this)->~StyleRuleKeyframe();
        return;
    case Namespace:
        toStyleRuleNamespace(this)->~StyleRuleNamespace();
        return;
    case Viewport:
        toStyleRuleViewport(this)->~StyleRuleViewport();
        return;
    case Unknown:
        return;
    }
    ASSERT_NOT_REACHED();
}
Esempio n. 6
0
void StyleRuleBase::destroy()
{
    switch (type()) {
    case Charset:
        delete toStyleRuleCharset(this);
        return;
    case Style:
        delete toStyleRule(this);
        return;
    case Page:
        delete toStyleRulePage(this);
        return;
    case FontFace:
        delete toStyleRuleFontFace(this);
        return;
    case Media:
        delete toStyleRuleMedia(this);
        return;
    case Supports:
        delete toStyleRuleSupports(this);
        return;
    case Import:
        delete toStyleRuleImport(this);
        return;
    case Keyframes:
        delete toStyleRuleKeyframes(this);
        return;
    case Keyframe:
        delete toStyleRuleKeyframe(this);
        return;
    case Namespace:
        delete toStyleRuleNamespace(this);
        return;
    case Viewport:
        delete toStyleRuleViewport(this);
        return;
    case Unknown:
        return;
    }
    ASSERT_NOT_REACHED();
}
Esempio n. 7
0
void StyleRuleBase::finalize()
{
    switch (type()) {
    case Style:
        toStyleRule(this)->~StyleRule();
        return;
    case Page:
        toStyleRulePage(this)->~StyleRulePage();
        return;
    case FontFace:
        toStyleRuleFontFace(this)->~StyleRuleFontFace();
        return;
    case Media:
        toStyleRuleMedia(this)->~StyleRuleMedia();
        return;
    case Supports:
        toStyleRuleSupports(this)->~StyleRuleSupports();
        return;
    case Import:
        toStyleRuleImport(this)->~StyleRuleImport();
        return;
    case Keyframes:
        toStyleRuleKeyframes(this)->~StyleRuleKeyframes();
        return;
    case Viewport:
        toStyleRuleViewport(this)->~StyleRuleViewport();
        return;
    case Filter:
        toStyleRuleFilter(this)->~StyleRuleFilter();
        return;
    case Unknown:
    case Charset:
    case Keyframe:
        ASSERT_NOT_REACHED();
        return;
    }
    ASSERT_NOT_REACHED();
}
Esempio n. 8
0
void StyleRuleBase::trace(Visitor* visitor)
{
    switch (type()) {
    case Style:
        toStyleRule(this)->traceAfterDispatch(visitor);
        return;
    case Page:
        toStyleRulePage(this)->traceAfterDispatch(visitor);
        return;
    case FontFace:
        toStyleRuleFontFace(this)->traceAfterDispatch(visitor);
        return;
    case Media:
        toStyleRuleMedia(this)->traceAfterDispatch(visitor);
        return;
    case Supports:
        toStyleRuleSupports(this)->traceAfterDispatch(visitor);
        return;
    case Import:
        toStyleRuleImport(this)->traceAfterDispatch(visitor);
        return;
    case Keyframes:
        toStyleRuleKeyframes(this)->traceAfterDispatch(visitor);
        return;
    case Viewport:
        toStyleRuleViewport(this)->traceAfterDispatch(visitor);
        return;
    case Filter:
        toStyleRuleFilter(this)->traceAfterDispatch(visitor);
        return;
    case Unknown:
    case Charset:
    case Keyframe:
        ASSERT_NOT_REACHED();
        return;
    }
    ASSERT_NOT_REACHED();
}
Esempio n. 9
0
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);
        }
    }
}
Esempio n. 10
0
void CSSKeyframesRule::reattach(StyleRuleBase* rule)
{
    ASSERT(rule);
    m_keyframesRule = toStyleRuleKeyframes(rule);
}