Example #1
0
JSValue jsCSSStyleDeclarationParentRule(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentRule()));
    return result;
}
String InspectorAnimationAgent::createCSSId(blink::Animation& animation) {
  String type =
      m_idToAnimationType.get(String::number(animation.sequenceNumber()));
  ASSERT(type != AnimationType::WebAnimation);

  KeyframeEffect* effect = toKeyframeEffect(animation.effect());
  Vector<CSSPropertyID> cssProperties;
  if (type == AnimationType::CSSAnimation) {
    for (CSSPropertyID property : animationProperties)
      cssProperties.append(property);
  } else {
    for (CSSPropertyID property : transitionProperties)
      cssProperties.append(property);
    cssProperties.append(cssPropertyID(animation.id()));
  }

  Element* element = effect->target();
  HeapVector<Member<CSSStyleDeclaration>> styles =
      m_cssAgent->matchingStyles(element);
  std::unique_ptr<WebCryptoDigestor> digestor =
      createDigestor(HashAlgorithmSha1);
  addStringToDigestor(digestor.get(), type);
  addStringToDigestor(digestor.get(), animation.id());
  for (CSSPropertyID property : cssProperties) {
    CSSStyleDeclaration* style =
        m_cssAgent->findEffectiveDeclaration(property, styles);
    // Ignore inline styles.
    if (!style || !style->parentStyleSheet() || !style->parentRule() ||
        style->parentRule()->type() != CSSRule::kStyleRule)
      continue;
    addStringToDigestor(digestor.get(), getPropertyNameString(property));
    addStringToDigestor(digestor.get(),
                        m_cssAgent->styleSheetId(style->parentStyleSheet()));
    addStringToDigestor(digestor.get(),
                        toCSSStyleRule(style->parentRule())->selectorText());
  }
  DigestValue digestResult;
  finishDigestor(digestor.get(), digestResult);
  return base64Encode(reinterpret_cast<const char*>(digestResult.data()), 10);
}
void JSCSSStyleDeclaration::markChildren(MarkStack& markStack)
{
    Base::markChildren(markStack);

    CSSStyleDeclaration* declaration = impl();
    JSGlobalData& globalData = *Heap::heap(this)->globalData();

    if (CSSRule* parentRule = declaration->parentRule())
        markDOMObjectWrapper(markStack, globalData, parentRule);

    if (declaration->isMutableStyleDeclaration()) {
        CSSMutableStyleDeclaration* mutableDeclaration = static_cast<CSSMutableStyleDeclaration*>(declaration);
        CSSMutableStyleDeclaration::const_iterator end = mutableDeclaration->end();
        for (CSSMutableStyleDeclaration::const_iterator it = mutableDeclaration->begin(); it != end; ++it)
            markDOMObjectWrapper(markStack, globalData, it->value());
    }
}
Example #4
0
JSValue* JSCSSStyleDeclaration::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case CssTextAttrNum: {
        CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl());
        return jsStringOrNull(exec, imp->cssText());
    }
    case LengthAttrNum: {
        CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl());
        return jsNumber(exec, imp->length());
    }
    case ParentRuleAttrNum: {
        CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl());
        return toJS(exec, WTF::getPtr(imp->parentRule()));
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}