Commit aeca636b authored by weinig's avatar weinig
Browse files

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21911 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0f3c9910
2007-05-30 Sam Weinig <sam@webkit.org>
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:
2007-05-30 Sam Weinig <sam@webkit.org>
 
Reviewed by Oliver the Hun.
......@@ -212,6 +212,8 @@ window.CSSStyleDeclaration.prototype.removeProperty [function]
window.CSSStyleDeclaration.prototype.setProperty [function]
window.CSSStyleRule [object CSSStyleRuleConstructor]
window.CSSStyleRule.prototype [printed above as window.CSSRule.prototype]
window.CSSStyleSheet [object StyleSheetConstructor]
window.CSSStyleSheet.prototype [object StyleSheetPrototype]
window.CSSValue [object CSSValueConstructor]
window.CSSValue.CSS_CUSTOM [number]
window.CSSValue.CSS_INHERIT [number]
......@@ -804,8 +806,7 @@ window.RangeException.prototype [object RangeExceptionPrototype]
window.RangeException.prototype.BAD_BOUNDARYPOINTS_ERR [number]
window.RangeException.prototype.INVALID_NODE_TYPE_ERR [number]
window.ReferenceError [function]
window.StyleSheet [object StyleSheetConstructor]
window.StyleSheet.prototype [object StyleSheetPrototype]
window.StyleSheet [printed above as window.CSSStyleSheet]
window.SyntaxError [function]
window.Text [object TextConstructor]
window.Text.prototype [printed above as window.CharacterData.prototype]
......
2007-05-30 Sam Weinig <sam@webkit.org>
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:
2007-05-30 Sam Weinig <sam@webkit.org>
 
