Commit 993adb85 authored by weinig's avatar weinig
Browse files

LayoutTests:

        Reviewed by Oliver.

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

        * fast/dom/Window/window-properties-expected.txt: new constructors added.

WebCore:

        Reviewed by Oliver.

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

        * DerivedSources.make:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/kjs_css.cpp:
        * bindings/js/kjs_css.h:
        * bindings/objc/DOMUtility.mm:
        (KJS::createDOMWrapper):
        * bindings/scripts/CodeGeneratorJS.pm:
        * css/MediaList.idl:
        * page/DOMWindow.idl: Add constructor.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5ff4182e
2007-05-29 Sam Weinig <sam@webkit.org>
Reviewed by Oliver.
Update results for http://bugs.webkit.org/show_bug.cgi?id=13912
Autogenerate the JS bindings for the MediaList
* fast/dom/Window/window-properties-expected.txt: new constructors added.
2007-05-29 Sam Weinig <sam@webkit.org>
 
Reviewed by Oliver.
......@@ -610,6 +610,11 @@ window.HTMLTitleElement.prototype [printed above as window.Element.prototype]
window.HTMLUListElement [object HTMLUListElementConstructor]
window.HTMLUListElement.prototype [printed above as window.Element.prototype]
window.Image [object Object]
window.MediaList [object MediaListConstructor]
window.MediaList.prototype [object MediaListPrototype]
window.MediaList.prototype.appendMedium [function]
window.MediaList.prototype.deleteMedium [function]
window.MediaList.prototype.item [function]
window.MutationEvent [object MutationEventConstructor]
window.MutationEvent.ADDITION [number]
window.MutationEvent.MODIFICATION [number]
......
2007-05-29 Sam Weinig <sam@webkit.org>
Reviewed by Oliver.
Patch for http://bugs.webkit.org/show_bug.cgi?id=13912
Autogenerate the JS bindings for the MediaList
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/kjs_css.cpp:
* bindings/js/kjs_css.h:
* bindings/objc/DOMUtility.mm:
(KJS::createDOMWrapper):
* bindings/scripts/CodeGeneratorJS.pm:
* css/MediaList.idl:
* page/DOMWindow.idl: Add constructor.
2007-05-29 Matt Perry <mpComplete@gmail.com>
 
