Changeset 21911 in webkit


Ignore:
Timestamp:
May 30, 2007 10:21:11 PM (17 years ago)
Author:
weinig
Message:

LayoutTests:

Reviewed by Oliver.

Update results for http://bugs.webkit.org/show_bug.cgi?id=13943
Autogenerate the JS bindings for the CSSStyleSheet

  • fast/dom/Window/window-properties-expected.txt:

WebCore:

Reviewed by Oliver.

Patch for http://bugs.webkit.org/show_bug.cgi?id=13943
Autogenerate the JS bindings for the CSSStyleSheet

  • DerivedSources.make:
  • WebCore.pro:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSStyleSheetCustom.cpp: (WebCore::toJS):
  • bindings/js/kjs_css.cpp:
  • bindings/js/kjs_css.h:
  • bindings/scripts/CodeGeneratorJS.pm:
  • css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::addRule): (WebCore::CSSStyleSheet::cssRules):
  • css/CSSStyleSheet.h: (WebCore::CSSStyleSheet::rules): (WebCore::CSSStyleSheet::removeRule):
  • css/CSSStyleSheet.idl:
  • page/DOMWindow.idl:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r21909 r21911  
     12007-05-30  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Oliver.
     4
     5        Update results for http://bugs.webkit.org/show_bug.cgi?id=13943
     6        Autogenerate the JS bindings for the CSSStyleSheet
     7
     8        * fast/dom/Window/window-properties-expected.txt:
     9
    1102007-05-30  Sam Weinig  <sam@webkit.org>
    211
  • trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt

    r21909 r21911  
    213213window.CSSStyleRule [object CSSStyleRuleConstructor]
    214214window.CSSStyleRule.prototype [printed above as window.CSSRule.prototype]
     215window.CSSStyleSheet [object StyleSheetConstructor]
     216window.CSSStyleSheet.prototype [object StyleSheetPrototype]
    215217window.CSSValue [object CSSValueConstructor]
    216218window.CSSValue.CSS_CUSTOM [number]
     
    805807window.RangeException.prototype.INVALID_NODE_TYPE_ERR [number]
    806808window.ReferenceError [function]
    807 window.StyleSheet [object StyleSheetConstructor]
    808 window.StyleSheet.prototype [object StyleSheetPrototype]
     809window.StyleSheet [printed above as window.CSSStyleSheet]
    809810window.SyntaxError [function]
    810811window.Text [object TextConstructor]
  • trunk/WebCore/ChangeLog

    r21910 r21911  
     12007-05-30  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Oliver.
     4
     5        Patch for http://bugs.webkit.org/show_bug.cgi?id=13943
     6        Autogenerate the JS bindings for the CSSStyleSheet
     7
     8        * DerivedSources.make:
     9        * WebCore.pro:
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * bindings/js/JSStyleSheetCustom.cpp:
     12        (WebCore::toJS):
     13        * bindings/js/kjs_css.cpp:
     14        * bindings/js/kjs_css.h:
     15        * bindings/scripts/CodeGeneratorJS.pm:
     16        * css/CSSStyleSheet.cpp:
     17        (WebCore::CSSStyleSheet::addRule):
     18        (WebCore::CSSStyleSheet::cssRules):
     19        * css/CSSStyleSheet.h:
     20        (WebCore::CSSStyleSheet::rules):
     21        (WebCore::CSSStyleSheet::removeRule):
     22        * css/CSSStyleSheet.idl:
     23        * page/DOMWindow.idl:
     24
    1252007-05-30  Sam Weinig  <sam@webkit.org>
    226
  • trunk/WebCore/DerivedSources.make

    r21896 r21911  
    310310    JSCSSRuleList.h \
    311311    JSCSSStyleRule.h \
     312    JSCSSStyleSheet.h \
    312313    JSCSSValue.h \
    313314    JSCSSValueList.h \
  • trunk/WebCore/WebCore.pro

    r21910 r21911  
    172172    css/CSSStyleDeclaration.idl \
    173173    css/CSSStyleRule.idl \
     174    css/CSSStyleSheet.idl \
    174175    css/CSSValue.idl \
    175176    css/CSSValueList.idl \
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r21910 r21911  
    28542854                BCC47E2709A3D6F100ADB771 /* FontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC47E2509A3D6F100ADB771 /* FontFamily.h */; settings = {ATTRIBUTES = (Private, ); }; };
    28552855                BCC47E6B09A3FE4700ADB771 /* FontDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC47E6A09A3FE4700ADB771 /* FontDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2856                BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */; };
     2857                BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */; };
    28562858                BCC71A130A0FF94D0014EE6E /* GlyphBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */; };
    28572859                BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */; };
     
    61286130                BCC47E2509A3D6F100ADB771 /* FontFamily.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontFamily.h; sourceTree = "<group>"; };
    61296131                BCC47E6A09A3FE4700ADB771 /* FontDescription.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontDescription.h; sourceTree = "<group>"; };
     6132                BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleSheet.cpp; sourceTree = "<group>"; };
     6133                BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleSheet.h; sourceTree = "<group>"; };
    61306134                BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphBuffer.h; sourceTree = "<group>"; };
    61316135                BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ColorData.gperf; sourceTree = "<group>"; };
     
    64676471                                BC46C2040C0DDCA10020CFC3 /* JSCSSStyleRule.cpp */,
    64686472                                BC46C2050C0DDCA10020CFC3 /* JSCSSStyleRule.h */,
     6473                                BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */,
     6474                                BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */,
    64696475                                14CF78A309F58CBF00EB3665 /* JSCSSValue.cpp */,
    64706476                                14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
     
    1149311499                                BC46C2030C0DDC8F0020CFC3 /* JSCSSPageRule.h in Headers */,
    1149411500                                BC46C2070C0DDCA10020CFC3 /* JSCSSStyleRule.h in Headers */,
     11501                                BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */,
    1149511502                        );
    1149611503                        runOnlyForDeploymentPostprocessing = 0;
     
    1290412911                                BC46C2060C0DDCA10020CFC3 /* JSCSSStyleRule.cpp in Sources */,
    1290512912                                BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
     12913                                BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */,
    1290612914                        );
    1290712915                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSStyleSheetCustom.cpp

    r21873 r21911  
    2828
    2929#include "CSSStyleSheet.h"
    30 #include "kjs_css.h"
     30#include "JSCSSStyleSheet.h"
     31#include "StyleSheet.h"
    3132
    3233namespace WebCore {
     
    4344
    4445    if (styleSheet->isCSSStyleSheet())
    45         ret = new KJS::DOMCSSStyleSheet(exec, static_cast<CSSStyleSheet*>(styleSheet));
     46        ret = new JSCSSStyleSheet(exec, static_cast<CSSStyleSheet*>(styleSheet));
    4647    else
    4748        ret = new JSStyleSheet(exec, styleSheet);
  • trunk/WebCore/bindings/js/kjs_css.cpp

    r21910 r21911  
    158158// -------------------------------------------------------------------------
    159159
    160 const ClassInfo DOMCSSStyleSheet::info = { "CSSStyleSheet", &WebCore::JSStyleSheet::info, &DOMCSSStyleSheetTable, 0 };
    161 
    162 /*
    163 @begin DOMCSSStyleSheetTable 5
    164   ownerRule     DOMCSSStyleSheet::OwnerRule     DontDelete|ReadOnly
    165   cssRules      DOMCSSStyleSheet::CssRules      DontDelete|ReadOnly
    166 # MSIE extension
    167   rules         DOMCSSStyleSheet::Rules         DontDelete|ReadOnly
    168 @end
    169 @begin DOMCSSStyleSheetPrototypeTable 6
    170   insertRule    DOMCSSStyleSheet::InsertRule    DontDelete|Function 2
    171   deleteRule    DOMCSSStyleSheet::DeleteRule    DontDelete|Function 1
    172 # MSIE extensions
    173   addRule       DOMCSSStyleSheet::AddRule       DontDelete|Function 2
    174   removeRule    DOMCSSStyleSheet::RemoveRule    DontDelete|Function 1
    175 @end
    176 */
    177 KJS_DEFINE_PROTOTYPE(DOMCSSStyleSheetPrototype)
    178 KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMCSSStyleSheetPrototypeFunction)
    179 KJS_IMPLEMENT_PROTOTYPE("DOMCSSStyleSheet",DOMCSSStyleSheetPrototype,DOMCSSStyleSheetPrototypeFunction) // warning, use _WITH_PARENT if DOMStyleSheet gets a prototype
    180 
    181 DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState* exec, CSSStyleSheet *ss)
    182   : JSStyleSheet(exec, ss)
    183 {
    184   setPrototype(DOMCSSStyleSheetPrototype::self(exec));
    185 }
    186 
    187 DOMCSSStyleSheet::~DOMCSSStyleSheet()
    188 {
    189 }
    190 
    191 JSValue* DOMCSSStyleSheet::getValueProperty(ExecState* exec, int token) const
    192 {
    193   switch (token) {
    194   case OwnerRule:
    195     return toJS(exec, static_cast<CSSStyleSheet*>(impl())->ownerRule());
    196   case CssRules:
    197     return toJS(exec, static_cast<CSSStyleSheet*>(impl())->cssRules());
    198   case Rules:
    199     return toJS(exec, static_cast<CSSStyleSheet*>(impl())->cssRules(true));
    200   default:
    201     ASSERT(0);
    202     return jsUndefined();
    203   }
    204 }
    205 
    206 bool DOMCSSStyleSheet::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    207 {
    208   return getStaticValueSlot<DOMCSSStyleSheet, JSStyleSheet>(exec, &DOMCSSStyleSheetTable, this, propertyName, slot);
    209 }
    210 
    211 JSValue* DOMCSSStyleSheetPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
    212 {
    213   if (!thisObj->inherits(&KJS::DOMCSSStyleSheet::info))
    214     return throwError(exec, TypeError);
    215   DOMExceptionTranslator exception(exec);
    216   CSSStyleSheet &styleSheet = *static_cast<CSSStyleSheet*>(static_cast<DOMCSSStyleSheet*>(thisObj)->impl());
    217   switch (id) {
    218     case DOMCSSStyleSheet::InsertRule:
    219       return jsNumber(styleSheet.insertRule(args[0]->toString(exec), args[1]->toInt32(exec), exception));
    220     case DOMCSSStyleSheet::DeleteRule:
    221       styleSheet.deleteRule(args[0]->toInt32(exec), exception);
    222       return jsUndefined();
    223     case DOMCSSStyleSheet::AddRule: {
    224       int index = args.size() >= 3 ? args[2]->toInt32(exec) : -1;
    225       styleSheet.addRule(args[0]->toString(exec), args[1]->toString(exec), index, exception);
    226       // As per Microsoft documentation, always return -1.
    227       return jsNumber(-1);
    228     }
    229     case DOMCSSStyleSheet::RemoveRule: {
    230       int index = args.size() >= 1 ? args[0]->toInt32(exec) : 0;
    231       styleSheet.removeRule(index, exception);
    232       return jsUndefined();
    233     }
    234   }
    235   return jsUndefined();
    236 }
    237 
    238 // -------------------------------------------------------------------------
    239 
    240160const ClassInfo DOMRGBColor::info = { "RGBColor", 0, &DOMRGBColorTable, 0 };
    241161
  • trunk/WebCore/bindings/js/kjs_css.h

    r21910 r21911  
    6161  JSValue* toJS(ExecState*, WebCore::StyleSheetList*, WebCore::Document*);
    6262
    63   class DOMCSSStyleSheet : public WebCore::JSStyleSheet {
    64   public:
    65     DOMCSSStyleSheet(ExecState*, WebCore::CSSStyleSheet*);
    66     virtual ~DOMCSSStyleSheet();
    67     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    68     JSValue* getValueProperty(ExecState*, int token) const;
    69     // no put - all read-only
    70     virtual const ClassInfo* classInfo() const { return &info; }
    71     static const ClassInfo info;
    72     enum { OwnerRule, CssRules, Rules, InsertRule, DeleteRule, AddRule, RemoveRule };
    73   };
    74 
    7563  class DOMRGBColor : public DOMObject {
    7664  public:
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r21910 r21911  
    14911491        $implIncludes{"kjs_dom.h"} = 1;
    14921492        $implIncludes{"NamedNodeMap.h"} = 1;
    1493     } elsif ($type eq "CSSStyleSheet") {
    1494         $implIncludes{"CSSStyleSheet.h"} = 1;
    1495         $implIncludes{"kjs_css.h"} = 1;
    14961493    } elsif ($type eq "Rect") {
    14971494        $implIncludes{"RectImpl.h"} = 1;
  • trunk/WebCore/css/CSSStyleSheet.cpp

    r17825 r21911  
    1 /**
    2  * This file is part of the DOM implementation for KDE.
    3  *
     1/*
    42 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    5  * Copyright (C) 2004, 2006 Apple Computer, Inc.
     3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    2018 * Boston, MA 02111-1307, USA.
    2119 */
     20
    2221#include "config.h"
    2322#include "CSSStyleSheet.h"
     
    2524#include "CSSImportRule.h"
    2625#include "CSSNamespace.h"
    27 #include "cssparser.h"
    2826#include "CSSRuleList.h"
    2927#include "Document.h"
    3028#include "ExceptionCode.h"
    3129#include "Node.h"
     30#include "cssparser.h"
    3231
    3332namespace WebCore {
     
    9594}
    9695
    97 unsigned CSSStyleSheet::addRule(const String &selector, const String &style, int index, ExceptionCode& ec)
    98 {
    99     if (index == -1)
    100         index = length();
    101     return insertRule(selector + " { " + style + " }", index, ec);
    102 }
    103 
    104 CSSRuleList *CSSStyleSheet::cssRules(bool omitCharsetRules)
     96int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
     97{
     98    insertRule(selector + " { " + style + " }", index, ec);
     99
     100    // As per Microsoft documentation, always return -1.
     101    return -1;
     102}
     103
     104int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
     105{
     106    return addRule(selector, style, length(), ec);
     107}
     108
     109
     110CSSRuleList* CSSStyleSheet::cssRules(bool omitCharsetRules)
    105111{
    106112    return new CSSRuleList(this, omitCharsetRules);
  • trunk/WebCore/css/CSSStyleSheet.h

    r18874 r21911  
    11/*
    2  * This file is part of the DOM implementation for KDE.
    3  *
    42 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    5  * Copyright (C) 2004, 2006 Apple Computer, Inc.
     3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    3735typedef int ExceptionCode;
    3836
    39 class CSSStyleSheet : public StyleSheet
    40 {
     37class CSSStyleSheet : public StyleSheet {
    4138public:
    4239    CSSStyleSheet(Node* parentNode, const String& href = String(), const String& charset = String());
     
    5451    unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
    5552    void deleteRule(unsigned index, ExceptionCode&);
    56     unsigned addRule(const String& selector, const String& style, int index, ExceptionCode&);
     53
     54    // IE Extensions
     55    CSSRuleList* rules() { return cssRules(true); }
     56    int addRule(const String& selector, const String& style, int index, ExceptionCode&);
     57    int addRule(const String& selector, const String& style, ExceptionCode&);
    5758    void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
    58    
     59    void removeRule(ExceptionCode& ec) { deleteRule(0, ec); }
     60
    5961    void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
    6062    const AtomicString& determineNamespace(const AtomicString& prefix);
  • trunk/WebCore/css/CSSStyleSheet.idl

    r16645 r21911  
    11/*
    2  * Copyright (C) 2006 Apple Computer, Inc.
     2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    3131        void               deleteRule(in unsigned long index)
    3232            raises(DOMException);
     33
     34        // IE Extensions
     35        readonly attribute CSSRuleList      rules;
     36
     37        long addRule(in DOMString selector,
     38                     in DOMString style,
     39                     in [Optional] unsigned long index)
     40            raises(DOMException);
     41        void removeRule(in [Optional] unsigned long index)
     42            raises(DOMException);
    3343    };
    3444
  • trunk/WebCore/page/DOMWindow.idl

    r21909 r21911  
    4343
    4444        // Global constructors
     45        attribute StyleSheetConstructor StyleSheet;
     46        attribute CSSStyleSheetConstructor CSSStyleSheet;
     47
     48        attribute CSSValueConstructor CSSValue;
    4549        attribute CSSPrimitiveValueConstructor CSSPrimitiveValue;
     50        attribute CSSValueListConstructor CSSValueList;
     51
    4652        attribute CSSRuleConstructor CSSRule;
    4753        attribute CSSCharsetRuleConstructor CSSCharsetRule;
     
    5157        attribute CSSPageRuleConstructor CSSPageRule;
    5258        attribute CSSStyleRuleConstructor CSSStyleRule;
     59
    5360        attribute CSSStyleDeclarationConstructor CSSStyleDeclaration;
    54         attribute CSSValueConstructor CSSValue;
    5561        attribute MediaListConstructor MediaList;
    56         attribute StyleSheetConstructor StyleSheet;
    5762        attribute CounterConstructor Counter;
    5863        attribute CSSRuleListConstructor CSSRuleList;
    59         attribute CSSValueListConstructor CSSValueList;
    6064
    6165        // FIXME: Implement the commented-out global constructors for interfaces listed in DOM Level 3 Core specification.
Note: See TracChangeset for help on using the changeset viewer.