2009-02-11 Dimitri Glazkov <dglazkov@chromium.org>
[WebKit-https.git] / WebCore / bindings / v8 / custom / V8HTMLInputElementCustom.cpp
index 1f2c6f3ac865afbf0f21207e954254a76b0cdcee..628634d2af3711221bcb44b8a6302e88cccb6bf8 100644 (file)
@@ -43,10 +43,8 @@ ACCESSOR_GETTER(HTMLInputElementSelectionStart)
     v8::Handle<v8::Object> holder = info.Holder();
     HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
 
-    if (!imp->canHaveSelection()) {
-        V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Accessing selectionStart on an input element that cannot have a selection.");
-        return v8::Undefined();
-    }
+    if (!imp->canHaveSelection())
+        return throwError("Accessing selectionStart on an input element that cannot have a selection.");
 
     int v = imp->selectionStart();
     return v8::Integer::New(v);
@@ -59,7 +57,7 @@ ACCESSOR_SETTER(HTMLInputElementSelectionStart)
     HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
 
     if (!imp->canHaveSelection()) {
-        V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Accessing selectionStart on an input element that cannot have a selection.");
+        throwError("Accessing selectionStart on an input element that cannot have a selection.");
         return;
     }
     imp->setSelectionStart(value->Int32Value());
@@ -71,10 +69,8 @@ ACCESSOR_GETTER(HTMLInputElementSelectionEnd)
     v8::Handle<v8::Object> holder = info.Holder();
     HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
 
-    if (!imp->canHaveSelection()) {
-        V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Accessing selectionEnd on an input element that cannot have a selection.");
-        return v8::Undefined();
-    }
+    if (!imp->canHaveSelection())
+        return throwError("Accessing selectionEnd on an input element that cannot have a selection.");
 
     int v = imp->selectionEnd();
     return v8::Integer::New(v);
@@ -87,9 +83,10 @@ ACCESSOR_SETTER(HTMLInputElementSelectionEnd)
     HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
 
     if (!imp->canHaveSelection()) {
-        V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Accessing selectionEnd on an input element that cannot have a selection.");
+        throwError("Accessing selectionEnd on an input element that cannot have a selection.");
         return;
     }
+
     imp->setSelectionEnd(value->Int32Value());
 }
 
@@ -99,10 +96,9 @@ CALLBACK_FUNC_DECL(HTMLInputElementSetSelectionRange)
     v8::Handle<v8::Object> holder = args.Holder();
     HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
 
-    if (!imp->canHaveSelection()) {
-        V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Calling setSelectionRange on an input element that cannot have a selection.");
-        return v8::Undefined();
-    }
+    if (!imp->canHaveSelection())
+        return throwError("Calling setSelectionRange on an input element that cannot have a selection.");
+
     int start = args[0]->Int32Value();
     int end = args[1]->Int32Value();