Beispiel #1
0
Value DOMCSSStyleDeclarationProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMCSSStyleDeclaration, thisObj);
    DOM::CSSStyleDeclaration styleDecl = static_cast< DOMCSSStyleDeclaration * >(thisObj.imp())->toStyleDecl();
    String str = args[0].toString(exec);
    DOM::DOMString s = str.value().string();

    switch(id)
    {
        case DOMCSSStyleDeclaration::GetPropertyValue:
            return String(styleDecl.getPropertyValue(s));
        case DOMCSSStyleDeclaration::GetPropertyCSSValue:
            return getDOMCSSValue(exec, styleDecl.getPropertyCSSValue(s));
        case DOMCSSStyleDeclaration::RemoveProperty:
            return String(styleDecl.removeProperty(s));
        case DOMCSSStyleDeclaration::GetPropertyPriority:
            return String(styleDecl.getPropertyPriority(s));
        case DOMCSSStyleDeclaration::SetProperty:
            styleDecl.setProperty(args[0].toString(exec).string(), args[1].toString(exec).string(), args[2].toString(exec).string());
            return Undefined();
        case DOMCSSStyleDeclaration::Item:
            return String(styleDecl.item(args[0].toInteger(exec)));
        default:
            return Undefined();
    }
}
Beispiel #2
0
Value DOMCSSPrimitiveValueProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMCSSPrimitiveValue, thisObj);
    DOM::CSSPrimitiveValue val = static_cast< DOMCSSPrimitiveValue * >(thisObj.imp())->toCSSPrimitiveValue();
    switch(id)
    {
        case DOMCSSPrimitiveValue::SetFloatValue:
            val.setFloatValue(args[0].toInteger(exec), args[1].toNumber(exec));
            return Undefined();
        case DOMCSSPrimitiveValue::GetFloatValue:
            return Number(val.getFloatValue(args[0].toInteger(exec)));
        case DOMCSSPrimitiveValue::SetStringValue:
            val.setStringValue(args[0].toInteger(exec), args[1].toString(exec).string());
            return Undefined();
        case DOMCSSPrimitiveValue::GetStringValue:
            return String(val.getStringValue());
        case DOMCSSPrimitiveValue::GetCounterValue:
            return getDOMCounter(exec, val.getCounterValue());
        case DOMCSSPrimitiveValue::GetRectValue:
            return getDOMRect(exec, val.getRectValue());
        case DOMCSSPrimitiveValue::GetRGBColorValue:
            return getDOMRGBColor(exec, val.getRGBColorValue());
        default:
            return Undefined();
    }
}
Beispiel #3
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();
  }
}
Beispiel #4
0
Value DOMStyleSheetListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMStyleSheetList, thisObj);
    DOM::StyleSheetList styleSheetList = static_cast< DOMStyleSheetList * >(thisObj.imp())->toStyleSheetList();
    if(id == DOMStyleSheetList::Item)
        return getDOMStyleSheet(exec, styleSheetList.item(args[0].toInteger(exec)));
    return Undefined();
}
Beispiel #5
0
Value DOMCSSRuleListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMCSSRuleList, thisObj );
  DOM::CSSRuleList cssRuleList = static_cast<DOMCSSRuleList *>(thisObj.imp())->toCSSRuleList();
  switch (id) {
    case DOMCSSRuleList::Item:
      return getDOMCSSRule(exec,cssRuleList.item(args[0].toInteger(exec)));
    default:
      return Undefined();
  }
}
Beispiel #6
0
Value DOMCSSRuleFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMCSSRule, thisObj );
  DOM::CSSRule cssRule = static_cast<DOMCSSRule *>(thisObj.imp())->toCSSRule();

  if (cssRule.type() == DOM::CSSRule::MEDIA_RULE) {
    DOM::CSSMediaRule rule = static_cast<DOM::CSSMediaRule>(cssRule);
    if (id == DOMCSSRule::Media_InsertRule)
      return Number(rule.insertRule(args[0].toString(exec).string(),args[1].toInteger(exec)));
    else if (id == DOMCSSRule::Media_DeleteRule)
      rule.deleteRule(args[0].toInteger(exec));
  }

  return Undefined();
}
Beispiel #7
0
Value KJS::DOMMediaListProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMMediaList, thisObj );
  DOM::MediaList mediaList = static_cast<DOMMediaList *>(thisObj.imp())->toMediaList();
  switch (id) {
    case DOMMediaList::Item:
      return String(mediaList.item(args[0].toInteger(exec)));
    case DOMMediaList::DeleteMedium:
      mediaList.deleteMedium(args[0].toString(exec).string());
      return Undefined();
    case DOMMediaList::AppendMedium:
      mediaList.appendMedium(args[0].toString(exec).string());
      return Undefined();
    default:
      return Undefined();
  }
}