[V8] Replace 'throwError(); return Undefined();' with 'return throwError()'
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 07:25:22 +0000 (07:25 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 07:25:22 +0000 (07:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87079

Reviewed by Adam Barth.

This patch replaces

    throwError();
    return v8::Undefined();

with

    return throwError();

No tests. No change in behavior.

* bindings/v8/DateExtension.cpp:
(WebCore::DateExtension::OnSleepDetected):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::openCallback):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::inspectedObjectCallback):
* bindings/v8/custom/V8SQLResultSetRowListCustom.cpp:
(WebCore::V8SQLResultSetRowList::itemCallback):
* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
(WebCore::V8WebGLRenderingContext::getAttachedShadersCallback):
(WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
(WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
(WebCore::V8WebGLRenderingContext::getUniformCallback):
(WebCore::vertexAttribAndUniformHelperf):
(WebCore::uniformHelperi):
(WebCore::uniformMatrixHelper):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/DateExtension.cpp
Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
Source/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp

index 7d8e700..317f3d0 100644 (file)
@@ -1,3 +1,38 @@
+2012-05-22  Kentaro Hara  <haraken@chromium.org>
+
+        [V8] Replace 'throwError(); return Undefined();' with 'return throwError()'
+        https://bugs.webkit.org/show_bug.cgi?id=87079
+
+        Reviewed by Adam Barth.
+
+        This patch replaces
+
+            throwError();
+            return v8::Undefined();
+
+        with
+
+            return throwError();
+
+        No tests. No change in behavior.
+
+        * bindings/v8/DateExtension.cpp:
+        (WebCore::DateExtension::OnSleepDetected):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::openCallback):
+        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+        (WebCore::V8InjectedScriptHost::inspectedObjectCallback):
+        * bindings/v8/custom/V8SQLResultSetRowListCustom.cpp:
+        (WebCore::V8SQLResultSetRowList::itemCallback):
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        (WebCore::V8WebGLRenderingContext::getAttachedShadersCallback):
+        (WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
+        (WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
+        (WebCore::V8WebGLRenderingContext::getUniformCallback):
+        (WebCore::vertexAttribAndUniformHelperf):
+        (WebCore::uniformHelperi):
+        (WebCore::uniformMatrixHelper):
+
 2012-05-22  Kenneth Russell  <kbr@google.com>
 
         Must set/reset pixel unpack alignment to 1 during texSubImage2D
index 883dfd3..8d34cb8 100644 (file)
@@ -118,8 +118,7 @@ v8::Handle<v8::Value> DateExtension::Setup(const v8::Arguments& args)
 
 v8::Handle<v8::Value> DateExtension::OnSleepDetected(const v8::Arguments& args)
 {
-    V8Proxy::throwError(V8Proxy::GeneralError, "Too much time spent in unload handler.", args.GetIsolate());
-    return v8::Undefined();
+    return V8Proxy::throwError(V8Proxy::GeneralError, "Too much time spent in unload handler.", args.GetIsolate());
 }
 
 }  // namespace WebCore
index 06e165e..1bd97d6 100644 (file)
@@ -148,10 +148,8 @@ v8::Handle<v8::Value> V8HTMLDocument::openCallback(const v8::Arguments& args)
             // Get the open property of the global object.
             v8::Local<v8::Value> function = global->Get(v8::String::New("open"));
             // If the open property is not a function throw a type error.
-            if (!function->IsFunction()) {
-                V8Proxy::throwTypeError("open is not a function");
-                return v8::Undefined();
-            }
+            if (!function->IsFunction())
+                return V8Proxy::throwTypeError("open is not a function");
             // Wrap up the arguments and call the function.
             OwnArrayPtr<v8::Local<v8::Value> > params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
             for (int i = 0; i < args.Length(); i++)
index 9f9780c..2a08dd1 100644 (file)
@@ -82,10 +82,8 @@ v8::Handle<v8::Value> V8InjectedScriptHost::inspectedObjectCallback(const v8::Ar
     if (args.Length() < 1)
         return v8::Undefined();
 
-    if (!args[0]->IsInt32()) {
-        V8Proxy::throwTypeError("argument has to be an integer");
-        return v8::Undefined();
-    }
+    if (!args[0]->IsInt32())
+        return V8Proxy::throwTypeError("argument has to be an integer");
 
     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
     InjectedScriptHost::InspectableObject* object = host->inspectedObject(args[0]->ToInt32()->Value());
index f7936ec..e8a763b 100644 (file)
@@ -43,23 +43,17 @@ v8::Handle<v8::Value> V8SQLResultSetRowList::itemCallback(const v8::Arguments& a
 {
     INC_STATS("DOM.SQLResultSetRowList.item()");
 
-    if (args.Length() == 0) {
-        V8Proxy::throwError(V8Proxy::SyntaxError, "Item index is required.", args.GetIsolate());
-        return v8::Undefined();
-    }
+    if (!args.Length())
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "Item index is required.", args.GetIsolate());
 
-    if (!args[0]->IsNumber()) {
-        V8Proxy::throwTypeError("Item index must be a number.");
-        return v8::Undefined();
-    }
+    if (!args[0]->IsNumber())
+        return V8Proxy::throwTypeError("Item index must be a number.");
 
     SQLResultSetRowList* rowList = V8SQLResultSetRowList::toNative(args.Holder());
 
     unsigned long index = args[0]->IntegerValue();
-    if (index >= rowList->length()) {
-        V8Proxy::throwError(V8Proxy::RangeError, "Item index is out of range.", args.GetIsolate());
-        return v8::Undefined();
-    }
+    if (index >= rowList->length())
+        return V8Proxy::throwError(V8Proxy::RangeError, "Item index is out of range.", args.GetIsolate());
 
     v8::Local<v8::Object> item = v8::Object::New();
     unsigned numColumns = rowList->columnNames().size();
index b019b87..ee9d1a7 100644 (file)
@@ -273,10 +273,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     Vector<RefPtr<WebGLShader> > shaders;
     bool succeed = context->getAttachedShaders(program, shaders, ec);
@@ -356,10 +354,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     unsigned pname = toInt32(args[1]);
     WebGLGetInfo info = context->getProgramParameter(program, pname, ec);
@@ -385,10 +381,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     unsigned pname = toInt32(args[1]);
     WebGLGetInfo info = context->getShaderParameter(shader, pname, ec);
@@ -428,16 +422,12 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
 
-    if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocation::HasInstance(args[1])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocation::HasInstance(args[1]))
+        return V8Proxy::throwTypeError();
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok);
 
@@ -504,10 +494,8 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments&
     if (isFunctionToCallForAttribute(functionToCall))
         index = toInt32(args[0]);
     else {
-        if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
-            V8Proxy::throwTypeError();
-            return v8::Handle<v8::Value>();
-        }
+        if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
+            return V8Proxy::throwTypeError();
         location = toWebGLUniformLocation(args[0], ok);
     }
 
@@ -533,10 +521,8 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments&
         return v8::Undefined();
     }
 
-    if (args[1].IsEmpty() || !args[1]->IsArray()) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args[1].IsEmpty() || !args[1]->IsArray())
+        return V8Proxy::throwTypeError();
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[1]);
     uint32_t len = array->Length();
@@ -580,10 +566,8 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
         return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
 
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);
 
@@ -603,10 +587,8 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
         return v8::Undefined();
     }
 
-    if (args[1].IsEmpty() || !args[1]->IsArray()) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args[1].IsEmpty() || !args[1]->IsArray())
+        return V8Proxy::throwTypeError();
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[1]);
     uint32_t len = array->Length();
@@ -695,10 +677,8 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
 
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
 
-    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
+        return V8Proxy::throwTypeError();
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);
     
@@ -718,10 +698,8 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
         return v8::Undefined();
     }
 
-    if (args[2].IsEmpty() || !args[2]->IsArray()) {
-        V8Proxy::throwTypeError();
-        return v8::Handle<v8::Value>();
-    }
+    if (args[2].IsEmpty() || !args[2]->IsArray())
+        return V8Proxy::throwTypeError();
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[2]);
     uint32_t len = array->Length();