Exemplo n.º 1
0
Value DOMCSSStyleSheet::tryGet(ExecState *exec, const Identifier &p) const
{
    DOM::CSSStyleSheet cssStyleSheet = static_cast< DOM::CSSStyleSheet >(styleSheet);
    if(p == "ownerRule")
        return getDOMCSSRule(exec, cssStyleSheet.ownerRule());
    else if(p == "cssRules" || p == "rules" /* MSIE extension */)
        return getDOMCSSRuleList(exec, cssStyleSheet.cssRules());
    return DOMStyleSheet::tryGet(exec, p);
}
Exemplo n.º 2
0
Value DOMCSSStyleSheetProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMCSSStyleSheet, thisObj );
  DOM::CSSStyleSheet styleSheet = static_cast<DOMCSSStyleSheet *>(thisObj.imp())->toCSSStyleSheet();

  switch (id) {
    case DOMCSSStyleSheet::InsertRule:
      return Number(styleSheet.insertRule(args[0].toString(exec).string(),(long unsigned int)args[1].toInteger(exec)));
    case DOMCSSStyleSheet::DeleteRule:
      styleSheet.deleteRule(args[0].toInteger(exec));
      return Undefined();
    // IE extensions
    case DOMCSSStyleSheet::AddRule: {
      //Unpassed/-1 means append. Since insertRule is picky (throws exceptions)
      //we adjust it to the desired length
      unsigned long index  = args[2].toInteger(exec);
      unsigned long length = styleSheet.cssRules().length();
      if (args[2].type() == UndefinedType) index = length;
      if (index > length)                  index = length;
      DOM::DOMString str = args[0].toString(exec).string() + " { " + args[1].toString(exec).string() + " } ";
      return Number(styleSheet.insertRule(str,index));
    }
    case DOMCSSStyleSheet::RemoveRule: {
      int index = args.size() > 0 ? args[0].toInteger(exec) : 0 /*first one*/;
      styleSheet.deleteRule(index);
      return Undefined();
    }
    default:
      return Undefined();
  }
}