summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/js
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch)
treed49911209b132da58d838efa852daf28d516df21 /WebCore/bindings/js
parent87eb0cb35bad8784770ebc807e6c982432e47107 (diff)
downloadexternal_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2
Initial Contribution
Diffstat (limited to 'WebCore/bindings/js')
-rw-r--r--WebCore/bindings/js/JSAttrCustom.cpp21
-rw-r--r--WebCore/bindings/js/JSAudioConstructor.h4
-rw-r--r--WebCore/bindings/js/JSCSSRuleCustom.cpp14
-rw-r--r--WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp95
-rw-r--r--WebCore/bindings/js/JSCSSValueCustom.cpp14
-rw-r--r--WebCore/bindings/js/JSCanvasPixelArrayCustom.cpp74
-rw-r--r--WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp20
-rw-r--r--WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp1
-rw-r--r--WebCore/bindings/js/JSCustomXPathNSResolver.h8
-rw-r--r--WebCore/bindings/js/JSDOMWindowCustom.cpp10
-rw-r--r--WebCore/bindings/js/JSDocumentCustom.cpp12
-rw-r--r--WebCore/bindings/js/JSElementCustom.cpp57
-rw-r--r--WebCore/bindings/js/JSEventCustom.cpp42
-rw-r--r--WebCore/bindings/js/JSEventTargetBase.h8
-rw-r--r--WebCore/bindings/js/JSEventTargetNode.cpp8
-rw-r--r--WebCore/bindings/js/JSEventTargetNode.h4
-rw-r--r--WebCore/bindings/js/JSHTMLAppletElementCustom.cpp4
-rw-r--r--WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp4
-rw-r--r--WebCore/bindings/js/JSHTMLFrameElementCustom.cpp25
-rw-r--r--WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp18
-rw-r--r--WebCore/bindings/js/JSHTMLInputElementBase.cpp6
-rw-r--r--WebCore/bindings/js/JSHTMLInputElementBase.h4
-rw-r--r--WebCore/bindings/js/JSHTMLObjectElementCustom.cpp4
-rw-r--r--WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp50
-rw-r--r--WebCore/bindings/js/JSHTMLOptionElementConstructor.h8
-rw-r--r--WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp2
-rw-r--r--WebCore/bindings/js/JSHTMLSelectElementCustom.cpp2
-rw-r--r--WebCore/bindings/js/JSHistoryCustom.cpp2
-rw-r--r--WebCore/bindings/js/JSLocation.cpp43
-rw-r--r--WebCore/bindings/js/JSLocation.h6
-rw-r--r--WebCore/bindings/js/JSNamedNodeMapCustom.cpp11
-rw-r--r--WebCore/bindings/js/JSNamedNodesCollection.cpp2
-rw-r--r--WebCore/bindings/js/JSNamedNodesCollection.h2
-rw-r--r--WebCore/bindings/js/JSNodeFilterCondition.cpp56
-rw-r--r--WebCore/bindings/js/JSNodeFilterCondition.h9
-rw-r--r--WebCore/bindings/js/JSNodeFilterCustom.cpp14
-rw-r--r--WebCore/bindings/js/JSNodeIteratorCustom.cpp39
-rw-r--r--WebCore/bindings/js/JSSVGPODTypeWrapper.h4
-rw-r--r--WebCore/bindings/js/JSSVGPointListCustom.cpp8
-rw-r--r--WebCore/bindings/js/JSSVGTransformListCustom.cpp8
-rw-r--r--WebCore/bindings/js/JSTreeWalkerCustom.cpp84
-rw-r--r--WebCore/bindings/js/JSXMLHttpRequest.cpp27
-rw-r--r--WebCore/bindings/js/JSXMLHttpRequest.h58
-rw-r--r--WebCore/bindings/js/JSXSLTProcessor.cpp28
-rw-r--r--WebCore/bindings/js/JSXSLTProcessor.h41
-rw-r--r--WebCore/bindings/js/kjs_binding.cpp32
-rw-r--r--WebCore/bindings/js/kjs_binding.h79
-rw-r--r--WebCore/bindings/js/kjs_css.h2
-rw-r--r--WebCore/bindings/js/kjs_dom.cpp2
-rw-r--r--WebCore/bindings/js/kjs_dom.h2
-rw-r--r--WebCore/bindings/js/kjs_events.cpp7
-rw-r--r--WebCore/bindings/js/kjs_events.h6
-rw-r--r--WebCore/bindings/js/kjs_html.cpp61
-rw-r--r--WebCore/bindings/js/kjs_html.h5
-rw-r--r--WebCore/bindings/js/kjs_navigator.cpp117
-rw-r--r--WebCore/bindings/js/kjs_navigator.h45
-rw-r--r--WebCore/bindings/js/kjs_proxy.cpp12
-rw-r--r--WebCore/bindings/js/kjs_window.cpp35
-rw-r--r--WebCore/bindings/js/kjs_window.h2
59 files changed, 575 insertions, 793 deletions
diff --git a/WebCore/bindings/js/JSAttrCustom.cpp b/WebCore/bindings/js/JSAttrCustom.cpp
index c7d3848..b2c9044 100644
--- a/WebCore/bindings/js/JSAttrCustom.cpp
+++ b/WebCore/bindings/js/JSAttrCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -29,24 +29,35 @@
#include "config.h"
#include "JSAttr.h"
+#include "Attr.h"
+#include "Document.h"
+#include "ExceptionCode.h"
#include "CSSHelper.h"
#include "HTMLFrameElementBase.h"
#include "HTMLNames.h"
-
-using namespace KJS;
+#include "PlatformString.h"
+#include "kjs_binding.h"
+#include "kjs_dom.h"
+#ifdef ANDROID_JAVASCRIPT_SECURITY
+#include "KURL.h"
+#endif
namespace WebCore {
using namespace HTMLNames;
-void JSAttr::setValue(ExecState* exec, JSValue* value)
+void JSAttr::setValue(KJS::ExecState* exec, KJS::JSValue* value)
{
Attr* imp = static_cast<Attr*>(impl());
String attrValue = valueToStringWithNullCheck(exec, value);
Element* ownerElement = imp->ownerElement();
if (ownerElement && (ownerElement->hasTagName(iframeTag) || ownerElement->hasTagName(frameTag))) {
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (equalIgnoringCase(imp->name(), "src") && protocolIs(parseURL(attrValue), "javascript")) {
+#else
+ if (equalIgnoringCase(imp->name(), "src") && parseURL(attrValue).startsWith("javascript:", false)) {
+#endif
if (!checkNodeSecurity(exec, static_cast<HTMLFrameElementBase*>(ownerElement)->contentDocument()))
return;
}
@@ -54,7 +65,7 @@ void JSAttr::setValue(ExecState* exec, JSValue* value)
ExceptionCode ec = 0;
imp->setValue(attrValue, ec);
- setDOMException(exec, ec);
+ KJS::setDOMException(exec, ec);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSAudioConstructor.h b/WebCore/bindings/js/JSAudioConstructor.h
index 3bfd857..558b7fe 100644
--- a/WebCore/bindings/js/JSAudioConstructor.h
+++ b/WebCore/bindings/js/JSAudioConstructor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -33,7 +33,7 @@
namespace WebCore {
- class JSAudioConstructor : public DOMObject {
+ class JSAudioConstructor : public KJS::DOMObject {
public:
JSAudioConstructor(KJS::ExecState*, Document*);
virtual bool implementsConstruct() const;
diff --git a/WebCore/bindings/js/JSCSSRuleCustom.cpp b/WebCore/bindings/js/JSCSSRuleCustom.cpp
index 44a52a6..00f7063 100644
--- a/WebCore/bindings/js/JSCSSRuleCustom.cpp
+++ b/WebCore/bindings/js/JSCSSRuleCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -31,6 +31,7 @@
#include "CSSImportRule.h"
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
+#include "CSSRule.h"
#include "CSSStyleRule.h"
#include "JSCSSCharsetRule.h"
#include "JSCSSFontFaceRule.h"
@@ -38,17 +39,16 @@
#include "JSCSSMediaRule.h"
#include "JSCSSPageRule.h"
#include "JSCSSStyleRule.h"
-
-using namespace KJS;
+#include "kjs_binding.h"
namespace WebCore {
-JSValue* toJS(ExecState* exec, CSSRule* rule)
+KJS::JSValue* toJS(KJS::ExecState* exec, CSSRule* rule)
{
if (!rule)
- return jsNull();
+ return KJS::jsNull();
- DOMObject* ret = ScriptInterpreter::getDOMObject(rule);
+ KJS::DOMObject* ret = KJS::ScriptInterpreter::getDOMObject(rule);
if (ret)
return ret;
@@ -77,7 +77,7 @@ JSValue* toJS(ExecState* exec, CSSRule* rule)
break;
}
- ScriptInterpreter::putDOMObject(rule, ret);
+ KJS::ScriptInterpreter::putDOMObject(rule, ret);
return ret;
}
diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
index 0723410..3e68ce0 100644
--- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
+++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -30,85 +30,48 @@
#include "CSSPrimitiveValue.h"
#include "CSSStyleDeclaration.h"
#include "CSSValue.h"
+#include "DeprecatedString.h"
#include "PlatformString.h"
#include <kjs/string_object.h>
-#include <wtf/ASCIICType.h>
-
-using namespace KJS;
-using namespace WTF;
namespace WebCore {
-// Check for a CSS prefix.
-// Passed prefix is all lowercase.
-// First characters of property name may be upper or lowercase.
-// Other characters in the prefix within the property name must be lowercase.
-// The prefix within the property name must be followed by a capital letter.
-static bool hasCSSPropertyNamePrefix(const Identifier& propertyName, const char* prefix)
+using namespace KJS;
+
+static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0)
{
-#ifndef NDEBUG
- ASSERT(*prefix);
- for (const char* p = prefix; *p; ++p)
- ASSERT(isASCIILower(*p));
-#endif
+ DeprecatedString prop = propertyName;
- unsigned length = propertyName.size();
- ASSERT(length);
+ int i = prop.length();
- if (toASCIILower(propertyName.data()[0].unicode()) != prefix[0])
- return false;
+ if (!i)
+ return prop;
- for (unsigned i = 1; i < length; ++i) {
- if (!prefix[i])
- return isASCIIUpper(propertyName.data()[i].unicode());
- if (propertyName.data()[0].unicode() != prefix[0])
- return false;
+ while (--i) {
+ ::UChar c = prop[i].unicode();
+ if (c >= 'A' && c <= 'Z')
+ prop.insert(i, '-');
}
- return false;
-}
-static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0)
-{
+ prop = prop.lower();
+
if (hadPixelOrPosPrefix)
*hadPixelOrPosPrefix = false;
- unsigned length = propertyName.size();
- if (!length)
- return String();
-
- Vector< ::UChar> name;
- name.reserveCapacity(length);
-
- unsigned i = 0;
-
- if (hasCSSPropertyNamePrefix(propertyName, "css"))
- i += 3;
- else if (hasCSSPropertyNamePrefix(propertyName, "pixel")) {
- i += 5;
+ if (prop.startsWith("css-"))
+ prop = prop.mid(4);
+ else if (prop.startsWith("pixel-")) {
+ prop = prop.mid(6);
if (hadPixelOrPosPrefix)
*hadPixelOrPosPrefix = true;
- } else if (hasCSSPropertyNamePrefix(propertyName, "pos")) {
- i += 3;
+ } else if (prop.startsWith("pos-")) {
+ prop = prop.mid(4);
if (hadPixelOrPosPrefix)
*hadPixelOrPosPrefix = true;
- } else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
- || hasCSSPropertyNamePrefix(propertyName, "khtml")
- || hasCSSPropertyNamePrefix(propertyName, "apple"))
- name.append('-');
-
- name.append(toASCIILower(propertyName.data()[i++].unicode()));
-
- for (; i < length; ++i) {
- ::UChar c = propertyName.data()[i].unicode();
- if (!isASCIIUpper(c))
- name.append(c);
- else {
- name.append('-');
- name.append(toASCIILower(c));
- }
- }
+ } else if (prop.startsWith("khtml-") || prop.startsWith("apple-") || prop.startsWith("webkit-"))
+ prop.insert(0, '-');
- return String::adopt(name);
+ return prop;
}
static bool isCSSPropertyName(const Identifier& propertyName)
@@ -121,10 +84,7 @@ bool JSCSSStyleDeclaration::canGetItemsForName(ExecState*, CSSStyleDeclaration*,
return isCSSPropertyName(propertyName);
}
-// FIXME: You can get these properties, and set them (see customPut below),
-// but you should also be able to enumerate them.
-JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSObject* originalObject,
- const Identifier& propertyName, const PropertySlot& slot)
+JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(slot.slotBase());
@@ -147,14 +107,13 @@ JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSObject* originalOb
// Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute.
if (propertyName == "filter")
- return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalGlobalObject()->stringPrototype(),
- thisObj->impl()->getPropertyValue(prop));
+ return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalGlobalObject()->stringPrototype(), thisObj->impl()->getPropertyValue(prop));
return jsString(thisObj->impl()->getPropertyValue(prop));
}
-bool JSCSSStyleDeclaration::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSCSSStyleDeclaration::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int /*attr*/)
{
if (!isCSSPropertyName(propertyName))
return false;
diff --git a/WebCore/bindings/js/JSCSSValueCustom.cpp b/WebCore/bindings/js/JSCSSValueCustom.cpp
index 88147d7..f544849 100644
--- a/WebCore/bindings/js/JSCSSValueCustom.cpp
+++ b/WebCore/bindings/js/JSCSSValueCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -27,9 +27,11 @@
#include "JSCSSValue.h"
#include "CSSPrimitiveValue.h"
+#include "CSSValue.h"
#include "CSSValueList.h"
#include "JSCSSPrimitiveValue.h"
#include "JSCSSValueList.h"
+#include "kjs_binding.h"
#if ENABLE(SVG)
#include "JSSVGColor.h"
@@ -38,16 +40,14 @@
#include "SVGPaint.h"
#endif
-using namespace KJS;
-
namespace WebCore {
-JSValue* toJS(ExecState* exec, CSSValue* value)
+KJS::JSValue* toJS(KJS::ExecState* exec, CSSValue* value)
{
if (!value)
- return jsNull();
+ return KJS::jsNull();
- DOMObject* ret = ScriptInterpreter::getDOMObject(value);
+ KJS::DOMObject* ret = KJS::ScriptInterpreter::getDOMObject(value);
if (ret)
return ret;
@@ -65,7 +65,7 @@ JSValue* toJS(ExecState* exec, CSSValue* value)
else
ret = new JSCSSValue(JSCSSValuePrototype::self(exec), value);
- ScriptInterpreter::putDOMObject(value, ret);
+ KJS::ScriptInterpreter::putDOMObject(value, ret);
return ret;
}
diff --git a/WebCore/bindings/js/JSCanvasPixelArrayCustom.cpp b/WebCore/bindings/js/JSCanvasPixelArrayCustom.cpp
deleted file mode 100644
index 23e6afd..0000000
--- a/WebCore/bindings/js/JSCanvasPixelArrayCustom.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSCanvasPixelArray.h"
-
-#include "CanvasPixelArray.h"
-
-using namespace KJS;
-
-namespace WebCore {
-
-JSValue* JSCanvasPixelArray::indexGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
-{
- CanvasPixelArray* array = static_cast<JSCanvasPixelArray*>(slot.slotBase())->impl();
- unsigned index = slot.index();
- unsigned char result;
- if (!array->get(index, result))
- return jsUndefined();
- return jsNumber(result);
-}
-
-void JSCanvasPixelArray::indexSetter(ExecState* exec, unsigned index, JSValue* value)
-{
- double pixelValue = value->toNumber(exec);
- if (exec->hadException())
- return;
- m_impl->set(index, pixelValue);
-}
-
-JSValue* toJS(ExecState* exec, CanvasPixelArray* pixels)
-{
- if (!pixels)
- return jsNull();
-
- DOMObject* ret = ScriptInterpreter::getDOMObject(pixels);
- if (ret)
- return ret;
-
- ret = new JSCanvasPixelArray(JSCanvasPixelArrayPrototype::self(exec), pixels);
-
- Collector::reportExtraMemoryCost(pixels->length());
-
- ScriptInterpreter::putDOMObject(pixels, ret);
-
- return ret;
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
index c5256d9..68328f4 100644
--- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
@@ -28,12 +28,10 @@
#include "FloatRect.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
-#include "ImageData.h"
#include "JSCanvasGradient.h"
#include "JSCanvasPattern.h"
#include "JSHTMLCanvasElement.h"
#include "JSHTMLImageElement.h"
-#include "JSImageData.h"
#include "kjs_html.h"
using namespace KJS;
@@ -335,22 +333,4 @@ JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const List&
return 0;
}
-JSValue* JSCanvasRenderingContext2D::putImageData(ExecState* exec, const List& args)
-{
- // putImageData has two variants
- // putImageData(ImageData, x, y)
- // putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight)
- CanvasRenderingContext2D* context = impl();
-
- ExceptionCode ec = 0;
- if (args.size() >= 7)
- context->putImageData(toImageData(args[0]), args[1]->toFloat(exec), args[2]->toFloat(exec),
- args[3]->toFloat(exec), args[4]->toFloat(exec), args[5]->toFloat(exec), args[6]->toFloat(exec), ec);
- else
- context->putImageData(toImageData(args[0]), args[1]->toFloat(exec), args[2]->toFloat(exec), ec);
-
- setDOMException(exec, ec);
- return jsUndefined();
-}
-
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp b/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
index cd50ebd..b63144c 100644
--- a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
+++ b/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
@@ -32,7 +32,6 @@
#include "CString.h"
#include "Frame.h"
#include "Logging.h"
-#include "MainThread.h"
#include "kjs_proxy.h"
#include "JSSQLTransaction.h"
#include "Page.h"
diff --git a/WebCore/bindings/js/JSCustomXPathNSResolver.h b/WebCore/bindings/js/JSCustomXPathNSResolver.h
index ddd407a..023e893 100644
--- a/WebCore/bindings/js/JSCustomXPathNSResolver.h
+++ b/WebCore/bindings/js/JSCustomXPathNSResolver.h
@@ -44,17 +44,17 @@ namespace WebCore {
class JSCustomXPathNSResolver : public XPathNSResolver {
public:
+
static PassRefPtr<JSCustomXPathNSResolver> create(KJS::ExecState*, KJS::JSValue*);
+ JSCustomXPathNSResolver(KJS::JSObject*, Frame*);
virtual ~JSCustomXPathNSResolver();
virtual String lookupNamespaceURI(const String& prefix);
private:
- JSCustomXPathNSResolver(KJS::JSObject*, Frame*);
-
- KJS::JSObject* m_customResolver; // JSCustomXPathNSResolvers are always temporary, thus no need to GC protect the object.
- RefPtr<Frame> m_frame;
+ KJS::JSObject* m_customResolver; // JSCustomXPathNSResolvers are always temporary, thus no need to GC protect the object.
+ RefPtr<Frame> m_frame;
};
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index af2353c..66631f6 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -107,16 +107,22 @@ bool JSDOMWindow::customGetOwnPropertySlot(ExecState* exec, const Identifier& pr
return false;
}
-bool JSDOMWindow::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSDOMWindow::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
if (!impl()->frame())
return true;
+ // Called by an internal KJS, save time and jump directly to JSGlobalObject.
+ if (attr != None && attr != DontDelete) {
+ JSGlobalObject::put(exec, propertyName, value, attr);
+ return true;
+ }
+
// We have a local override (e.g. "var location"), save time and jump directly to JSGlobalObject.
PropertySlot slot;
if (JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot)) {
if (allowsAccessFrom(exec))
- JSGlobalObject::put(exec, propertyName, value);
+ JSGlobalObject::put(exec, propertyName, value, attr);
return true;
}
diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp
index a957405..133c576 100644
--- a/WebCore/bindings/js/JSDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSDocumentCustom.cpp
@@ -21,12 +21,14 @@
#include "JSDocument.h"
#include "DOMWindow.h"
+#include "Document.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLDocument.h"
#include "JSDOMWindow.h"
#include "JSHTMLDocument.h"
#include "JSLocation.h"
+#include "kjs_binding.h"
#include "kjs_proxy.h"
#if ENABLE(SVG)
@@ -34,10 +36,10 @@
#include "SVGDocument.h"
#endif
-using namespace KJS;
-
namespace WebCore {
+using namespace KJS;
+
void JSDocument::mark()
{
JSEventTargetNode::mark();
@@ -50,7 +52,7 @@ JSValue* JSDocument::location(ExecState* exec) const
if (!frame)
return jsNull();
- Window* win = Window::retrieveWindow(frame);
+ KJS::Window* win = KJS::Window::retrieveWindow(frame);
ASSERT(win);
return win->location();
}
@@ -67,7 +69,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue* value)
// not the target frame.
Frame* activeFrame = static_cast<JSDOMWindow*>(exec->dynamicGlobalObject())->impl()->frame();
if (activeFrame)
- str = activeFrame->document()->completeURL(str).string();
+ str = activeFrame->document()->completeURL(str);
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), false, userGesture);
@@ -94,7 +96,7 @@ JSValue* toJS(ExecState* exec, Document* doc)
// Make sure the document is kept around by the window object, and works right with the
// back/forward cache.
if (doc->frame())
- Window::retrieveWindow(doc->frame())->putDirect("document", ret, DontDelete|ReadOnly);
+ KJS::Window::retrieveWindow(doc->frame())->putDirect("document", ret, DontDelete|ReadOnly);
else {
size_t nodeCount = 0;
for (Node* n = doc; n; n = n->traverseNextNode())
diff --git a/WebCore/bindings/js/JSElementCustom.cpp b/WebCore/bindings/js/JSElementCustom.cpp
index 814ef06..f300f85 100644
--- a/WebCore/bindings/js/JSElementCustom.cpp
+++ b/WebCore/bindings/js/JSElementCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -30,20 +30,31 @@
#include "config.h"
#include "JSElement.h"
+#include "Attr.h"
+#include "Document.h"
+#include "Element.h"
#include "CSSHelper.h"
#include "ExceptionCode.h"
#include "HTMLFrameElementBase.h"
#include "HTMLNames.h"
-
-using namespace KJS;
+#include "PlatformString.h"
+#include "kjs_binding.h"
+#include "kjs_dom.h"
+#ifdef ANDROID_JAVASCRIPT_SECURITY
+#include "KURL.h"
+#endif
namespace WebCore {
using namespace HTMLNames;
-static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* element, const String& name, const String& value)
+static inline bool allowSettingSrcToJavascriptURL(KJS::ExecState* exec, Element* element, String name, String value)
{
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIs(parseURL(value), "javascript")) {
+#else
+ if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && parseURL(value).startsWith("javascript:", false)) {
+#endif
HTMLFrameElementBase* frame = static_cast<HTMLFrameElementBase*>(element);
if (!checkNodeSecurity(exec, frame->contentDocument()))
return false;
@@ -51,7 +62,7 @@ static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* elem
return true;
}
-JSValue* JSElement::setAttribute(ExecState* exec, const List& args)
+KJS::JSValue* JSElement::setAttribute(KJS::ExecState* exec, const KJS::List& args)
{
ExceptionCode ec = 0;
String name = args[0]->toString(exec);
@@ -59,33 +70,33 @@ JSValue* JSElement::setAttribute(ExecState* exec, const List& args)
Element* imp = impl();
if (!allowSettingSrcToJavascriptURL(exec, imp, name, value))
- return jsUndefined();
+ return KJS::jsUndefined();
imp->setAttribute(name, value, ec);
- setDOMException(exec, ec);
- return jsUndefined();
+ KJS::setDOMException(exec, ec);
+ return KJS::jsUndefined();
}
-JSValue* JSElement::setAttributeNode(ExecState* exec, const List& args)
+KJS::JSValue* JSElement::setAttributeNode(KJS::ExecState* exec, const KJS::List& args)
{
ExceptionCode ec = 0;
bool newAttrOk;
Attr* newAttr = toAttr(args[0], newAttrOk);
if (!newAttrOk) {
setDOMException(exec, TYPE_MISMATCH_ERR);
- return jsUndefined();
+ return KJS::jsUndefined();
}
Element* imp = impl();
if (!allowSettingSrcToJavascriptURL(exec, imp, newAttr->name(), newAttr->value()))
- return jsUndefined();
+ return KJS::jsUndefined();
- JSValue* result = toJS(exec, WTF::getPtr(imp->setAttributeNode(newAttr, ec)));
- setDOMException(exec, ec);
+ KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->setAttributeNode(newAttr, ec)));
+ KJS::setDOMException(exec, ec);
return result;
}
-JSValue* JSElement::setAttributeNS(ExecState* exec, const List& args)
+KJS::JSValue* JSElement::setAttributeNS(KJS::ExecState* exec, const KJS::List& args)
{
ExceptionCode ec = 0;
String namespaceURI = valueToStringWithNullCheck(exec, args[0]);
@@ -94,29 +105,29 @@ JSValue* JSElement::setAttributeNS(ExecState* exec, const List& args)
Element* imp = impl();
if (!allowSettingSrcToJavascriptURL(exec, imp, qualifiedName, value))
- return jsUndefined();
+ return KJS::jsUndefined();
imp->setAttributeNS(namespaceURI, qualifiedName, value, ec);
- setDOMException(exec, ec);
- return jsUndefined();
+ KJS::setDOMException(exec, ec);
+ return KJS::jsUndefined();
}
-JSValue* JSElement::setAttributeNodeNS(ExecState* exec, const List& args)
+KJS::JSValue* JSElement::setAttributeNodeNS(KJS::ExecState* exec, const KJS::List& args)
{
ExceptionCode ec = 0;
bool newAttrOk;
Attr* newAttr = toAttr(args[0], newAttrOk);
if (!newAttrOk) {
- setDOMException(exec, TYPE_MISMATCH_ERR);
- return jsUndefined();
+ KJS::setDOMException(exec, TYPE_MISMATCH_ERR);
+ return KJS::jsUndefined();
}
Element* imp = impl();
if (!allowSettingSrcToJavascriptURL(exec, imp, newAttr->name(), newAttr->value()))
- return jsUndefined();
+ return KJS::jsUndefined();
- JSValue* result = toJS(exec, WTF::getPtr(imp->setAttributeNodeNS(newAttr, ec)));
- setDOMException(exec, ec);
+ KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->setAttributeNodeNS(newAttr, ec)));
+ KJS::setDOMException(exec, ec);
return result;
}
diff --git a/WebCore/bindings/js/JSEventCustom.cpp b/WebCore/bindings/js/JSEventCustom.cpp
index e1e044c..4ba7f96 100644
--- a/WebCore/bindings/js/JSEventCustom.cpp
+++ b/WebCore/bindings/js/JSEventCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -32,6 +32,7 @@
#include "Clipboard.h"
#include "Event.h"
#include "JSKeyboardEvent.h"
+#include "JSMessageEvent.h"
#include "JSMouseEvent.h"
#include "JSMutationEvent.h"
#include "JSOverflowEvent.h"
@@ -40,6 +41,7 @@
#include "JSUIEvent.h"
#include "JSWheelEvent.h"
#include "KeyboardEvent.h"
+#include "MessageEvent.h"
#include "MouseEvent.h"
#include "MutationEvent.h"
#include "OverflowEvent.h"
@@ -49,16 +51,6 @@
#include "WheelEvent.h"
#include "kjs_events.h"
-#if ENABLE(CROSS_DOCUMENT_MESSAGING)
-#include "JSMessageEvent.h"
-#include "MessageEvent.h"
-#endif
-
-#if ENABLE(SVG)
-#include "JSSVGZoomEvent.h"
-#include "SVGZoomEvent.h"
-#endif
-
using namespace KJS;
namespace WebCore {
@@ -75,26 +67,22 @@ JSValue* toJS(ExecState* exec, Event* event)
if (!event)
return jsNull();
+
DOMObject* ret = ScriptInterpreter::getDOMObject(event);
if (ret)
return ret;
- if (event->isUIEvent()) {
- if (event->isKeyboardEvent())
- ret = new JSKeyboardEvent(JSKeyboardEventPrototype::self(exec), static_cast<KeyboardEvent*>(event));
- else if (event->isTextEvent())
- ret = new JSTextEvent(JSTextEventPrototype::self(exec), static_cast<TextEvent*>(event));
- else if (event->isMouseEvent())
- ret = new JSMouseEvent(JSMouseEventPrototype::self(exec), static_cast<MouseEvent*>(event));
- else if (event->isWheelEvent())
- ret = new JSWheelEvent(JSWheelEventPrototype::self(exec), static_cast<WheelEvent*>(event));
-#if ENABLE(SVG)
- else if (event->isSVGZoomEvent())
- ret = new JSSVGZoomEvent(JSSVGZoomEventPrototype::self(exec), static_cast<SVGZoomEvent*>(event), 0);
-#endif
- else
- ret = new JSUIEvent(JSUIEventPrototype::self(exec), static_cast<UIEvent*>(event));
- } else if (event->isMutationEvent())
+ if (event->isKeyboardEvent())
+ ret = new JSKeyboardEvent(JSKeyboardEventPrototype::self(exec), static_cast<KeyboardEvent*>(event));
+ else if (event->isTextEvent())
+ ret = new JSTextEvent(JSTextEventPrototype::self(exec), static_cast<TextEvent*>(event));
+ else if (event->isMouseEvent())
+ ret = new JSMouseEvent(JSMouseEventPrototype::self(exec), static_cast<MouseEvent*>(event));
+ else if (event->isWheelEvent())
+ ret = new JSWheelEvent(JSWheelEventPrototype::self(exec), static_cast<WheelEvent*>(event));
+ else if (event->isUIEvent())
+ ret = new JSUIEvent(JSUIEventPrototype::self(exec), static_cast<UIEvent*>(event));
+ else if (event->isMutationEvent())
ret = new JSMutationEvent(JSMutationEventPrototype::self(exec), static_cast<MutationEvent*>(event));
else if (event->isOverflowEvent())
ret = new JSOverflowEvent(JSOverflowEventPrototype::self(exec), static_cast<OverflowEvent*>(event));
diff --git a/WebCore/bindings/js/JSEventTargetBase.h b/WebCore/bindings/js/JSEventTargetBase.h
index 218ad18..e62459a 100644
--- a/WebCore/bindings/js/JSEventTargetBase.h
+++ b/WebCore/bindings/js/JSEventTargetBase.h
@@ -86,7 +86,7 @@ namespace WebCore {
return KJS::jsUndefined();
}
- void putValueProperty(const JSEventTarget* owner, KJS::ExecState* exec, int token, KJS::JSValue* value)
+ void putValueProperty(const JSEventTarget* owner, KJS::ExecState* exec, int token, KJS::JSValue* value, int attr)
{
AtomicString eventName = eventNameForPropertyToken(token);
if (!eventName.isEmpty())
@@ -104,9 +104,9 @@ namespace WebCore {
}
template<class JSParent>
- void put(JSEventTarget* owner, KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value)
+ void put(JSEventTarget* owner, KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value, int attr)
{
- KJS::lookupPut<JSEventTarget, JSParent>(exec, propertyName, value, &KJS::JSEventTargetPropertiesTable, owner);
+ KJS::lookupPut<JSEventTarget, JSParent>(exec, propertyName, value, attr, &KJS::JSEventTargetPropertiesTable, owner);
}
};
@@ -134,7 +134,7 @@ namespace WebCore {
}
KJS::JSObject* newObject = new JSEventTargetPrototype<JSEventTargetPrototypeParent, JSEventTargetPrototypeInformation>(exec);
- globalObject->putDirect(*prototypeName, newObject, KJS::DontEnum);
+ globalObject->putDirect(*prototypeName, newObject, KJS::Internal | KJS::DontEnum);
return newObject;
}
diff --git a/WebCore/bindings/js/JSEventTargetNode.cpp b/WebCore/bindings/js/JSEventTargetNode.cpp
index 92c0048..d097aad 100644
--- a/WebCore/bindings/js/JSEventTargetNode.cpp
+++ b/WebCore/bindings/js/JSEventTargetNode.cpp
@@ -46,14 +46,14 @@ JSValue* JSEventTargetNode::getValueProperty(ExecState* exec, int token) const
return m_base.getValueProperty(this, exec, token);
}
-void JSEventTargetNode::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSEventTargetNode::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- m_base.put<JSNode>(this, exec, propertyName, value);
+ m_base.put<JSNode>(this, exec, propertyName, value, attr);
}
-void JSEventTargetNode::putValueProperty(ExecState* exec, int token, JSValue* value)
+void JSEventTargetNode::putValueProperty(ExecState* exec, int token, JSValue* value, int attr)
{
- m_base.putValueProperty(this, exec, token, value);
+ m_base.putValueProperty(this, exec, token, value, attr);
}
void JSEventTargetNode::setListener(ExecState* exec, const AtomicString& eventType, JSValue* func) const
diff --git a/WebCore/bindings/js/JSEventTargetNode.h b/WebCore/bindings/js/JSEventTargetNode.h
index f83490a..b73482a 100644
--- a/WebCore/bindings/js/JSEventTargetNode.h
+++ b/WebCore/bindings/js/JSEventTargetNode.h
@@ -45,8 +45,8 @@ namespace WebCore {
bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*);
- void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*);
+ virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue* value, int attr);
+ void putValueProperty(KJS::ExecState*, int token, KJS::JSValue* value, int attr);
private:
JSEventTargetBase<JSEventTargetNode> m_base;
diff --git a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
index d34b8b5..fc21b80 100644
--- a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
@@ -39,9 +39,9 @@ bool JSHTMLAppletElement::customGetOwnPropertySlot(ExecState* exec, const Identi
return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this, static_cast<HTMLElement*>(impl()));
}
-bool JSHTMLAppletElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSHTMLAppletElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- return runtimeObjectCustomPut(exec, propertyName, value, static_cast<HTMLElement*>(impl()));
+ return runtimeObjectCustomPut(exec, propertyName, value, attr, static_cast<HTMLElement*>(impl()));
}
bool JSHTMLAppletElement::implementsCall() const
diff --git a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
index 1224f2c..2652a82 100644
--- a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
@@ -39,9 +39,9 @@ bool JSHTMLEmbedElement::customGetOwnPropertySlot(ExecState* exec, const Identif
return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this, static_cast<HTMLElement*>(impl()));
}
-bool JSHTMLEmbedElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSHTMLEmbedElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- return runtimeObjectCustomPut(exec, propertyName, value, static_cast<HTMLElement*>(impl()));
+ return runtimeObjectCustomPut(exec, propertyName, value, attr, static_cast<HTMLElement*>(impl()));
}
bool JSHTMLEmbedElement::implementsCall() const
diff --git a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
index b5b6370..9f729b4 100644
--- a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -29,26 +29,35 @@
#include "config.h"
#include "JSHTMLFrameElement.h"
+#include "Document.h"
#include "CSSHelper.h"
#include "HTMLFrameElement.h"
-
-using namespace KJS;
+#include "PlatformString.h"
+#include "kjs_binding.h"
+#include "kjs_dom.h"
+#ifdef ANDROID_JAVASCRIPT_SECURITY
+#include "KURL.h"
+#endif
namespace WebCore {
-static inline bool allowSettingJavascriptURL(ExecState* exec, HTMLFrameElement* imp, const String& value)
+static inline bool allowSettingJavascriptURL(KJS::ExecState* exec, HTMLFrameElement* imp, String value)
{
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (protocolIs(parseURL(value), "javascript")) {
+#else
+ if (parseURL(value).startsWith("javascript:", false)) {
+#endif
if (!checkNodeSecurity(exec, imp->contentDocument()))
return false;
}
return true;
}
-void JSHTMLFrameElement::setSrc(ExecState* exec, JSValue* value)
+void JSHTMLFrameElement::setSrc(KJS::ExecState* exec, KJS::JSValue* value)
{
HTMLFrameElement* imp = static_cast<HTMLFrameElement*>(impl());
- String srcValue = valueToStringWithNullCheck(exec, value);
+ String srcValue = KJS::valueToStringWithNullCheck(exec, value);
if (!allowSettingJavascriptURL(exec, imp, srcValue))
return;
@@ -57,10 +66,10 @@ void JSHTMLFrameElement::setSrc(ExecState* exec, JSValue* value)
return;
}
-void JSHTMLFrameElement::setLocation(ExecState* exec, JSValue* value)
+void JSHTMLFrameElement::setLocation(KJS::ExecState* exec, KJS::JSValue* value)
{
HTMLFrameElement* imp = static_cast<HTMLFrameElement*>(impl());
- String locationValue = valueToStringWithNullCheck(exec, value);
+ String locationValue = KJS::valueToStringWithNullCheck(exec, value);
if (!allowSettingJavascriptURL(exec, imp, locationValue))
return;
diff --git a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp
index 309c932..0f9f5a5 100644
--- a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -29,25 +29,35 @@
#include "config.h"
#include "JSHTMLIFrameElement.h"
+#include "Document.h"
#include "CSSHelper.h"
#include "HTMLIFrameElement.h"
-
-using namespace KJS;
+#include "PlatformString.h"
+#include "kjs_binding.h"
+#include "kjs_dom.h"
+#ifdef ANDROID_JAVASCRIPT_SECURITY
+#include "KURL.h"
+#endif
namespace WebCore {
-void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue* value)
+void JSHTMLIFrameElement::setSrc(KJS::ExecState* exec, KJS::JSValue* value)
{
HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl());
String srcValue = valueToStringWithNullCheck(exec, value);
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (protocolIs(parseURL(srcValue), "javascript")) {
+#else
+ if (parseURL(srcValue).startsWith("javascript:", false)) {
+#endif
if (!checkNodeSecurity(exec, imp->contentDocument()))
return;
}
imp->setSrc(srcValue);
+ return;
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLInputElementBase.cpp b/WebCore/bindings/js/JSHTMLInputElementBase.cpp
index f4b54b3..e0417bc 100644
--- a/WebCore/bindings/js/JSHTMLInputElementBase.cpp
+++ b/WebCore/bindings/js/JSHTMLInputElementBase.cpp
@@ -90,12 +90,12 @@ JSValue* JSHTMLInputElementBase::getValueProperty(ExecState* exec, int token) co
return jsUndefined();
}
-void JSHTMLInputElementBase::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSHTMLInputElementBase::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- lookupPut<JSHTMLInputElementBase, JSHTMLElement>(exec, propertyName, value, &JSHTMLInputElementBaseTable, this);
+ lookupPut<JSHTMLInputElementBase, JSHTMLElement>(exec, propertyName, value, attr, &JSHTMLInputElementBaseTable, this);
}
-void JSHTMLInputElementBase::putValueProperty(ExecState* exec, int token, JSValue* value)
+void JSHTMLInputElementBase::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
HTMLInputElement& input = *static_cast<HTMLInputElement*>(impl());
ASSERT(input.canHaveSelection());
diff --git a/WebCore/bindings/js/JSHTMLInputElementBase.h b/WebCore/bindings/js/JSHTMLInputElementBase.h
index cb90e07..32bca58 100644
--- a/WebCore/bindings/js/JSHTMLInputElementBase.h
+++ b/WebCore/bindings/js/JSHTMLInputElementBase.h
@@ -36,8 +36,8 @@ namespace WebCore {
virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, JSValue*);
- void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*);
+ virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, JSValue*, int attr);
+ void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*, int attr);
virtual const KJS::ClassInfo* classInfo() const { return &info; }
static const KJS::ClassInfo info;
enum { SelectionStart, SelectionEnd };
diff --git a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
index 83e9b0d..7976138 100644
--- a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
@@ -39,9 +39,9 @@ bool JSHTMLObjectElement::customGetOwnPropertySlot(ExecState* exec, const Identi
return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this, static_cast<HTMLElement*>(impl()));
}
-bool JSHTMLObjectElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSHTMLObjectElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- return runtimeObjectCustomPut(exec, propertyName, value, static_cast<HTMLElement*>(impl()));
+ return runtimeObjectCustomPut(exec, propertyName, value, attr, static_cast<HTMLElement*>(impl()));
}
bool JSHTMLObjectElement::implementsCall() const
diff --git a/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp b/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
index 551854a..0311b32 100644
--- a/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
+++ b/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -25,13 +25,13 @@
#include "JSHTMLOptionElement.h"
#include "Text.h"
-using namespace KJS;
-
namespace WebCore {
-JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec, Document* document)
- : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
- , m_document(document)
+using namespace KJS;
+
+JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec, Document* d)
+ : KJS::DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+ , m_doc(d)
{
putDirect(exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
}
@@ -43,28 +43,26 @@ bool JSHTMLOptionElementConstructor::implementsConstruct() const
JSObject* JSHTMLOptionElementConstructor::construct(ExecState* exec, const List& args)
{
- ExceptionCode ec = 0;
-
- RefPtr<HTMLOptionElement> element = static_pointer_cast<HTMLOptionElement>(m_document->createElement("option", ec));
- if (element) {
- RefPtr<Text> text = m_document->createTextNode("");
- if (!args[0]->isUndefined())
- text->setData(args[0]->toString(exec), ec);
- if (ec == 0)
- element->appendChild(text.release(), ec);
- if (ec == 0 && !args[1]->isUndefined())
- element->setValue(args[1]->toString(exec));
- if (ec == 0)
- element->setDefaultSelected(args[2]->toBoolean(exec));
- if (ec == 0)
- element->setSelected(args[3]->toBoolean(exec));
+ int exception = 0;
+ RefPtr<Element> el(m_doc->createElement("option", exception));
+ HTMLOptionElement* opt = 0;
+ if (el) {
+ opt = static_cast<HTMLOptionElement*>(el.get());
+ int sz = args.size();
+ RefPtr<Text> text = m_doc->createTextNode("");
+ opt->appendChild(text, exception);
+ if (exception == 0 && sz > 0)
+ text->setData(args[0]->toString(exec), exception);
+ if (exception == 0 && sz > 1)
+ opt->setValue(args[1]->toString(exec));
+ if (exception == 0 && sz > 2)
+ opt->setDefaultSelected(args[2]->toBoolean(exec));
+ if (exception == 0 && sz > 3)
+ opt->setSelected(args[3]->toBoolean(exec));
}
- setDOMException(exec, ec);
- if (ec || !element)
- return 0;
-
- return static_cast<JSObject*>(toJS(exec, element.release()));
+ setDOMException(exec, exception);
+ return static_cast<JSObject*>(toJS(exec, opt));
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLOptionElementConstructor.h b/WebCore/bindings/js/JSHTMLOptionElementConstructor.h
index 47a95c7..ac347fa 100644
--- a/WebCore/bindings/js/JSHTMLOptionElementConstructor.h
+++ b/WebCore/bindings/js/JSHTMLOptionElementConstructor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,13 +25,13 @@
namespace WebCore {
- class JSHTMLOptionElementConstructor : public DOMObject {
+ class JSHTMLOptionElementConstructor : public KJS::DOMObject {
public:
JSHTMLOptionElementConstructor(KJS::ExecState*, Document*);
virtual bool implementsConstruct() const;
- virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List& args);
+ virtual KJS::JSObject *construct(KJS::ExecState*, const KJS::List& args);
private:
- RefPtr<Document> m_document;
+ RefPtr<Document> m_doc;
};
}
diff --git a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
index c0daf19..b0da9a7 100644
--- a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
@@ -60,7 +60,7 @@ void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue* value)
setDOMException(exec, ec);
}
-void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue* value)
+void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue* value, int attr)
{
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
diff --git a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
index 9688cfe..c127d4b 100644
--- a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
@@ -62,7 +62,7 @@ void selectIndexSetter(HTMLSelectElement* select, KJS::ExecState* exec, unsigned
}
}
-void JSHTMLSelectElement::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value)
+void JSHTMLSelectElement::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value, int attr)
{
selectIndexSetter(static_cast<HTMLSelectElement*>(impl()), exec, index, value);
}
diff --git a/WebCore/bindings/js/JSHistoryCustom.cpp b/WebCore/bindings/js/JSHistoryCustom.cpp
index 0e5d0d0..36f1785 100644
--- a/WebCore/bindings/js/JSHistoryCustom.cpp
+++ b/WebCore/bindings/js/JSHistoryCustom.cpp
@@ -72,7 +72,7 @@ bool JSHistory::customGetOwnPropertySlot(ExecState* exec, const Identifier& prop
return true;
}
-bool JSHistory::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value)
+bool JSHistory::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
// Only allow putting by frames in the same origin.
if (!allowsAccessFromFrame(exec, impl()->frame()))
diff --git a/WebCore/bindings/js/JSLocation.cpp b/WebCore/bindings/js/JSLocation.cpp
index 2fc1a34..b4e63de 100644
--- a/WebCore/bindings/js/JSLocation.cpp
+++ b/WebCore/bindings/js/JSLocation.cpp
@@ -26,6 +26,7 @@
#include "DOMWindow.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "PlatformString.h"
#include "kjs_proxy.h"
#include "kjs_window.h"
@@ -131,12 +132,12 @@ bool JSLocation::customGetOwnPropertySlot(ExecState* exec, const Identifier& pro
return true;
}
-void JSLocation::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSLocation::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
if (!m_frame)
return;
- String str = value->toString(exec);
+ DeprecatedString str = value->toString(exec);
KURL url = m_frame->loader()->url();
bool sameDomainAccess = allowsAccessFromFrame(exec, m_frame);
@@ -151,7 +152,6 @@ void JSLocation::put(ExecState* exec, const Identifier& propertyName, JSValue* v
switch (entry->value.intValue) {
case Href: {
- // FIXME: Why isn't this security check needed for the other properties, like Host, below?
Frame* frame = Window::retrieveActive(exec)->impl()->frame();
if (!frame)
return;
@@ -160,30 +160,27 @@ void JSLocation::put(ExecState* exec, const Identifier& propertyName, JSValue* v
url = frame->loader()->completeURL(str);
break;
}
- case Hash:
+ case Hash: {
if (str.startsWith("#"))
- str = str.substring(1);
+ str = str.mid(1);
if (url.ref() == str)
return;
url.setRef(str);
break;
- case Host:
+ }
+ case Host: {
url.setHostAndPort(str);
break;
+ }
case Hostname:
url.setHost(str);
break;
case Pathname:
url.setPath(str);
break;
- case Port: {
- // FIXME: Could make this a little less ugly if String provided a toUnsignedShort function.
- int port = str.toInt();
- if (port < 0 || port > 0xFFFF)
- port = 0;
- url.setPort(port);
+ case Port:
+ url.setPort(str.toUInt());
break;
- }
case Protocol:
url.setProtocol(str);
break;
@@ -197,12 +194,16 @@ void JSLocation::put(ExecState* exec, const Identifier& propertyName, JSValue* v
}
} else {
if (sameDomainAccess)
- JSObject::put(exec, propertyName, value);
+ JSObject::put(exec, propertyName, value, attr);
return;
}
Frame* activeFrame = Window::retrieveActive(exec)->impl()->frame();
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!url.protocolIs("javascript") || sameDomainAccess) {
+#else
+ if (!url.deprecatedString().startsWith("javascript:", false) || sameDomainAccess) {
+#endif
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
m_frame->loader()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), false, userGesture);
}
@@ -237,9 +238,13 @@ JSValue* jsLocationProtoFuncReplace(ExecState* exec, JSObject* thisObj, const Li
if (activeFrame) {
if (!activeFrame->loader()->shouldAllowNavigation(frame))
return jsUndefined();
- String str = args[0]->toString(exec);
+ DeprecatedString str = args[0]->toString(exec);
const Window* window = Window::retrieveWindow(frame);
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!protocolIs(str, "javascript") || (window && window->allowsAccessFrom(exec))) {
+#else
+ if (!str.startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) {
+#endif
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
frame->loader()->scheduleLocationChange(activeFrame->loader()->completeURL(str).string(), activeFrame->loader()->outgoingReferrer(), true, userGesture);
}
@@ -261,7 +266,11 @@ JSValue* jsLocationProtoFuncReload(ExecState* exec, JSObject* thisObj, const Lis
if (!window->allowsAccessFrom(exec))
return jsUndefined();
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!frame->loader()->url().protocolIs("javascript") || (window && window->allowsAccessFrom(exec))) {
+#else
+ if (!frame->loader()->url().deprecatedString().startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) {
+#endif
bool userGesture = Window::retrieveActive(exec)->impl()->frame()->scriptProxy()->processingUserGesture();
frame->loader()->scheduleRefresh(userGesture);
}
@@ -283,7 +292,11 @@ JSValue* jsLocationProtoFuncAssign(ExecState* exec, JSObject* thisObj, const Lis
return jsUndefined();
const Window* window = Window::retrieveWindow(frame);
String dstUrl = activeFrame->loader()->completeURL(args[0]->toString(exec)).string();
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!protocolIs(dstUrl, "javascript") || (window && window->allowsAccessFrom(exec))) {
+#else
+ if (!dstUrl.startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) {
+#endif
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
// We want a new history item if this JS was called via a user gesture
frame->loader()->scheduleLocationChange(dstUrl, activeFrame->loader()->outgoingReferrer(), false, userGesture);
diff --git a/WebCore/bindings/js/JSLocation.h b/WebCore/bindings/js/JSLocation.h
index 152c8a3..684cb40 100644
--- a/WebCore/bindings/js/JSLocation.h
+++ b/WebCore/bindings/js/JSLocation.h
@@ -30,8 +30,8 @@ namespace WebCore {
class Frame;
- class JSLocation : public DOMObject {
- typedef DOMObject Base;
+ class JSLocation : public KJS::DOMObject {
+ typedef KJS::DOMObject Base;
friend class KJS::Window;
public:
@@ -39,7 +39,7 @@ namespace WebCore {
virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*);
+ virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
virtual bool deleteProperty(KJS::ExecState*, const KJS::Identifier&);
virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);
diff --git a/WebCore/bindings/js/JSNamedNodeMapCustom.cpp b/WebCore/bindings/js/JSNamedNodeMapCustom.cpp
index 7cb60bf..ae63a12 100644
--- a/WebCore/bindings/js/JSNamedNodeMapCustom.cpp
+++ b/WebCore/bindings/js/JSNamedNodeMapCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -27,22 +27,21 @@
#include "JSNamedNodeMap.h"
#include "NamedNodeMap.h"
+#include "PlatformString.h"
#include "kjs_binding.h"
#include "kjs_dom.h"
-using namespace KJS;
-
namespace WebCore {
-bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, const Identifier& propertyName)
+bool JSNamedNodeMap::canGetItemsForName(KJS::ExecState*, NamedNodeMap* impl, const KJS::Identifier& propertyName)
{
return impl->getNamedItem(propertyName);
}
-JSValue* JSNamedNodeMap::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+KJS::JSValue* JSNamedNodeMap::nameGetter(KJS::ExecState* exec, KJS::JSObject* originalObject, const KJS::Identifier& propertyName, const KJS::PropertySlot& slot)
{
JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(slot.slotBase());
- return toJS(exec, thisObj->impl()->getNamedItem(propertyName));
+ return KJS::toJS(exec, thisObj->impl()->getNamedItem(propertyName));
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSNamedNodesCollection.cpp b/WebCore/bindings/js/JSNamedNodesCollection.cpp
index 1fc008f..977ce82 100644
--- a/WebCore/bindings/js/JSNamedNodesCollection.cpp
+++ b/WebCore/bindings/js/JSNamedNodesCollection.cpp
@@ -41,7 +41,7 @@ const ClassInfo JSNamedNodesCollection::info = { "Collection", 0, 0 };
// for constructs like document.forms.<name>[1],
// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
JSNamedNodesCollection::JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >& nodes)
- : DOMObject(prototype)
+ : KJS::DOMObject(prototype)
, m_nodes(nodes)
{
}
diff --git a/WebCore/bindings/js/JSNamedNodesCollection.h b/WebCore/bindings/js/JSNamedNodesCollection.h
index 4b89c80..336e0cb 100644
--- a/WebCore/bindings/js/JSNamedNodesCollection.h
+++ b/WebCore/bindings/js/JSNamedNodesCollection.h
@@ -35,7 +35,7 @@ namespace WebCore {
// Internal class, used for the collection return by e.g. document.forms.myinput
// when multiple nodes have the same name.
- class JSNamedNodesCollection : public DOMObject {
+ class JSNamedNodesCollection : public KJS::DOMObject {
public:
JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >&);
diff --git a/WebCore/bindings/js/JSNodeFilterCondition.cpp b/WebCore/bindings/js/JSNodeFilterCondition.cpp
index 17884f9..a21509a 100644
--- a/WebCore/bindings/js/JSNodeFilterCondition.cpp
+++ b/WebCore/bindings/js/JSNodeFilterCondition.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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 Lesser General Public
@@ -29,17 +29,7 @@
namespace WebCore {
-using namespace KJS;
-
-// FIXME: Add takeException as a member of ExecState?
-static JSValue* takeException(ExecState* exec)
-{
- JSValue* exception = exec->exception();
- exec->clearException();
- return exception;
-}
-
-JSNodeFilterCondition::JSNodeFilterCondition(JSObject* filter)
+JSNodeFilterCondition::JSNodeFilterCondition(KJS::JSObject* filter)
: m_filter(filter)
{
}
@@ -49,36 +39,22 @@ void JSNodeFilterCondition::mark()
m_filter->mark();
}
-short JSNodeFilterCondition::acceptNode(Node* filterNode, JSValue*& exception) const
+short JSNodeFilterCondition::acceptNode(Node* filterNode) const
{
- // FIXME: It makes no sense for this to depend on the document being in a frame!
- Frame* frame = filterNode->document()->frame();
- if (!frame)
- return NodeFilter::FILTER_REJECT;
-
- JSLock lock;
-
- if (!m_filter->implementsCall())
- return NodeFilter::FILTER_REJECT;
-
- ExecState* exec = frame->scriptProxy()->globalObject()->globalExec();
- List args;
- args.append(toJS(exec, filterNode));
- if (exec->hadException()) {
- exception = takeException(exec);
- return NodeFilter::FILTER_REJECT;
- }
- JSValue* result = m_filter->call(exec, m_filter, args);
- if (exec->hadException()) {
- exception = takeException(exec);
- return NodeFilter::FILTER_REJECT;
+ Node* node = filterNode;
+ Frame* frame = node->document()->frame();
+ KJSProxy* proxy = frame->scriptProxy();
+ if (proxy && m_filter->implementsCall()) {
+ KJS::JSLock lock;
+ KJS::ExecState* exec = proxy->globalObject()->globalExec();
+ KJS::List args;
+ args.append(toJS(exec, node));
+ KJS::JSObject* obj = m_filter;
+ KJS::JSValue* result = obj->call(exec, obj, args);
+ return result->toInt32(exec);
}
- int intResult = result->toInt32(exec);
- if (exec->hadException()) {
- exception = takeException(exec);
- return NodeFilter::FILTER_REJECT;
- }
- return intResult;
+
+ return NodeFilter::FILTER_REJECT;
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSNodeFilterCondition.h b/WebCore/bindings/js/JSNodeFilterCondition.h
index 65519e9..bd172b9 100644
--- a/WebCore/bindings/js/JSNodeFilterCondition.h
+++ b/WebCore/bindings/js/JSNodeFilterCondition.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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 Lesser General Public
@@ -21,10 +21,7 @@
#define JSNodeFilterCondition_h
#include "NodeFilterCondition.h"
-
-namespace KJS {
- class JSObject;
-}
+#include "kjs_dom.h"
namespace WebCore {
@@ -33,7 +30,7 @@ namespace WebCore {
class JSNodeFilterCondition : public NodeFilterCondition {
public:
JSNodeFilterCondition(KJS::JSObject* filter);
- virtual short acceptNode(Node*, KJS::JSValue*& exception) const;
+ virtual short acceptNode(Node*) const;
virtual void mark();
protected:
diff --git a/WebCore/bindings/js/JSNodeFilterCustom.cpp b/WebCore/bindings/js/JSNodeFilterCustom.cpp
index 413abf9..258059c 100644
--- a/WebCore/bindings/js/JSNodeFilterCustom.cpp
+++ b/WebCore/bindings/js/JSNodeFilterCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -29,9 +29,6 @@
#include "JSNodeFilterCondition.h"
#include "NodeFilter.h"
#include "kjs_binding.h"
-#include "kjs_dom.h"
-
-using namespace KJS;
namespace WebCore {
@@ -41,15 +38,6 @@ void JSNodeFilter::mark()
DOMObject::mark();
}
-JSValue* JSNodeFilter::acceptNode(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- short result = impl()->acceptNode(toNode(args[0]), exception);
- if (exception)
- exec->setException(exception);
- return jsNumber(result);
-}
-
NodeFilter* toNodeFilter(KJS::JSValue* val)
{
if (!val || !val->isObject())
diff --git a/WebCore/bindings/js/JSNodeIteratorCustom.cpp b/WebCore/bindings/js/JSNodeIteratorCustom.cpp
index 937efa0..deb0ffe 100644
--- a/WebCore/bindings/js/JSNodeIteratorCustom.cpp
+++ b/WebCore/bindings/js/JSNodeIteratorCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,17 +16,12 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-
#include "config.h"
#include "JSNodeIterator.h"
-#include "JSNode.h"
-#include "Node.h"
#include "NodeFilter.h"
#include "NodeIterator.h"
-using namespace KJS;
-
namespace WebCore {
void JSNodeIterator::mark()
@@ -37,36 +32,4 @@ void JSNodeIterator::mark()
DOMObject::mark();
}
-JSValue* JSNodeIterator::nextNode(ExecState* exec, const List& args)
-{
- ExceptionCode ec = 0;
- JSValue* exception = 0;
- Node* node = impl()->nextNode(ec, exception);
- if (ec) {
- setDOMException(exec, ec);
- return jsUndefined();
- }
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSNodeIterator::previousNode(ExecState* exec, const List& args)
-{
- ExceptionCode ec = 0;
- JSValue* exception = 0;
- Node* node = impl()->previousNode(ec, exception);
- if (ec) {
- setDOMException(exec, ec);
- return jsUndefined();
- }
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
}
diff --git a/WebCore/bindings/js/JSSVGPODTypeWrapper.h b/WebCore/bindings/js/JSSVGPODTypeWrapper.h
index 1275950..03cb401 100644
--- a/WebCore/bindings/js/JSSVGPODTypeWrapper.h
+++ b/WebCore/bindings/js/JSSVGPODTypeWrapper.h
@@ -38,9 +38,9 @@
namespace WebCore {
template<typename PODType>
-class JSSVGPODTypeWrapper : public RefCounted<JSSVGPODTypeWrapper<PODType> > {
+class JSSVGPODTypeWrapper : public RefCounted<JSSVGPODTypeWrapper<PODType> >
+{
public:
- JSSVGPODTypeWrapper() : RefCounted<JSSVGPODTypeWrapper<PODType> >(0) { }
virtual ~JSSVGPODTypeWrapper() { }
// Getter wrapper
diff --git a/WebCore/bindings/js/JSSVGPointListCustom.cpp b/WebCore/bindings/js/JSSVGPointListCustom.cpp
index af4fc91..2c7127f 100644
--- a/WebCore/bindings/js/JSSVGPointListCustom.cpp
+++ b/WebCore/bindings/js/JSSVGPointListCustom.cpp
@@ -56,7 +56,7 @@ JSValue* JSSVGPointList::initialize(ExecState* exec, const List& args)
SVGPointList* imp = static_cast<SVGPointList*>(impl());
SVGList<RefPtr<SVGPODListItem<FloatPoint> > >* listImp = imp;
- SVGPODListItem<FloatPoint>* listItem = listImp->initialize(SVGPODListItem<FloatPoint>::copy(newItem), ec).get();
+ SVGPODListItem<FloatPoint>* listItem = listImp->initialize(new SVGPODListItem<FloatPoint>(newItem), ec).get();
JSSVGPODTypeWrapperCreatorForList<FloatPoint>* obj = new JSSVGPODTypeWrapperCreatorForList<FloatPoint>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -104,7 +104,7 @@ JSValue* JSSVGPointList::insertItemBefore(ExecState* exec, const List& args)
SVGPointList* imp = static_cast<SVGPointList*>(impl());
SVGList<RefPtr<SVGPODListItem<FloatPoint> > >* listImp = imp;
- SVGPODListItem<FloatPoint>* listItem = listImp->insertItemBefore(SVGPODListItem<FloatPoint>::copy(newItem), index, ec).get();
+ SVGPODListItem<FloatPoint>* listItem = listImp->insertItemBefore(new SVGPODListItem<FloatPoint>(newItem), index, ec).get();
JSSVGPODTypeWrapperCreatorForList<FloatPoint>* obj = new JSSVGPODTypeWrapperCreatorForList<FloatPoint>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -130,7 +130,7 @@ JSValue* JSSVGPointList::replaceItem(ExecState* exec, const List& args)
SVGPointList* imp = static_cast<SVGPointList*>(impl());
SVGList<RefPtr<SVGPODListItem<FloatPoint> > >* listImp = imp;
- SVGPODListItem<FloatPoint>* listItem = listImp->replaceItem(SVGPODListItem<FloatPoint>::copy(newItem), index, ec).get();
+ SVGPODListItem<FloatPoint>* listItem = listImp->replaceItem(new SVGPODListItem<FloatPoint>(newItem), index, ec).get();
JSSVGPODTypeWrapperCreatorForList<FloatPoint>* obj = new JSSVGPODTypeWrapperCreatorForList<FloatPoint>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -174,7 +174,7 @@ JSValue* JSSVGPointList::appendItem(ExecState* exec, const List& args)
SVGPointList* imp = static_cast<SVGPointList*>(impl());
SVGList<RefPtr<SVGPODListItem<FloatPoint> > >* listImp = imp;
- SVGPODListItem<FloatPoint>* listItem = listImp->appendItem(SVGPODListItem<FloatPoint>::copy(newItem), ec).get();
+ SVGPODListItem<FloatPoint>* listItem = listImp->appendItem(new SVGPODListItem<FloatPoint>(newItem), ec).get();
JSSVGPODTypeWrapperCreatorForList<FloatPoint>* obj = new JSSVGPODTypeWrapperCreatorForList<FloatPoint>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
diff --git a/WebCore/bindings/js/JSSVGTransformListCustom.cpp b/WebCore/bindings/js/JSSVGTransformListCustom.cpp
index d3d8d25..1251131 100644
--- a/WebCore/bindings/js/JSSVGTransformListCustom.cpp
+++ b/WebCore/bindings/js/JSSVGTransformListCustom.cpp
@@ -56,7 +56,7 @@ JSValue* JSSVGTransformList::initialize(ExecState* exec, const List& args)
SVGTransformList* imp = static_cast<SVGTransformList*>(impl());
SVGList<RefPtr<SVGPODListItem<SVGTransform> > >* listImp = imp;
- SVGPODListItem<SVGTransform>* listItem = listImp->initialize(SVGPODListItem<SVGTransform>::copy(newItem), ec).get();
+ SVGPODListItem<SVGTransform>* listItem = listImp->initialize(new SVGPODListItem<SVGTransform>(newItem), ec).get();
JSSVGPODTypeWrapperCreatorForList<SVGTransform>* obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -104,7 +104,7 @@ JSValue* JSSVGTransformList::insertItemBefore(ExecState* exec, const List& args)
SVGTransformList* imp = static_cast<SVGTransformList*>(impl());
SVGList<RefPtr<SVGPODListItem<SVGTransform> > >* listImp = imp;
- SVGPODListItem<SVGTransform>* listItem = listImp->insertItemBefore(SVGPODListItem<SVGTransform>::copy(newItem), index, ec).get();
+ SVGPODListItem<SVGTransform>* listItem = listImp->insertItemBefore(new SVGPODListItem<SVGTransform>(newItem), index, ec).get();
JSSVGPODTypeWrapperCreatorForList<SVGTransform>* obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -130,7 +130,7 @@ JSValue* JSSVGTransformList::replaceItem(ExecState* exec, const List& args)
SVGTransformList* imp = static_cast<SVGTransformList*>(impl());
SVGList<RefPtr<SVGPODListItem<SVGTransform> > >* listImp = imp;
- SVGPODListItem<SVGTransform>* listItem = listImp->replaceItem(SVGPODListItem<SVGTransform>::copy(newItem), index, ec).get();
+ SVGPODListItem<SVGTransform>* listItem = listImp->replaceItem(new SVGPODListItem<SVGTransform>(newItem), index, ec).get();
JSSVGPODTypeWrapperCreatorForList<SVGTransform>* obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
@@ -174,7 +174,7 @@ JSValue* JSSVGTransformList::appendItem(ExecState* exec, const List& args)
SVGTransformList* imp = static_cast<SVGTransformList*>(impl());
SVGList<RefPtr<SVGPODListItem<SVGTransform> > >* listImp = imp;
- SVGPODListItem<SVGTransform>* listItem = listImp->appendItem(SVGPODListItem<SVGTransform>::copy(newItem), ec).get();
+ SVGPODListItem<SVGTransform>* listItem = listImp->appendItem(new SVGPODListItem<SVGTransform>(newItem), ec).get();
JSSVGPODTypeWrapperCreatorForList<SVGTransform>* obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
KJS::JSValue* result = toJS(exec, obj, m_context.get());
diff --git a/WebCore/bindings/js/JSTreeWalkerCustom.cpp b/WebCore/bindings/js/JSTreeWalkerCustom.cpp
index c9dbcd9..c73fe40 100644
--- a/WebCore/bindings/js/JSTreeWalkerCustom.cpp
+++ b/WebCore/bindings/js/JSTreeWalkerCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,17 +16,12 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-
#include "config.h"
#include "JSTreeWalker.h"
-#include "JSNode.h"
-#include "Node.h"
#include "NodeFilter.h"
#include "TreeWalker.h"
-using namespace KJS;
-
namespace WebCore {
void JSTreeWalker::mark()
@@ -37,81 +32,4 @@ void JSTreeWalker::mark()
DOMObject::mark();
}
-JSValue* JSTreeWalker::parentNode(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->parentNode(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::firstChild(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->firstChild(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::lastChild(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->lastChild(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::nextSibling(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->nextSibling(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::previousSibling(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->previousSibling(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::previousNode(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->previousNode(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
-JSValue* JSTreeWalker::nextNode(ExecState* exec, const List& args)
-{
- JSValue* exception = 0;
- Node* node = impl()->nextNode(exception);
- if (exception) {
- exec->setException(exception);
- return jsUndefined();
- }
- return toJS(exec, node);
-}
-
}
diff --git a/WebCore/bindings/js/JSXMLHttpRequest.cpp b/WebCore/bindings/js/JSXMLHttpRequest.cpp
index 99d89f5..1d9b281 100644
--- a/WebCore/bindings/js/JSXMLHttpRequest.cpp
+++ b/WebCore/bindings/js/JSXMLHttpRequest.cpp
@@ -31,12 +31,13 @@
#include "kjs_events.h"
#include "kjs_window.h"
-using namespace KJS;
-using namespace WebCore;
-
#include "JSXMLHttpRequest.lut.h"
-namespace WebCore {
+namespace KJS {
+
+using namespace WebCore;
+
+////////////////////// JSXMLHttpRequest Object ////////////////////////
/* Source for JSXMLHttpRequestPrototypeTable.
@begin JSXMLHttpRequestPrototypeTable 7
@@ -138,12 +139,12 @@ JSValue* JSXMLHttpRequest::getValueProperty(ExecState* exec, int token) const
}
}
-void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- lookupPut<JSXMLHttpRequest, DOMObject>(exec, propertyName, value, &JSXMLHttpRequestTable, this);
+ lookupPut<JSXMLHttpRequest,DOMObject>(exec, propertyName, value, attr, &JSXMLHttpRequestTable, this );
}
-void JSXMLHttpRequest::putValueProperty(ExecState* exec, int token, JSValue* value)
+void JSXMLHttpRequest::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
switch (token) {
case Onreadystatechange: {
@@ -196,7 +197,7 @@ void JSXMLHttpRequest::mark()
JSXMLHttpRequest::JSXMLHttpRequest(JSObject* prototype, Document* d)
: DOMObject(prototype)
- , m_impl(XMLHttpRequest::create(d))
+ , m_impl(new XMLHttpRequest(d))
{
ScriptInterpreter::putDOMObject(m_impl.get(), this);
}
@@ -249,6 +250,7 @@ JSValue* jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState* exec, JSO
return header;
}
+
JSValue* jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSXMLHttpRequest::info))
@@ -264,7 +266,7 @@ JSValue* jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec, JSObject* thisOb
Frame* frame = Window::retrieveActive(exec)->impl()->frame();
if (!frame)
return jsUndefined();
- KURL url = frame->loader()->completeURL(args[1]->toString(exec));
+ KURL url = frame->loader()->completeURL(DeprecatedString(args[1]->toString(exec)));
bool async = true;
if (args.size() >= 3)
@@ -296,9 +298,10 @@ JSValue* jsXMLHttpRequestPrototypeFunctionSend(ExecState* exec, JSObject* thisOb
String body;
if (args.size() >= 1) {
- if (args[0]->toObject(exec)->inherits(&JSDocument::info))
- body = static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl())->toString();
- else {
+ if (args[0]->toObject(exec)->inherits(&JSDocument::info)) {
+ Document* doc = static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl());
+ body = doc->toString().deprecatedString();
+ } else {
// converting certain values (like null) to object can set an exception
if (exec->hadException())
exec->clearException();
diff --git a/WebCore/bindings/js/JSXMLHttpRequest.h b/WebCore/bindings/js/JSXMLHttpRequest.h
index 6567a6b..23ea7d0 100644
--- a/WebCore/bindings/js/JSXMLHttpRequest.h
+++ b/WebCore/bindings/js/JSXMLHttpRequest.h
@@ -1,5 +1,7 @@
+// -*- c-basic-offset: 2 -*-
/*
- * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
+ * This file is part of the KDE libraries
+ * Copyright (C) 2003 Apple Computer, Inc.
* Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com>
*
* This library is free software; you can redistribute it and/or
@@ -27,52 +29,56 @@ namespace WebCore {
class XMLHttpRequest;
class Document;
+}
+
+namespace KJS {
+
class JSXMLHttpRequestConstructorImp : public DOMObject {
public:
- JSXMLHttpRequestConstructorImp(KJS::ExecState*, Document*);
+ JSXMLHttpRequestConstructorImp(ExecState*, WebCore::Document*);
virtual bool implementsConstruct() const;
- virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List&);
+ virtual JSObject* construct(ExecState*, const List&);
private:
- RefPtr<Document> doc;
+ RefPtr<WebCore::Document> doc;
};
class JSXMLHttpRequest : public DOMObject {
public:
- JSXMLHttpRequest(KJS::JSObject* prototype, Document*);
+ JSXMLHttpRequest(JSObject* prototype, WebCore::Document*);
~JSXMLHttpRequest();
- virtual const KJS::ClassInfo* classInfo() const { return &info; }
- static const KJS::ClassInfo info;
+ virtual const ClassInfo* classInfo() const { return &info; }
+ static const ClassInfo info;
enum { Onload, Onreadystatechange, ReadyState, ResponseText, ResponseXML, Status,
StatusText, Abort, GetAllResponseHeaders, GetResponseHeader, Open, Send, SetRequestHeader, OverrideMIMEType,
AddEventListener, RemoveEventListener, DispatchEvent };
- virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
- KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::JSValue*);
- void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*);
- virtual bool toBoolean(KJS::ExecState*) const { return true; }
+ virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
+ JSValue* getValueProperty(ExecState*, int token) const;
+ virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None);
+ void putValueProperty(ExecState*, int token, JSValue* value, int /*attr*/);
+ virtual bool toBoolean(ExecState*) const { return true; }
virtual void mark();
- XMLHttpRequest* impl() const { return m_impl.get(); }
+ WebCore::XMLHttpRequest* impl() const { return m_impl.get(); }
private:
- RefPtr<XMLHttpRequest> m_impl;
+ RefPtr<WebCore::XMLHttpRequest> m_impl;
};
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionAbort(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionGetResponseHeader(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionOpen(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionSend(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionSetRequestHeader(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionOverrideMIMEType(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionAddEventListener(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionRemoveEventListener(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXMLHttpRequestPrototypeFunctionDispatchEvent(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-
-} // namespace WebCore
+JSValue* jsXMLHttpRequestPrototypeFunctionAbort(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionOpen(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionSend(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionSetRequestHeader(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionOverrideMIMEType(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionAddEventListener(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionRemoveEventListener(ExecState*, JSObject*, const List&);
+JSValue* jsXMLHttpRequestPrototypeFunctionDispatchEvent(ExecState*, JSObject*, const List&);
+
+} // namespace KJS
#endif // JSXMLHttpRequest_h
diff --git a/WebCore/bindings/js/JSXSLTProcessor.cpp b/WebCore/bindings/js/JSXSLTProcessor.cpp
index 7902f61..20481fe 100644
--- a/WebCore/bindings/js/JSXSLTProcessor.cpp
+++ b/WebCore/bindings/js/JSXSLTProcessor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 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
@@ -30,17 +30,15 @@
#include "JSXSLTProcessor.h"
#include "XSLTProcessor.h"
+#include "JSXSLTProcessor.lut.h"
#include "kjs_dom.h"
#include "JSDocument.h"
#include "Document.h"
#include "DocumentFragment.h"
-using namespace KJS;
using namespace WebCore;
-#include "JSXSLTProcessor.lut.h"
-
-namespace WebCore {
+namespace KJS {
const ClassInfo JSXSLTProcessor::info = { "XSLTProcessor", 0, 0 };
@@ -62,7 +60,7 @@ KJS_IMPLEMENT_PROTOTYPE("XSLTProcessor", XSLTProcessorPrototype)
JSXSLTProcessor::JSXSLTProcessor(JSObject* prototype)
: DOMObject(prototype)
- , m_impl(XSLTProcessor::create())
+ , m_impl(new XSLTProcessor())
{
}
@@ -73,7 +71,7 @@ JSXSLTProcessor::~JSXSLTProcessor()
JSValue* jsXSLTProcessorPrototypeFunctionImportStylesheet(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -89,7 +87,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionImportStylesheet(ExecState* exec, JSObj
JSValue* jsXSLTProcessorPrototypeFunctionTransformToFragment(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -106,7 +104,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionTransformToFragment(ExecState* exec, JS
JSValue* jsXSLTProcessorPrototypeFunctionTransformToDocument(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -124,7 +122,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionTransformToDocument(ExecState* exec, JS
JSValue* jsXSLTProcessorPrototypeFunctionSetParameter(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -139,7 +137,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionSetParameter(ExecState* exec, JSObject*
JSValue* jsXSLTProcessorPrototypeFunctionGetParameter(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -155,7 +153,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionGetParameter(ExecState* exec, JSObject*
JSValue* jsXSLTProcessorPrototypeFunctionRemoveParameter(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -169,7 +167,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionRemoveParameter(ExecState* exec, JSObje
JSValue* jsXSLTProcessorPrototypeFunctionClearParameters(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -179,7 +177,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionClearParameters(ExecState* exec, JSObje
JSValue* jsXSLTProcessorPrototypeFunctionReset(ExecState* exec, JSObject* thisObj, const List& args)
{
- if (!thisObj->inherits(&JSXSLTProcessor::info))
+ if (!thisObj->inherits(&KJS::JSXSLTProcessor::info))
return throwError(exec, TypeError);
XSLTProcessor& processor = *static_cast<JSXSLTProcessor*>(thisObj)->impl();
@@ -187,7 +185,7 @@ JSValue* jsXSLTProcessorPrototypeFunctionReset(ExecState* exec, JSObject* thisOb
return jsUndefined();
}
-XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState* exec)
+XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState *exec)
: DOMObject(exec->lexicalGlobalObject()->objectPrototype())
{
putDirect(exec->propertyNames().prototype, XSLTProcessorPrototype::self(exec), None);
diff --git a/WebCore/bindings/js/JSXSLTProcessor.h b/WebCore/bindings/js/JSXSLTProcessor.h
index 26ba6b3..05cde1e 100644
--- a/WebCore/bindings/js/JSXSLTProcessor.h
+++ b/WebCore/bindings/js/JSXSLTProcessor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,45 +31,46 @@
#include "kjs_binding.h"
namespace WebCore {
-
-class XSLTProcessor;
+ class XSLTProcessor;
+}
// Eventually we should implement XSLTException:
// http://lxr.mozilla.org/seamonkey/source/content/xsl/public/nsIXSLTException.idl
// http://bugs.webkit.org/show_bug.cgi?id=5446
+namespace KJS {
+
class JSXSLTProcessor : public DOMObject {
public:
- JSXSLTProcessor(KJS::JSObject* prototype);
+ JSXSLTProcessor(JSObject* prototype);
~JSXSLTProcessor();
- virtual const KJS::ClassInfo* classInfo() const { return &info; }
- static const KJS::ClassInfo info;
-
- XSLTProcessor* impl() const { return m_impl.get(); }
+ virtual const ClassInfo *classInfo() const { return &info; }
+ static const ClassInfo info;
+ WebCore::XSLTProcessor *impl() const { return m_impl.get(); }
private:
- RefPtr<XSLTProcessor> m_impl;
+ RefPtr<WebCore::XSLTProcessor> m_impl;
};
class XSLTProcessorConstructorImp : public DOMObject {
public:
- XSLTProcessorConstructorImp(KJS::ExecState*);
+ XSLTProcessorConstructorImp(ExecState*);
virtual bool implementsConstruct() const;
- virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List&);
+ virtual JSObject* construct(ExecState*, const List&);
};
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionImportStylesheet(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionTransformToFragment(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionTransformToDocument(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionSetParameter(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionGetParameter(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionRemoveParameter(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionClearParameters(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
-KJS::JSValue* jsXSLTProcessorPrototypeFunctionReset(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
+JSValue* jsXSLTProcessorPrototypeFunctionImportStylesheet(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionTransformToFragment(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionTransformToDocument(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionSetParameter(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionGetParameter(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionRemoveParameter(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionClearParameters(ExecState*, JSObject*, const List&);
+JSValue* jsXSLTProcessorPrototypeFunctionReset(ExecState*, JSObject*, const List&);
-} // namespace WebCore
+} // namespace KJS
#endif // ENABLE(XSLT)
diff --git a/WebCore/bindings/js/kjs_binding.cpp b/WebCore/bindings/js/kjs_binding.cpp
index 5855ca0..31078c7 100644
--- a/WebCore/bindings/js/kjs_binding.cpp
+++ b/WebCore/bindings/js/kjs_binding.cpp
@@ -36,7 +36,6 @@
#include "JSNode.h"
#include "JSRangeException.h"
#include "JSXMLHttpRequestException.h"
-#include "KURL.h"
#include "RangeException.h"
#include "XMLHttpRequestException.h"
#include "kjs_window.h"
@@ -52,10 +51,12 @@
#endif
using namespace KJS;
+using namespace WebCore;
+using namespace HTMLNames;
-namespace WebCore {
+// FIXME: Move all this stuff into the WebCore namespace.
-using namespace HTMLNames;
+namespace KJS {
typedef HashMap<void*, DOMObject*> DOMObjectMap;
typedef HashMap<WebCore::Node*, JSNode*> NodeMap;
@@ -261,27 +262,6 @@ JSValue* jsStringOrFalse(const String& s)
return jsString(s);
}
-JSValue* jsStringOrNull(const KURL& url)
-{
- if (url.isNull())
- return jsNull();
- return jsString(url.string());
-}
-
-JSValue* jsStringOrUndefined(const KURL& url)
-{
- if (url.isNull())
- return jsUndefined();
- return jsString(url.string());
-}
-
-JSValue* jsStringOrFalse(const KURL& url)
-{
- if (url.isNull())
- return jsBoolean(false);
- return jsString(url.string());
-}
-
String valueToStringWithNullCheck(ExecState* exec, JSValue* val)
{
if (val->isNull())
@@ -340,6 +320,10 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
exec->setException(errorObject);
}
+} // namespace KJS
+
+namespace WebCore {
+
bool allowsAccessFromFrame(ExecState* exec, Frame* frame)
{
if (!frame)
diff --git a/WebCore/bindings/js/kjs_binding.h b/WebCore/bindings/js/kjs_binding.h
index fb95652..00e98d5 100644
--- a/WebCore/bindings/js/kjs_binding.h
+++ b/WebCore/bindings/js/kjs_binding.h
@@ -31,12 +31,10 @@
#endif
namespace WebCore {
-
class AtomicString;
class Document;
class Event;
class Frame;
- class KURL;
class Node;
class String;
class JSNode;
@@ -46,16 +44,21 @@ namespace WebCore {
#if ENABLE(SVG)
class SVGElement;
#endif
+}
+
+namespace KJS {
- // Base class for all objects in this binding except Window.
- class DOMObject : public KJS::JSObject {
+ /**
+ * Base class for all objects in this binding EXCEPT Window
+ */
+ class DOMObject : public JSObject {
protected:
- explicit DOMObject(KJS::JSValue* prototype) // FIXME: this should take a JSObject once JSLocation has a real prototype
+ explicit DOMObject(JSValue* prototype) // FIXME: this should take a JSObject once JSLocation has a real prototype
: JSObject(prototype)
{
// DOMObject destruction is not thread-safe because DOMObjects wrap
// unsafe WebCore DOM data structures.
- KJS::Collector::collectOnMainThreadOnly(this);
+ Collector::collectOnMainThreadOnly(this);
}
#ifndef NDEBUG
@@ -66,25 +69,27 @@ namespace WebCore {
DOMObject();
};
- class ScriptInterpreter : public KJS::Interpreter {
+ class ScriptInterpreter : public Interpreter {
public:
static DOMObject* getDOMObject(void* objectHandle);
static void putDOMObject(void* objectHandle, DOMObject*);
static void forgetDOMObject(void* objectHandle);
- static JSNode* getDOMNodeForDocument(Document*, Node*);
- static void putDOMNodeForDocument(Document*, Node*, JSNode* nodeWrapper);
- static void forgetDOMNodeForDocument(Document*, Node*);
- static void forgetAllDOMNodesForDocument(Document*);
- static void updateDOMNodeDocument(Node*, Document* oldDoc, Document* newDoc);
- static void markDOMNodesForDocument(Document*);
+ static WebCore::JSNode* getDOMNodeForDocument(WebCore::Document*, WebCore::Node*);
+ static void putDOMNodeForDocument(WebCore::Document*, WebCore::Node*, WebCore::JSNode* nodeWrapper);
+ static void forgetDOMNodeForDocument(WebCore::Document*, WebCore::Node*);
+ static void forgetAllDOMNodesForDocument(WebCore::Document*);
+ static void updateDOMNodeDocument(WebCore::Node*, WebCore::Document* oldDoc, WebCore::Document* newDoc);
+ static void markDOMNodesForDocument(WebCore::Document*);
};
- // Retrieve from cache, or create, a JS wrapper for a DOM object.
- template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline KJS::JSValue* cacheDOMObject(KJS::ExecState* exec, DOMObj* domObj)
+ /**
+ * Retrieve from cache, or create, a JS object around a DOM object
+ */
+ template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline JSValue* cacheDOMObject(ExecState* exec, DOMObj* domObj)
{
if (!domObj)
- return KJS::jsNull();
+ return jsNull();
if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj))
return ret;
DOMObject* ret = new JSDOMObj(JSDOMObjPrototype::self(exec), domObj);
@@ -93,11 +98,13 @@ namespace WebCore {
}
#if ENABLE(SVG)
- // Retrieve from cache, or create, a JS wrapper for an SVG DOM object.
- template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline KJS::JSValue* cacheSVGDOMObject(KJS::ExecState* exec, DOMObj* domObj, SVGElement* context)
+ /**
+ * Retrieve from cache, or create, a JS object around a SVG DOM object
+ */
+ template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline JSValue* cacheSVGDOMObject(ExecState* exec, DOMObj* domObj, WebCore::SVGElement* context)
{
if (!domObj)
- return KJS::jsNull();
+ return jsNull();
if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj))
return ret;
DOMObject* ret = new JSDOMObj(JSDOMObjPrototype::self(exec), domObj, context);
@@ -107,36 +114,35 @@ namespace WebCore {
#endif
// Convert a DOM implementation exception code into a JavaScript exception in the execution state.
- void setDOMException(KJS::ExecState*, ExceptionCode);
+ void setDOMException(ExecState*, WebCore::ExceptionCode);
// Helper class to call setDOMException on exit without adding lots of separate calls to that function.
class DOMExceptionTranslator : Noncopyable {
public:
- explicit DOMExceptionTranslator(KJS::ExecState* exec) : m_exec(exec), m_code(0) { }
+ explicit DOMExceptionTranslator(ExecState* exec) : m_exec(exec), m_code(0) { }
~DOMExceptionTranslator() { setDOMException(m_exec, m_code); }
- operator ExceptionCode&() { return m_code; }
+ operator WebCore::ExceptionCode&() { return m_code; }
private:
- KJS::ExecState* m_exec;
- ExceptionCode m_code;
+ ExecState* m_exec;
+ WebCore::ExceptionCode m_code;
};
- KJS::JSValue* jsStringOrNull(const String&); // null if the string is null
- KJS::JSValue* jsStringOrNull(const KURL&); // null if the URL is null
+ JSValue* jsStringOrNull(const WebCore::String&); // null if the string is null
+ JSValue* jsStringOrUndefined(const WebCore::String&); // undefined if the string is null
+ JSValue* jsStringOrFalse(const WebCore::String&); // boolean false if the string is null
- KJS::JSValue* jsStringOrUndefined(const String&); // undefined if the string is null
- KJS::JSValue* jsStringOrUndefined(const KURL&); // undefined if the URL is null
+ // see JavaScriptCore for explanation should be used for UString that is already owned
+ // by another object, so that collecting the JSString wrapper is unlikely to save memory.
+ JSValue* jsOwnedStringOrNull(const KJS::UString&);
- KJS::JSValue* jsStringOrFalse(const String&); // boolean false if the string is null
- KJS::JSValue* jsStringOrFalse(const KURL&); // boolean false if the URL is null
+ WebCore::String valueToStringWithNullCheck(ExecState*, JSValue*); // null String if the value is null
+ WebCore::String valueToStringWithUndefinedOrNullCheck(ExecState*, JSValue*); // null String if the value is null or undefined
- // See JavaScriptCore for explanation: Should be used for any UString that is already owned by another
- // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
- KJS::JSValue* jsOwnedStringOrNull(const KJS::UString&);
+ template <typename T> inline JSValue* toJS(ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
- String valueToStringWithNullCheck(KJS::ExecState*, KJS::JSValue*); // null String if the value is null
- String valueToStringWithUndefinedOrNullCheck(KJS::ExecState*, KJS::JSValue*); // null String if the value is null or undefined
+} // namespace KJS
- template <typename T> inline KJS::JSValue* toJS(KJS::ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
+namespace WebCore {
// Helpers for Window, History, and Location classes to implement cross-domain policy.
// Besides the cross-domain check, they need non-caching versions of staticFunctionGetter for
@@ -144,6 +150,7 @@ namespace WebCore {
bool allowsAccessFromFrame(KJS::ExecState*, Frame*);
bool allowsAccessFromFrame(KJS::ExecState*, Frame*, String& message);
void printErrorMessageForFrame(Frame*, const String& message);
+
KJS::JSValue* nonCachingStaticFunctionGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier& propertyName, const KJS::PropertySlot&);
KJS::JSValue* objectToStringFunctionGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier& propertyName, const KJS::PropertySlot&);
diff --git a/WebCore/bindings/js/kjs_css.h b/WebCore/bindings/js/kjs_css.h
index 5a42e0c..d7f14aa 100644
--- a/WebCore/bindings/js/kjs_css.h
+++ b/WebCore/bindings/js/kjs_css.h
@@ -28,7 +28,7 @@
namespace WebCore {
- class JSRGBColor : public DOMObject {
+ class JSRGBColor : public KJS::DOMObject {
public:
JSRGBColor(KJS::JSObject* prototype, unsigned color);
~JSRGBColor();
diff --git a/WebCore/bindings/js/kjs_dom.cpp b/WebCore/bindings/js/kjs_dom.cpp
index e718d41..0f8c616 100644
--- a/WebCore/bindings/js/kjs_dom.cpp
+++ b/WebCore/bindings/js/kjs_dom.cpp
@@ -87,7 +87,7 @@ JSValue* toJS(ExecState* exec, EventTarget* target)
return jsNull();
}
-JSObject* getRuntimeObject(ExecState* exec, Node* n)
+JSValue* getRuntimeObject(ExecState* exec, Node* n)
{
if (!n)
return 0;
diff --git a/WebCore/bindings/js/kjs_dom.h b/WebCore/bindings/js/kjs_dom.h
index 6e0f136..413e627 100644
--- a/WebCore/bindings/js/kjs_dom.h
+++ b/WebCore/bindings/js/kjs_dom.h
@@ -32,7 +32,7 @@ namespace WebCore {
Attr* toAttr(KJS::JSValue*, bool& ok);
bool checkNodeSecurity(KJS::ExecState*, Node*);
- KJS::JSObject* getRuntimeObject(KJS::ExecState*, Node*);
+ KJS::JSValue* getRuntimeObject(KJS::ExecState*, Node*);
KJS::JSValue* toJS(KJS::ExecState*, EventTarget*);
KJS::JSObject* getNodeConstructor(KJS::ExecState*);
diff --git a/WebCore/bindings/js/kjs_events.cpp b/WebCore/bindings/js/kjs_events.cpp
index f289209..8976c04 100644
--- a/WebCore/bindings/js/kjs_events.cpp
+++ b/WebCore/bindings/js/kjs_events.cpp
@@ -34,6 +34,7 @@
#include "HTMLNames.h"
#include "JSEvent.h"
#include "JSEventTargetNode.h"
+#include "KURL.h"
#include "Page.h"
#include "kjs_proxy.h"
#include "kjs_window.h"
@@ -404,12 +405,12 @@ JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const
}
}
-void JSClipboard::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSClipboard::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- lookupPut<JSClipboard, DOMObject>(exec, propertyName, value, &JSClipboardTable, this);
+ lookupPut<JSClipboard, DOMObject>(exec, propertyName, value, attr, &JSClipboardTable, this );
}
-void JSClipboard::putValueProperty(ExecState* exec, int token, JSValue* value)
+void JSClipboard::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
Clipboard* clipboard = impl();
switch (token) {
diff --git a/WebCore/bindings/js/kjs_events.h b/WebCore/bindings/js/kjs_events.h
index b488cc4..03d9f6c 100644
--- a/WebCore/bindings/js/kjs_events.h
+++ b/WebCore/bindings/js/kjs_events.h
@@ -97,15 +97,15 @@ namespace WebCore {
KJS::JSValue* getNodeEventListener(Node*, const AtomicString& eventType);
- class JSClipboard : public DOMObject {
+ class JSClipboard : public KJS::DOMObject {
public:
JSClipboard(KJS::JSObject* prototype, Clipboard*);
virtual ~JSClipboard();
virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*);
- void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*);
+ virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+ void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*, int attr);
virtual const KJS::ClassInfo* classInfo() const { return &info; }
static const KJS::ClassInfo info;
diff --git a/WebCore/bindings/js/kjs_html.cpp b/WebCore/bindings/js/kjs_html.cpp
index 8f2c7c4..c143c1e 100644
--- a/WebCore/bindings/js/kjs_html.cpp
+++ b/WebCore/bindings/js/kjs_html.cpp
@@ -84,6 +84,7 @@ JSValue* runtimeObjectGetter(ExecState* exec, JSObject* originalObject, const Id
{
JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
+
return getRuntimeObject(exec, element);
}
@@ -91,32 +92,37 @@ JSValue* runtimeObjectPropertyGetter(ExecState* exec, JSObject* originalObject,
{
JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
- JSObject* runtimeObject = getRuntimeObject(exec, element);
- if (!runtimeObject)
- return jsUndefined();
- return runtimeObject->get(exec, propertyName);
+
+ if (JSValue* runtimeObject = getRuntimeObject(exec, element))
+ return static_cast<JSObject*>(runtimeObject)->get(exec, propertyName);
+ return jsUndefined();
}
-bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, JSHTMLElement* originalObj, HTMLElement* thisImp)
+bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, WebCore::JSHTMLElement* originalObj, HTMLElement* thisImp)
{
- JSObject* runtimeObject = getRuntimeObject(exec, thisImp);
- if (!runtimeObject)
- return false;
- if (!runtimeObject->hasProperty(exec, propertyName))
- return false;
- slot.setCustom(originalObj, runtimeObjectPropertyGetter);
- return true;
+ JSValue* runtimeObject = getRuntimeObject(exec, thisImp);
+ if (runtimeObject) {
+ JSObject* imp = static_cast<JSObject*>(runtimeObject);
+ if (imp->hasProperty(exec, propertyName)) {
+ slot.setCustom(originalObj, runtimeObjectPropertyGetter);
+ return true;
+ }
+ }
+
+ return false;
}
-bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue* value, HTMLElement* thisImp)
+bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int /*attr*/, HTMLElement* thisImp)
{
- JSObject* runtimeObject = getRuntimeObject(exec, thisImp);
- if (!runtimeObject)
- return 0;
- if (!runtimeObject->hasProperty(exec, propertyName))
- return false;
- runtimeObject->put(exec, propertyName, value);
- return true;
+ if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp)) {
+ JSObject* imp = static_cast<JSObject*>(runtimeObject);
+ if (imp->canPut(exec, propertyName)) {
+ imp->put(exec, propertyName, value);
+ return true;
+ }
+ }
+
+ return false;
}
bool runtimeObjectImplementsCall(HTMLElement* thisImp)
@@ -125,18 +131,17 @@ bool runtimeObjectImplementsCall(HTMLElement* thisImp)
if (!frame)
return false;
ExecState* exec = frame->scriptProxy()->globalObject()->globalExec();
- JSObject* runtimeObject = getRuntimeObject(exec, thisImp);
- if (!runtimeObject)
- return false;
- return runtimeObject->implementsCall();
+ if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp))
+ return static_cast<JSObject*>(runtimeObject)->implementsCall();
+
+ return false;
}
JSValue* runtimeObjectCallAsFunction(ExecState* exec, JSObject* thisObj, const List& args, HTMLElement* thisImp)
{
- JSObject* runtimeObject = getRuntimeObject(exec, thisImp);
- if (!runtimeObject)
- return jsUndefined();
- return runtimeObject->call(exec, thisObj, args);
+ if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp))
+ return static_cast<JSObject*>(runtimeObject)->call(exec, thisObj, args);
+ return jsUndefined();
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/kjs_html.h b/WebCore/bindings/js/kjs_html.h
index 4b519d2..cebd299 100644
--- a/WebCore/bindings/js/kjs_html.h
+++ b/WebCore/bindings/js/kjs_html.h
@@ -1,5 +1,6 @@
// -*- c-basic-offset: 2 -*-
/*
+ * This file is part of the KDE libraries
* Copyright (C) 1999 Harri Porten (porten@kde.org)
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
*
@@ -30,7 +31,7 @@ namespace WebCore {
class HTMLElement;
class JSHTMLElement;
- class ImageConstructorImp : public DOMObject {
+ class ImageConstructorImp : public KJS::DOMObject {
public:
ImageConstructorImp(KJS::ExecState*, Document*);
@@ -48,7 +49,7 @@ namespace WebCore {
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*);
- bool runtimeObjectCustomPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, HTMLElement*);
+ bool runtimeObjectCustomPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr, HTMLElement*);
bool runtimeObjectImplementsCall(HTMLElement*);
KJS::JSValue* runtimeObjectCallAsFunction(KJS::ExecState*, KJS::JSObject*, const KJS::List&, HTMLElement*);
diff --git a/WebCore/bindings/js/kjs_navigator.cpp b/WebCore/bindings/js/kjs_navigator.cpp
index 6e9fbbd..dcdcf61 100644
--- a/WebCore/bindings/js/kjs_navigator.cpp
+++ b/WebCore/bindings/js/kjs_navigator.cpp
@@ -1,8 +1,9 @@
+// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 2000 Harri Porten (porten@kde.org)
* Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org)
* Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2003, 2004, 2005, 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 Lesser General Public
@@ -63,22 +64,21 @@
#define WEBCORE_NAVIGATOR_VENDOR_SUB ""
#endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
-using namespace KJS;
using namespace WebCore;
-namespace WebCore {
+namespace KJS {
class PluginBase : public DOMObject {
public:
- PluginBase(ExecState*);
+ PluginBase(ExecState *exec);
virtual ~PluginBase();
static void refresh(bool reload);
protected:
static void cachePluginDataIfNecessary();
- static Vector<PluginInfo*>* plugins;
- static Vector<MimeClassInfo*>* mimes;
+ static Vector<PluginInfo*> *plugins;
+ static Vector<MimeClassInfo*> *mimes;
private:
static int m_plugInCacheRefCount;
@@ -87,73 +87,73 @@ namespace WebCore {
class Plugins : public PluginBase {
public:
- Plugins(ExecState* exec) : PluginBase(exec) { }
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- JSValue* getValueProperty(ExecState*, int token) const;
+ Plugins(ExecState *exec) : PluginBase(exec) {};
+ virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+ JSValue *getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Length };
private:
- static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
- static JSValue* nameGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
+ static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+ static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
};
JSValue* pluginsFunctionRefresh(ExecState*, JSObject*, const List&);
class MimeTypes : public PluginBase {
public:
- MimeTypes(ExecState* exec) : PluginBase(exec) { };
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- JSValue* getValueProperty(ExecState*, int token) const;
+ MimeTypes(ExecState *exec) : PluginBase(exec) { };
+ virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+ JSValue *getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Length };
private:
- static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
- static JSValue* nameGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
+ static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+ static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
};
class Plugin : public PluginBase {
public:
- Plugin(ExecState* exec, PluginInfo* info) : PluginBase(exec), m_info(info) { }
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- JSValue* getValueProperty(ExecState*, int token) const;
+ Plugin(ExecState *exec, PluginInfo *info) : PluginBase(exec), m_info(info) { }
+ virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+ JSValue *getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Name, Filename, Description, Length };
private:
- static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
- static JSValue* nameGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
+ static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+ static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
- PluginInfo* m_info;
+ PluginInfo *m_info;
};
class MimeType : public PluginBase {
public:
- MimeType(ExecState* exec, MimeClassInfo* info) : PluginBase(exec), m_info(info) { }
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- JSValue* getValueProperty(ExecState*, int token) const;
+ MimeType( ExecState *exec, MimeClassInfo *info ) : PluginBase(exec), m_info(info) { }
+ virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+ JSValue *getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Type, Suffixes, Description, EnabledPlugin };
private:
- MimeClassInfo* m_info;
+ MimeClassInfo *m_info;
};
-}
+} // namespace
#include "kjs_navigator.lut.h"
-namespace WebCore {
+namespace KJS {
const ClassInfo Plugins::info = { "PluginArray", 0, &PluginsTable };
const ClassInfo MimeTypes::info = { "MimeTypeArray", 0, &MimeTypesTable };
const ClassInfo Plugin::info = { "Plugin", 0, &PluginTable };
const ClassInfo MimeType::info = { "MimeType", 0, &MimeTypeTable };
-Vector<PluginInfo*>* PluginBase::plugins = 0;
-Vector<MimeClassInfo*>* PluginBase::mimes = 0;
-int PluginBase::m_plugInCacheRefCount = 0;
+Vector<PluginInfo*> *KJS::PluginBase::plugins = 0;
+Vector<MimeClassInfo*> *KJS::PluginBase::mimes = 0;
+int KJS::PluginBase::m_plugInCacheRefCount = 0;
const ClassInfo Navigator::info = { "Navigator", 0, &NavigatorTable };
/*
@@ -181,7 +181,7 @@ Navigator::Navigator(JSObject* prototype, Frame* frame)
{
}
-bool Navigator::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+bool Navigator::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticPropertySlot<Navigator, JSObject>(exec, &NavigatorTable, this, propertyName, slot);
}
@@ -213,7 +213,7 @@ static bool needsYouTubeQuirk(ExecState* exec, Frame* frame)
// Do the quirk only if the function is called by an "isSafari" function.
// However, that function is not itself named -- it is stored in the isSafari
- // property, though, so that's how we recognize it.
+ // property, though, so that's how recognize it.
ExecState* callingExec = exec->callingExecState();
if (!callingExec)
return false;
@@ -228,9 +228,9 @@ static bool needsYouTubeQuirk(ExecState* exec, Frame* frame)
if (isSafariFunction != callingFunction)
return false;
- Document* document = frame->document();
// FIXME: The document is never null, so we should remove this check along with the
// other similar ones in this file when we are absolutely sure it's safe.
+ Document* document = frame->document();
if (!document)
return false;
@@ -370,30 +370,30 @@ void PluginBase::refresh(bool reload)
@end
*/
-JSValue* Plugins::getValueProperty(ExecState* exec, int token) const
+JSValue *Plugins::getValueProperty(ExecState *exec, int token) const
{
ASSERT(token == Length);
return jsNumber(plugins->size());
}
-JSValue* Plugins::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *Plugins::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
return new Plugin(exec, plugins->at(slot.index()));
}
-JSValue* Plugins::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *Plugins::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
AtomicString atomicPropertyName = propertyName;
Vector<PluginInfo*>::iterator end = plugins->end();
for (Vector<PluginInfo*>::iterator itr = plugins->begin(); itr != end; itr++) {
- PluginInfo* pl = *itr;
+ PluginInfo *pl = *itr;
if (pl->name == atomicPropertyName)
return new Plugin(exec, pl);
}
return jsUndefined();
}
-bool Plugins::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+bool Plugins::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
const HashEntry* entry = Lookup::findEntry(&PluginsTable, propertyName);
if (entry) {
@@ -433,30 +433,30 @@ bool Plugins::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName
@end
*/
-JSValue* MimeTypes::getValueProperty(ExecState* exec, int token) const
+JSValue *MimeTypes::getValueProperty(ExecState *exec, int token) const
{
ASSERT(token == Length);
return jsNumber(mimes->size());
}
-JSValue* MimeTypes::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *MimeTypes::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
return new MimeType(exec, mimes->at(slot.index()));
}
-JSValue* MimeTypes::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *MimeTypes::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
AtomicString atomicPropertyName = propertyName;
Vector<MimeClassInfo*>::iterator end = mimes->end();
for (Vector<MimeClassInfo*>::iterator itr = mimes->begin(); itr != end; itr++) {
- MimeClassInfo* m = (*itr);
+ MimeClassInfo *m = (*itr);
if (m->type == atomicPropertyName)
return new MimeType(exec, m);
}
return jsUndefined();
}
-bool MimeTypes::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+bool MimeTypes::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
const HashEntry* entry = Lookup::findEntry(&MimeTypesTable, propertyName);
if (entry) {
@@ -497,7 +497,7 @@ bool MimeTypes::getOwnPropertySlot(ExecState* exec, const Identifier& propertyNa
@end
*/
-JSValue* Plugin::getValueProperty(ExecState* exec, int token) const
+JSValue *Plugin::getValueProperty(ExecState *exec, int token) const
{
switch (token) {
case Name:
@@ -514,19 +514,19 @@ JSValue* Plugin::getValueProperty(ExecState* exec, int token) const
}
}
-JSValue* Plugin::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *Plugin::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
- Plugin* thisObj = static_cast<Plugin*>(slot.slotBase());
+ Plugin *thisObj = static_cast<Plugin *>(slot.slotBase());
return new MimeType(exec, thisObj->m_info->mimes.at(slot.index()));
}
-JSValue* Plugin::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *Plugin::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
- Plugin* thisObj = static_cast<Plugin*>(slot.slotBase());
+ Plugin *thisObj = static_cast<Plugin *>(slot.slotBase());
AtomicString atomicPropertyName = propertyName;
Vector<MimeClassInfo*>::iterator end = thisObj->m_info->mimes.end();
for (Vector<MimeClassInfo*>::iterator itr = thisObj->m_info->mimes.begin(); itr != end; itr++) {
- MimeClassInfo* m = (*itr);
+ MimeClassInfo *m = (*itr);
if (m->type == atomicPropertyName)
return new MimeType(exec, m);
}
@@ -534,7 +534,7 @@ JSValue* Plugin::nameGetter(ExecState* exec, JSObject* originalObject, const Ide
}
-bool Plugin::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+bool Plugin::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
const HashEntry* entry = Lookup::findEntry(&PluginTable, propertyName);
if (entry) {
@@ -574,7 +574,7 @@ bool Plugin::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName,
@end
*/
-JSValue* MimeType::getValueProperty(ExecState* exec, int token) const
+JSValue *MimeType::getValueProperty(ExecState *exec, int token) const
{
switch (token) {
case Type:
@@ -597,7 +597,7 @@ JSValue* MimeType::getValueProperty(ExecState* exec, int token) const
}
}
-bool MimeType::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+bool MimeType::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticValueSlot<MimeType, PluginBase>(exec, &MimeTypeTable, this, propertyName, slot);
}
@@ -610,11 +610,12 @@ JSValue* pluginsFunctionRefresh(ExecState* exec, JSObject*, const List& args)
JSValue* navigatorProtoFuncJavaEnabled(ExecState* exec, JSObject* thisObj, const List&)
{
- if (!thisObj->inherits(&Navigator::info))
- return throwError(exec, TypeError);
- Navigator* nav = static_cast<Navigator*>(thisObj);
- Settings* settings = nav->frame() ? nav->frame()->settings() : 0;
- return jsBoolean(settings && settings->isJavaEnabled());
+ if (!thisObj->inherits(&KJS::Navigator::info))
+ return throwError(exec, TypeError);
+ Navigator *nav = static_cast<Navigator *>(thisObj);
+ // javaEnabled()
+ Settings* settings = nav->frame() ? nav->frame()->settings() : 0;
+ return jsBoolean(settings && settings->isJavaEnabled());
}
} // namespace
diff --git a/WebCore/bindings/js/kjs_navigator.h b/WebCore/bindings/js/kjs_navigator.h
index e16f7ea..032a696 100644
--- a/WebCore/bindings/js/kjs_navigator.h
+++ b/WebCore/bindings/js/kjs_navigator.h
@@ -1,6 +1,7 @@
+// -*- c-basic-offset: 2 -*-
/*
+ * This file is part of the KDE libraries
* Copyright (C) 2000 Harri Porten (porten@kde.org)
- * Copyright (C) 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
@@ -23,28 +24,28 @@
#include "kjs_binding.h"
namespace WebCore {
-
class Frame;
-
- class Navigator : public DOMObject {
- public:
- Navigator(KJS::JSObject* prototype, Frame*);
-
- virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
- KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
- virtual const KJS::ClassInfo* classInfo() const { return &info; }
- static const KJS::ClassInfo info;
-
- enum { AppCodeName, AppName, AppVersion, Language, UserAgent, Platform,
- _Plugins, _MimeTypes, Product, ProductSub, Vendor, VendorSub, CookieEnabled };
-
- Frame* frame() const { return m_frame; }
-
- private:
- Frame* m_frame;
- };
-
- KJS::JSValue* navigatorProtoFuncJavaEnabled(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
+}
+
+namespace KJS {
+
+ class Navigator : public DOMObject {
+ public:
+ Navigator(JSObject* prototype, WebCore::Frame*);
+
+ virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+ JSValue *getValueProperty(ExecState *exec, int token) const;
+ virtual const ClassInfo* classInfo() const { return &info; }
+ static const ClassInfo info;
+ enum { AppCodeName, AppName, AppVersion, Language, UserAgent, Platform,
+ _Plugins, _MimeTypes, Product, ProductSub, Vendor, VendorSub, CookieEnabled };
+ WebCore::Frame *frame() const { return m_frame; }
+ private:
+ WebCore::Frame *m_frame;
+ };
+
+ // Functions
+ JSValue* navigatorProtoFuncJavaEnabled(ExecState*, JSObject*, const List&);
} // namespace
diff --git a/WebCore/bindings/js/kjs_proxy.cpp b/WebCore/bindings/js/kjs_proxy.cpp
index 7b29b4b..433c9e9 100644
--- a/WebCore/bindings/js/kjs_proxy.cpp
+++ b/WebCore/bindings/js/kjs_proxy.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 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 Lesser General Public
@@ -147,6 +147,16 @@ void KJSProxy::initScript()
m_globalObject = new JSDOMWindow(m_frame->domWindow());
+ // FIXME: We can get rid of this (and eliminate compatMode entirely).
+ String userAgent = m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->url() : KURL());
+ if (userAgent.find("Microsoft") >= 0 || userAgent.find("MSIE") >= 0)
+ m_globalObject->setCompatMode(IECompat);
+ else {
+ // If we find "Mozilla" but not "(compatible, ...)" we are a real Netscape
+ if (userAgent.find("Mozilla") >= 0 && userAgent.find("compatible") == -1)
+ m_globalObject->setCompatMode(NetscapeCompat);
+ }
+
m_frame->loader()->dispatchWindowObjectAvailable();
}
diff --git a/WebCore/bindings/js/kjs_window.cpp b/WebCore/bindings/js/kjs_window.cpp
index 04d65cc..4cc7bbf 100644
--- a/WebCore/bindings/js/kjs_window.cpp
+++ b/WebCore/bindings/js/kjs_window.cpp
@@ -292,8 +292,7 @@ static HashMap<String, String> parseModalDialogFeatures(const String& featuresAr
{
HashMap<String, String> map;
- Vector<String> features;
- featuresArg.split(';', features);
+ Vector<String> features = featuresArg.split(';');
Vector<String>::const_iterator end = features.end();
for (Vector<String>::const_iterator it = features.begin(); it != end; ++it) {
String s = *it;
@@ -361,16 +360,20 @@ static Frame* createWindow(ExecState* exec, Frame* openerFrame, const String& ur
if (dialogArgs)
newWindow->putDirect("dialogArguments", dialogArgs);
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!protocolIs(url, "javascript") || newWindow->allowsAccessFrom(exec)) {
- KURL completedURL = url.isEmpty() ? KURL("") : activeFrame->document()->completeURL(url);
+#else
+ if (!url.startsWith("javascript:", false) || newWindow->allowsAccessFrom(exec)) {
+#endif
+ String completedURL = url.isEmpty() ? url : activeFrame->document()->completeURL(url);
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
if (created) {
- newFrame->loader()->changeLocation(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture);
+ newFrame->loader()->changeLocation(KURL(completedURL.deprecatedString()), activeFrame->loader()->outgoingReferrer(), false, userGesture);
if (Document* oldDoc = openerFrame->document())
newFrame->document()->setBaseURL(oldDoc->baseURL());
} else if (!url.isEmpty())
- newFrame->loader()->scheduleLocationChange(completedURL.string(), activeFrame->loader()->outgoingReferrer(), false, userGesture);
+ newFrame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture);
}
return newFrame;
@@ -642,7 +645,7 @@ bool Window::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName,
// precedence over the index and name getters.
JSValue* proto = prototype();
if (proto->isObject()) {
- if (static_cast<JSObject*>(proto)->getPropertySlot(exec, propertyName, slot)) {
+ if (static_cast<JSObject*>(proto)->getOwnPropertySlot(exec, propertyName, slot)) {
if (!allowsAccessFrom(exec))
slot.setUndefined(this);
return true;
@@ -678,13 +681,13 @@ bool Window::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName,
return Base::getOwnPropertySlot(exec, propertyName, slot);
}
-void Window::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void Window::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
const HashEntry* entry = Lookup::findEntry(&WindowTable, propertyName);
if (entry) {
if (entry->attr & Function) {
if (allowsAccessFrom(exec))
- Base::put(exec, propertyName, value);
+ Base::put(exec, propertyName, value, attr);
return;
}
if (entry->attr & ReadOnly)
@@ -698,7 +701,7 @@ void Window::put(ExecState* exec, const Identifier& propertyName, JSValue* value
if (Settings* settings = p->settings()) {
if (settings->usesDashboardBackwardCompatibilityMode() && !p->tree()->parent()) {
if (allowsAccessFrom(exec))
- putDirect(propertyName, value);
+ putDirect(propertyName, value, attr);
return;
}
}
@@ -706,7 +709,11 @@ void Window::put(ExecState* exec, const Identifier& propertyName, JSValue* value
if (!p->loader()->shouldAllowNavigation(impl()->frame()))
return;
String dstUrl = p->loader()->completeURL(value->toString(exec)).string();
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!protocolIs(dstUrl, "javascript") || allowsAccessFrom(exec)) {
+#else
+ if (!dstUrl.startsWith("javascript:", false) || allowsAccessFrom(exec)) {
+#endif
bool userGesture = p->scriptProxy()->processingUserGesture();
// We want a new history item if this JS was called via a user gesture
impl()->frame()->loader()->scheduleLocationChange(dstUrl, p->loader()->outgoingReferrer(), false, userGesture);
@@ -819,7 +826,7 @@ void Window::put(ExecState* exec, const Identifier& propertyName, JSValue* value
}
}
if (allowsAccessFrom(exec))
- Base::put(exec, propertyName, value);
+ Base::put(exec, propertyName, value, attr);
}
bool Window::allowsAccessFrom(const JSGlobalObject* other) const
@@ -917,7 +924,7 @@ String Window::crossDomainAccessErrorMessage(const JSGlobalObject* other, Securi
return String();
// FIXME: this error message should contain more specifics of why the same origin check has failed.
return String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains, protocols and ports must match.\n",
- targetDocument->url().string().utf8().data(), originDocument->url().string().utf8().data());
+ targetDocument->url().utf8().data(), originDocument->url().utf8().data());
}
void Window::printErrorMessage(const String& message) const
@@ -1172,10 +1179,14 @@ JSValue* windowProtoFuncOpen(ExecState* exec, JSObject* thisObj, const List& arg
String completedURL;
if (!urlString.isEmpty())
- completedURL = activeFrame->document()->completeURL(urlString).string();
+ completedURL = activeFrame->document()->completeURL(urlString);
const Window* targetedWindow = Window::retrieveWindow(frame);
+#ifdef ANDROID_JAVASCRIPT_SECURITY
if (!completedURL.isEmpty() && (!protocolIs(completedURL, "javascript") || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) {
+#else
+ if (!completedURL.isEmpty() && (!completedURL.startsWith("javascript:", false) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) {
+#endif
bool userGesture = activeFrame->scriptProxy()->processingUserGesture();
frame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture);
}
diff --git a/WebCore/bindings/js/kjs_window.h b/WebCore/bindings/js/kjs_window.h
index ad415aa..14887a5 100644
--- a/WebCore/bindings/js/kjs_window.h
+++ b/WebCore/bindings/js/kjs_window.h
@@ -75,7 +75,7 @@ namespace KJS {
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
+ virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attr = None);
int installTimeout(const UString& handler, int t, bool singleShot);
int installTimeout(JSValue* function, const List& args, int t, bool singleShot);