Reviewed by Darin Adler.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Mar 2008 17:46:01 +0000 (17:46 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Mar 2008 17:46:01 +0000 (17:46 +0000)
        Remame ImageConstructorImp to JSImageConstructor and move it into its
        own file.

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * bindings/js/JSImageConstructor.cpp: Copied from bindings/js/kjs_html.cpp.
        (WebCore::JSImageConstructor::JSImageConstructor):
        (WebCore::JSImageConstructor::construct):
        * bindings/js/JSImageConstructor.h: Copied from bindings/js/kjs_html.h.
        * bindings/js/kjs_html.cpp:
        (WebCore::getRuntimeObject): Make this function static since it is only used
        in this file.
        * bindings/js/kjs_html.h:
        * bindings/js/kjs_window.cpp:
        (WebCore::JSDOMWindowBase::getValueProperty):

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

WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/bindings/js/JSImageConstructor.cpp [new file with mode: 0644]
WebCore/bindings/js/JSImageConstructor.h [new file with mode: 0644]
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_html.h
WebCore/bindings/js/kjs_window.cpp

index de83bfb..cd84163 100644 (file)
@@ -1,3 +1,26 @@
+2008-03-04  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Remame ImageConstructorImp to JSImageConstructor and move it into its
+        own file.
+
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * bindings/js/JSImageConstructor.cpp: Copied from bindings/js/kjs_html.cpp.
+        (WebCore::JSImageConstructor::JSImageConstructor):
+        (WebCore::JSImageConstructor::construct):
+        * bindings/js/JSImageConstructor.h: Copied from bindings/js/kjs_html.h.
+        * bindings/js/kjs_html.cpp:
+        (WebCore::getRuntimeObject): Make this function static since it is only used
+        in this file.
+        * bindings/js/kjs_html.h:
+        * bindings/js/kjs_window.cpp:
+        (WebCore::JSDOMWindowBase::getValueProperty):
+
 2008-03-04  Adam Roben  <aroben@apple.com>
 
         Fix an uninitialized value warning in CodeGeneratorJS.pm
index 45f0069..102b606 100644 (file)
@@ -467,6 +467,7 @@ webcore_sources += \
        WebCore/bindings/js/JSEventCustom.cpp \
        WebCore/bindings/js/JSEventTargetBase.cpp \
        WebCore/bindings/js/JSHistoryCustom.cpp \
+       WebCore/bindings/js/JSImageConstructor.cpp \
        WebCore/bindings/js/JSLocation.cpp \
        WebCore/bindings/js/JSEventTargetNode.cpp \
        WebCore/bindings/js/JSHTMLAppletElementCustom.cpp \
index c47b291..ad96a9b 100644 (file)
@@ -419,6 +419,7 @@ SOURCES += \
     bindings/js/JSHTMLOptionElementConstructor.cpp \
     bindings/js/JSHTMLOptionsCollectionCustom.cpp \
     bindings/js/JSHTMLSelectElementCustom.cpp \
+    bindings/js/JSImageConstructor.cpp \
     bindings/js/JSLocation.cpp \
     bindings/js/JSNamedNodeMapCustom.cpp \
     bindings/js/JSNamedNodesCollection.cpp  \
index d24914b..ea92c6e 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\bindings\js\JSImageConstructor.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\bindings\js\JSImageConstructor.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\bindings\js\JSLocation.cpp"\r
                                        >\r
                                </File>\r
index 17b7166..fa457be 100644 (file)
                BC64B4DA0CB4298A005F2B62 /* CSSFontFaceSrcValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4D20CB4298A005F2B62 /* CSSFontFaceSrcValue.h */; };
                BC64B4DB0CB4298A005F2B62 /* CSSFontSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */; };
                BC64B4DC0CB4298A005F2B62 /* CSSFontSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */; };