Reviewed by Maciej.
......@@ -383,6 +383,7 @@ all : \
JSHTMLTitleElement.h \
JSHTMLUListElement.h \
JSKeyboardEvent.h \
JSMediaList.h \
JSMouseEvent.h \
JSMutationEvent.h \
JSNode.h \
......
......@@ -2764,6 +2764,8 @@
BC305C790C076BB300CD20F0 /* JSHTMLObjectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC305C770C076BB300CD20F0 /* JSHTMLObjectElement.cpp */; };
BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */; };
BC305CA40C0781BB00CD20F0 /* JSHTMLObjectElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC305CA30C0781BB00CD20F0 /* JSHTMLObjectElementCustom.cpp */; };
BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */; };
BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */; };
BC3FCAA90AC3DB5800BA54AD /* PlatformScrollBar.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */; settings = {ATTRIBUTES = (); }; };
BC4918C60BFEA050009D6316 /* JSHTMLFrameElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4918C00BFEA050009D6316 /* JSHTMLFrameElement.cpp */; };
BC4918C70BFEA050009D6316 /* JSHTMLFrameElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4918C10BFEA050009D6316 /* JSHTMLFrameElement.h */; };
......@@ -6022,6 +6024,8 @@
BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLObjectElement.h; sourceTree = "<group>"; };
BC305CA30C0781BB00CD20F0 /* JSHTMLObjectElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLObjectElementCustom.cpp; sourceTree = "<group>"; };
BC3B364705C9D5E200E42902 /* AtomicStringList.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AtomicStringList.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; };
BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; };
BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformScrollBar.h; sourceTree = "<group>"; };
BC4918C00BFEA050009D6316 /* JSHTMLFrameElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFrameElement.cpp; sourceTree = "<group>"; };
BC4918C10BFEA050009D6316 /* JSHTMLFrameElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLFrameElement.h; sourceTree = "<group>"; };
......@@ -6398,8 +6402,6 @@
14DFB33F0A7DF7630018F769 /* Derived Sources */ = {
isa = PBXGroup;
children = (
BCE013980C0BEF180043860A /* JSStyleSheet.cpp */,
BCE013990C0BEF180043860A /* JSStyleSheet.h */,
65DF31D809D1C122000BE325 /* JSAttr.cpp */,
65DF31D909D1C123000BE325 /* JSAttr.h */,
65DF323309D1DE65000BE325 /* JSCanvasGradient.cpp */,
......@@ -6568,6 +6570,8 @@
1A85B20F0A1B258700D8C87C /* JSHTMLUListElement.h */,
A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */,
A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */,
BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */,
BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
A86629CC09DA2B47009633A5 /* JSMouseEvent.cpp */,
A86629CB09DA2B47009633A5 /* JSMouseEvent.h */,
65DF31E709D1CC60000BE325 /* JSMutationEvent.cpp */,
......@@ -6588,6 +6592,8 @@
65DF31EE09D1CC60000BE325 /* JSRange.h */,
D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */,
D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */,
BCE013980C0BEF180043860A /* JSStyleSheet.cpp */,
BCE013990C0BEF180043860A /* JSStyleSheet.h */,
B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */,
B20111060AB7740500DB0E68 /* JSSVGAElement.h */,
B222F6960AB771950022EFAD /* JSSVGAngle.cpp */,
......@@ -11437,6 +11443,7 @@
BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */,
BC6D44ED0C07F2ED0072D2C9 /* JSHTMLEmbedElement.h in Headers */,
BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */,
BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -12839,6 +12846,7 @@
BC5825F30C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp in Sources */,
BCE0139A0C0BEF180043860A /* JSStyleSheet.cpp in Sources */,
BC98A27D0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp in Sources */,
BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -42,6 +42,7 @@
#include "JSCSSRuleList.h"
#include "JSCSSStyleDeclaration.h"
#include "JSCSSValueList.h"
#include "JSMediaList.h"
#include "JSStyleSheet.h"
#include "MediaList.h"
#include "StyleSheetList.h"
......@@ -176,108 +177,6 @@ JSValue* DOMStyleSheetListFunc::callAsFunction(ExecState* exec, JSObject* thisOb
// -------------------------------------------------------------------------
const ClassInfo DOMMediaList::info = { "MediaList", 0, &DOMMediaListTable, 0 };
/*
@begin DOMMediaListTable 2
mediaText DOMMediaList::MediaText DontDelete|ReadOnly
length DOMMediaList::Length DontDelete|ReadOnly
@end
@begin DOMMediaListPrototypeTable 3
item DOMMediaList::Item DontDelete|Function 1
deleteMedium DOMMediaList::DeleteMedium DontDelete|Function 1
appendMedium DOMMediaList::AppendMedium DontDelete|Function 1
@end
*/
KJS_DEFINE_PROTOTYPE(DOMMediaListPrototype)
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMMediaListPrototypeFunction)
KJS_IMPLEMENT_PROTOTYPE("DOMMediaList", DOMMediaListPrototype, DOMMediaListPrototypeFunction)
DOMMediaList::DOMMediaList(ExecState* exec, MediaList *ml)
: m_impl(ml)
{
setPrototype(DOMMediaListPrototype::self(exec));
}
DOMMediaList::~DOMMediaList()
{
ScriptInterpreter::forgetDOMObject(m_impl.get());
}
JSValue* DOMMediaList::getValueProperty(ExecState* exec, int token)
{
switch (token) {
case MediaText:
return jsStringOrNull(m_impl->mediaText());
case Length:
return jsNumber(m_impl->length());
default:
ASSERT(0);
return jsUndefined();
}
}
JSValue* DOMMediaList::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
DOMMediaList *thisObj = static_cast<DOMMediaList*>(slot.slotBase());
return jsStringOrNull(thisObj->m_impl->item(slot.index()));
}
bool DOMMediaList::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
const HashEntry* entry = Lookup::findEntry(&DOMMediaListTable, propertyName);
if (entry) {
slot.setStaticEntry(this, entry, staticValueGetter<DOMMediaList>);
return true;
}
bool ok;
unsigned u = propertyName.toUInt32(&ok);
if (ok && u < m_impl->length()) {
slot.setCustomIndex(this, u, indexGetter);
return true;
}
return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
}
void DOMMediaList::put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr)
{
DOMExceptionTranslator exception(exec);
MediaList &mediaList = *m_impl;
if (propertyName == "mediaText")
mediaList.setMediaText(valueToStringWithNullCheck(exec, value), exception);
else
DOMObject::put(exec, propertyName, value, attr);
}
JSValue* toJS(ExecState* exec, MediaList *ml)
{
return cacheDOMObject<MediaList, DOMMediaList>(exec, ml);
}
JSValue* KJS::DOMMediaListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
{
if (!thisObj->inherits(&KJS::DOMMediaList::info))
return throwError(exec, TypeError);
DOMExceptionTranslator exception(exec);
MediaList& mediaList = *static_cast<DOMMediaList *>(thisObj)->impl();
switch (id) {
case DOMMediaList::Item:
return jsStringOrNull(mediaList.item(args[0]->toInt32(exec)));
case DOMMediaList::DeleteMedium:
mediaList.deleteMedium(args[0]->toString(exec), exception);
return jsUndefined();
case DOMMediaList::AppendMedium:
mediaList.appendMedium(args[0]->toString(exec), exception);
return jsUndefined();
default:
return jsUndefined();
}
}
// -------------------------------------------------------------------------
const ClassInfo DOMCSSStyleSheet::info = { "CSSStyleSheet", &WebCore::JSStyleSheet::info, &DOMCSSStyleSheetTable, 0 };
/*
......
......@@ -69,26 +69,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 DOMMediaList : public DOMObject {
public:
DOMMediaList(ExecState*, WebCore::MediaList*);
virtual ~DOMMediaList();
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token);
virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attr = None);
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState*) const { return true; }
static const ClassInfo info;
enum { MediaText, Length,
Item, DeleteMedium, AppendMedium };
WebCore::MediaList* impl() const { return m_impl.get(); }
private:
static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
RefPtr<WebCore::MediaList> m_impl;
};
JSValue* toJS(ExecState*, WebCore::MediaList*);
class DOMCSSStyleSheet : public WebCore::JSStyleSheet {
public:
DOMCSSStyleSheet(ExecState*, WebCore::CSSStyleSheet*);
......
......@@ -34,6 +34,7 @@
#import "JSDOMImplementation.h"
#import "JSEvent.h"
#import "JSHTMLOptionsCollection.h"
#import "JSMediaList.h"
#import "JSNodeIterator.h"
#import "JSRange.h"
#import "JSStyleSheet.h"
......@@ -70,6 +71,7 @@ static inline id createDOMWrapper(KJS::JSObject* object)
WRAP(CSSStyleDeclaration)
WRAP(Counter)
WRAP(HTMLOptionsCollection)
WRAP(MediaList)
WRAP(Range)
WRAP(StyleSheet)
WRAP(XPathExpression)
......@@ -84,7 +86,6 @@ static inline id createDOMWrapper(KJS::JSObject* object)
WRAP(CSSRule)
WRAP(CSSValue)
WRAP(Event)
WRAP(MediaList)
WRAP(NamedNodeMap)
WRAP(Node)
WRAP(NodeList)
......
......@@ -166,6 +166,14 @@ sub UsesManualToJSImplementation
return 0;
}
sub IndexGetterReturnsStrings
{
my $type = shift;
return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList";
return 0;
}
sub CreateSVGContextInterfaceName
{
my $type = shift;
......@@ -1129,7 +1137,7 @@ sub GenerateImplementation
push(@implContent, "\nJSValue* ${className}::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)\n");
push(@implContent, "{\n");
push(@implContent, " ${className}* thisObj = static_cast<$className*>(slot.slotBase());\n");
if ($interfaceName eq "CSSStyleDeclaration") {
if (IndexGetterReturnsStrings($implClassName)) {
push(@implContent, " return jsStringOrNull(thisObj->impl()->item(slot.index()));\n");
} else {
push(@implContent, " return toJS(exec, static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
......@@ -1472,9 +1480,8 @@ sub NativeToJSValue
} elsif ($type eq "NamedNodeMap") {
$implIncludes{"kjs_dom.h"} = 1;
$implIncludes{"NamedNodeMap.h"} = 1;
} elsif ($type eq "CSSStyleSheet" or $type eq "StyleSheet" or $type eq "MediaList") {
} elsif ($type eq "CSSStyleSheet") {
$implIncludes{"CSSStyleSheet.h"} = 1;
$implIncludes{"MediaList.h"} = 1;
$implIncludes{"kjs_css.h"} = 1;
} elsif ($type eq "Rect") {
$implIncludes{"RectImpl.h"} = 1;
......
/*
* Copyright (C) 2006 Apple Computer, Inc.
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -26,17 +26,18 @@
module stylesheets {
// Introduced in DOM Level 2:
interface MediaList {
interface [GenerateConstructor, HasIndexGetter] MediaList {
attribute [ConvertNullToNullString] DOMString mediaText
attribute [ConvertNullToNullString, ConvertNullStringTo=Null] DOMString mediaText
setter raises(DOMException);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
[ConvertNullStringTo=Null] DOMString item(in unsigned long index);
void deleteMedium(in DOMString oldMedium)
raises(DOMException);
void appendMedium(in DOMString newMedium)
raises(DOMException);
};
}
......@@ -46,6 +46,7 @@ module window {
attribute CSSRuleConstructor CSSRule;
attribute CSSStyleDeclarationConstructor CSSStyleDeclaration;
attribute CSSValueConstructor CSSValue;
attribute MediaListConstructor MediaList;
attribute StyleSheetConstructor StyleSheet;
// FIXME: Implement the commented-out global constructors for interfaces listed in DOM Level 3 Core specification.
......
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