JSValue* jsCSSMediaRulePrototypeFunctionDeleteRule(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCSSMediaRule::s_info)) return throwError(exec, TypeError); JSCSSMediaRule* castedThisObj = static_cast<JSCSSMediaRule*>(thisValue); CSSMediaRule* imp = static_cast<CSSMediaRule*>(castedThisObj->impl()); ExceptionCode ec = 0; unsigned index = args[0]->toInt32(exec); imp->deleteRule(index, ec); setDOMException(exec, ec); return jsUndefined(); }
JSValue JSC_HOST_CALL jsCSSMediaRulePrototypeFunctionDeleteRule(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSCSSMediaRule::s_info)) return throwError(exec, TypeError); JSCSSMediaRule* castedThisObj = static_cast<JSCSSMediaRule*>(asObject(thisValue)); CSSMediaRule* imp = static_cast<CSSMediaRule*>(castedThisObj->impl()); ExceptionCode ec = 0; unsigned index = args.at(0).toInt32(exec); imp->deleteRule(index, ec); setDOMException(exec, ec); return jsUndefined(); }
JSValue* jsCSSMediaRulePrototypeFunctionInsertRule(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCSSMediaRule::s_info)) return throwError(exec, TypeError); JSCSSMediaRule* castedThisObj = static_cast<JSCSSMediaRule*>(thisValue); CSSMediaRule* imp = static_cast<CSSMediaRule*>(castedThisObj->impl()); ExceptionCode ec = 0; const UString& rule = args[0]->toString(exec); unsigned index = args[1]->toInt32(exec); KJS::JSValue* result = jsNumber(exec, imp->insertRule(rule, index, ec)); setDOMException(exec, ec); return result; }
JSValue* JSCSSMediaRule::getValueProperty(ExecState* exec, int token) const { switch (token) { case MediaAttrNum: { CSSMediaRule* imp = static_cast<CSSMediaRule*>(impl()); return toJS(exec, WTF::getPtr(imp->media())); } case CssRulesAttrNum: { CSSMediaRule* imp = static_cast<CSSMediaRule*>(impl()); return toJS(exec, WTF::getPtr(imp->cssRules())); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
CSSRule* CSSStream::ParseRule(CSSStyleSheet* parentStyleSheet, CSSRule* parentRule, ICSSRuleListener* pListener) { // stream->SkipSpaces(); getnextc(); if (m_c == L'/') { getnextc(); //if (c == L'*') EatChar(L'*'); { CSSCommentRule* p = new CSSCommentRule; //p->AddRef(); p->m_textOffset[0] = stream.m_ipos-2; p->m_textOffset[1] = stream.m_ipos-2; p->m_textOffset[2] = stream.m_ipos; p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; StringStream cssText; cssText << L"/*"; while (!stream.eof()) { if (stream.m_c == L'*') { stream.getnextc(); if (stream.m_c == L'/') { stream.getnextc(); break; } } cssText << (WCHAR)stream.m_c; } p->m_textOffset[3] = stream.m_ipos; stream.EatChar(L'*'); stream.EatChar(L'/'); p->m_textOffset[4] = stream.m_ipos; p->m_textOffset[5] = stream.m_ipos; cssText << L"*/"; p->m_cssText = cssText->str(); *pVal = p; } } else if (m_c == L'@') // at-rule { ASSERT(0); #if 0 String id = stream.GetID(); StringStream strbuilder; strbuilder << L"@"; strbuilder << id; int curly = 0; while (!stream.eof()) { strbuilder << (WCHAR)m_c; if (stream.m_c == L'{') { curly++; } else if (stream.m_c == L'}') { curly--; if (curly == 0) break; } else if (stream.m_c == L';') { if (curly == 0) { break; } } } // Read spaces while (!stream.eof()) { if (!isspace(stream.m_c)) { break; } strbuilder << (WCHAR)stream.m_c; stream.getnextc(); } String cssText = strbuilder->str(); pCallback->AtRule(id, cssText); if (id == L"charset") { CSSCharsetRule* p = new CSSCharsetRule; if (p) { // p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } else if (id == L"import") { CSSImportRule* p = new CSSImportRule; if (p) { // p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } else if (id == L"fontface") { CSSFontFaceRule* p = new CSSFontFaceRule; if (p) { // p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } else if (id == L"media") { CSSMediaRule* p = new CSSMediaRule; if (p) { //p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } else if (id == L"color-profile") { SVGColorProfileRule* p = new SVGColorProfileRule; if (p) { // p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } /* else if (!tcscmp(id, L"charset")) { } */ else // Unknown at-rule { CSSUnknownRule* p = new CSSUnknownRule; if (p) { //p->AddRef(); p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; p->set_cssText(cssText); *pVal = p; } } #endif } else { ParseStyleRule(); if (p) { // p->m_textOffset[0] = stream.m_ipos; p->m_parentStyleSheet = parentStyleSheet; p->m_parentRule = parentRule; StringStream cssText; // Skip selectors while (!stream.eof()) { cssText << (WCHAR)stream.m_c; if (m_c == L'{') { break; } stream.getnextc(); } p->m_textOffset[1] = stream.m_ipos; // Skip style declaration stream.EatChar(L'{'); int curly = 1; p->m_textOffset[2] = stream.m_ipos; while (!stream.eof()) { cssText << (WCHAR)stream.m_c; p->m_textOffset[3] = stream.m_ipos; if (stream.m_c == '"') { stream.getnextc(); //if (delimiter == L'\'' || L'\"') { while (!stream.eof()) { cssText << (WCHAR)stream.m_c; if (stream.m_c == '\\') { stream.getnextc(); cssText << (WCHAR)stream.m_c; } else if (stream.m_c == '"') { break; } } } } else if (stream.m_c == L'{') { curly++; } else if (stream.m_c == L'}') { curly--; if (curly == 0) { break; } } } p->m_textOffset[4] = stream.m_ipos; // Read spaces while (!stream.eof()) { if (!isspace(stream.m_c)) { break; } cssText << (WCHAR)stream.m_c; stream.getnextc(); } p->m_textOffset[5] = stream.m_ipos; p->set_cssText(cssText->str()); p->m_pListener = pListener; *pVal = p; } } return Success; }