+               BC6C49F30D7DBA0500FFA558 /* JSImageConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6C49F10D7DBA0500FFA558 /* JSImageConstructor.cpp */; };
+               BC6C49F40D7DBA0500FFA558 /* JSImageConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6C49F20D7DBA0500FFA558 /* JSImageConstructor.h */; };
                BC6D44BE0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */; };
                BC6D44EC0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6D44EA0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp */; };
                BC6D44ED0C07F2ED0072D2C9 /* JSHTMLEmbedElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6D44EB0C07F2ED0072D2C9 /* JSHTMLEmbedElement.h */; };
                BC64B4D20CB4298A005F2B62 /* CSSFontFaceSrcValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSrcValue.h; sourceTree = "<group>"; };
                BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontSelector.cpp; sourceTree = "<group>"; };
                BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontSelector.h; sourceTree = "<group>"; };
+               BC6C49F10D7DBA0500FFA558 /* JSImageConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageConstructor.cpp; sourceTree = "<group>"; };
+               BC6C49F20D7DBA0500FFA558 /* JSImageConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSImageConstructor.h; sourceTree = "<group>"; };
                BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLEmbedElementCustom.cpp; sourceTree = "<group>"; };
                BC6D44EA0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLEmbedElement.cpp; sourceTree = "<group>"; };
                BC6D44EB0C07F2ED0072D2C9 /* JSHTMLEmbedElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLEmbedElement.h; sourceTree = "<group>"; };
                                A80E7E630A1A82EC007FB8C5 /* JSHTMLInputElementBase.h */,
                                A826E8AD0A1A8F2300CD1BB6 /* JSHTMLOptionElementConstructor.cpp */,
                                A826E8AC0A1A8F2300CD1BB6 /* JSHTMLOptionElementConstructor.h */,
+                               BC6C49F10D7DBA0500FFA558 /* JSImageConstructor.cpp */,
+                               BC6C49F20D7DBA0500FFA558 /* JSImageConstructor.h */,
                                BCA379120D163E5500B793D6 /* JSLocation.cpp */,
                                BCA379130D163E5500B793D6 /* JSLocation.h */,
                                BCD9C26C0C17AA81005C90A2 /* JSNamedNodesCollection.cpp */,
                                1AF326780D78B9440068F0C4 /* AXObjectCache.h in Headers */,
                                1AF3267B0D78B94E0068F0C4 /* GlobalHistory.h in Headers */,
                                BCA83E500D7CE1E9003421A8 /* JSClipboard.h in Headers */,
+                               BC6C49F40D7DBA0500FFA558 /* JSImageConstructor.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1AF3264B0D78B5530068F0C4 /* WebCoreScriptDebugger.mm in Sources */,
                                BCA83E4F0D7CE1E9003421A8 /* JSClipboard.cpp in Sources */,
                                BCA83E520D7CE205003421A8 /* JSClipboardCustom.cpp in Sources */,
