⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kjs_css.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*@begin DOMMediaListTable 2  mediaText	DOMMediaList::MediaText		DontDelete|ReadOnly  length	DOMMediaList::Length		DontDelete|ReadOnly@end@begin DOMMediaListProtoTable 3  item		DOMMediaList::Item		DontDelete|Function 1  deleteMedium	DOMMediaList::DeleteMedium	DontDelete|Function 1  appendMedium	DOMMediaList::AppendMedium	DontDelete|Function 1@end*/DEFINE_PROTOTYPE("DOMMediaList", DOMMediaListProto)IMPLEMENT_PROTOFUNC_DOM(DOMMediaListProtoFunc)IMPLEMENT_PROTOTYPE(DOMMediaListProto, DOMMediaListProtoFunc)DOMMediaList::DOMMediaList(ExecState *exec, const DOM::MediaList& ml)  : DOMObject(DOMMediaListProto::self(exec)), mediaList(ml) { }DOMMediaList::~DOMMediaList(){  ScriptInterpreter::forgetDOMObject(mediaList.handle());}Value DOMMediaList::tryGet(ExecState *exec, const Identifier &p) const{  if (p == "mediaText")    return String(mediaList.mediaText());  else if (p == lengthPropertyName)    return Number(mediaList.length());  bool ok;  long unsigned int u = p.toULong(&ok);  if (ok)    return String(mediaList.item(u));  return DOMObject::tryGet(exec, p);}void DOMMediaList::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr){  if (propertyName == "mediaText")    mediaList.setMediaText(value.toString(exec).string());  else    DOMObject::tryPut(exec, propertyName, value, attr);}Value KJS::getDOMMediaList(ExecState *exec, const DOM::MediaList& ml){  return cacheDOMObject<DOM::MediaList, KJS::DOMMediaList>(exec, ml);}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();  }}// -------------------------------------------------------------------------const ClassInfo DOMCSSStyleSheet::info = { "CSSStyleSheet", 0, &DOMCSSStyleSheetTable, 0 };/*@begin DOMCSSStyleSheetTable 2  ownerRule	DOMCSSStyleSheet::OwnerRule	DontDelete|ReadOnly  cssRules	DOMCSSStyleSheet::CssRules	DontDelete|ReadOnly# MSIE extension  rules		DOMCSSStyleSheet::Rules		DontDelete|ReadOnly@end@begin DOMCSSStyleSheetProtoTable 2  insertRule	DOMCSSStyleSheet::InsertRule	DontDelete|Function 2  deleteRule	DOMCSSStyleSheet::DeleteRule	DontDelete|Function 1# IE extensions  addRule	DOMCSSStyleSheet::AddRule	DontDelete|Function 3  removeRule	DOMCSSStyleSheet::RemoveRule	DontDelete|Function 1@end*/DEFINE_PROTOTYPE("DOMCSSStyleSheet",DOMCSSStyleSheetProto)IMPLEMENT_PROTOFUNC_DOM(DOMCSSStyleSheetProtoFunc)IMPLEMENT_PROTOTYPE(DOMCSSStyleSheetProto,DOMCSSStyleSheetProtoFunc) // warning, use _WITH_PARENT if DOMStyleSheet gets a protoDOMCSSStyleSheet::DOMCSSStyleSheet(ExecState *exec, const DOM::CSSStyleSheet& ss)  : DOMStyleSheet(DOMCSSStyleSheetProto::self(exec),ss) { }DOMCSSStyleSheet::~DOMCSSStyleSheet(){}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);}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: {      DOM::DOMString str = args[0].toString(exec).string() + " { " + args[1].toString(exec).string() + " } ";      return Number(styleSheet.insertRule(str,(long unsigned int)args[2].toInteger(exec)));    }    case DOMCSSStyleSheet::RemoveRule: {      int index = args.size() > 0 ? args[0].toInteger(exec) : 0 /*first one*/;      styleSheet.deleteRule(index);      return Undefined();    }    default:      return Undefined();  }}// -------------------------------------------------------------------------const ClassInfo DOMCSSRuleList::info = { "CSSRuleList", 0, &DOMCSSRuleListTable, 0 };/*@begin DOMCSSRuleListTable 3  length		DOMCSSRuleList::Length		DontDelete|ReadOnly  item			DOMCSSRuleList::Item		DontDelete|Function 1@end*/IMPLEMENT_PROTOFUNC_DOM(DOMCSSRuleListFunc) // not really a proto, but doesn't matterDOMCSSRuleList::DOMCSSRuleList(ExecState* exec, const DOM::CSSRuleList& rl)  : DOMObject(exec->interpreter()->builtinObjectPrototype()), cssRuleList(rl){}DOMCSSRuleList::~DOMCSSRuleList(){  ScriptInterpreter::forgetDOMObject(cssRuleList.handle());}Value DOMCSSRuleList::tryGet(ExecState *exec, const Identifier &p) const{  Value result;  if (p == lengthPropertyName)    return Number(cssRuleList.length());  else if (p == "item")    return lookupOrCreateFunction<DOMCSSRuleListFunc>(exec,p,this,DOMCSSRuleList::Item,1,DontDelete|Function);  bool ok;  long unsigned int u = p.toULong(&ok);  if (ok)    return getDOMCSSRule(exec,DOM::CSSRuleList(cssRuleList).item(u));  return DOMObject::tryGet(exec,p);}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();  }}Value KJS::getDOMCSSRuleList(ExecState *exec, const DOM::CSSRuleList& rl){  return cacheDOMObject<DOM::CSSRuleList, KJS::DOMCSSRuleList>(exec, rl);}// -------------------------------------------------------------------------IMPLEMENT_PROTOFUNC_DOM(DOMCSSRuleFunc) // Not a proto, but doesn't matterDOMCSSRule::DOMCSSRule(ExecState* exec, const DOM::CSSRule& r)  : DOMObject(exec->interpreter()->builtinObjectPrototype()), cssRule(r){}DOMCSSRule::~DOMCSSRule(){  ScriptInterpreter::forgetDOMObject(cssRule.handle());}const ClassInfo DOMCSSRule::info = { "CSSRule", 0, &DOMCSSRuleTable, 0 };const ClassInfo DOMCSSRule::style_info = { "CSSStyleRule", &DOMCSSRule::info, &DOMCSSStyleRuleTable, 0 };const ClassInfo DOMCSSRule::media_info = { "CSSMediaRule", &DOMCSSRule::info, &DOMCSSMediaRuleTable, 0 };const ClassInfo DOMCSSRule::fontface_info = { "CSSFontFaceRule", &DOMCSSRule::info, &DOMCSSFontFaceRuleTable, 0 };const ClassInfo DOMCSSRule::page_info = { "CSSPageRule", &DOMCSSRule::info, &DOMCSSPageRuleTable, 0 };const ClassInfo DOMCSSRule::import_info = { "CSSImportRule", &DOMCSSRule::info, &DOMCSSImportRuleTable, 0 };const ClassInfo DOMCSSRule::charset_info = { "CSSCharsetRule", &DOMCSSRule::info, &DOMCSSCharsetRuleTable, 0 };const ClassInfo* DOMCSSRule::classInfo() const{  switch (cssRule.type()) {  case DOM::CSSRule::STYLE_RULE:    return &style_info;  case DOM::CSSRule::MEDIA_RULE:    return &media_info;  case DOM::CSSRule::FONT_FACE_RULE:    return &fontface_info;  case DOM::CSSRule::PAGE_RULE:    return &page_info;  case DOM::CSSRule::IMPORT_RULE:    return &import_info;  case DOM::CSSRule::CHARSET_RULE:    return &charset_info;  case DOM::CSSRule::UNKNOWN_RULE:  default:    return &info;  }}/*@begin DOMCSSRuleTable 4  type			DOMCSSRule::Type	DontDelete|ReadOnly  cssText		DOMCSSRule::CssText	DontDelete|ReadOnly  parentStyleSheet	DOMCSSRule::ParentStyleSheet	DontDelete|ReadOnly  parentRule		DOMCSSRule::ParentRule	DontDelete|ReadOnly@end@begin DOMCSSStyleRuleTable 2  selectorText		DOMCSSRule::Style_SelectorText	DontDelete  style			DOMCSSRule::Style_Style		DontDelete|ReadOnly@end@begin DOMCSSMediaRuleTable 4  media			DOMCSSRule::Media_Media		DontDelete|ReadOnly  cssRules		DOMCSSRule::Media_CssRules	DontDelete|ReadOnly  insertRule		DOMCSSRule::Media_InsertRule	DontDelete|Function 2  deleteRule		DOMCSSRule::Media_DeleteRule	DontDelete|Function 1@end@begin DOMCSSFontFaceRuleTable 1  style			DOMCSSRule::FontFace_Style	DontDelete|ReadOnly@end@begin DOMCSSPageRuleTable 2  selectorText		DOMCSSRule::Page_SelectorText	DontDelete  style			DOMCSSRule::Page_Style		DontDelete|ReadOnly@end@begin DOMCSSImportRuleTable 3  href			DOMCSSRule::Import_Href		DontDelete|ReadOnly  media			DOMCSSRule::Import_Media	DontDelete|ReadOnly  styleSheet		DOMCSSRule::Import_StyleSheet	DontDelete|ReadOnly@end@begin DOMCSSCharsetRuleTable 1  encoding		DOMCSSRule::Charset_Encoding	DontDelete@end*/Value DOMCSSRule::tryGet(ExecState *exec, const Identifier &propertyName) const{#ifdef KJS_VERBOSE  kdDebug(6070) << "DOMCSSRule::tryGet " << propertyName.qstring() << endl;#endif  const HashTable* table = classInfo()->propHashTable; // get the right hashtable  const HashEntry* entry = Lookup::findEntry(table, propertyName);  if (entry) {    if (entry->attr & Function)      return lookupOrCreateFunction<DOMCSSRuleFunc>(exec, propertyName, this, entry->value, entry->params, entry->attr);    return getValueProperty(exec, entry->value);  }  // Base CSSRule stuff or parent class forward, as usual  return DOMObjectLookupGet<DOMCSSRuleFunc, DOMCSSRule, DOMObject>(exec, propertyName, &DOMCSSRuleTable, this);}Value DOMCSSRule::getValueProperty(ExecState *exec, int token) const{  switch (token) {  case Type:    return Number(cssRule.type());  case CssText:    return String(cssRule.cssText());  case ParentStyleSheet:    return getDOMStyleSheet(exec,cssRule.parentStyleSheet());  case ParentRule:    return getDOMCSSRule(exec,cssRule.parentRule());  // for DOM::CSSRule::STYLE_RULE:  case Style_SelectorText:    return String(static_cast<DOM::CSSStyleRule>(cssRule).selectorText());  case Style_Style:    return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSStyleRule>(cssRule).style());  // for DOM::CSSRule::MEDIA_RULE:  case Media_Media:    return getDOMMediaList(exec,static_cast<DOM::CSSMediaRule>(cssRule).media());  case Media_CssRules:    return getDOMCSSRuleList(exec,static_cast<DOM::CSSMediaRule>(cssRule).cssRules());  // for DOM::CSSRule::FONT_FACE_RULE:  case FontFace_Style:    return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSFontFaceRule>(cssRule).style());  // for DOM::CSSRule::PAGE_RULE:  case Page_SelectorText:    return String(static_cast<DOM::CSSPageRule>(cssRule).selectorText());  case Page_Style:    return getDOMCSSStyleDeclaration(exec,static_cast<DOM::CSSPageRule>(cssRule).style());  // for DOM::CSSRule::IMPORT_RULE:  case Import_Href:    return String(static_cast<DOM::CSSImportRule>(cssRule).href());  case Import_Media:    return getDOMMediaList(exec,static_cast<DOM::CSSImportRule>(cssRule).media());  case Import_StyleSheet:    return getDOMStyleSheet(exec,static_cast<DOM::CSSImportRule>(cssRule).styleSheet());  // for DOM::CSSRule::CHARSET_RULE:  case Charset_Encoding:    return String(static_cast<DOM::CSSCharsetRule>(cssRule).encoding());  default:    kdDebug(6070) << "WARNING: DOMCSSRule::getValueProperty unhandled token " << token << endl;  }  return Undefined();}void DOMCSSRule::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr){  const HashTable* table = classInfo()->propHashTable; // get the right hashtable  const HashEntry* entry = Lookup::findEntry(table, propertyName);  if (entry) {    if (entry->attr & Function) // function: put as override property    {      ObjectImp::put(exec, propertyName, value, attr);      return;    }    else if ((entry->attr & ReadOnly) == 0) // let DOMObjectLookupPut print the warning if not    {      putValueProperty(exec, entry->value, value, attr);      return;    }  }  DOMObjectLookupPut<DOMCSSRule, DOMObject>(exec, propertyName, value, attr, &DOMCSSRuleTable, this);}void DOMCSSRule::putValueProperty(ExecState *exec, int token, const Value& value, int){  switch (token) {  // for DOM::CSSRule::STYLE_RULE:  case Style_SelectorText:    static_cast<DOM::CSSStyleRule>(cssRule).setSelectorText(value.toString(exec).string());    return;  // for DOM::CSSRule::PAGE_RULE:  case Page_SelectorText:    static_cast<DOM::CSSPageRule>(cssRule).setSelectorText(value.toString(exec).string());    return;  // for DOM::CSSRule::CHARSET_RULE:  case Charset_Encoding:    static_cast<DOM::CSSCharsetRule>(cssRule).setEncoding(value.toString(exec).string());    return;  default:    kdDebug(6070) << "WARNING: DOMCSSRule::putValueProperty unhandled token " << token << endl;  }}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();}Value KJS::getDOMCSSRule(ExecState *exec, const DOM::CSSRule& r){  return cacheDOMObject<DOM::CSSRule, KJS::DOMCSSRule>(exec, r);}// -------------------------------------------------------------------------DOM::CSSRule KJS::toCSSRule(const Value& val){  Object obj = Object::dynamicCast(val);  if (!obj.isValid() || !obj.inherits(&DOMCSSRule::info))    return DOM::CSSRule();  const DOMCSSRule *dobj = static_cast<const DOMCSSRule*>(obj.imp());  return dobj->toCSSRule();}// -------------------------------------------------------------------------const ClassInfo CSSRuleConstructor::info = { "CSSRuleConstructor", 0, &CSSRuleConstructorTable, 0 };/*@begin CSSRuleConstructorTable 7  UNKNOWN_RULE	CSSRuleConstructor::UNKNOWN_RULE	DontDelete|ReadOnly  STYLE_RULE	CSSRuleConstructor::STYLE_RULE		DontDelete|ReadOnly  CHARSET_RULE	CSSRuleConstructor::CHARSET_RULE	DontDelete|ReadOnly  IMPORT_RULE	CSSRuleConstructor::IMPORT_RULE		DontDelete|ReadOnly  MEDIA_RULE	CSSRuleConstructor::MEDIA_RULE		DontDelete|ReadOnly  FONT_FACE_RULE CSSRuleConstructor::FONT_FACE_RULE	DontDelete|ReadOnly  PAGE_RULE	CSSRuleConstructor::PAGE_RULE		DontDelete|ReadOnly@end*/CSSRuleConstructor::CSSRuleConstructor(ExecState *exec)  : DOMObject(exec->interpreter()->builtinObjectPrototype()){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -