webengine/osswebengine/DerivedSources/WebCore/JSCSSMediaRule.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 "JSCSSMediaRule.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "CSSMediaRule.h"
       
    28 #include "CSSRuleList.h"
       
    29 #include "ExceptionCode.h"
       
    30 #include "JSCSSRuleList.h"
       
    31 #include "JSMediaList.h"
       
    32 #include "MediaList.h"
       
    33 
       
    34 using namespace KJS;
       
    35 
       
    36 namespace WebCore {
       
    37 
       
    38 /* Hash table */
       
    39 
       
    40 static const HashEntry JSCSSMediaRuleTableEntries[] =
       
    41 {
       
    42     { "media", JSCSSMediaRule::MediaAttrNum, DontDelete|ReadOnly, 0, &JSCSSMediaRuleTableEntries[3] },
       
    43     { 0, 0, 0, 0, 0 },
       
    44     { 0, 0, 0, 0, 0 },
       
    45     { "cssRules", JSCSSMediaRule::CssRulesAttrNum, DontDelete|ReadOnly, 0, &JSCSSMediaRuleTableEntries[4] },
       
    46     { "constructor", JSCSSMediaRule::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
       
    47 };
       
    48 
       
    49 static const HashTable JSCSSMediaRuleTable = 
       
    50 {
       
    51     2, 5, JSCSSMediaRuleTableEntries, 3
       
    52 };
       
    53 
       
    54 /* Hash table for constructor */
       
    55 
       
    56 static const HashEntry JSCSSMediaRuleConstructorTableEntries[] =
       
    57 {
       
    58     { 0, 0, 0, 0, 0 }
       
    59 };
       
    60 
       
    61 static const HashTable JSCSSMediaRuleConstructorTable = 
       
    62 {
       
    63     2, 1, JSCSSMediaRuleConstructorTableEntries, 1
       
    64 };
       
    65 
       
    66 class JSCSSMediaRuleConstructor : public DOMObject {
       
    67 public:
       
    68     JSCSSMediaRuleConstructor(ExecState* exec)
       
    69     {
       
    70         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
       
    71         putDirect(exec->propertyNames().prototype, JSCSSMediaRulePrototype::self(exec), None);
       
    72     }
       
    73     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
       
    74     JSValue* getValueProperty(ExecState*, int token) const;
       
    75     virtual const ClassInfo* classInfo() const { return &info; }
       
    76     static const ClassInfo info;
       
    77 
       
    78     virtual bool implementsHasInstance() const { return true; }
       
    79 };
       
    80 
       
    81 const ClassInfo JSCSSMediaRuleConstructor::info = { "CSSMediaRuleConstructor", 0, &JSCSSMediaRuleConstructorTable, 0 };
       
    82 
       
    83 bool JSCSSMediaRuleConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    84 {
       
    85     return getStaticValueSlot<JSCSSMediaRuleConstructor, DOMObject>(exec, &JSCSSMediaRuleConstructorTable, this, propertyName, slot);
       
    86 }
       
    87 
       
    88 JSValue* JSCSSMediaRuleConstructor::getValueProperty(ExecState*, int token) const
       
    89 {
       
    90     // The token is the numeric value of its associated constant
       
    91     return jsNumber(token);
       
    92 }
       
    93 
       
    94 /* Hash table for prototype */
       
    95 
       
    96 static const HashEntry JSCSSMediaRulePrototypeTableEntries[] =
       
    97 {
       
    98     { "insertRule", JSCSSMediaRule::InsertRuleFuncNum, DontDelete|Function, 2, 0 },
       
    99     { "deleteRule", JSCSSMediaRule::DeleteRuleFuncNum, DontDelete|Function, 1, 0 }
       
   100 };
       
   101 
       
   102 static const HashTable JSCSSMediaRulePrototypeTable = 
       
   103 {
       
   104     2, 2, JSCSSMediaRulePrototypeTableEntries, 2
       
   105 };
       
   106 
       
   107 const ClassInfo JSCSSMediaRulePrototype::info = { "CSSMediaRulePrototype", 0, &JSCSSMediaRulePrototypeTable, 0 };
       
   108 
       
   109 JSObject* JSCSSMediaRulePrototype::self(ExecState* exec)
       
   110 {
       
   111     return KJS::cacheGlobalObject<JSCSSMediaRulePrototype>(exec, "[[JSCSSMediaRule.prototype]]");
       
   112 }
       
   113 
       
   114 bool JSCSSMediaRulePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   115 {
       
   116     return getStaticFunctionSlot<JSCSSMediaRulePrototypeFunction, JSObject>(exec, &JSCSSMediaRulePrototypeTable, this, propertyName, slot);
       
   117 }
       
   118 
       
   119 const ClassInfo JSCSSMediaRule::info = { "CSSMediaRule", &JSCSSRule::info, &JSCSSMediaRuleTable, 0 };
       
   120 
       
   121 JSCSSMediaRule::JSCSSMediaRule(ExecState* exec, CSSMediaRule* impl)
       
   122     : JSCSSRule(exec, impl)
       
   123 {
       
   124     setPrototype(JSCSSMediaRulePrototype::self(exec));
       
   125 }
       
   126 
       
   127 bool JSCSSMediaRule::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   128 {
       
   129     return getStaticValueSlot<JSCSSMediaRule, JSCSSRule>(exec, &JSCSSMediaRuleTable, this, propertyName, slot);
       
   130 }
       
   131 
       
   132 JSValue* JSCSSMediaRule::getValueProperty(ExecState* exec, int token) const
       
   133 {
       
   134     switch (token) {
       
   135     case MediaAttrNum: {
       
   136         CSSMediaRule* imp = static_cast<CSSMediaRule*>(impl());
       
   137 
       
   138         return toJS(exec, WTF::getPtr(imp->media()));
       
   139     }
       
   140     case CssRulesAttrNum: {
       
   141         CSSMediaRule* imp = static_cast<CSSMediaRule*>(impl());
       
   142 
       
   143         return toJS(exec, WTF::getPtr(imp->cssRules()));
       
   144     }
       
   145     case ConstructorAttrNum:
       
   146         return getConstructor(exec);
       
   147     }
       
   148     return 0;
       
   149 }
       
   150 
       
   151 JSValue* JSCSSMediaRule::getConstructor(ExecState* exec)
       
   152 {
       
   153     return KJS::cacheGlobalObject<JSCSSMediaRuleConstructor>(exec, "[[CSSMediaRule.constructor]]");
       
   154 }
       
   155 JSValue* JSCSSMediaRulePrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   156 {
       
   157     if (!thisObj->inherits(&JSCSSMediaRule::info))
       
   158       return throwError(exec, TypeError);
       
   159 
       
   160     CSSMediaRule* imp = static_cast<CSSMediaRule*>(static_cast<JSCSSMediaRule*>(thisObj)->impl());
       
   161 
       
   162     switch (id) {
       
   163     case JSCSSMediaRule::InsertRuleFuncNum: {
       
   164         ExceptionCode ec = 0;
       
   165         String rule = args[0]->toString(exec);
       
   166         bool indexOk;
       
   167         unsigned index = args[1]->toInt32(exec, indexOk);
       
   168         if (!indexOk) {
       
   169             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   170             return jsUndefined();
       
   171         }
       
   172 
       
   173 
       
   174         KJS::JSValue* result = jsNumber(imp->insertRule(rule, index, ec));
       
   175         setDOMException(exec, ec);
       
   176         return result;
       
   177     }
       
   178     case JSCSSMediaRule::DeleteRuleFuncNum: {
       
   179         ExceptionCode ec = 0;
       
   180         bool indexOk;
       
   181         unsigned index = args[0]->toInt32(exec, indexOk);
       
   182         if (!indexOk) {
       
   183             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   184             return jsUndefined();
       
   185         }
       
   186 
       
   187         imp->deleteRule(index, ec);
       
   188         setDOMException(exec, ec);
       
   189         return jsUndefined();
       
   190     }
       
   191     }
       
   192     return 0;
       
   193 }
       
   194 
       
   195 }