📄 kjs_css.cpp
字号:
MEDIA_RULE CSSRuleConstructor::MEDIA_RULE DontDelete|ReadOnly
FONT_FACE_RULE CSSRuleConstructor::FONT_FACE_RULE DontDelete|ReadOnly
PAGE_RULE CSSRuleConstructor::PAGE_RULE DontDelete|ReadOnly
@end
*/
Value CSSRuleConstructor::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<CSSRuleConstructor,DOMObject>(exec,p,&CSSRuleConstructorTable,this);
}
Value CSSRuleConstructor::getValueProperty(ExecState *, int token) const
{
switch (token) {
case UNKNOWN_RULE:
return Number(DOM::CSSRule::UNKNOWN_RULE);
case STYLE_RULE:
return Number(DOM::CSSRule::STYLE_RULE);
case CHARSET_RULE:
return Number(DOM::CSSRule::CHARSET_RULE);
case IMPORT_RULE:
return Number(DOM::CSSRule::IMPORT_RULE);
case MEDIA_RULE:
return Number(DOM::CSSRule::MEDIA_RULE);
case FONT_FACE_RULE:
return Number(DOM::CSSRule::FONT_FACE_RULE);
case PAGE_RULE:
return Number(DOM::CSSRule::PAGE_RULE);
}
return Value();
}
Value KJS::getCSSRuleConstructor(ExecState *exec)
{
return cacheGlobalObject<CSSRuleConstructor>( exec, "[[cssRule.constructor]]" );
}
// -------------------------------------------------------------------------
const ClassInfo DOMCSSValue::info = { "CSSValue", 0, &DOMCSSValueTable, 0 };
/*
@begin DOMCSSValueTable 2
cssText DOMCSSValue::CssText DontDelete|ReadOnly
cssValueType DOMCSSValue::CssValueType DontDelete|ReadOnly
@end
*/
DOMCSSValue::~DOMCSSValue()
{
ScriptInterpreter::forgetDOMObject(cssValue.handle());
}
Value DOMCSSValue::tryGet(ExecState *exec, const Identifier &p) const
{
if (p == "cssText")
return getStringOrNull(cssValue.cssText());
else if (p == "cssValueType");
return Number(cssValue.cssValueType());
return DOMObject::tryGet(exec,p);
}
void DOMCSSValue::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
{
if (propertyName == "cssText")
cssValue.setCssText(value.toString(exec).string());
else
DOMObject::tryPut(exec, propertyName, value, attr);
}
Value KJS::getDOMCSSValue(ExecState *exec, DOM::CSSValue v)
{
DOMObject *ret;
if (v.isNull())
return Null();
ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
if ((ret = interp->getDOMObject(v.handle())))
return Value(ret);
else {
if (v.isCSSValueList())
ret = new DOMCSSValueList(exec,v);
else if (v.isCSSPrimitiveValue())
ret = new DOMCSSPrimitiveValue(exec,v);
else
ret = new DOMCSSValue(exec,v);
interp->putDOMObject(v.handle(),ret);
return Value(ret);
}
}
// -------------------------------------------------------------------------
const ClassInfo CSSValueConstructor::info = { "CSSValueConstructor", 0, &CSSValueConstructorTable, 0 };
/*
@begin CSSValueConstructorTable 5
CSS_INHERIT CSSValueConstructor::CSS_INHERIT DontDelete|ReadOnly
CSS_PRIMITIVE_VALUE CSSValueConstructor::CSS_PRIMITIVE_VALUE DontDelete|ReadOnly
CSS_VALUE_LIST CSSValueConstructor::CSS_VALUE_LIST DontDelete|ReadOnly
CSS_CUSTOM CSSValueConstructor::CSS_CUSTOM DontDelete|ReadOnly
@end
*/
Value CSSValueConstructor::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<CSSValueConstructor,DOMObject>(exec,p,&CSSValueConstructorTable,this);
}
Value CSSValueConstructor::getValueProperty(ExecState *, int token) const
{
switch (token) {
case CSS_INHERIT:
return Number(DOM::CSSValue::CSS_INHERIT);
case CSS_PRIMITIVE_VALUE:
return Number(DOM::CSSValue::CSS_PRIMITIVE_VALUE);
case CSS_VALUE_LIST:
return Number(DOM::CSSValue::CSS_VALUE_LIST);
case CSS_CUSTOM:
return Number(DOM::CSSValue::CSS_CUSTOM);
}
return Value();
}
Value KJS::getCSSValueConstructor(ExecState *exec)
{
return cacheGlobalObject<CSSValueConstructor>( exec, "[[cssValue.constructor]]" );
}
// -------------------------------------------------------------------------
const ClassInfo DOMCSSPrimitiveValue::info = { "CSSPrimitiveValue", 0, &DOMCSSPrimitiveValueTable, 0 };
/*
@begin DOMCSSPrimitiveValueTable 1
primitiveType DOMCSSPrimitiveValue::PrimitiveType DontDelete|ReadOnly
@end
@begin DOMCSSPrimitiveValueProtoTable 3
setFloatValue DOMCSSPrimitiveValue::SetFloatValue DontDelete|Function 2
getFloatValue DOMCSSPrimitiveValue::GetFloatValue DontDelete|Function 1
setStringValue DOMCSSPrimitiveValue::SetStringValue DontDelete|Function 2
getStringValue DOMCSSPrimitiveValue::GetStringValue DontDelete|Function 0
getCounterValue DOMCSSPrimitiveValue::GetCounterValue DontDelete|Function 0
getRectValue DOMCSSPrimitiveValue::GetRectValue DontDelete|Function 0
getRGBColorValue DOMCSSPrimitiveValue::GetRGBColorValue DontDelete|Function 0
@end
*/
DEFINE_PROTOTYPE("DOMCSSPrimitiveValue",DOMCSSPrimitiveValueProto)
IMPLEMENT_PROTOFUNC(DOMCSSPrimitiveValueProtoFunc)
IMPLEMENT_PROTOTYPE(DOMCSSPrimitiveValueProto,DOMCSSPrimitiveValueProtoFunc)
DOMCSSPrimitiveValue::DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValue v)
: DOMCSSValue(DOMCSSPrimitiveValueProto::self(exec), v) { }
Value DOMCSSPrimitiveValue::tryGet(ExecState *exec, const Identifier &p) const
{
if (p=="primitiveType")
return Number(static_cast<DOM::CSSPrimitiveValue>(cssValue).primitiveType());
return DOMObject::tryGet(exec,p);
}
Value DOMCSSPrimitiveValueProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
if (!thisObj.inherits(&KJS::DOMCSSPrimitiveValue::info)) {
Object err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
DOM::CSSPrimitiveValue val = static_cast<DOMCSSPrimitiveValue *>(thisObj.imp())->toCSSPrimitiveValue();
switch (id) {
case DOMCSSPrimitiveValue::SetFloatValue:
val.setFloatValue(args[0].toInt32(exec),args[1].toNumber(exec));
return Undefined();
case DOMCSSPrimitiveValue::GetFloatValue:
return Number(val.getFloatValue(args[0].toInt32(exec)));
case DOMCSSPrimitiveValue::SetStringValue:
val.setStringValue(args[0].toInt32(exec),args[1].toString(exec).string());
return Undefined();
case DOMCSSPrimitiveValue::GetStringValue:
return getStringOrNull(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();
}
}
// -------------------------------------------------------------------------
const ClassInfo CSSPrimitiveValueConstructor::info = { "CSSPrimitiveValueConstructor", 0, &CSSPrimitiveValueConstructorTable, 0 };
/*
@begin CSSPrimitiveValueConstructorTable 27
CSS_UNKNOWN DOM::CSSPrimitiveValue::CSS_UNKNOWN DontDelete|ReadOnly
CSS_NUMBER DOM::CSSPrimitiveValue::CSS_NUMBER DontDelete|ReadOnly
CSS_PERCENTAGE DOM::CSSPrimitiveValue::CSS_PERCENTAGE DontDelete|ReadOnly
CSS_EMS DOM::CSSPrimitiveValue::CSS_EMS DontDelete|ReadOnly
CSS_EXS DOM::CSSPrimitiveValue::CSS_EXS DontDelete|ReadOnly
CSS_PX DOM::CSSPrimitiveValue::CSS_PX DontDelete|ReadOnly
CSS_CM DOM::CSSPrimitiveValue::CSS_CM DontDelete|ReadOnly
CSS_MM DOM::CSSPrimitiveValue::CSS_MM DontDelete|ReadOnly
CSS_IN DOM::CSSPrimitiveValue::CSS_IN DontDelete|ReadOnly
CSS_PT DOM::CSSPrimitiveValue::CSS_PT DontDelete|ReadOnly
CSS_PC DOM::CSSPrimitiveValue::CSS_PC DontDelete|ReadOnly
CSS_DEG DOM::CSSPrimitiveValue::CSS_DEG DontDelete|ReadOnly
CSS_RAD DOM::CSSPrimitiveValue::CSS_RAD DontDelete|ReadOnly
CSS_GRAD DOM::CSSPrimitiveValue::CSS_GRAD DontDelete|ReadOnly
CSS_MS DOM::CSSPrimitiveValue::CSS_MS DontDelete|ReadOnly
CSS_S DOM::CSSPrimitiveValue::CSS_S DontDelete|ReadOnly
CSS_HZ DOM::CSSPrimitiveValue::CSS_HZ DontDelete|ReadOnly
CSS_KHZ DOM::CSSPrimitiveValue::CSS_KHZ DontDelete|ReadOnly
CSS_DIMENSION DOM::CSSPrimitiveValue::CSS_DIMENSION DontDelete|ReadOnly
CSS_STRING DOM::CSSPrimitiveValue::CSS_STRING DontDelete|ReadOnly
CSS_URI DOM::CSSPrimitiveValue::CSS_URI DontDelete|ReadOnly
CSS_IDENT DOM::CSSPrimitiveValue::CSS_IDENT DontDelete|ReadOnly
CSS_ATTR DOM::CSSPrimitiveValue::CSS_ATTR DontDelete|ReadOnly
CSS_COUNTER DOM::CSSPrimitiveValue::CSS_COUNTER DontDelete|ReadOnly
CSS_RECT DOM::CSSPrimitiveValue::CSS_RECT DontDelete|ReadOnly
CSS_RGBCOLOR DOM::CSSPrimitiveValue::CSS_RGBCOLOR DontDelete|ReadOnly
@end
*/
Value CSSPrimitiveValueConstructor::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<CSSPrimitiveValueConstructor,CSSValueConstructor>(exec,p,&CSSPrimitiveValueConstructorTable,this);
}
Value CSSPrimitiveValueConstructor::getValueProperty(ExecState *, int token) const
{
// We use the token as the value to return directly
return Number(token);
}
Value KJS::getCSSPrimitiveValueConstructor(ExecState *exec)
{
return cacheGlobalObject<CSSPrimitiveValueConstructor>( exec, "[[cssPrimitiveValue.constructor]]" );
}
// -------------------------------------------------------------------------
const ClassInfo DOMCSSValueList::info = { "CSSValueList", 0, &DOMCSSValueListTable, 0 };
/*
@begin DOMCSSValueListTable 3
length DOMCSSValueList::Length DontDelete|ReadOnly
item DOMCSSValueList::Item DontDelete|Function 1
@end
*/
IMPLEMENT_PROTOFUNC(DOMCSSValueListFunc) // not really a proto, but doesn't matter
DOMCSSValueList::DOMCSSValueList(ExecState *exec, DOM::CSSValueList v)
: DOMCSSValue(exec, v) { }
Value DOMCSSValueList::tryGet(ExecState *exec, const Identifier &p) const
{
Value result;
DOM::CSSValueList valueList = static_cast<DOM::CSSValueList>(cssValue);
if (p == lengthPropertyName)
return Number(valueList.length());
else if (p == "item")
return lookupOrCreateFunction<DOMCSSValueListFunc>(exec,p,this,DOMCSSValueList::Item,1,DontDelete|Function);
bool ok;
long unsigned int u = p.toULong(&ok);
if (ok)
return getDOMCSSValue(exec,valueList.item(u));
return DOMCSSValue::tryGet(exec,p);
}
Value DOMCSSValueListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
if (!thisObj.inherits(&KJS::DOMCSSValue::info)) {
Object err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
DOM::CSSValueList valueList = static_cast<DOMCSSValueList *>(thisObj.imp())->toValueList();
switch (id) {
case DOMCSSValueList::Item:
return getDOMCSSValue(exec,valueList.item(args[0].toInt32(exec)));
default:
return Undefined();
}
}
// -------------------------------------------------------------------------
const ClassInfo DOMRGBColor::info = { "RGBColor", 0, &DOMRGBColorTable, 0 };
/*
@begin DOMRGBColorTable 3
red DOMRGBColor::Red DontDelete|ReadOnly
green DOMRGBColor::Green DontDelete|ReadOnly
blue DOMRGBColor::Blue DontDelete|ReadOnly
@end
*/
DOMRGBColor::~DOMRGBColor()
{
//rgbColors.remove(rgbColor.handle());
}
Value DOMRGBColor::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<DOMRGBColor,DOMObject>(exec, p,
&DOMRGBColorTable,
this);
}
Value DOMRGBColor::getValueProperty(ExecState *exec, int token) const
{
switch (token) {
case Red:
return getDOMCSSValue(exec, rgbColor.red());
case Green:
return getDOMCSSValue(exec, rgbColor.green());
case Blue:
return getDOMCSSValue(exec, rgbColor.blue());
default:
return Value();
}
}
Value KJS::getDOMRGBColor(ExecState *, DOM::RGBColor c)
{
// ### implement equals for RGBColor since they're not refcounted objects
return Value(new DOMRGBColor(c));
}
// -------------------------------------------------------------------------
const ClassInfo DOMRect::info = { "Rect", 0, &DOMRectTable, 0 };
/*
@begin DOMRectTable 4
top DOMRect::Top DontDelete|ReadOnly
right DOMRect::Right DontDelete|ReadOnly
bottom DOMRect::Bottom DontDelete|ReadOnly
left DOMRect::Left DontDelete|ReadOnly
@end
*/
DOMRect::~DOMRect()
{
ScriptInterpreter::forgetDOMObject(rect.handle());
}
Value DOMRect::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<DOMRect,DOMObject>(exec, p,
&DOMRectTable, this);
}
Value DOMRect::getValueProperty(ExecState *exec, int token) const
{
switch (token) {
case Top:
return getDOMCSSValue(exec, rect.top());
case Right:
return getDOMCSSValue(exec, rect.right());
case Bottom:
return getDOMCSSValue(exec, rect.bottom());
case Left:
return getDOMCSSValue(exec, rect.left());
default:
return Value();
}
}
Value KJS::getDOMRect(ExecState *exec, DOM::Rect r)
{
return cacheDOMObject<DOM::Rect, KJS::DOMRect>(exec, r);
}
// -------------------------------------------------------------------------
const ClassInfo DOMCounter::info = { "Counter", 0, &DOMCounterTable, 0 };
/*
@begin DOMCounterTable 3
identifier DOMCounter::identifier DontDelete|ReadOnly
listStyle DOMCounter::listStyle DontDelete|ReadOnly
separator DOMCounter::separator DontDelete|ReadOnly
@end
*/
DOMCounter::~DOMCounter()
{
ScriptInterpreter::forgetDOMObject(counter.handle());
}
Value DOMCounter::tryGet(ExecState *exec, const Identifier &p) const
{
return DOMObjectLookupGetValue<DOMCounter,DOMObject>(exec, p,
&DOMCounterTable, this);
}
Value DOMCounter::getValueProperty(ExecState *, int token) const
{
switch (token) {
case identifier:
return getStringOrNull(counter.identifier());
case listStyle:
return getStringOrNull(counter.listStyle());
case separator:
return getStringOrNull(counter.separator());
default:
return Value();
}
}
Value KJS::getDOMCounter(ExecState *exec, DOM::Counter c)
{
return cacheDOMObject<DOM::Counter, KJS::DOMCounter>(exec, c);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -