webengine/osswebengine/DerivedSources/WebCore/JSCSSRule.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2     This file is part of the WebKit open source project.
       
     3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Library General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Library General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Library General Public License
       
    16     along with this library; see the file COPYING.LIB.  If not, write to
       
    17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18     Boston, MA 02110-1301, USA.
       
    19 */
       
    20 
       
    21 #include "config.h"
       
    22 
       
    23 #include "JSCSSRule.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "CSSRule.h"
       
    28 #include "CSSStyleSheet.h"
       
    29 #include "JSCSSRule.h"
       
    30 #include "JSCSSStyleSheet.h"
       
    31 #include "PlatformString.h"
       
    32 
       
    33 using namespace KJS;
       
    34 
       
    35 namespace WebCore {
       
    36 
       
    37 /* Hash table */
       
    38 
       
    39 static const HashEntry JSCSSRuleTableEntries[] =
       
    40 {
       
    41     { "cssText", JSCSSRule::CssTextAttrNum, DontDelete, 0, 0 },
       
    42     { 0, 0, 0, 0, 0 },
       
    43     { "parentStyleSheet", JSCSSRule::ParentStyleSheetAttrNum, DontDelete|ReadOnly, 0, &JSCSSRuleTableEntries[6] },
       
    44     { "type", JSCSSRule::TypeAttrNum, DontDelete|ReadOnly, 0, &JSCSSRuleTableEntries[5] },
       
    45     { 0, 0, 0, 0, 0 },
       
    46     { "parentRule", JSCSSRule::ParentRuleAttrNum, DontDelete|ReadOnly, 0, 0 },
       
    47     { "constructor", JSCSSRule::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
       
    48 };
       
    49 
       
    50 static const HashTable JSCSSRuleTable = 
       
    51 {
       
    52     2, 7, JSCSSRuleTableEntries, 5
       
    53 };
       
    54 
       
    55 /* Hash table for constructor */
       
    56 
       
    57 static const HashEntry JSCSSRuleConstructorTableEntries[] =
       
    58 {
       
    59     { 0, 0, 0, 0, 0 },
       
    60     { "MEDIA_RULE", CSSRule::MEDIA_RULE, DontDelete|ReadOnly, 0, 0 },
       
    61     { "IMPORT_RULE", CSSRule::IMPORT_RULE, DontDelete|ReadOnly, 0, &JSCSSRuleConstructorTableEntries[8] },
       
    62     { "UNKNOWN_RULE", CSSRule::UNKNOWN_RULE, DontDelete|ReadOnly, 0, &JSCSSRuleConstructorTableEntries[7] },
       
    63     { 0, 0, 0, 0, 0 },
       
    64     { "STYLE_RULE", CSSRule::STYLE_RULE, DontDelete|ReadOnly, 0, 0 },
       
    65     { "PAGE_RULE", CSSRule::PAGE_RULE, DontDelete|ReadOnly, 0, 0 },
       
    66     { "CHARSET_RULE", CSSRule::CHARSET_RULE, DontDelete|ReadOnly, 0, 0 },
       
    67     { "FONT_FACE_RULE", CSSRule::FONT_FACE_RULE, DontDelete|ReadOnly, 0, 0 }
       
    68 };
       
    69 
       
    70 static const HashTable JSCSSRuleConstructorTable = 
       
    71 {
       
    72     2, 9, JSCSSRuleConstructorTableEntries, 7
       
    73 };
       
    74 
       
    75 class JSCSSRuleConstructor : public DOMObject {
       
    76 public:
       
    77     JSCSSRuleConstructor(ExecState* exec)
       
    78     {
       
    79         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
       
    80         putDirect(exec->propertyNames().prototype, JSCSSRulePrototype::self(exec), None);
       
    81     }
       
    82     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
       
    83     JSValue* getValueProperty(ExecState*, int token) const;
       
    84     virtual const ClassInfo* classInfo() const { return &info; }
       
    85     static const ClassInfo info;
       
    86 
       
    87     virtual bool implementsHasInstance() const { return true; }
       
    88 };
       
    89 
       
    90 const ClassInfo JSCSSRuleConstructor::info = { "CSSRuleConstructor", 0, &JSCSSRuleConstructorTable, 0 };
       
    91 
       
    92 bool JSCSSRuleConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    93 {
       
    94     return getStaticValueSlot<JSCSSRuleConstructor, DOMObject>(exec, &JSCSSRuleConstructorTable, this, propertyName, slot);
       
    95 }
       
    96 
       
    97 JSValue* JSCSSRuleConstructor::getValueProperty(ExecState*, int token) const
       
    98 {
       
    99     // The token is the numeric value of its associated constant
       
   100     return jsNumber(token);
       
   101 }
       
   102 
       
   103 /* Hash table for prototype */
       
   104 
       
   105 static const HashEntry JSCSSRulePrototypeTableEntries[] =
       
   106 {
       
   107     { 0, 0, 0, 0, 0 },
       
   108     { "MEDIA_RULE", CSSRule::MEDIA_RULE, DontDelete|ReadOnly, 0, 0 },
       
   109     { "IMPORT_RULE", CSSRule::IMPORT_RULE, DontDelete|ReadOnly, 0, &JSCSSRulePrototypeTableEntries[8] },
       
   110     { "UNKNOWN_RULE", CSSRule::UNKNOWN_RULE, DontDelete|ReadOnly, 0, &JSCSSRulePrototypeTableEntries[7] },
       
   111     { 0, 0, 0, 0, 0 },
       
   112     { "STYLE_RULE", CSSRule::STYLE_RULE, DontDelete|ReadOnly, 0, 0 },
       
   113     { "PAGE_RULE", CSSRule::PAGE_RULE, DontDelete|ReadOnly, 0, 0 },
       
   114     { "CHARSET_RULE", CSSRule::CHARSET_RULE, DontDelete|ReadOnly, 0, 0 },
       
   115     { "FONT_FACE_RULE", CSSRule::FONT_FACE_RULE, DontDelete|ReadOnly, 0, 0 }
       
   116 };
       
   117 
       
   118 static const HashTable JSCSSRulePrototypeTable = 
       
   119 {
       
   120     2, 9, JSCSSRulePrototypeTableEntries, 7
       
   121 };
       
   122 
       
   123 const ClassInfo JSCSSRulePrototype::info = { "CSSRulePrototype", 0, &JSCSSRulePrototypeTable, 0 };
       
   124 
       
   125 JSObject* JSCSSRulePrototype::self(ExecState* exec)
       
   126 {
       
   127     return KJS::cacheGlobalObject<JSCSSRulePrototype>(exec, "[[JSCSSRule.prototype]]");
       
   128 }
       
   129 
       
   130 bool JSCSSRulePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   131 {
       
   132     return getStaticValueSlot<JSCSSRulePrototype, JSObject>(exec, &JSCSSRulePrototypeTable, this, propertyName, slot);
       
   133 }
       
   134 
       
   135 JSValue* JSCSSRulePrototype::getValueProperty(ExecState*, int token) const
       
   136 {
       
   137     // The token is the numeric value of its associated constant
       
   138     return jsNumber(token);
       
   139 }
       
   140 
       
   141 const ClassInfo JSCSSRule::info = { "CSSRule", 0, &JSCSSRuleTable, 0 };
       
   142 
       
   143 JSCSSRule::JSCSSRule(ExecState* exec, CSSRule* impl)
       
   144     : m_impl(impl)
       
   145 {
       
   146     setPrototype(JSCSSRulePrototype::self(exec));
       
   147 }
       
   148 
       
   149 JSCSSRule::~JSCSSRule()
       
   150 {
       
   151     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
   152 }
       
   153 
       
   154 bool JSCSSRule::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   155 {
       
   156     return getStaticValueSlot<JSCSSRule, KJS::DOMObject>(exec, &JSCSSRuleTable, this, propertyName, slot);
       
   157 }
       
   158 
       
   159 JSValue* JSCSSRule::getValueProperty(ExecState* exec, int token) const
       
   160 {
       
   161     switch (token) {
       
   162     case TypeAttrNum: {
       
   163         CSSRule* imp = static_cast<CSSRule*>(impl());
       
   164 
       
   165         return jsNumber(imp->type());
       
   166     }
       
   167     case CssTextAttrNum: {
       
   168         CSSRule* imp = static_cast<CSSRule*>(impl());
       
   169 
       
   170         return jsStringOrNull(imp->cssText());
       
   171     }
       
   172     case ParentStyleSheetAttrNum: {
       
   173         CSSRule* imp = static_cast<CSSRule*>(impl());
       
   174 
       
   175         return toJS(exec, WTF::getPtr(imp->parentStyleSheet()));
       
   176     }
       
   177     case ParentRuleAttrNum: {
       
   178         CSSRule* imp = static_cast<CSSRule*>(impl());
       
   179 
       
   180         return toJS(exec, WTF::getPtr(imp->parentRule()));
       
   181     }
       
   182     case ConstructorAttrNum:
       
   183         return getConstructor(exec);
       
   184     }
       
   185     return 0;
       
   186 }
       
   187 
       
   188 void JSCSSRule::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
       
   189 {
       
   190     lookupPut<JSCSSRule, KJS::DOMObject>(exec, propertyName, value, attr, &JSCSSRuleTable, this);
       
   191 }
       
   192 
       
   193 void JSCSSRule::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
       
   194 {
       
   195     switch (token) {
       
   196     case CssTextAttrNum: {
       
   197         CSSRule* imp = static_cast<CSSRule*>(impl());
       
   198 
       
   199         ExceptionCode ec = 0;
       
   200         imp->setCssText(valueToStringWithNullCheck(exec, value), ec);
       
   201         setDOMException(exec, ec);
       
   202         break;
       
   203     }
       
   204     }
       
   205 }
       
   206 
       
   207 JSValue* JSCSSRule::getConstructor(ExecState* exec)
       
   208 {
       
   209     return KJS::cacheGlobalObject<JSCSSRuleConstructor>(exec, "[[CSSRule.constructor]]");
       
   210 }
       
   211 CSSRule* toCSSRule(KJS::JSValue* val)
       
   212 {
       
   213     return val->isObject(&JSCSSRule::info) ? static_cast<JSCSSRule*>(val)->impl() : 0;
       
   214 }
       
   215 
       
   216 }