WebCore:
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2008 01:41:16 +0000 (01:41 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2008 01:41:16 +0000 (01:41 +0000)
        Reviewed by Darin.

        HTMLAudioElement needs generated constructor. Otherwise video instanceof HTMLAudioElement is true which is
        bit strange.

        Renamed custom constructor JSHTMLAudioElementConstructor to JSAudioConstructor to avoid name clashes.

        Test: media/constructors.html

        * ChangeLog:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSAudioConstructor.cpp: Copied from WebCore/bindings/js/JSHTMLAudioElementConstructor.cpp.
        (WebCore::JSAudioConstructor::JSAudioConstructor):
        (WebCore::JSAudioConstructor::implementsConstruct):
        (WebCore::JSAudioConstructor::construct):
        * bindings/js/JSAudioConstructor.h: Copied from WebCore/bindings/js/JSHTMLAudioElementConstructor.h.
        * bindings/js/JSHTMLAudioElementConstructor.cpp: Removed.
        * bindings/js/JSHTMLAudioElementConstructor.h: Removed.
        * bindings/js/kjs_window.cpp:
        (KJS::Window::getValueProperty):
        * html/HTMLAudioElement.idl:

LayoutTests:

        Reviewed by Darin.

        Test that media element constructors behave consistently.

        * media/constructors-expected.txt: Added.
        * media/constructors.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29328 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/constructors-expected.txt [new file with mode: 0644]
LayoutTests/media/constructors.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSAudioConstructor.cpp [moved from WebCore/bindings/js/JSHTMLAudioElementConstructor.cpp with 88% similarity]
WebCore/bindings/js/JSAudioConstructor.h [moved from WebCore/bindings/js/JSHTMLAudioElementConstructor.h with 88% similarity]
WebCore/bindings/js/kjs_window.cpp
WebCore/html/HTMLAudioElement.idl

index b3ca87e..9b4e32a 100644 (file)
@@ -1,3 +1,12 @@
+2008-01-08  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        Test that media element constructors behave consistently.
+
+        * media/constructors-expected.txt: Added.
+        * media/constructors.html: Added.
+
 2008-01-08  Adam Roben  <aroben@apple.com>
 
         * fast/replaced/image-map.html: Disabled this until bug 16782 is
diff --git a/LayoutTests/media/constructors-expected.txt b/LayoutTests/media/constructors-expected.txt
new file mode 100644 (file)
index 0000000..a0c3011
--- /dev/null
@@ -0,0 +1,13 @@
+Test that media constructors behave consistently.
+
+TEST(audioJS instanceof HTMLAudioElement) OK
+TEST(audioJS instanceof HTMLMediaElement) OK
+TEST(!(audioJS instanceof HTMLVideoElement)) OK
+TEST(audioElem instanceof HTMLAudioElement) OK
+TEST(audioElem instanceof HTMLMediaElement) OK
+TEST(!(audioElem instanceof HTMLVideoElement)) OK
+TEST(videoElem instanceof HTMLVideoElement) OK
+TEST(videoElem instanceof HTMLMediaElement) OK
+TEST(!(videoElem instanceof HTMLAudioElement)) OK
+END OF TEST
+
diff --git a/LayoutTests/media/constructors.html b/LayoutTests/media/constructors.html
new file mode 100644 (file)
index 0000000..4508107
--- /dev/null
@@ -0,0 +1,20 @@
+<body>
+<p>Test that media constructors behave consistently.</p>
+<video></video>
+<audio></audio>
+<script src=video-test.js></script>
+<script>
+var audioJS = new Audio();
+var videoElem = document.getElementsByTagName('video')[0];
+var audioElem = document.getElementsByTagName('audio')[0];
+test("audioJS instanceof HTMLAudioElement");
+test("audioJS instanceof HTMLMediaElement");
+test("!(audioJS instanceof HTMLVideoElement)");
+test("audioElem instanceof HTMLAudioElement");
+test("audioElem instanceof HTMLMediaElement");
+test("!(audioElem instanceof HTMLVideoElement)");
+test("videoElem instanceof HTMLVideoElement");
+test("videoElem instanceof HTMLMediaElement");
+test("!(videoElem instanceof HTMLAudioElement)");
+endTest();
+</script>
index e984fc0..9bcab14 100644 (file)
@@ -1,3 +1,27 @@
+2008-01-08  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        HTMLAudioElement needs generated constructor. Otherwise video instanceof HTMLAudioElement is true which is 
+        bit strange.
+        
+        Renamed custom constructor JSHTMLAudioElementConstructor to JSAudioConstructor to avoid name clashes.
+
+        Test: media/constructors.html
+
+        * ChangeLog:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSAudioConstructor.cpp: Copied from WebCore/bindings/js/JSHTMLAudioElementConstructor.cpp.
+        (WebCore::JSAudioConstructor::JSAudioConstructor):
+        (WebCore::JSAudioConstructor::implementsConstruct):
+        (WebCore::JSAudioConstructor::construct):
+        * bindings/js/JSAudioConstructor.h: Copied from WebCore/bindings/js/JSHTMLAudioElementConstructor.h.
+        * bindings/js/JSHTMLAudioElementConstructor.cpp: Removed.
+        * bindings/js/JSHTMLAudioElementConstructor.h: Removed.
+        * bindings/js/kjs_window.cpp:
+        (KJS::Window::getValueProperty):
+        * html/HTMLAudioElement.idl:
+
 2008-01-08  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Mitz.
index e4ed021..5da896a 100644 (file)
                E446143A0CD689C800FADA75 /* JSHTMLMediaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B423800CBFB73C00AF2ECE /* JSHTMLMediaElement.h */; };
                E446143B0CD689CC00FADA75 /* JSHTMLSourceElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B423710CBFB6E000AF2ECE /* JSHTMLSourceElement.cpp */; };
                E446143C0CD689CC00FADA75 /* JSHTMLSourceElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B423720CBFB6E000AF2ECE /* JSHTMLSourceElement.h */; };
