| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 break; | 477 break; |
| 478 default: | 478 default: |
| 479 // TODO(ctguil): Support additional webkit notifications. | 479 // TODO(ctguil): Support additional webkit notifications. |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 return true; | 482 return true; |
| 483 } | 483 } |
| 484 | 484 |
| 485 // Conversion for the incoming value. The map isn't perfect; v8 has Uint32, | 485 // Conversion for the incoming value. The map isn't perfect; v8 has Uint32, |
| 486 // and int64 which don't fit as Value::TYPE_INTEGER, so we let them fall into | 486 // and int64 which don't fit as Value::TYPE_INTEGER, so we let them fall into |
| 487 // being TYPE_REALs. Dates are converted to a string (which can then be parsed | 487 // being TYPE_DOUBLEs. Dates are converted to a string (which can then be |
| 488 // into a base::Time), as are regexps. Arrays are converted into lists, | 488 // parsed into a base::Time), as are regexps. Arrays are converted into lists, |
| 489 // recursively. We don't deal with binary objects or functions - they become | 489 // recursively. We don't deal with binary objects or functions - they become |
| 490 // null values. | 490 // null values. |
| 491 static Value* ConvertV8Value(const v8::Handle<v8::Value>& v8value) { | 491 static Value* ConvertV8Value(const v8::Handle<v8::Value>& v8value) { |
| 492 if (v8value->IsBoolean()) { | 492 if (v8value->IsBoolean()) { |
| 493 return Value::CreateBooleanValue(v8value->BooleanValue()); | 493 return Value::CreateBooleanValue(v8value->BooleanValue()); |
| 494 } else if (v8value->IsInt32()) { | 494 } else if (v8value->IsInt32()) { |
| 495 return Value::CreateIntegerValue(v8value->Int32Value()); | 495 return Value::CreateIntegerValue(v8value->Int32Value()); |
| 496 } else if (v8value->IsNumber()) { | 496 } else if (v8value->IsNumber()) { |
| 497 return Value::CreateRealValue(v8value->NumberValue()); | 497 return Value::CreateDoubleValue(v8value->NumberValue()); |
| 498 } else if (v8value->IsString()) { | 498 } else if (v8value->IsString()) { |
| 499 return Value::CreateStringValue(*v8::String::Utf8Value(v8value)); | 499 return Value::CreateStringValue(*v8::String::Utf8Value(v8value)); |
| 500 } else if (v8value->IsDate()) { | 500 } else if (v8value->IsDate()) { |
| 501 v8::Date* date = v8::Date::Cast(*v8value); | 501 v8::Date* date = v8::Date::Cast(*v8value); |
| 502 return Value::CreateRealValue(date->NumberValue() / 1000.0); | 502 return Value::CreateDoubleValue(date->NumberValue() / 1000.0); |
| 503 } else if (v8value->IsRegExp()) { | 503 } else if (v8value->IsRegExp()) { |
| 504 return Value::CreateStringValue( | 504 return Value::CreateStringValue( |
| 505 *v8::String::Utf8Value(v8value->ToString())); | 505 *v8::String::Utf8Value(v8value->ToString())); |
| 506 } else if (v8value->IsArray()) { | 506 } else if (v8value->IsArray()) { |
| 507 v8::Array* array = v8::Array::Cast(*v8value); | 507 v8::Array* array = v8::Array::Cast(*v8value); |
| 508 uint32_t length = array->Length(); | 508 uint32_t length = array->Length(); |
| 509 scoped_ptr<ListValue> list(new ListValue); | 509 scoped_ptr<ListValue> list(new ListValue); |
| 510 for (uint32_t i = 0 ; i < length ; ++i) { | 510 for (uint32_t i = 0 ; i < length ; ++i) { |
| 511 list->Set(i, ConvertV8Value(array->Get(i))); | 511 list->Set(i, ConvertV8Value(array->Get(i))); |
| 512 } | 512 } |
| (...skipping 5257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5770 if (cmd == kJavaScriptStressTestSetStressRunType) { | 5770 if (cmd == kJavaScriptStressTestSetStressRunType) { |
| 5771 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); | 5771 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); |
| 5772 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { | 5772 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { |
| 5773 v8::Testing::PrepareStressRun(param); | 5773 v8::Testing::PrepareStressRun(param); |
| 5774 } | 5774 } |
| 5775 } | 5775 } |
| 5776 | 5776 |
| 5777 void RenderView::OnContextMenuClosed() { | 5777 void RenderView::OnContextMenuClosed() { |
| 5778 context_menu_node_.reset(); | 5778 context_menu_node_.reset(); |
| 5779 } | 5779 } |
| OLD | NEW |