Reviewed by Oliver.
......@@ -309,6 +309,7 @@ all : \
JSCSSRule.h \
JSCSSRuleList.h \
JSCSSStyleRule.h \
JSCSSStyleSheet.h \
JSCSSValue.h \
JSCSSValueList.h \
JSCanvasGradient.h \
......
......@@ -171,6 +171,7 @@ IDL_BINDINGS += \
css/CSSRuleList.idl \
css/CSSStyleDeclaration.idl \
css/CSSStyleRule.idl \
css/CSSStyleSheet.idl \
css/CSSValue.idl \
css/CSSValueList.idl \
css/MediaList.idl \
......
......@@ -2853,6 +2853,8 @@
BCC47E2609A3D6F100ADB771 /* FontFamily.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC47E2409A3D6F100ADB771 /* FontFamily.cpp */; };
BCC47E2709A3D6F100ADB771 /* FontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC47E2509A3D6F100ADB771 /* FontFamily.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCC47E6B09A3FE4700ADB771 /* FontDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC47E6A09A3FE4700ADB771 /* FontDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */; };
BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */; };
BCC71A130A0FF94D0014EE6E /* GlyphBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */; };
BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */; };
BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */; };
......@@ -6127,6 +6129,8 @@
BCC47E2409A3D6F100ADB771 /* FontFamily.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamily.cpp; sourceTree = "<group>"; };
BCC47E2509A3D6F100ADB771 /* FontFamily.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontFamily.h; sourceTree = "<group>"; };
BCC47E6A09A3FE4700ADB771 /* FontDescription.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontDescription.h; sourceTree = "<group>"; };
BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleSheet.cpp; sourceTree = "<group>"; };
BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleSheet.h; sourceTree = "<group>"; };
BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphBuffer.h; sourceTree = "<group>"; };
BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ColorData.gperf; sourceTree = "<group>"; };
BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLViewSourceDocument.h; sourceTree = "<group>"; };
......@@ -6466,6 +6470,8 @@
142011B50A003133008303F9 /* JSCSSStyleDeclaration.h */,
BC46C2040C0DDCA10020CFC3 /* JSCSSStyleRule.cpp */,
BC46C2050C0DDCA10020CFC3 /* JSCSSStyleRule.h */,
BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */,
BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */,
14CF78A309F58CBF00EB3665 /* JSCSSValue.cpp */,
14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
......@@ -11492,6 +11498,7 @@
BC46C2010C0DDC8F0020CFC3 /* JSCSSMediaRule.h in Headers */,
BC46C2030C0DDC8F0020CFC3 /* JSCSSPageRule.h in Headers */,
BC46C2070C0DDCA10020CFC3 /* JSCSSStyleRule.h in Headers */,
BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -12903,6 +12910,7 @@
BC46C2020C0DDC8F0020CFC3 /* JSCSSPageRule.cpp in Sources */,
BC46C2060C0DDCA10020CFC3 /* JSCSSStyleRule.cpp in Sources */,
BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -27,7 +27,8 @@
#include "JSStyleSheet.h"
#include "CSSStyleSheet.h"
#include "kjs_css.h"
#include "JSCSSStyleSheet.h"
#include "StyleSheet.h"
namespace WebCore {
......@@ -42,7 +43,7 @@ KJS::JSValue* toJS(KJS::ExecState* exec, StyleSheet* styleSheet)
return ret;
if (styleSheet->isCSSStyleSheet())
ret = new KJS::DOMCSSStyleSheet(exec, static_cast<CSSStyleSheet*>(styleSheet));
ret = new JSCSSStyleSheet(exec, static_cast<CSSStyleSheet*>(styleSheet));
else
ret = new JSStyleSheet(exec, styleSheet);
......
......@@ -157,86 +157,6 @@ JSValue* DOMStyleSheetListFunc::callAsFunction(ExecState* exec, JSObject* thisOb
// -------------------------------------------------------------------------
const ClassInfo DOMCSSStyleSheet::info = { "CSSStyleSheet", &WebCore::JSStyleSheet::info, &DOMCSSStyleSheetTable, 0 };
/*
@begin DOMCSSStyleSheetTable 5
ownerRule DOMCSSStyleSheet::OwnerRule DontDelete|ReadOnly
cssRules DOMCSSStyleSheet::CssRules DontDelete|ReadOnly
# MSIE extension
rules DOMCSSStyleSheet::Rules DontDelete|ReadOnly
@end
@begin DOMCSSStyleSheetPrototypeTable 6
insertRule DOMCSSStyleSheet::InsertRule DontDelete|Function 2
deleteRule DOMCSSStyleSheet::DeleteRule DontDelete|Function 1
# MSIE extensions
addRule DOMCSSStyleSheet::AddRule DontDelete|Function 2
removeRule DOMCSSStyleSheet::RemoveRule DontDelete|Function 1
@end
*/
KJS_DEFINE_PROTOTYPE(DOMCSSStyleSheetPrototype)
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMCSSStyleSheetPrototypeFunction)
KJS_IMPLEMENT_PROTOTYPE("DOMCSSStyleSheet",DOMCSSStyleSheetPrototype,DOMCSSStyleSheetPrototypeFunction) // warning, use _WITH_PARENT if DOMStyleSheet gets a prototype
DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState* exec, CSSStyleSheet *ss)
: JSStyleSheet(exec, ss)
{
setPrototype(DOMCSSStyleSheetPrototype::self(exec));
}
DOMCSSStyleSheet::~DOMCSSStyleSheet()
{
}
JSValue* DOMCSSStyleSheet::getValueProperty(ExecState* exec, int token) const
{
switch (token) {
case OwnerRule:
return toJS(exec, static_cast<CSSStyleSheet*>(impl())->ownerRule());
case CssRules:
return toJS(exec, static_cast<CSSStyleSheet*>(impl())->cssRules());
case Rules:
return toJS(exec, static_cast<CSSStyleSheet*>(impl())->cssRules(true));
default:
ASSERT(0);
return jsUndefined();
}
}
bool DOMCSSStyleSheet::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticValueSlot<DOMCSSStyleSheet, JSStyleSheet>(exec, &DOMCSSStyleSheetTable, this, propertyName, slot);
}
JSValue* DOMCSSStyleSheetPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
{
if (!thisObj->inherits(&KJS::DOMCSSStyleSheet::info))
return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
CSSStyleSheet &styleSheet = *static_cast<CSSStyleSheet*>(static_cast<DOMCSSStyleSheet*>(thisObj)->impl());
switch (id) {
case DOMCSSStyleSheet::InsertRule:
return jsNumber(styleSheet.insertRule(args[0]->toString(exec), args[1]->toInt32(exec), exception));
case DOMCSSStyleSheet::DeleteRule:
styleSheet.deleteRule(args[0]->toInt32(exec), exception);
return jsUndefined();
case DOMCSSStyleSheet::AddRule: {
int index = args.size() >= 3 ? args[2]->toInt32(exec) : -1;
styleSheet.addRule(args[0]->toString(exec), args[1]->toString(exec), index, exception);
// As per Microsoft documentation, always return -1.
return jsNumber(-1);
}
case DOMCSSStyleSheet::RemoveRule: {
int index = args.size() >= 1 ? args[0]->toInt32(exec) : 0;
styleSheet.removeRule(index, exception);
return jsUndefined();
}
}
return jsUndefined();
}
// -------------------------------------------------------------------------
const ClassInfo DOMRGBColor::info = { "RGBColor", 0, &DOMRGBColorTable, 0 };
/*
......
......@@ -60,18 +60,6 @@ namespace KJS {
// The document is only used for get-stylesheet-by-name (make optional if necessary)
JSValue* toJS(ExecState*, WebCore::StyleSheetList*, WebCore::Document*);
class DOMCSSStyleSheet : public WebCore::JSStyleSheet {
public:
DOMCSSStyleSheet(ExecState*, WebCore::CSSStyleSheet*);
virtual ~DOMCSSStyleSheet();
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { OwnerRule, CssRules, Rules, InsertRule, DeleteRule, AddRule, RemoveRule };
};
class DOMRGBColor : public DOMObject {
public:
DOMRGBColor(ExecState*, unsigned color);
......
......@@ -1490,9 +1490,6 @@ sub NativeToJSValue
} elsif ($type eq "NamedNodeMap") {
$implIncludes{"kjs_dom.h"} = 1;
$implIncludes{"NamedNodeMap.h"} = 1;
} elsif ($type eq "CSSStyleSheet") {
$implIncludes{"CSSStyleSheet.h"} = 1;
$implIncludes{"kjs_css.h"} = 1;
} elsif ($type eq "Rect") {
$implIncludes{"RectImpl.h"} = 1;
$implIncludes{"kjs_css.h"} = 1;
......
/**
* This file is part of the DOM implementation for KDE.
*
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2006 Apple Computer, Inc.
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -19,16 +17,17 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "CSSStyleSheet.h"
#include "CSSImportRule.h"
#include "CSSNamespace.h"
#include "cssparser.h"
#include "CSSRuleList.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "Node.h"
#include "cssparser.h"
namespace WebCore {
......@@ -94,14 +93,21 @@ unsigned CSSStyleSheet::insertRule(const String& rule, unsigned index, Exception
return index;
}
unsigned CSSStyleSheet::addRule(const String &selector, const String &style, int index, ExceptionCode& ec)
int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
{
if (index == -1)
index = length();
return insertRule(selector + " { " + style + " }", index, ec);
insertRule(selector + " { " + style + " }", index, ec);
// As per Microsoft documentation, always return -1.
return -1;
}
CSSRuleList *CSSStyleSheet::cssRules(bool omitCharsetRules)
int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
{
return addRule(selector, style, length(), ec);
}
CSSRuleList* CSSStyleSheet::cssRules(bool omitCharsetRules)
{
return new CSSRuleList(this, omitCharsetRules);
}
......
/*
* This file is part of the DOM implementation for KDE.
*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2006 Apple Computer, Inc.
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -36,8 +34,7 @@ class Document;
typedef int ExceptionCode;
class CSSStyleSheet : public StyleSheet
{
class CSSStyleSheet : public StyleSheet {
public:
CSSStyleSheet(Node* parentNode, const String& href = String(), const String& charset = String());
CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href = String(), const String& charset = String());
......@@ -53,9 +50,14 @@ public:
CSSRuleList* cssRules(bool omitCharsetRules = false);
unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
void deleteRule(unsigned index, ExceptionCode&);
unsigned addRule(const String& selector, const String& style, int index, ExceptionCode&);
// IE Extensions
CSSRuleList* rules() { return cssRules(true); }
int addRule(const String& selector, const String& style, int index, ExceptionCode&);
int addRule(const String& selector, const String& style, ExceptionCode&);
void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
void removeRule(ExceptionCode& ec) { deleteRule(0, ec); }
void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
const AtomicString& determineNamespace(const AtomicString& prefix);
......
/*
* Copyright (C) 2006 Apple Computer, Inc.
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
......@@ -30,6 +30,16 @@ module css {
raises(DOMException);
void deleteRule(in unsigned long index)
raises(DOMException);
// IE Extensions
readonly attribute CSSRuleList rules;
long addRule(in DOMString selector,
in DOMString style,
in [Optional] unsigned long index)
raises(DOMException);
void removeRule(in [Optional] unsigned long index)
raises(DOMException);
};
}
......@@ -42,7 +42,13 @@ module window {
readonly attribute double devicePixelRatio;
// Global constructors
attribute StyleSheetConstructor StyleSheet;
attribute CSSStyleSheetConstructor CSSStyleSheet;
attribute CSSValueConstructor CSSValue;
attribute CSSPrimitiveValueConstructor CSSPrimitiveValue;
attribute CSSValueListConstructor CSSValueList;
attribute CSSRuleConstructor CSSRule;
attribute CSSCharsetRuleConstructor CSSCharsetRule;
attribute CSSFontFaceRuleConstructor CSSFontFaceRule;
......@@ -50,13 +56,11 @@ module window {
attribute CSSMediaRuleConstructor CSSMediaRule;
attribute CSSPageRuleConstructor CSSPageRule;
attribute CSSStyleRuleConstructor CSSStyleRule;
attribute CSSStyleDeclarationConstructor CSSStyleDeclaration;
attribute CSSValueConstructor CSSValue;
attribute MediaListConstructor MediaList;
attribute StyleSheetConstructor StyleSheet;
attribute CounterConstructor Counter;
attribute CSSRuleListConstructor CSSRuleList;
attribute CSSValueListConstructor CSSValueList;
// FIXME: Implement the commented-out global constructors for interfaces listed in DOM Level 3 Core specification.
// attribute DOMExceptionConstructor DOMException;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment