OSDN Git Service

Merge "Removing tests that pass after a v8 merge"
[android-x86/external-webkit.git] / WebCore / bindings / js / JSLocationCustom.cpp
index 8599242..b00249f 100644 (file)
@@ -27,6 +27,8 @@
 #include "ExceptionCode.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "JSBinding.h"
+#include "JSBindingState.h"
 #include "JSDOMBinding.h"
 #include "JSDOMWindowCustom.h"
 #include "KURL.h"
@@ -39,19 +41,19 @@ using namespace JSC;
 
 namespace WebCore {
 
-static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
+static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
 {
-    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
+    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
 }
 
-static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
+static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
 {
-    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
+    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
 }
 
-static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&)
+static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
 {
-    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
+    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
 }
 
 bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
@@ -186,12 +188,8 @@ void JSLocation::defineGetter(ExecState* exec, const Identifier& propertyName, J
 
 static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList)
 {
-    Frame* lexicalFrame = toLexicalFrame(exec);
-    if (!lexicalFrame)
-        return;
-
-    if (!protocolIsJavaScript(url) || allowsAccessFromFrame(exec, frame))
-        frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture(exec));
+    JSBindingState state(exec);
+    JSBinding::Frame::navigateIfAllowed(&state, frame, url, lockHistory, lockBackForwardList);
 }
 
 void JSLocation::setHref(ExecState* exec, JSValue value)
@@ -199,7 +197,7 @@ void JSLocation::setHref(ExecState* exec, JSValue value)
     Frame* frame = impl()->frame();
     ASSERT(frame);
 
-    KURL url = completeURL(exec, value.toString(exec));
+    KURL url = completeURL(exec, ustringToString(value.toString(exec)));
     if (url.isNull())
         return;
 
@@ -215,7 +213,7 @@ void JSLocation::setProtocol(ExecState* exec, JSValue value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
-    if (!url.setProtocol(value.toString(exec))) {
+    if (!url.setProtocol(ustringToString(value.toString(exec)))) {
         setDOMException(exec, SYNTAX_ERR);
         return;
     }
@@ -229,7 +227,7 @@ void JSLocation::setHost(ExecState* exec, JSValue value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
-    url.setHostAndPort(value.toString(exec));
+    url.setHostAndPort(ustringToString(value.toString(exec)));
 
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
@@ -240,7 +238,7 @@ void JSLocation::setHostname(ExecState* exec, JSValue value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
-    url.setHost(value.toString(exec));
+    url.setHost(ustringToString(value.toString(exec)));
 
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
@@ -253,7 +251,7 @@ void JSLocation::setPort(ExecState* exec, JSValue value)
     KURL url = frame->loader()->url();
     // FIXME: Could make this a little less ugly if String provided a toUnsignedShort function.
     const UString& portString = value.toString(exec);
-    int port = charactersToInt(portString.data(), portString.size());
+    int port = charactersToInt(portString.characters(), portString.length());
     if (port < 0 || port > 0xFFFF)
         url.removePort();
     else
@@ -268,7 +266,7 @@ void JSLocation::setPathname(ExecState* exec, JSValue value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
-    url.setPath(value.toString(exec));
+    url.setPath(ustringToString(value.toString(exec)));
 
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
@@ -279,7 +277,7 @@ void JSLocation::setSearch(ExecState* exec, JSValue value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
-    url.setQuery(value.toString(exec));
+    url.setQuery(ustringToString(value.toString(exec)));
 
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
@@ -291,7 +289,7 @@ void JSLocation::setHash(ExecState* exec, JSValue value)
 
     KURL url = frame->loader()->url();
     String oldFragmentIdentifier = url.fragmentIdentifier();
-    String str = value.toString(exec);
+    String str = ustringToString(value.toString(exec));
     if (str.startsWith("#"))
         str = str.substring(1);
     if (equalIgnoringNullity(oldFragmentIdentifier, str))
@@ -301,41 +299,31 @@ void JSLocation::setHash(ExecState* exec, JSValue value)
     navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
 }
 
-JSValue JSLocation::replace(ExecState* exec, const ArgList& args)
+JSValue JSLocation::replace(ExecState* exec)
 {
-    Frame* frame = impl()->frame();
-    if (!frame)
-        return jsUndefined();
-
-    KURL url = completeURL(exec, args.at(0).toString(exec));
-    if (url.isNull())
-        return jsUndefined();
-
-    if (!shouldAllowNavigation(exec, frame))
-        return jsUndefined();
-
-    navigateIfAllowed(exec, frame, url, true, true);
+    JSBindingState state(exec);
+    JSBinding::Location::replace(&state, impl(), ustringToString(exec->argument(0).toString(exec)));
     return jsUndefined();
 }
 
-JSValue JSLocation::reload(ExecState* exec, const ArgList&)
+JSValue JSLocation::reload(ExecState* exec)
 {
     Frame* frame = impl()->frame();
     if (!frame || !allowsAccessFromFrame(exec, frame))
         return jsUndefined();
 
     if (!protocolIsJavaScript(frame->loader()->url()))
-        frame->redirectScheduler()->scheduleRefresh(processingUserGesture(exec));
+        frame->navigationScheduler()->scheduleRefresh();
     return jsUndefined();
 }
 
-JSValue JSLocation::assign(ExecState* exec, const ArgList& args)
+JSValue JSLocation::assign(ExecState* exec)
 {
     Frame* frame = impl()->frame();
     if (!frame)
         return jsUndefined();
 
-    KURL url = completeURL(exec, args.at(0).toString(exec));
+    KURL url = completeURL(exec, ustringToString(exec->argument(0).toString(exec)));
     if (url.isNull())
         return jsUndefined();
 
@@ -347,7 +335,7 @@ JSValue JSLocation::assign(ExecState* exec, const ArgList& args)
     return jsUndefined();
 }
 
-JSValue JSLocation::toString(ExecState* exec, const ArgList&)
+JSValue JSLocation::toString(ExecState* exec)
 {
     Frame* frame = impl()->frame();
     if (!frame || !allowsAccessFromFrame(exec, frame))