#include "config.h"
#include "JSRGBColor.h"
#include "CSSPrimitiveValue.h"
#include "JSCSSPrimitiveValue.h"
using namespace JSC;
static JSValue jsRGBColorRed(ExecState*, const Identifier&, const PropertySlot&);
static JSValue jsRGBColorGreen(ExecState*, const Identifier&, const PropertySlot&);
static JSValue jsRGBColorBlue(ExecState*, const Identifier&, const PropertySlot&);
#include "JSRGBColor.lut.h"
namespace WebCore {
ASSERT_CLASS_FITS_IN_CELL(JSRGBColor);
const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 };
JSRGBColor::JSRGBColor(ExecState* exec, unsigned color)
: DOMObject(getDOMStructure<JSRGBColor>(exec))
, m_color(color)
{
}
bool JSRGBColor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticValueSlot<JSRGBColor, DOMObject>(exec, &JSRGBColorTable, this, propertyName, slot);
}
JSValue getJSRGBColor(ExecState* exec, unsigned color)
{
return new (exec) JSRGBColor(exec, color);
}
}
using namespace WebCore;
JSValue jsRGBColorRed(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 16) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}
JSValue jsRGBColorGreen(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 8) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}
JSValue jsRGBColorBlue(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
return toJS(exec, CSSPrimitiveValue::create(static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}