summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaphet@chromium.org <japhet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 18:33:52 +0000
committerjaphet@chromium.org <japhet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 18:33:52 +0000
commitce5008313a17a76c805440928e9cac9a8a3f1e9f (patch)
treec9c5443eae691dec611bb36224c27334ab4a8ad0
parent3a6bc9040f96a70e85682033a44f25866bc1a62a (diff)
downloadchromium_src-ce5008313a17a76c805440928e9cac9a8a3f1e9f.zip
chromium_src-ce5008313a17a76c805440928e9cac9a8a3f1e9f.tar.gz
chromium_src-ce5008313a17a76c805440928e9cac9a8a3f1e9f.tar.bz2
Delete V8Binding and use the upstreamed version. BUG=15789
Review URL: http://codereview.chromium.org/155030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19963 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc2
-rw-r--r--webkit/port/bindings/v8/v8_binding.cpp130
-rw-r--r--webkit/port/bindings/v8/v8_binding.h135
-rw-r--r--webkit/webkit.gyp3
5 files changed, 3 insertions, 269 deletions
diff --git a/DEPS b/DEPS
index 993aaf3..58d5dc9 100644
--- a/DEPS
+++ b/DEPS
@@ -1,7 +1,7 @@
vars = {
"webkit_trunk":
"http://svn.webkit.org/repository/webkit/trunk",
- "webkit_revision": "45555",
+ "webkit_revision": "45559",
}
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index e7308b4..b1378c6 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -172,7 +172,7 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
v8::TryCatch try_catch;
v8::Handle<v8::Value> res_obj = function->Call(context->Global(), 2, args);
if (try_catch.HasCaught()) {
- *exception = WebCore::ToWebCoreString(try_catch.Message()->Get());
+ *exception = WebCore::toWebCoreString(try_catch.Message()->Get());
return "";
} else {
v8::Handle<v8::String> res_json = v8::Handle<v8::String>::Cast(res_obj);
diff --git a/webkit/port/bindings/v8/v8_binding.cpp b/webkit/port/bindings/v8/v8_binding.cpp
deleted file mode 100644
index 616d7b2..0000000
--- a/webkit/port/bindings/v8/v8_binding.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "v8_binding.h"
-
-#include "AtomicString.h"
-#include "CString.h"
-#include "MathExtras.h"
-#include "PlatformString.h"
-#include "StringBuffer.h"
-
-#include <v8.h>
-
-namespace WebCore {
-
-// WebCoreStringResource is a helper class for v8ExternalString. It is used
-// to manage the life-cycle of the underlying buffer of the external string.
-class WebCoreStringResource: public v8::String::ExternalStringResource {
- public:
- explicit WebCoreStringResource(const String& str)
- : impl_(str.impl()) { }
-
- virtual ~WebCoreStringResource() {}
-
- const uint16_t* data() const {
- return reinterpret_cast<const uint16_t*>(impl_.characters());
- }
-
- size_t length() const { return impl_.length(); }
-
- String webcore_string() { return impl_; }
-
- private:
- // A shallow copy of the string.
- // Keeps the string buffer alive until the V8 engine garbage collects it.
- String impl_;
-};
-
-
-String v8StringToWebCoreString(
- v8::Handle<v8::String> v8_str, bool externalize) {
- WebCoreStringResource* str_resource = static_cast<WebCoreStringResource*>(
- v8_str->GetExternalStringResource());
- if (str_resource) {
- return str_resource->webcore_string();
- }
-
- int length = v8_str->Length();
- if (length == 0) {
- // Avoid trying to morph empty strings, as they do not have enough room to
- // contain the external reference.
- return StringImpl::empty();
- }
-
- UChar* buffer;
- String result = String::createUninitialized(length, buffer);
- v8_str->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
-
- if (externalize) {
- WebCoreStringResource* resource = new WebCoreStringResource(result);
- if (!v8_str->MakeExternal(resource)) {
- // In case of a failure delete the external resource as it was not used.
- delete resource;
- }
- }
- return result;
-}
-
-
-String v8ValueToWebCoreString(v8::Handle<v8::Value> obj) {
- if (obj->IsString()) {
- v8::Handle<v8::String> v8_str = v8::Handle<v8::String>::Cast(obj);
- String webCoreString = v8StringToWebCoreString(v8_str, true);
- return webCoreString;
- } else if (obj->IsInt32()) {
- int value = obj->Int32Value();
- // Most numbers used are <= 100. Even if they aren't used
- // there's very little in using the space.
- const int kLowNumbers = 100;
- static AtomicString lowNumbers[kLowNumbers + 1];
- String webCoreString;
- if (0 <= value && value <= kLowNumbers) {
- webCoreString = lowNumbers[value];
- if (!webCoreString) {
- AtomicString valueString = AtomicString(String::number(value));
- lowNumbers[value] = valueString;
- webCoreString = valueString;
- }
- } else {
- webCoreString = String::number(value);
- }
- return webCoreString;
- } else {
- v8::TryCatch block;
- v8::Handle<v8::String> v8_str = obj->ToString();
- // Check for empty handles to handle the case where an exception
- // is thrown as part of invoking toString on the object.
- if (v8_str.IsEmpty())
- return StringImpl::empty();
- return v8StringToWebCoreString(v8_str, false);
- }
-}
-
-
-AtomicString v8StringToAtomicWebCoreString(v8::Handle<v8::String> v8_str) {
- String str = v8StringToWebCoreString(v8_str, true);
- return AtomicString(str);
-}
-
-
-AtomicString v8ValueToAtomicWebCoreString(v8::Handle<v8::Value> v8_str) {
- String str = v8ValueToWebCoreString(v8_str);
- return AtomicString(str);
-}
-
-
-v8::Handle<v8::String> v8String(const String& str) {
- if (!str.length())
- return v8::String::Empty();
- return v8::String::NewExternal(new WebCoreStringResource(str));
-}
-
-v8::Local<v8::String> v8ExternalString(const String& str) {
- if (!str.length())
- return v8::String::Empty();
- return v8::String::NewExternal(new WebCoreStringResource(str));
-}
-
-} // namespace WebCore
diff --git a/webkit/port/bindings/v8/v8_binding.h b/webkit/port/bindings/v8/v8_binding.h
deleted file mode 100644
index 2882026..0000000
--- a/webkit/port/bindings/v8/v8_binding.h
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_BINDING_H__
-#define V8_BINDING_H__
-
-#include "config.h"
-
-#include "MathExtras.h"
-#include "PlatformString.h"
-
-#include <v8.h>
-
-namespace WebCore {
-
-// The string returned by this function is still owned by the argument
-// and will be deallocated when the argument is deallocated.
-inline const uint16_t* FromWebCoreString(const String& str) {
- return reinterpret_cast<const uint16_t*>(str.characters());
-}
-
-// Convert v8 types to a WebCore::String. If the V8 string is not already
-// an external string then it is transformed into an external string at this
-// point to avoid repeated conversions.
-String v8StringToWebCoreString(
- v8::Handle<v8::String> obj, bool externalize);
-String v8ValueToWebCoreString(v8::Handle<v8::Value> obj);
-
-// TODO(mbelshe): drop this in favor of the type specific
-// v8ValueToWebCoreString when we rework the code generation.
-inline String ToWebCoreString(v8::Handle<v8::Value> obj) {
- return v8ValueToWebCoreString(obj);
-}
-
-inline String ToWebCoreString(v8::Handle<v8::String> string) {
- return v8StringToWebCoreString(string, true);
-}
-
-// Convert v8 types to a WebCore::AtomicString.
-AtomicString v8StringToAtomicWebCoreString(v8::Handle<v8::String> obj);
-AtomicString v8ValueToAtomicWebCoreString(v8::Handle<v8::Value> obj);
-
-inline String valueToStringWithNullCheck(v8::Handle<v8::Value> value) {
- if (value->IsNull()) return String();
- return ToWebCoreString(value);
-}
-
-inline String valueToStringWithNullOrUndefinedCheck(
- v8::Handle<v8::Value> value) {
- if (value->IsNull() || value->IsUndefined()) return String();
- return ToWebCoreString(value);
-}
-
-// Convert a value to a 32-bit integer. The conversion fails if the
-// value cannot be converted to an integer or converts to nan or to an
-// infinity.
-// FIXME: Rename to toInt32() once V8 bindings migration is complete.
-inline int ToInt32(v8::Handle<v8::Value> value, bool& ok) {
- ok = true;
-
- // Fast case. The value is already a 32-bit integer.
- if (value->IsInt32()) {
- return value->Int32Value();
- }
-
- // Can the value be converted to a number?
- v8::Local<v8::Number> number_object = value->ToNumber();
- if (number_object.IsEmpty()) {
- ok = false;
- return 0;
- }
-
- // Does the value convert to nan or to an infinity?
- double number_value = number_object->Value();
- if (isnan(number_value) || isinf(number_value)) {
- ok = false;
- return 0;
- }
-
- // Can the value be converted to a 32-bit integer?
- v8::Local<v8::Int32> int_value = value->ToInt32();
- if (int_value.IsEmpty()) {
- ok = false;
- return 0;
- }
-
- // Return the result of the int32 conversion.
- return int_value->Value();
-}
-
-// Convert a value to a 32-bit integer assuming the conversion cannot fail.
-// FIXME: Rename to toInt32() once V8 bindings migration is complete.
-inline int ToInt32(v8::Handle<v8::Value> value) {
- bool ok;
- return ToInt32(value, ok);
-}
-
-inline String ToString(const String& string) {
- return string;
-}
-
-// Convert a string to a V8 string.
-v8::Handle<v8::String> v8String(const String& str);
-
-inline v8::Handle<v8::String> v8UndetectableString(const String& str) {
- return v8::String::NewUndetectable(FromWebCoreString(str), str.length());
-}
-
-// Return a V8 external string that shares the underlying buffer with the given
-// WebCore string. The reference counting mechanism is used to keep the
-// underlying buffer alive while the string is still live in the V8 engine.
-v8::Local<v8::String> v8ExternalString(const String& str);
-
-inline v8::Handle<v8::Value> v8StringOrNull(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::Null())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::Undefined())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-inline v8::Handle<v8::Value> v8StringOrFalse(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::False())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-} // namespace WebCore
-
-#endif // V8_BINDING_H__
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index be7658d..ec66b73 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1112,6 +1112,7 @@
'../third_party/WebKit/WebCore/bindings/v8/ScriptValue.h',
'../third_party/WebKit/WebCore/bindings/v8/V8AbstractEventListener.cpp',
'../third_party/WebKit/WebCore/bindings/v8/V8AbstractEventListener.h',
+ '../third_party/WebKit/WebCore/bindings/v8/V8Binding.cpp',
'../third_party/WebKit/WebCore/bindings/v8/V8Binding.h',
'../third_party/WebKit/WebCore/bindings/v8/V8Collection.cpp',
'../third_party/WebKit/WebCore/bindings/v8/V8Collection.h',
@@ -1165,8 +1166,6 @@
'port/bindings/v8/npruntime_impl.h',
'port/bindings/v8/npruntime_internal.h',
'port/bindings/v8/npruntime_priv.h',
- 'port/bindings/v8/v8_binding.h',
- 'port/bindings/v8/v8_binding.cpp',
'port/bindings/v8/V8NPUtils.cpp',
'port/bindings/v8/V8NPUtils.h',
'port/bindings/v8/V8NPObject.cpp',