-               E446143D0CD68A2300FADA75 /* JSHTMLAudioElementConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B41E070CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.cpp */; };
-               E446143E0CD68A2300FADA75 /* JSHTMLAudioElementConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E080CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.h */; };
                E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B41E330CBFB60900AF2ECE /* RenderVideo.cpp */; };
                E44614520CD68A3500FADA75 /* RenderVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E340CBFB60900AF2ECE /* RenderVideo.h */; };
                E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C279560CF9741900E97B98 /* RenderMedia.cpp */; };
                E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; };
+               E4EEFFC80D34550C00469A58 /* JSAudioConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4EEFFC60D34550C00469A58 /* JSAudioConstructor.cpp */; };
+               E4EEFFC90D34550C00469A58 /* JSAudioConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = E4EEFFC70D34550C00469A58 /* JSAudioConstructor.h */; };
                ED048ABC0833F132006E1E67 /* textAreaResizeCorner.tiff in Resources */ = {isa = PBXBuildFile; fileRef = ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */; };
                ED2BA83C09A24B91006C0AC4 /* DocumentMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; };
                E4B41E010CBF8EAA00AF2ECE /* ProgressEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressEvent.cpp; sourceTree = "<group>"; };
                E4B41E020CBF8EAA00AF2ECE /* ProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressEvent.h; sourceTree = "<group>"; };
                E4B41E030CBF8EAA00AF2ECE /* ProgressEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ProgressEvent.idl; sourceTree = "<group>"; };
-               E4B41E070CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAudioElementConstructor.cpp; sourceTree = "<group>"; };
-               E4B41E080CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAudioElementConstructor.h; sourceTree = "<group>"; };
                E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaPlayer.cpp; sourceTree = "<group>"; };
                E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayer.h; sourceTree = "<group>"; };
                E4B41E100CBF90EF00AF2ECE /* MediaPlayerPrivateQTKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivateQTKit.h; sourceTree = "<group>"; };
                E4B423860CBFB73C00AF2ECE /* JSProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSProgressEvent.h; sourceTree = "<group>"; };
                E4C279560CF9741900E97B98 /* RenderMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMedia.cpp; sourceTree = "<group>"; };
                E4C279570CF9741900E97B98 /* RenderMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMedia.h; sourceTree = "<group>"; };
+               E4EEFFC60D34550C00469A58 /* JSAudioConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioConstructor.cpp; sourceTree = "<group>"; };
+               E4EEFFC70D34550C00469A58 /* JSAudioConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAudioConstructor.h; sourceTree = "<group>"; };
                ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = textAreaResizeCorner.tiff; sourceTree = "<group>"; };
                ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarker.h; sourceTree = "<group>"; };
                ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = "<group>"; };
                BC4EDEF70C08F414007EDD49 /* Custom */ = {
                        isa = PBXGroup;
                        children = (
+                               E4EEFFC60D34550C00469A58 /* JSAudioConstructor.cpp */,
+                               E4EEFFC70D34550C00469A58 /* JSAudioConstructor.h */,
                                BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
                                1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */,
                                BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
                                BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */,
                                BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
                                BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
-                               E4B41E070CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.cpp */,
-                               E4B41E080CBF8F2100AF2ECE /* JSHTMLAudioElementConstructor.h */,
                                BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
                                BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
                                BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */,
                                1A4A2DF20A1B852A00C807F8 /* JSHTMLAppletElement.h in Headers */,
                                1AE2AA1F0A1CDAB400B42B25 /* JSHTMLAreaElement.h in Headers */,
                                E44614380CD689C500FADA75 /* JSHTMLAudioElement.h in Headers */,
-                               E446143E0CD68A2300FADA75 /* JSHTMLAudioElementConstructor.h in Headers */,
                                1AE2AA250A1CDAB400B42B25 /* JSHTMLBRElement.h in Headers */,
                                A80E7B110A19D606007FB8C5 /* JSHTMLBaseElement.h in Headers */,
                                1AE2AA210A1CDAB400B42B25 /* JSHTMLBaseFontElement.h in Headers */,
                                371F51A10D262FA000ECE0D5 /* CSSSegmentedFontFace.h in Headers */,
                                371F53E90D2704F900ECE0D5 /* CSSUnicodeRangeValue.h in Headers */,
                                ABFE7E130D32FAF60066F4D2 /* MediaControlElements.h in Headers */,
+                               E4EEFFC90D34550C00469A58 /* JSAudioConstructor.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC4EDEF40C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp in Sources */,
                                1AE2AA1E0A1CDAB400B42B25 /* JSHTMLAreaElement.cpp in Sources */,
                                E44614370CD689C400FADA75 /* JSHTMLAudioElement.cpp in Sources */,
-                               E446143D0CD68A2300FADA75 /* JSHTMLAudioElementConstructor.cpp in Sources */,
                                1AE2AA240A1CDAB400B42B25 /* JSHTMLBRElement.cpp in Sources */,
                                A80E7B120A19D606007FB8C5 /* JSHTMLBaseElement.cpp in Sources */,
                                1AE2AA200A1CDAB400B42B25 /* JSHTMLBaseFontElement.cpp in Sources */,
                                371F51A20D262FA000ECE0D5 /* CSSSegmentedFontFace.cpp in Sources */,
                                371F53EA0D2704F900ECE0D5 /* CSSUnicodeRangeValue.cpp in Sources */,
                                ABFE7E120D32FAF60066F4D2 /* MediaControlElements.cpp in Sources */,
+                               E4EEFFC80D34550C00469A58 /* JSAudioConstructor.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -26,7 +26,7 @@
 #include "config.h"
 
 #if ENABLE(VIDEO)
-#include "JSHTMLAudioElementConstructor.h"
+#include "JSAudioConstructor.h"
 
 #include "Document.h"
 #include "HTMLAudioElement.h"
@@ -37,19 +37,19 @@ using namespace KJS;
 
 namespace WebCore {
 
-JSHTMLAudioElementConstructor::JSHTMLAudioElementConstructor(ExecState* exec, Document* d)
+JSAudioConstructor::JSAudioConstructor(ExecState* exec, Document* d)
     : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
     , m_doc(d)
 {
     put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
-bool JSHTMLAudioElementConstructor::implementsConstruct() const
+bool JSAudioConstructor::implementsConstruct() const
 {
     return true;
 }
 
-JSObject* JSHTMLAudioElementConstructor::construct(ExecState* exec, const List& args)
+JSObject* JSAudioConstructor::construct(ExecState* exec, const List& args)
 {
     int exception = 0;
     RefPtr<Element> el(m_doc->createElement("audio", exception));
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef JSHTMLAudioElementConstructor_h
-#define JSHTMLAudioElementConstructor_h
+#ifndef JSAudioConstructor_h
+#define JSAudioConstructor_h
 
 #if ENABLE(VIDEO)
 
@@ -33,9 +33,9 @@
 
 namespace WebCore {
 
-    class JSHTMLAudioElementConstructor : public KJS::DOMObject {
+    class JSAudioConstructor : public KJS::DOMObject {
     public:
-        JSHTMLAudioElementConstructor(KJS::ExecState*, Document*);
+        JSAudioConstructor(KJS::ExecState*, Document*);
         virtual bool implementsConstruct() const;
         virtual KJS::JSObject *construct(KJS::ExecState*, const KJS::List& args);
     private:
index d1f7436..7dc988e 100644 (file)
@@ -41,7 +41,7 @@
 #include "HTMLDocument.h"
 #include "JSDOMWindow.h"
 #include "JSEvent.h"
-#include "JSHTMLAudioElementConstructor.h"
+#include "JSAudioConstructor.h"
 #include "JSHTMLCollection.h"
 #include "JSHTMLOptionElementConstructor.h"
 #include "JSXMLHttpRequest.h"
@@ -499,7 +499,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
         return jsUndefined();
       if (!MediaPlayer::isAvailable())
         return jsUndefined();
-      return new JSHTMLAudioElementConstructor(exec, impl()->frame()->document());
+      return new JSAudioConstructor(exec, impl()->frame()->document());
 #else
       return jsUndefined();
 #endif
index 107b8b1..f335d86 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 module html {
-    interface [Conditional=VIDEO] HTMLAudioElement : HTMLMediaElement {
+    interface [GenerateConstructor, Conditional=VIDEO] HTMLAudioElement : HTMLMediaElement {
     
     };
 }