+                               BC6C49F30D7DBA0500FFA558 /* JSImageConstructor.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 8a3d8ba..7336ac6 100644 (file)
@@ -72,6 +72,7 @@ This file contains the list of files needed to build WebCore.
         bindings/js/JSHTMLOptionElementConstructor.cpp
         bindings/js/JSHTMLOptionsCollectionCustom.cpp
         bindings/js/JSHTMLSelectElementCustom.cpp
+        bindings/js/JSImageConstructor.cpp
         bindings/js/JSLocation.cpp
         bindings/js/JSNamedNodeMapCustom.cpp
         bindings/js/JSNamedNodesCollection.cpp
diff --git a/WebCore/bindings/js/JSImageConstructor.cpp b/WebCore/bindings/js/JSImageConstructor.cpp
new file mode 100644 (file)
index 0000000..9062476
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "JSImageConstructor.h"
+
+#include "Document.h"
+#include "HTMLImageElement.h"
+#include "JSNode.h"
+
+using namespace KJS;
+
+namespace WebCore {
+
+JSImageConstructor::JSImageConstructor(ExecState* exec, Document* document)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+    , m_document(document)
+{
+}
+
+JSObject* JSImageConstructor::construct(ExecState* exec, const List& args)
+{
+    bool widthSet = false;
+    bool heightSet = false;
+    int width = 0;
+    int height = 0;
+
+    if (args.size() > 0) {
+        widthSet = true;
+        width = args[0]->toInt32(exec);
+    }
+
+    if (args.size() > 1) {
+        heightSet = true;
+        height = args[1]->toInt32(exec);
+    }
+
+    // Calling toJS on the document causes the JS document wrapper to be
+    // added to the window object. This is done to ensure that JSDocument::mark
+    // will be called (which will cause the image element to be marked if necessary).
+    // This is only a problem for elements created using the Image constructor since all
+    // other elements are created through the document, using document.createElement for example.
+    toJS(exec, m_document.get());
+
+    HTMLImageElement* image = new HTMLImageElement(m_document.get());
+    JSObject* result = static_cast<JSObject*>(toJS(exec, image));
+
+    if (widthSet)
+        image->setWidth(width);
+    if (heightSet)
+        image->setHeight(height);
+
+    return result;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/js/JSImageConstructor.h b/WebCore/bindings/js/JSImageConstructor.h
new file mode 100644 (file)
index 0000000..d8f491b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (C) 1999 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef JSImageConstructor_h
+#define JSImageConstructor_h
+
+#include "kjs_binding.h"
+
+namespace WebCore {
+
+    class Document;
+
+    class JSImageConstructor : public DOMObject {
+    public:
+        JSImageConstructor(KJS::ExecState*, Document*);
+
+        virtual bool implementsConstruct() const { return true; }
+        virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List&);
+
+    private:
+        RefPtr<Document> m_document;
+    };
+
+} // namespace WebCore
+
+#endif // JSImageConstructor_h
index da78d6d..6069b4b 100644 (file)
@@ -1,8 +1,6 @@
-// -*- c-basic-offset: 4 -*-
 /*
- *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *  Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -25,7 +23,6 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLDocument.h"
-#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "JSHTMLElement.h"
 #include "kjs_proxy.h"
@@ -41,54 +38,9 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* doc)
-    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
-    , m_doc(doc)
-{
-}
-
-JSObject* ImageConstructorImp::construct(ExecState*  exec, const List& list)
-{
-    bool widthSet = false;
-    bool heightSet = false;
-    int width = 0;
-    int height = 0;
-
-    if (list.size() > 0) {
-        widthSet = true;
-        JSValue* w = list.at(0);
-        width = w->toInt32(exec);
-    }
-
-    if (list.size() > 1) {
-        heightSet = true;
-        JSValue* h = list.at(1);
-        height = h->toInt32(exec);
-    }
-
-    // Calling toJS on the document causes the JS document wrapper to be
-    // added to the window object. This is done to ensure that JSDocument::mark
-    // will be called (which will cause the image element to be marked if necessary).
-    // This is only a problem for elements created using the Image constructor since all
-    // other elements are created through the document, using document.createElement for example.
-    toJS(exec, m_doc.get());
-    
-    HTMLImageElement* image = new HTMLImageElement(m_doc.get());
-    JSObject* result = static_cast<JSObject*>(toJS(exec, image));
-
-    if (widthSet)
-        image->setWidth(width);
-    if (heightSet)
-        image->setHeight(height);
-
-    return result;
-}
-
-// -------------------------------------------------------------------------
-
 // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
 
-JSObject* getRuntimeObject(ExecState* exec, Node* node)
+static JSObject* getRuntimeObject(ExecState* exec, Node* node)
 {
     if (!node)
         return 0;
index d418357..14bd66f 100644 (file)
@@ -1,7 +1,6 @@
-// -*- c-basic-offset: 2 -*-
 /*
  *  Copyright (C) 1999 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ *  Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 
 namespace WebCore {
 
-    class Document;
-    class HTMLCollection;
     class HTMLElement;
     class JSHTMLElement;
     class Node;
 
-    class ImageConstructorImp : public DOMObject {
-    public:
-        ImageConstructorImp(KJS::ExecState*, Document*);
-
-        virtual bool implementsConstruct() const { return true; }
-        virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List&);
-
-    private:
-        RefPtr<Document> m_doc;
-    };
-
-
     // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
     // FIXME: Move these to a more appropriate place.
 
-    KJS::JSObject* getRuntimeObject(KJS::ExecState*, Node*);
     KJS::JSValue* runtimeObjectGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
     KJS::JSValue* runtimeObjectPropertyGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
     bool runtimeObjectCustomGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&, JSHTMLElement*, HTMLElement*);
index b025460..2a674fc 100644 (file)
@@ -43,6 +43,7 @@
 #include "JSEvent.h"
 #include "JSHTMLCollection.h"
 #include "JSHTMLOptionElementConstructor.h"
+#include "JSImageConstructor.h"
 #include "JSLocation.h"
 #include "JSNode.h"
 #include "JSXMLHttpRequest.h"
@@ -60,7 +61,6 @@
 #include "htmlediting.h"
 #include "kjs_css.h"
 #include "kjs_events.h"
-#include "kjs_html.h"
 #include "kjs_navigator.h"
 #include "kjs_proxy.h"
 #include <wtf/AlwaysInline.h>
@@ -471,7 +471,7 @@ JSValue *JSDOMWindowBase::getValueProperty(ExecState *exec, int token) const
         return jsUndefined();
       // FIXME: this property (and the few below) probably shouldn't create a new object every
       // time
-      return new ImageConstructorImp(exec, impl()->frame()->document());
+      return new JSImageConstructor(exec, impl()->frame()->document());
     case Option:
       if (!allowsAccessFrom(exec))
         return jsUndefined();