Changeset 117926 in webkit
- Timestamp:
- May 22, 2012 12:42:10 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117925 r117926 1 2012-05-22 Kentaro Hara <haraken@chromium.org> 2 3 [V8] setDOMException() should return v8::Handle<v8::Value>() 4 https://bugs.webkit.org/show_bug.cgi?id=87083 5 6 Reviewed by Adam Barth. 7 8 The following patterns are used here and there in V8 bindings: 9 10 setDOMException(); 11 return v8::Handle<v8::Value>(); 12 13 and 14 15 setDOMException(); 16 return v8::Undefined(); 17 18 By returning v8::Handle<v8::Value>() from setDOMException(), we can simplify the above patterns into this: 19 20 return setDOMException(); 21 22 This patch just replaces the code in CodeGeneratorV8.pm. I'll replace 23 all other custom bindings in a follow-up patch. 24 25 No tests. No change in behavior. 26 27 * bindings/scripts/CodeGeneratorV8.pm: 28 (GenerateSetDOMException): 29 (GenerateFunctionCallback): 30 (GenerateFunctionCallString): 31 * bindings/scripts/test/V8/V8TestEventTarget.cpp: 32 (WebCore::TestEventTargetV8Internal::itemCallback): 33 (WebCore::TestEventTargetV8Internal::dispatchEventCallback): 34 * bindings/scripts/test/V8/V8TestInterface.cpp: 35 (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback): 36 * bindings/scripts/test/V8/V8TestObj.cpp: 37 (WebCore::TestObjV8Internal::attrWithGetterExceptionAttrGetter): 38 (WebCore::TestObjV8Internal::stringAttrWithGetterExceptionAttrGetter): 39 (WebCore::TestObjV8Internal::withScriptStateAttributeRaisesAttrGetter): 40 (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter): 41 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter): 42 (WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback): 43 (WebCore::TestObjV8Internal::methodWithExceptionCallback): 44 (WebCore::TestObjV8Internal::withScriptStateVoidExceptionCallback): 45 (WebCore::TestObjV8Internal::withScriptStateObjExceptionCallback): 46 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback): 47 (WebCore::TestObjV8Internal::getSVGDocumentCallback): 48 (WebCore::TestObjV8Internal::strictFunctionCallback): 49 * bindings/v8/V8Proxy.cpp: 50 (WebCore::V8Proxy::setDOMException): 51 * bindings/v8/V8Proxy.h: 52 (V8Proxy): 53 1 54 2012-05-22 MORITA Hajime <morrita@google.com> 2 55 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r117898 r117926 651 651 my $result = ""; 652 652 653 $result .= $indent . "if (UNLIKELY(ec)) {\n"; 654 $result .= $indent . " V8Proxy::setDOMException(ec, $getIsolate);\n"; 655 $result .= $indent . " return v8::Handle<v8::Value>();\n"; 656 $result .= $indent . "}\n"; 657 653 $result .= $indent . "if (UNLIKELY(ec))\n"; 654 $result .= $indent . " return V8Proxy::setDOMException(ec, $getIsolate);\n"; 658 655 return $result; 659 656 } … … 1409 1406 AddToImplIncludes("ExceptionCode.h"); 1410 1407 push(@implContentDecls, " $nativeClassName wrapper = V8${implClassName}::toNative(args.Holder());\n"); 1411 push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n"); 1412 push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n"); 1413 push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); 1414 push(@implContentDecls, " }\n"); 1408 push(@implContentDecls, " if (wrapper->role() == AnimValRole)\n"); 1409 push(@implContentDecls, " return V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n"); 1415 1410 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); 1416 1411 push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); … … 1467 1462 push(@implContentDecls, " }\n"); 1468 1463 push(@implContentDecls, " fail:\n"); 1469 push(@implContentDecls, " V8Proxy::setDOMException(ec, args.GetIsolate());\n"); 1470 push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); 1464 push(@implContentDecls, " return V8Proxy::setDOMException(ec, args.GetIsolate());\n"); 1471 1465 } 1472 1466 … … 3334 3328 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) { 3335 3329 push @arguments, "$paramName->propertyReference()"; 3336 $result .= $indent . "if (!$paramName) {\n"; 3337 $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n"; 3338 $result .= $indent . " return v8::Handle<v8::Value>();\n"; 3339 $result .= $indent . "}\n"; 3330 $result .= $indent . "if (!$paramName)\n"; 3331 $result .= $indent . " return V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n"; 3340 3332 } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") { 3341 3333 push @arguments, "$paramName.get()"; -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp
r117925 r117926 60 60 } 61 61 fail: 62 V8Proxy::setDOMException(ec, args.GetIsolate()); 63 return v8::Handle<v8::Value>(); 62 return V8Proxy::setDOMException(ec, args.GetIsolate()); 64 63 } 65 64 … … 101 100 } 102 101 fail: 103 V8Proxy::setDOMException(ec, args.GetIsolate()); 104 return v8::Handle<v8::Value>(); 102 return V8Proxy::setDOMException(ec, args.GetIsolate()); 105 103 } 106 104 -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
r117925 r117926 141 141 } 142 142 fail: 143 V8Proxy::setDOMException(ec, args.GetIsolate()); 144 return v8::Handle<v8::Value>(); 143 return V8Proxy::setDOMException(ec, args.GetIsolate()); 145 144 } 146 145 -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r117925 r117926 627 627 ExceptionCode ec = 0; 628 628 int v = imp->attrWithGetterException(ec); 629 if (UNLIKELY(ec)) { 630 V8Proxy::setDOMException(ec, info.GetIsolate()); 631 return v8::Handle<v8::Value>(); 632 } 629 if (UNLIKELY(ec)) 630 return V8Proxy::setDOMException(ec, info.GetIsolate()); 633 631 return v8::Integer::New(v); 634 632 } … … 671 669 ExceptionCode ec = 0; 672 670 String v = imp->stringAttrWithGetterException(ec); 673 if (UNLIKELY(ec)) { 674 V8Proxy::setDOMException(ec, info.GetIsolate()); 675 return v8::Handle<v8::Value>(); 676 } 671 if (UNLIKELY(ec)) 672 return V8Proxy::setDOMException(ec, info.GetIsolate()); 677 673 return v8String(v, info.GetIsolate()); 678 674 } … … 764 760 return v8::Undefined(); 765 761 RefPtr<TestObj> v = imp->withScriptStateAttributeRaises(state, ec); 766 if (UNLIKELY(ec)) { 767 V8Proxy::setDOMException(ec, info.GetIsolate()); 768 return v8::Handle<v8::Value>(); 769 } 762 if (UNLIKELY(ec)) 763 return V8Proxy::setDOMException(ec, info.GetIsolate()); 770 764 if (state.hadException()) 771 765 return throwError(state.exception(), info.GetIsolate()); … … 799 793 return v8::Undefined(); 800 794 RefPtr<TestObj> v = imp->withScriptExecutionContextAttributeRaises(scriptContext, ec); 801 if (UNLIKELY(ec)) { 802 V8Proxy::setDOMException(ec, info.GetIsolate()); 803 return v8::Handle<v8::Value>(); 804 } 795 if (UNLIKELY(ec)) 796 return V8Proxy::setDOMException(ec, info.GetIsolate()); 805 797 return toV8(v.release(), info.GetIsolate()); 806 798 } … … 863 855 return v8::Undefined(); 864 856 RefPtr<TestObj> v = imp->withScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, ec); 865 if (UNLIKELY(ec)) { 866 V8Proxy::setDOMException(ec, info.GetIsolate()); 867 return v8::Handle<v8::Value>(); 868 } 857 if (UNLIKELY(ec)) 858 return V8Proxy::setDOMException(ec, info.GetIsolate()); 869 859 if (state.hadException()) 870 860 return throwError(state.exception(), info.GetIsolate()); … … 1348 1338 } 1349 1339 fail: 1350 V8Proxy::setDOMException(ec, args.GetIsolate()); 1351 return v8::Handle<v8::Value>(); 1340 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1352 1341 } 1353 1342 … … 1411 1400 } 1412 1401 fail: 1413 V8Proxy::setDOMException(ec, args.GetIsolate()); 1414 return v8::Handle<v8::Value>(); 1402 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1415 1403 } 1416 1404 … … 1474 1462 } 1475 1463 fail: 1476 V8Proxy::setDOMException(ec, args.GetIsolate()); 1477 return v8::Handle<v8::Value>(); 1464 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1478 1465 } 1479 1466 … … 1493 1480 } 1494 1481 fail: 1495 V8Proxy::setDOMException(ec, args.GetIsolate()); 1496 return v8::Handle<v8::Value>(); 1482 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1497 1483 } 1498 1484 … … 1540 1526 } 1541 1527 fail: 1542 V8Proxy::setDOMException(ec, args.GetIsolate()); 1543 return v8::Handle<v8::Value>(); 1528 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1544 1529 } 1545 1530 … … 1929 1914 } 1930 1915 fail: 1931 V8Proxy::setDOMException(ec, args.GetIsolate()); 1932 return v8::Handle<v8::Value>(); 1916 return V8Proxy::setDOMException(ec, args.GetIsolate()); 1933 1917 } 1934 1918 … … 2027 2011 } 2028 2012 fail: 2029 V8Proxy::setDOMException(ec, args.GetIsolate()); 2030 return v8::Handle<v8::Value>(); 2013 return V8Proxy::setDOMException(ec, args.GetIsolate()); 2031 2014 } 2032 2015 -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r117873 r117926 587 587 break; 588 588 589 v oidV8Proxy::setDOMException(int ec, v8::Isolate* isolate)589 v8::Handle<v8::Value> V8Proxy::setDOMException(int ec, v8::Isolate* isolate) 590 590 { 591 591 if (ec <= 0) 592 return ;592 return v8::Handle<v8::Value>(); 593 593 594 594 ExceptionCodeDescription description(ec); … … 600 600 601 601 if (exception.IsEmpty()) 602 return ;602 return v8::Handle<v8::Value>(); 603 603 604 604 // Attach an Error object to the DOMException. This is then lazily used to get the stack value. … … 608 608 exception->ToObject()->SetAccessor(v8String("stack", isolate), DOMExceptionStackGetter, DOMExceptionStackSetter, error); 609 609 610 v8::ThrowException(exception);610 return v8::ThrowException(exception); 611 611 } 612 612 -
trunk/Source/WebCore/bindings/v8/V8Proxy.h
r117898 r117926 235 235 // If the exception code is different from zero, a DOM exception is 236 236 // schedule to be thrown. 237 static v oidsetDOMException(int exceptionCode, v8::Isolate*);237 static v8::Handle<v8::Value> setDOMException(int exceptionCode, v8::Isolate*); 238 238 239 239 // Schedule an error object to be thrown.
Note: See TracChangeset
for help on using the changeset viewer.