Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 1051753003: bindings: Add toBoolean() to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 RefPtrWillBeRawPtr<NodeFilter> filter = NodeFilter::create(); 101 RefPtrWillBeRawPtr<NodeFilter> filter = NodeFilter::create();
102 102
103 v8::Handle<v8::Object> filterWrapper = toV8(filter.get(), creationContext, s criptState->isolate()).As<v8::Object>(); 103 v8::Handle<v8::Object> filterWrapper = toV8(filter.get(), creationContext, s criptState->isolate()).As<v8::Object>();
104 104
105 RefPtrWillBeRawPtr<NodeFilterCondition> condition = V8NodeFilterCondition::c reate(callback, filterWrapper, scriptState); 105 RefPtrWillBeRawPtr<NodeFilterCondition> condition = V8NodeFilterCondition::c reate(callback, filterWrapper, scriptState);
106 filter->setCondition(condition.release()); 106 filter->setCondition(condition.release());
107 107
108 return filter.release(); 108 return filter.release();
109 } 109 }
110 110
111 bool toBooleanSlow(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionSt ate& exceptionState)
112 {
113 ASSERT(!value->IsBoolean());
114 v8::TryCatch block;
115 bool result = false;
116 if (!v8Call(value->BooleanValue(isolate->GetCurrentContext()), result, block ))
117 exceptionState.rethrowV8Exception(block.Exception());
118 return result;
119 }
120
111 const int32_t kMaxInt32 = 0x7fffffff; 121 const int32_t kMaxInt32 = 0x7fffffff;
112 const int32_t kMinInt32 = -kMaxInt32 - 1; 122 const int32_t kMinInt32 = -kMaxInt32 - 1;
113 const uint32_t kMaxUInt32 = 0xffffffff; 123 const uint32_t kMaxUInt32 = 0xffffffff;
114 const int64_t kJSMaxInteger = 0x20000000000000LL - 1; // 2^53 - 1, maximum uniqu ely representable integer in ECMAScript. 124 const int64_t kJSMaxInteger = 0x20000000000000LL - 1; // 2^53 - 1, maximum uniqu ely representable integer in ECMAScript.
115 125
116 static double enforceRange(double x, double minimum, double maximum, const char* typeName, ExceptionState& exceptionState) 126 static double enforceRange(double x, double minimum, double maximum, const char* typeName, ExceptionState& exceptionState)
117 { 127 {
118 if (std::isnan(x) || std::isinf(x)) { 128 if (std::isnan(x) || std::isinf(x)) {
119 exceptionState.throwTypeError("Value is" + String(std::isinf(x) ? " infi nite and" : "") + " not of type '" + String(typeName) + "'."); 129 exceptionState.throwTypeError("Value is" + String(std::isinf(x) ? " infi nite and" : "") + " not of type '" + String(typeName) + "'.");
120 return 0; 130 return 0;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 v8::Local<v8::Value> data = info.Data(); 983 v8::Local<v8::Value> data = info.Data();
974 ASSERT(data->IsExternal()); 984 ASSERT(data->IsExternal());
975 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); 985 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext());
976 if (!perContextData) 986 if (!perContextData)
977 return; 987 return;
978 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 988 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
979 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 989 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
980 } 990 }
981 991
982 } // namespace blink 992 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698